kopia lustrzana https://github.com/OpenDroneMap/ODM
merged sansvtk branch, pdal compiles
commit
0d9d65969d
|
@ -23,6 +23,13 @@ if (WIN32)
|
||||||
set(GDAL_LIBRARY "${GDAL_ROOT}/lib/gdal_i.lib")
|
set(GDAL_LIBRARY "${GDAL_ROOT}/lib/gdal_i.lib")
|
||||||
set(GDAL_INCLUDE_DIR "${GDAL_ROOT}/include/gdal")
|
set(GDAL_INCLUDE_DIR "${GDAL_ROOT}/include/gdal")
|
||||||
|
|
||||||
|
# Also download missing headers :/
|
||||||
|
if (NOT EXISTS "${GDAL_INCLUDE_DIR}/ogrsf_frmts.h")
|
||||||
|
file(DOWNLOAD "https://raw.githubusercontent.com/OSGeo/gdal/release/3.2/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h" "${GDAL_INCLUDE_DIR}/ogrsf_frmts.h")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# TODO: copy gdal302.dll to superbuild/install/bin
|
||||||
|
|
||||||
set(WIN32_GDAL_ARGS -DGDAL_FOUND=TRUE -DGDAL_LIBRARY=${GDAL_LIBRARY} -DGDAL_INCLUDE_DIR=${GDAL_INCLUDE_DIR})
|
set(WIN32_GDAL_ARGS -DGDAL_FOUND=TRUE -DGDAL_LIBRARY=${GDAL_LIBRARY} -DGDAL_INCLUDE_DIR=${GDAL_INCLUDE_DIR})
|
||||||
else()
|
else()
|
||||||
set(PYTHON_EXE_PATH "/usr/bin/python3")
|
set(PYTHON_EXE_PATH "/usr/bin/python3")
|
||||||
|
@ -122,12 +129,11 @@ SETUP_EXTERNAL_PROJECT(Hexer 1.4 ON)
|
||||||
|
|
||||||
set(custom_libs OpenSfM
|
set(custom_libs OpenSfM
|
||||||
LASzip
|
LASzip
|
||||||
Zstd
|
|
||||||
PDAL
|
PDAL
|
||||||
Untwine
|
Untwine
|
||||||
Entwine
|
Entwine
|
||||||
MvsTexturing
|
MvsTexturing
|
||||||
OpenMVS
|
OpenMVS
|
||||||
)
|
)
|
||||||
|
|
||||||
externalproject_add(mve
|
externalproject_add(mve
|
||||||
|
@ -149,25 +155,30 @@ ProcessorCount(nproc)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set (POISSON_BUILD_CMD ${CMAKE_MAKE_PROGRAM} ${SB_SOURCE_DIR}/PoissonRecon/PoissonRecon.vcxproj /p:configuration=${CMAKE_BUILD_TYPE} /p:PlatformToolset=${CMAKE_VS_PLATFORM_TOOLSET} /p:WindowsTargetPlatformVersion=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION})
|
set (POISSON_BUILD_CMD ${CMAKE_MAKE_PROGRAM} ${SB_SOURCE_DIR}/PoissonRecon/PoissonRecon.vcxproj /p:configuration=${CMAKE_BUILD_TYPE} /p:PlatformToolset=${CMAKE_VS_PLATFORM_TOOLSET} /p:WindowsTargetPlatformVersion=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION})
|
||||||
|
set (POISSON_BIN_PATH "Win32/${CMAKE_BUILD_TYPE}/PoissonRecon.exe")
|
||||||
else()
|
else()
|
||||||
set (POISSON_BUILD_CMD make -j${nproc} poissonrecon)
|
set (POISSON_BUILD_CMD make -j${nproc} poissonrecon)
|
||||||
|
set (POISSON_BIN_PATH "Linux/PoissonRecon")
|
||||||
endif()
|
endif()
|
||||||
externalproject_add(poissonrecon
|
externalproject_add(poissonrecon
|
||||||
GIT_REPOSITORY https://github.com/mkazhdan/PoissonRecon.git
|
GIT_REPOSITORY https://github.com/mkazhdan/PoissonRecon.git
|
||||||
GIT_TAG ce5005ae3094d902d551a65a8b3131e06f45e7cf
|
GIT_TAG ce5005ae3094d902d551a65a8b3131e06f45e7cf
|
||||||
|
PREFIX ${SB_BINARY_DIR}/PoissonRecon
|
||||||
SOURCE_DIR ${SB_SOURCE_DIR}/PoissonRecon
|
SOURCE_DIR ${SB_SOURCE_DIR}/PoissonRecon
|
||||||
UPDATE_COMMAND ""
|
UPDATE_COMMAND ""
|
||||||
CONFIGURE_COMMAND ""
|
CONFIGURE_COMMAND ""
|
||||||
BUILD_IN_SOURCE 1
|
BUILD_IN_SOURCE 1
|
||||||
BUILD_COMMAND ${POISSON_BUILD_CMD}
|
BUILD_COMMAND ${POISSON_BUILD_CMD}
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${SB_SOURCE_DIR}/PoissonRecon/Bin/${POISSON_BIN_PATH} ${SB_INSTALL_DIR}/bin
|
||||||
)
|
)
|
||||||
|
|
||||||
externalproject_add(dem2mesh
|
externalproject_add(dem2mesh
|
||||||
GIT_REPOSITORY https://github.com/OpenDroneMap/dem2mesh.git
|
GIT_REPOSITORY https://github.com/OpenDroneMap/dem2mesh.git
|
||||||
GIT_TAG master
|
GIT_TAG master
|
||||||
|
PREFIX ${SB_BINARY_DIR}/dem2mesh
|
||||||
SOURCE_DIR ${SB_SOURCE_DIR}/dem2mesh
|
SOURCE_DIR ${SB_SOURCE_DIR}/dem2mesh
|
||||||
CMAKE_ARGS ${WIN32_GDAL_ARGS}
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR}
|
||||||
|
${WIN32_GDAL_ARGS}
|
||||||
UPDATE_COMMAND ""
|
UPDATE_COMMAND ""
|
||||||
BUILD_IN_SOURCE 1
|
BUILD_IN_SOURCE 1
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ""
|
||||||
|
@ -176,10 +187,10 @@ externalproject_add(dem2mesh
|
||||||
externalproject_add(dem2points
|
externalproject_add(dem2points
|
||||||
GIT_REPOSITORY https://github.com/OpenDroneMap/dem2points.git
|
GIT_REPOSITORY https://github.com/OpenDroneMap/dem2points.git
|
||||||
GIT_TAG master
|
GIT_TAG master
|
||||||
|
PREFIX ${SB_BINARY_DIR}/dem2points
|
||||||
SOURCE_DIR ${SB_SOURCE_DIR}/dem2points
|
SOURCE_DIR ${SB_SOURCE_DIR}/dem2points
|
||||||
UPDATE_COMMAND ""
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR}
|
||||||
BUILD_IN_SOURCE 1
|
${WIN32_GDAL_ARGS}
|
||||||
INSTALL_COMMAND ""
|
|
||||||
)
|
)
|
||||||
|
|
||||||
externalproject_add(lastools
|
externalproject_add(lastools
|
||||||
|
|
|
@ -8,8 +8,8 @@ ExternalProject_Add(${_proj_name}
|
||||||
STAMP_DIR ${_SB_BINARY_DIR}/stamp
|
STAMP_DIR ${_SB_BINARY_DIR}/stamp
|
||||||
#--Download step--------------
|
#--Download step--------------
|
||||||
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
|
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
|
||||||
GIT_REPOSITORY https://github.com/connormanning/entwine/
|
GIT_REPOSITORY https://github.com/OpenDroneMap/entwine/
|
||||||
GIT_TAG 2.1.0
|
GIT_TAG 2411
|
||||||
#--Update/Patch step----------
|
#--Update/Patch step----------
|
||||||
UPDATE_COMMAND ""
|
UPDATE_COMMAND ""
|
||||||
#--Configure step-------------
|
#--Configure step-------------
|
||||||
|
@ -18,7 +18,8 @@ ExternalProject_Add(${_proj_name}
|
||||||
-DCMAKE_CXX_FLAGS=-isystem\ ${SB_SOURCE_DIR}/pdal
|
-DCMAKE_CXX_FLAGS=-isystem\ ${SB_SOURCE_DIR}/pdal
|
||||||
-DADDITIONAL_LINK_DIRECTORIES_PATHS=${SB_INSTALL_DIR}/lib
|
-DADDITIONAL_LINK_DIRECTORIES_PATHS=${SB_INSTALL_DIR}/lib
|
||||||
-DWITH_TESTS=OFF
|
-DWITH_TESTS=OFF
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
-DWITH_ZSTD=OFF
|
||||||
|
-DCMAKE_BUILD_TYPE=Release
|
||||||
-DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR}
|
-DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR}
|
||||||
#--Build step-----------------
|
#--Build step-----------------
|
||||||
BINARY_DIR ${_SB_BINARY_DIR}
|
BINARY_DIR ${_SB_BINARY_DIR}
|
||||||
|
|
|
@ -15,6 +15,7 @@ ExternalProject_Add(${_proj_name}
|
||||||
SOURCE_DIR ${SB_SOURCE_DIR}/${_proj_name}
|
SOURCE_DIR ${SB_SOURCE_DIR}/${_proj_name}
|
||||||
CMAKE_ARGS
|
CMAKE_ARGS
|
||||||
-DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR}
|
-DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR}
|
||||||
|
${WIN32_GDAL_ARGS}
|
||||||
#--Build step-----------------
|
#--Build step-----------------
|
||||||
BINARY_DIR ${_SB_BINARY_DIR}
|
BINARY_DIR ${_SB_BINARY_DIR}
|
||||||
#--Install step---------------
|
#--Install step---------------
|
||||||
|
|
|
@ -20,7 +20,7 @@ ExternalProject_Add(${_proj_name}
|
||||||
#--Download step--------------
|
#--Download step--------------
|
||||||
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
|
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
|
||||||
GIT_REPOSITORY https://github.com/OpenDroneMap/openMVS
|
GIT_REPOSITORY https://github.com/OpenDroneMap/openMVS
|
||||||
GIT_TAG 247
|
GIT_TAG 2411
|
||||||
#--Update/Patch step----------
|
#--Update/Patch step----------
|
||||||
UPDATE_COMMAND ""
|
UPDATE_COMMAND ""
|
||||||
#--Configure step-------------
|
#--Configure step-------------
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
set(_proj_name pdal)
|
set(_proj_name pdal)
|
||||||
set(_SB_BINARY_DIR "${SB_BINARY_DIR}/${_proj_name}")
|
set(_SB_BINARY_DIR "${SB_BINARY_DIR}/${_proj_name}")
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
set(LASZIP_LIB "${SB_INSTALL_DIR}/lib/laszip.lib")
|
||||||
|
else()
|
||||||
|
set(LASZIP_LIB "${SB_INSTALL_DIR}/lib/liblaszip.so")
|
||||||
|
endif()
|
||||||
|
|
||||||
ExternalProject_Add(${_proj_name}
|
ExternalProject_Add(${_proj_name}
|
||||||
DEPENDS zstd hexer laszip
|
DEPENDS hexer laszip
|
||||||
PREFIX ${_SB_BINARY_DIR}
|
PREFIX ${_SB_BINARY_DIR}
|
||||||
TMP_DIR ${_SB_BINARY_DIR}/tmp
|
TMP_DIR ${_SB_BINARY_DIR}/tmp
|
||||||
STAMP_DIR ${_SB_BINARY_DIR}/stamp
|
STAMP_DIR ${_SB_BINARY_DIR}/stamp
|
||||||
|
@ -17,30 +23,32 @@ ExternalProject_Add(${_proj_name}
|
||||||
-DBUILD_PGPOINTCLOUD_TESTS=OFF
|
-DBUILD_PGPOINTCLOUD_TESTS=OFF
|
||||||
-DBUILD_PLUGIN_PGPOINTCLOUD=OFF
|
-DBUILD_PLUGIN_PGPOINTCLOUD=OFF
|
||||||
-DBUILD_PLUGIN_CPD=OFF
|
-DBUILD_PLUGIN_CPD=OFF
|
||||||
-DBUILD_PLUGIN_GREYHOUND=OFF
|
-DBUILD_PLUGIN_GREYHOUND=OFF
|
||||||
-DBUILD_PLUGIN_HEXBIN=ON
|
-DBUILD_PLUGIN_HEXBIN=ON
|
||||||
-DBUILD_PLUGIN_ICEBRIDGE=OFF
|
-DBUILD_PLUGIN_ICEBRIDGE=OFF
|
||||||
-DBUILD_PLUGIN_MRSID=OFF
|
-DBUILD_PLUGIN_MRSID=OFF
|
||||||
-DBUILD_PLUGIN_NITF=OFF
|
-DBUILD_PLUGIN_NITF=OFF
|
||||||
-DBUILD_PLUGIN_OCI=OFF
|
-DBUILD_PLUGIN_OCI=OFF
|
||||||
-DBUILD_PLUGIN_P2G=OFF
|
-DBUILD_PLUGIN_P2G=OFF
|
||||||
-DBUILD_PLUGIN_SQLITE=OFF
|
-DBUILD_PLUGIN_SQLITE=OFF
|
||||||
-DBUILD_PLUGIN_RIVLIB=OFF
|
-DBUILD_PLUGIN_RIVLIB=OFF
|
||||||
-DBUILD_PLUGIN_PYTHON=OFF
|
-DBUILD_PLUGIN_PYTHON=OFF
|
||||||
-DWITH_ZSTD=ON
|
-DWITH_ZSTD=OFF
|
||||||
-DENABLE_CTEST=OFF
|
-DENABLE_CTEST=OFF
|
||||||
-DWITH_APPS=ON
|
-DWITH_APPS=ON
|
||||||
-DWITH_LAZPERF=OFF
|
-DWITH_LAZPERF=OFF
|
||||||
-DWITH_GEOTIFF=ON
|
-DWITH_GEOTIFF=ON
|
||||||
-DWITH_LASZIP=ON
|
-DWITH_LASZIP=ON
|
||||||
-DLASZIP_FOUND=TRUE
|
-DLASZIP_FOUND=TRUE
|
||||||
-DLASZIP_LIBRARIES=${SB_INSTALL_DIR}/lib/liblaszip.so
|
-DLASZIP_LIBRARIES=${LASZIP_LIB}
|
||||||
-DLASZIP_VERSION=3.1.1
|
-DLASZIP_VERSION=3.1.1
|
||||||
-DLASZIP_INCLUDE_DIR=${SB_INSTALL_DIR}/include
|
-DLASZIP_INCLUDE_DIR=${SB_INSTALL_DIR}/include
|
||||||
-DLASZIP_LIBRARY=${SB_INSTALL_DIR}/lib/liblaszip.so
|
-DLASZIP_LIBRARY=${LASZIP_LIB}
|
||||||
-DWITH_TESTS=OFF
|
-DWITH_TESTS=OFF
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
-DCMAKE_BUILD_TYPE=Release
|
||||||
-DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR}
|
-DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR}
|
||||||
|
${WIN32_CMAKE_ARGS}
|
||||||
|
${WIN32_GDAL_ARGS}
|
||||||
#--Build step-----------------
|
#--Build step-----------------
|
||||||
BINARY_DIR ${_SB_BINARY_DIR}
|
BINARY_DIR ${_SB_BINARY_DIR}
|
||||||
#--Install step---------------
|
#--Install step---------------
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
set(_proj_name zstd)
|
|
||||||
set(_SB_BINARY_DIR "${SB_BINARY_DIR}/${_proj_name}")
|
|
||||||
|
|
||||||
ExternalProject_Add(${_proj_name}
|
|
||||||
PREFIX ${_SB_BINARY_DIR}
|
|
||||||
TMP_DIR ${_SB_BINARY_DIR}/tmp
|
|
||||||
STAMP_DIR ${_SB_BINARY_DIR}/stamp
|
|
||||||
#--Download step--------------
|
|
||||||
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
|
|
||||||
GIT_REPOSITORY https://github.com/facebook/zstd
|
|
||||||
GIT_TAG b84274da0f641907dfe472d5da132d872202e9b8
|
|
||||||
#--Update/Patch step----------
|
|
||||||
UPDATE_COMMAND ""
|
|
||||||
#--Configure step-------------
|
|
||||||
SOURCE_DIR ${SB_SOURCE_DIR}/${_proj_name}
|
|
||||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -DZSTD_BUILD_PROGRAMS=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR}
|
|
||||||
<SOURCE_DIR>/build/cmake
|
|
||||||
#--Build step-----------------
|
|
||||||
BINARY_DIR ${_SB_BINARY_DIR}
|
|
||||||
#--Install step---------------
|
|
||||||
INSTALL_DIR ${SB_INSTALL_DIR}
|
|
||||||
#--Output logging-------------
|
|
||||||
LOG_DOWNLOAD OFF
|
|
||||||
LOG_CONFIGURE OFF
|
|
||||||
LOG_BUILD OFF
|
|
||||||
)
|
|
|
@ -174,6 +174,7 @@ clean() {
|
||||||
${RUNPATH}/SuperBuild/build/opencv \
|
${RUNPATH}/SuperBuild/build/opencv \
|
||||||
${RUNPATH}/SuperBuild/download \
|
${RUNPATH}/SuperBuild/download \
|
||||||
${RUNPATH}/SuperBuild/src/ceres \
|
${RUNPATH}/SuperBuild/src/ceres \
|
||||||
|
${RUNPATH}/SuperBuild/src/PoissonRecon \
|
||||||
${RUNPATH}/SuperBuild/src/untwine \
|
${RUNPATH}/SuperBuild/src/untwine \
|
||||||
${RUNPATH}/SuperBuild/src/entwine \
|
${RUNPATH}/SuperBuild/src/entwine \
|
||||||
${RUNPATH}/SuperBuild/src/gflags \
|
${RUNPATH}/SuperBuild/src/gflags \
|
||||||
|
@ -185,10 +186,13 @@ clean() {
|
||||||
${RUNPATH}/SuperBuild/src/opengv \
|
${RUNPATH}/SuperBuild/src/opengv \
|
||||||
${RUNPATH}/SuperBuild/src/pcl \
|
${RUNPATH}/SuperBuild/src/pcl \
|
||||||
${RUNPATH}/SuperBuild/src/pdal \
|
${RUNPATH}/SuperBuild/src/pdal \
|
||||||
|
${RUNPATH}/SuperBuild/src/dem2mesh \
|
||||||
|
${RUNPATH}/SuperBuild/build/dem2mesh \
|
||||||
|
${RUNPATH}/SuperBuild/src/dem2points \
|
||||||
|
${RUNPATH}/SuperBuild/build/dem2points \
|
||||||
${RUNPATH}/SuperBuild/src/openmvs \
|
${RUNPATH}/SuperBuild/src/openmvs \
|
||||||
${RUNPATH}/SuperBuild/build/openmvs \
|
${RUNPATH}/SuperBuild/build/openmvs \
|
||||||
${RUNPATH}/SuperBuild/src/vcg \
|
${RUNPATH}/SuperBuild/src/vcg
|
||||||
${RUNPATH}/SuperBuild/src/zstd
|
|
||||||
|
|
||||||
# find in /code and delete static libraries and intermediate object files
|
# find in /code and delete static libraries and intermediate object files
|
||||||
find ${RUNPATH} -type f -name "*.a" -delete -or -type f -name "*.o" -delete
|
find ${RUNPATH} -type f -name "*.a" -delete -or -type f -name "*.o" -delete
|
||||||
|
|
|
@ -19,7 +19,6 @@ Licensing for portions of OpenDroneMap are as follows:
|
||||||
* Flann - BSD2 - http://opensource.org/licenses/bsd-license.php
|
* Flann - BSD2 - http://opensource.org/licenses/bsd-license.php
|
||||||
* Eigen - MPL2 - http://www.mozilla.org/MPL/2.0
|
* Eigen - MPL2 - http://www.mozilla.org/MPL/2.0
|
||||||
* Qhull - http://www.qhull.org/COPYING.txt
|
* Qhull - http://www.qhull.org/COPYING.txt
|
||||||
* vtk5 - BSD - http://www.vtk.org/VTK/project/license.html
|
|
||||||
* libext - https://github.com/OpenDroneMap/OpenDroneMap/blob/gh-pages/licenses/libext_copyright.txt
|
* libext - https://github.com/OpenDroneMap/OpenDroneMap/blob/gh-pages/licenses/libext_copyright.txt
|
||||||
* libx11 - https://github.com/OpenDroneMap/OpenDroneMap/blob/gh-pages/licenses/libx11_copyright.txt
|
* libx11 - https://github.com/OpenDroneMap/OpenDroneMap/blob/gh-pages/licenses/libx11_copyright.txt
|
||||||
* MVS Texturing - BSD - https://github.com/nmoehrle/mvs-texturing/blob/master/LICENSE.txt
|
* MVS Texturing - BSD - https://github.com/nmoehrle/mvs-texturing/blob/master/LICENSE.txt
|
||||||
|
|
|
@ -5,4 +5,3 @@ endif()
|
||||||
|
|
||||||
# Add ODM sub-modules
|
# Add ODM sub-modules
|
||||||
add_subdirectory(odm_orthophoto)
|
add_subdirectory(odm_orthophoto)
|
||||||
add_subdirectory(odm_cleanmesh)
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
project(odm_cleanmesh)
|
|
||||||
cmake_minimum_required(VERSION 2.8)
|
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR})
|
|
||||||
|
|
||||||
set (CMAKE_CXX_STANDARD 11)
|
|
||||||
find_package(VTK REQUIRED)
|
|
||||||
include(${VTK_USE_FILE})
|
|
||||||
|
|
||||||
# Add compiler options.
|
|
||||||
add_definitions(-Wall -Wextra)
|
|
||||||
|
|
||||||
# Add source directory
|
|
||||||
aux_source_directory("./src" SRC_LIST)
|
|
||||||
|
|
||||||
# Add exectuteable
|
|
||||||
add_executable(${PROJECT_NAME} ${SRC_LIST})
|
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} ${VTK_LIBRARIES})
|
|
|
@ -1,106 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
conditions and the following disclaimer. Redistributions in binary form must reproduce
|
|
||||||
the above copyright notice, this list of conditions and the following disclaimer
|
|
||||||
in the documentation and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
Neither the name of the Johns Hopkins University nor the names of its contributors
|
|
||||||
may be used to endorse or promote products derived from this software without specific
|
|
||||||
prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
|
|
||||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
||||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
||||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
||||||
DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CMD_LINE_PARSER_INCLUDED
|
|
||||||
#define CMD_LINE_PARSER_INCLUDED
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <cstring>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
int strcasecmp( const char* c1 , const char* c2 );
|
|
||||||
#endif // WIN32
|
|
||||||
|
|
||||||
class cmdLineReadable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool set;
|
|
||||||
char *name;
|
|
||||||
cmdLineReadable( const char *name );
|
|
||||||
virtual ~cmdLineReadable( void );
|
|
||||||
virtual int read( char** argv , int argc );
|
|
||||||
virtual void writeValue( char* str ) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template< class Type > void cmdLineWriteValue( Type t , char* str );
|
|
||||||
template< class Type > void cmdLineCleanUp( Type* t );
|
|
||||||
template< class Type > Type cmdLineInitialize( void );
|
|
||||||
template< class Type > Type cmdLineCopy( Type t );
|
|
||||||
template< class Type > Type cmdLineStringToType( const char* str );
|
|
||||||
|
|
||||||
template< class Type >
|
|
||||||
class cmdLineParameter : public cmdLineReadable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Type value;
|
|
||||||
cmdLineParameter( const char *name );
|
|
||||||
cmdLineParameter( const char *name , Type v );
|
|
||||||
~cmdLineParameter( void );
|
|
||||||
int read( char** argv , int argc );
|
|
||||||
void writeValue( char* str ) const;
|
|
||||||
bool expectsArg( void ) const { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template< class Type , int Dim >
|
|
||||||
class cmdLineParameterArray : public cmdLineReadable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Type values[Dim];
|
|
||||||
cmdLineParameterArray( const char *name, const Type* v=NULL );
|
|
||||||
~cmdLineParameterArray( void );
|
|
||||||
int read( char** argv , int argc );
|
|
||||||
void writeValue( char* str ) const;
|
|
||||||
bool expectsArg( void ) const { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template< class Type >
|
|
||||||
class cmdLineParameters : public cmdLineReadable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int count;
|
|
||||||
Type *values;
|
|
||||||
cmdLineParameters( const char* name );
|
|
||||||
~cmdLineParameters( void );
|
|
||||||
int read( char** argv , int argc );
|
|
||||||
void writeValue( char* str ) const;
|
|
||||||
bool expectsArg( void ) const { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
void cmdLineParse( int argc , char **argv, cmdLineReadable** params );
|
|
||||||
char* FileExtension( char* fileName );
|
|
||||||
char* LocalFileName( char* fileName );
|
|
||||||
char* DirectoryName( char* fileName );
|
|
||||||
char* GetFileExtension( const char* fileName );
|
|
||||||
char* GetLocalFileName( const char* fileName );
|
|
||||||
char** ReadWords( const char* fileName , int& cnt );
|
|
||||||
|
|
||||||
#include "CmdLineParser.inl"
|
|
||||||
#endif // CMD_LINE_PARSER_INCLUDED
|
|
|
@ -1,300 +0,0 @@
|
||||||
/* -*- C++ -*-
|
|
||||||
Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
conditions and the following disclaimer. Redistributions in binary form must reproduce
|
|
||||||
the above copyright notice, this list of conditions and the following disclaimer
|
|
||||||
in the documentation and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
Neither the name of the Johns Hopkins University nor the names of its contributors
|
|
||||||
may be used to endorse or promote products derived from this software without specific
|
|
||||||
prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
|
|
||||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
||||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
||||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
||||||
DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#if defined( WIN32 ) || defined( _WIN64 )
|
|
||||||
inline int strcasecmp( const char* c1 , const char* c2 ){ return _stricmp( c1 , c2 ); }
|
|
||||||
#endif // WIN32 || _WIN64
|
|
||||||
|
|
||||||
template< > void cmdLineCleanUp< int >( int* t ){ *t = 0; }
|
|
||||||
template< > void cmdLineCleanUp< float >( float* t ){ *t = 0; }
|
|
||||||
template< > void cmdLineCleanUp< double >( double* t ){ *t = 0; }
|
|
||||||
template< > void cmdLineCleanUp< char* >( char** t ){ if( *t ) free( *t ) ; *t = NULL; }
|
|
||||||
template< > int cmdLineInitialize< int >( void ){ return 0; }
|
|
||||||
template< > float cmdLineInitialize< float >( void ){ return 0.f; }
|
|
||||||
template< > double cmdLineInitialize< double >( void ){ return 0.; }
|
|
||||||
template< > char* cmdLineInitialize< char* >( void ){ return NULL; }
|
|
||||||
template< > void cmdLineWriteValue< int >( int t , char* str ){ sprintf( str , "%d" , t ); }
|
|
||||||
template< > void cmdLineWriteValue< float >( float t , char* str ){ sprintf( str , "%f" , t ); }
|
|
||||||
template< > void cmdLineWriteValue< double >( double t , char* str ){ sprintf( str , "%f" , t ); }
|
|
||||||
template< > void cmdLineWriteValue< char* >( char* t , char* str ){ if( t ) sprintf( str , "%s" , t ) ; else str[0]=0; }
|
|
||||||
template< > int cmdLineCopy( int t ){ return t; }
|
|
||||||
template< > float cmdLineCopy( float t ){ return t; }
|
|
||||||
template< > double cmdLineCopy( double t ){ return t; }
|
|
||||||
#if defined( WIN32 ) || defined( _WIN64 )
|
|
||||||
template< > char* cmdLineCopy( char* t ){ return _strdup( t ); }
|
|
||||||
#else // !WIN32 && !_WIN64
|
|
||||||
template< > char* cmdLineCopy( char* t ){ return strdup( t ); }
|
|
||||||
#endif // WIN32 || _WIN64
|
|
||||||
template< > int cmdLineStringToType( const char* str ){ return atoi( str ); }
|
|
||||||
template< > float cmdLineStringToType( const char* str ){ return float( atof( str ) ); }
|
|
||||||
template< > double cmdLineStringToType( const char* str ){ return double( atof( str ) ); }
|
|
||||||
#if defined( WIN32 ) || defined( _WIN64 )
|
|
||||||
template< > char* cmdLineStringToType( const char* str ){ return _strdup( str ); }
|
|
||||||
#else // !WIN32 && !_WIN64
|
|
||||||
template< > char* cmdLineStringToType( const char* str ){ return strdup( str ); }
|
|
||||||
#endif // WIN32 || _WIN64
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////
|
|
||||||
// cmdLineReadable //
|
|
||||||
/////////////////////
|
|
||||||
#if defined( WIN32 ) || defined( _WIN64 )
|
|
||||||
inline cmdLineReadable::cmdLineReadable( const char *name ) : set(false) { this->name = _strdup( name ); }
|
|
||||||
#else // !WIN32 && !_WIN64
|
|
||||||
inline cmdLineReadable::cmdLineReadable( const char *name ) : set(false) { this->name = strdup( name ); }
|
|
||||||
#endif // WIN32 || _WIN64
|
|
||||||
|
|
||||||
inline cmdLineReadable::~cmdLineReadable( void ){ if( name ) free( name ) ; name = NULL; }
|
|
||||||
inline int cmdLineReadable::read( char** , int ){ set = true ; return 0; }
|
|
||||||
inline void cmdLineReadable::writeValue( char* str ) const { str[0] = 0; }
|
|
||||||
|
|
||||||
//////////////////////
|
|
||||||
// cmdLineParameter //
|
|
||||||
//////////////////////
|
|
||||||
template< class Type > cmdLineParameter< Type >::~cmdLineParameter( void ) { cmdLineCleanUp( &value ); }
|
|
||||||
template< class Type > cmdLineParameter< Type >::cmdLineParameter( const char *name ) : cmdLineReadable( name ){ value = cmdLineInitialize< Type >(); }
|
|
||||||
template< class Type > cmdLineParameter< Type >::cmdLineParameter( const char *name , Type v ) : cmdLineReadable( name ){ value = cmdLineCopy< Type >( v ); }
|
|
||||||
template< class Type >
|
|
||||||
int cmdLineParameter< Type >::read( char** argv , int argc )
|
|
||||||
{
|
|
||||||
if( argc>0 )
|
|
||||||
{
|
|
||||||
cmdLineCleanUp< Type >( &value ) , value = cmdLineStringToType< Type >( argv[0] );
|
|
||||||
set = true;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else return 0;
|
|
||||||
}
|
|
||||||
template< class Type >
|
|
||||||
void cmdLineParameter< Type >::writeValue( char* str ) const { cmdLineWriteValue< Type >( value , str ); }
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////
|
|
||||||
// cmdLineParameterArray //
|
|
||||||
///////////////////////////
|
|
||||||
template< class Type , int Dim >
|
|
||||||
cmdLineParameterArray< Type , Dim >::cmdLineParameterArray( const char *name , const Type* v ) : cmdLineReadable( name )
|
|
||||||
{
|
|
||||||
if( v ) for( int i=0 ; i<Dim ; i++ ) values[i] = cmdLineCopy< Type >( v[i] );
|
|
||||||
else for( int i=0 ; i<Dim ; i++ ) values[i] = cmdLineInitialize< Type >();
|
|
||||||
}
|
|
||||||
template< class Type , int Dim >
|
|
||||||
cmdLineParameterArray< Type , Dim >::~cmdLineParameterArray( void ){ for( int i=0 ; i<Dim ; i++ ) cmdLineCleanUp< Type >( values+i ); }
|
|
||||||
template< class Type , int Dim >
|
|
||||||
int cmdLineParameterArray< Type , Dim >::read( char** argv , int argc )
|
|
||||||
{
|
|
||||||
if( argc>=Dim )
|
|
||||||
{
|
|
||||||
for( int i=0 ; i<Dim ; i++ ) cmdLineCleanUp< Type >( values+i ) , values[i] = cmdLineStringToType< Type >( argv[i] );
|
|
||||||
set = true;
|
|
||||||
return Dim;
|
|
||||||
}
|
|
||||||
else return 0;
|
|
||||||
}
|
|
||||||
template< class Type , int Dim >
|
|
||||||
void cmdLineParameterArray< Type , Dim >::writeValue( char* str ) const
|
|
||||||
{
|
|
||||||
char* temp=str;
|
|
||||||
for( int i=0 ; i<Dim ; i++ )
|
|
||||||
{
|
|
||||||
cmdLineWriteValue< Type >( values[i] , temp );
|
|
||||||
temp = str+strlen( str );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
///////////////////////
|
|
||||||
// cmdLineParameters //
|
|
||||||
///////////////////////
|
|
||||||
template< class Type >
|
|
||||||
cmdLineParameters< Type >::cmdLineParameters( const char* name ) : cmdLineReadable( name ) , values(NULL) , count(0) { }
|
|
||||||
template< class Type >
|
|
||||||
cmdLineParameters< Type >::~cmdLineParameters( void )
|
|
||||||
{
|
|
||||||
if( values ) delete[] values;
|
|
||||||
values = NULL;
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
template< class Type >
|
|
||||||
int cmdLineParameters< Type >::read( char** argv , int argc )
|
|
||||||
{
|
|
||||||
if( values ) delete[] values;
|
|
||||||
values = NULL;
|
|
||||||
|
|
||||||
if( argc>0 )
|
|
||||||
{
|
|
||||||
count = atoi(argv[0]);
|
|
||||||
if( count <= 0 || argc <= count ) return 1;
|
|
||||||
values = new Type[count];
|
|
||||||
if( !values ) return 0;
|
|
||||||
for( int i=0 ; i<count ; i++ ) values[i] = cmdLineStringToType< Type >( argv[i+1] );
|
|
||||||
set = true;
|
|
||||||
return count+1;
|
|
||||||
}
|
|
||||||
else return 0;
|
|
||||||
}
|
|
||||||
template< class Type >
|
|
||||||
void cmdLineParameters< Type >::writeValue( char* str ) const
|
|
||||||
{
|
|
||||||
char* temp=str;
|
|
||||||
for( int i=0 ; i<count ; i++ )
|
|
||||||
{
|
|
||||||
cmdLineWriteValue< Type >( values[i] , temp );
|
|
||||||
temp = str+strlen( str );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline char* FileExtension( char* fileName )
|
|
||||||
{
|
|
||||||
char* temp = fileName;
|
|
||||||
for( unsigned int i=0 ; i<strlen(fileName) ; i++ ) if( fileName[i]=='.' ) temp = &fileName[i+1];
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char* GetFileExtension( const char* fileName )
|
|
||||||
{
|
|
||||||
char* fileNameCopy;
|
|
||||||
char* ext=NULL;
|
|
||||||
char* temp;
|
|
||||||
|
|
||||||
fileNameCopy=new char[strlen(fileName)+1];
|
|
||||||
assert(fileNameCopy);
|
|
||||||
strcpy(fileNameCopy,fileName);
|
|
||||||
temp=strtok(fileNameCopy,".");
|
|
||||||
while(temp!=NULL)
|
|
||||||
{
|
|
||||||
if(ext!=NULL){delete[] ext;}
|
|
||||||
ext=new char[strlen(temp)+1];
|
|
||||||
assert(ext);
|
|
||||||
strcpy(ext,temp);
|
|
||||||
temp=strtok(NULL,".");
|
|
||||||
}
|
|
||||||
delete[] fileNameCopy;
|
|
||||||
return ext;
|
|
||||||
}
|
|
||||||
inline char* GetLocalFileName( const char* fileName )
|
|
||||||
{
|
|
||||||
char* fileNameCopy;
|
|
||||||
char* name=NULL;
|
|
||||||
char* temp;
|
|
||||||
|
|
||||||
fileNameCopy=new char[strlen(fileName)+1];
|
|
||||||
assert(fileNameCopy);
|
|
||||||
strcpy(fileNameCopy,fileName);
|
|
||||||
temp=strtok(fileNameCopy,"\\");
|
|
||||||
while(temp!=NULL){
|
|
||||||
if(name!=NULL){delete[] name;}
|
|
||||||
name=new char[strlen(temp)+1];
|
|
||||||
assert(name);
|
|
||||||
strcpy(name,temp);
|
|
||||||
temp=strtok(NULL,"\\");
|
|
||||||
}
|
|
||||||
delete[] fileNameCopy;
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
inline char* LocalFileName( char* fileName )
|
|
||||||
{
|
|
||||||
char* temp = fileName;
|
|
||||||
for( int i=0 ; i<(int)strlen(fileName) ; i++ ) if( fileName[i] =='\\' ) temp = &fileName[i+1];
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
inline char* DirectoryName( char* fileName )
|
|
||||||
{
|
|
||||||
for( int i=int( strlen(fileName) )-1 ; i>=0 ; i-- )
|
|
||||||
if( fileName[i] =='\\' )
|
|
||||||
{
|
|
||||||
fileName[i] = 0;
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
fileName[0] = 0;
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void cmdLineParse( int argc , char **argv , cmdLineReadable** params )
|
|
||||||
{
|
|
||||||
while( argc>0 )
|
|
||||||
{
|
|
||||||
if( argv[0][0]=='-' )
|
|
||||||
{
|
|
||||||
cmdLineReadable* readable=NULL;
|
|
||||||
for( int i=0 ; params[i]!=NULL && readable==NULL ; i++ ) if( !strcasecmp( params[i]->name , argv[0]+1 ) ) readable = params[i];
|
|
||||||
if( readable )
|
|
||||||
{
|
|
||||||
int j = readable->read( argv+1 , argc-1 );
|
|
||||||
argv += j , argc -= j;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf( stderr , "[WARNING] Invalid option: %s\n" , argv[0] );
|
|
||||||
for( int i=0 ; params[i]!=NULL ; i++ ) printf( "\t-%s\n" , params[i]->name );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else fprintf( stderr , "[WARNING] Parameter name should be of the form -<name>: %s\n" , argv[0] );
|
|
||||||
++argv , --argc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char** ReadWords(const char* fileName,int& cnt)
|
|
||||||
{
|
|
||||||
char** names;
|
|
||||||
char temp[500];
|
|
||||||
FILE* fp;
|
|
||||||
|
|
||||||
fp=fopen(fileName,"r");
|
|
||||||
if(!fp){return NULL;}
|
|
||||||
cnt=0;
|
|
||||||
while(fscanf(fp," %s ",temp)==1){cnt++;}
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
names=new char*[cnt];
|
|
||||||
if(!names){return NULL;}
|
|
||||||
|
|
||||||
fp=fopen(fileName,"r");
|
|
||||||
if(!fp){
|
|
||||||
delete[] names;
|
|
||||||
cnt=0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
cnt=0;
|
|
||||||
while(fscanf(fp," %s ",temp)==1){
|
|
||||||
names[cnt]=new char[strlen(temp)+1];
|
|
||||||
if(!names){
|
|
||||||
for(int j=0;j<cnt;j++){delete[] names[j];}
|
|
||||||
delete[] names;
|
|
||||||
cnt=0;
|
|
||||||
fclose(fp);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
strcpy(names[cnt],temp);
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
return names;
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdarg>
|
|
||||||
#include "CmdLineParser.h"
|
|
||||||
|
|
||||||
struct Logger{
|
|
||||||
bool verbose;
|
|
||||||
const char* outputFile;
|
|
||||||
|
|
||||||
Logger(){
|
|
||||||
this->verbose = false;
|
|
||||||
this->outputFile = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator() ( const char* format , ... )
|
|
||||||
{
|
|
||||||
if( outputFile )
|
|
||||||
{
|
|
||||||
FILE* fp = fopen( outputFile , "a" );
|
|
||||||
va_list args;
|
|
||||||
va_start( args , format );
|
|
||||||
vfprintf( fp , format , args );
|
|
||||||
fclose( fp );
|
|
||||||
va_end( args );
|
|
||||||
}
|
|
||||||
if( verbose )
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
va_start( args , format );
|
|
||||||
vprintf( format , args );
|
|
||||||
va_end( args );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,114 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
#include <fstream>
|
|
||||||
#include <vtkPolyDataConnectivityFilter.h>
|
|
||||||
#include <vtkSmartPointer.h>
|
|
||||||
#include <vtkPLYReader.h>
|
|
||||||
#include <vtkPLYWriter.h>
|
|
||||||
#include <vtkAlgorithmOutput.h>
|
|
||||||
#include <vtkQuadricDecimation.h>
|
|
||||||
#include "CmdLineParser.h"
|
|
||||||
#include "Logger.h"
|
|
||||||
|
|
||||||
Logger logWriter;
|
|
||||||
|
|
||||||
cmdLineParameter< char* >
|
|
||||||
InputFile( "inputFile" ) ,
|
|
||||||
OutputFile( "outputFile" );
|
|
||||||
cmdLineParameter< int >
|
|
||||||
DecimateMesh( "decimateMesh" );
|
|
||||||
cmdLineReadable
|
|
||||||
RemoveIslands( "removeIslands" ) ,
|
|
||||||
Verbose( "verbose" );
|
|
||||||
|
|
||||||
cmdLineReadable* params[] = {
|
|
||||||
&InputFile , &OutputFile , &DecimateMesh, &RemoveIslands, &Verbose ,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
void help(char *ex){
|
|
||||||
std::cout << "Usage: " << ex << std::endl
|
|
||||||
<< "\t -" << InputFile.name << " <input polygon mesh>" << std::endl
|
|
||||||
<< "\t -" << OutputFile.name << " <output polygon mesh>" << std::endl
|
|
||||||
<< "\t [-" << DecimateMesh.name << " <target number of vertices>]" << std::endl
|
|
||||||
<< "\t [-" << RemoveIslands.name << "]" << std::endl
|
|
||||||
|
|
||||||
<< "\t [-" << Verbose.name << "]" << std::endl;
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void logArgs(cmdLineReadable* params[], Logger& logWriter){
|
|
||||||
logWriter("Running with parameters:\n");
|
|
||||||
char str[1024];
|
|
||||||
for( int i=0 ; params[i] ; i++ ){
|
|
||||||
if( params[i]->set ){
|
|
||||||
params[i]->writeValue( str );
|
|
||||||
if( strlen( str ) ) logWriter( "\t--%s %s\n" , params[i]->name , str );
|
|
||||||
else logWriter( "\t--%s\n" , params[i]->name );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
cmdLineParse( argc-1 , &argv[1] , params );
|
|
||||||
if( !InputFile.set || !OutputFile.set ) help(argv[0]);
|
|
||||||
if( !RemoveIslands.set && !DecimateMesh.set ) help (argv[0]);
|
|
||||||
|
|
||||||
|
|
||||||
logWriter.verbose = Verbose.set;
|
|
||||||
// logWriter.outputFile = "odm_cleanmesh_log.txt";
|
|
||||||
logArgs(params, logWriter);
|
|
||||||
|
|
||||||
vtkSmartPointer<vtkPLYReader> reader =
|
|
||||||
vtkSmartPointer<vtkPLYReader>::New();
|
|
||||||
reader->SetFileName ( InputFile.value );
|
|
||||||
reader->Update();
|
|
||||||
|
|
||||||
vtkPolyData *nextOutput = reader->GetOutput();
|
|
||||||
|
|
||||||
vtkSmartPointer<vtkPolyDataConnectivityFilter> connectivityFilter =
|
|
||||||
vtkSmartPointer<vtkPolyDataConnectivityFilter>::New();
|
|
||||||
connectivityFilter->SetExtractionModeToLargestRegion();
|
|
||||||
|
|
||||||
vtkSmartPointer<vtkQuadricDecimation> decimationFilter =
|
|
||||||
vtkSmartPointer<vtkQuadricDecimation>::New();
|
|
||||||
|
|
||||||
if (RemoveIslands.set){
|
|
||||||
logWriter("Removing islands\n");
|
|
||||||
connectivityFilter->SetInputData(nextOutput);
|
|
||||||
connectivityFilter->Update();
|
|
||||||
nextOutput = connectivityFilter->GetOutput();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DecimateMesh.set){
|
|
||||||
logWriter("Decimating mesh\n");
|
|
||||||
|
|
||||||
int vertexCount = nextOutput->GetNumberOfPoints();
|
|
||||||
logWriter("Current vertex count: %d\n", vertexCount);
|
|
||||||
logWriter("Wanted vertex count: %d\n", DecimateMesh.value);
|
|
||||||
|
|
||||||
if (vertexCount > DecimateMesh.value){
|
|
||||||
double targetReduction = 1.0 - static_cast<double>(DecimateMesh.value) / static_cast<double>(vertexCount);
|
|
||||||
logWriter("Target reduction set to %f\n", targetReduction);
|
|
||||||
decimationFilter->SetTargetReduction(targetReduction);
|
|
||||||
decimationFilter->SetInputData(nextOutput);
|
|
||||||
decimationFilter->Update();
|
|
||||||
nextOutput = decimationFilter->GetOutput();
|
|
||||||
}else{
|
|
||||||
logWriter("Skipping decimation\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logWriter("Saving cleaned mesh to file... \n");
|
|
||||||
|
|
||||||
vtkSmartPointer<vtkPLYWriter> plyWriter =
|
|
||||||
vtkSmartPointer<vtkPLYWriter>::New();
|
|
||||||
plyWriter->SetFileName(OutputFile.value);
|
|
||||||
plyWriter->SetFileTypeToBinary();
|
|
||||||
plyWriter->SetInputData(nextOutput);
|
|
||||||
plyWriter->Write();
|
|
||||||
|
|
||||||
logWriter("OK\n");
|
|
||||||
}
|
|
|
@ -11,6 +11,10 @@ add_definitions(-Wall -Wextra)
|
||||||
# Find pcl at the location specified by PCL_DIR
|
# Find pcl at the location specified by PCL_DIR
|
||||||
find_package(PCL 1.8 HINTS "${PCL_DIR}/share/pcl-1.8" REQUIRED)
|
find_package(PCL 1.8 HINTS "${PCL_DIR}/share/pcl-1.8" REQUIRED)
|
||||||
find_package(GDAL REQUIRED)
|
find_package(GDAL REQUIRED)
|
||||||
|
|
||||||
|
# PCL should already link to Boost, but for some reason it doesn't...
|
||||||
|
find_package(Boost COMPONENTS filesystem REQUIRED)
|
||||||
|
|
||||||
include_directories(${GDAL_INCLUDE_DIR})
|
include_directories(${GDAL_INCLUDE_DIR})
|
||||||
|
|
||||||
# Find OpenCV at the default location
|
# Find OpenCV at the default location
|
||||||
|
@ -35,4 +39,4 @@ add_executable(${PROJECT_NAME} ${SRC_LIST})
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||||
CXX_STANDARD 11
|
CXX_STANDARD 11
|
||||||
)
|
)
|
||||||
target_link_libraries(odm_orthophoto ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES} ${PCL_SURFACE_LIBRARIES} ${OpenCV_LIBS} ${GDAL_LIBRARY})
|
target_link_libraries(odm_orthophoto ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES} ${PCL_SURFACE_LIBRARIES} ${OpenCV_LIBS} ${GDAL_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
|
||||||
|
|
|
@ -542,6 +542,14 @@ def config(argv=None, parser=None):
|
||||||
default=False,
|
default=False,
|
||||||
help='Set this parameter if you want to generate a PNG rendering of the orthophoto. '
|
help='Set this parameter if you want to generate a PNG rendering of the orthophoto. '
|
||||||
'Default: %(default)s')
|
'Default: %(default)s')
|
||||||
|
|
||||||
|
parser.add_argument('--orthophoto-kmz',
|
||||||
|
action=StoreTrue,
|
||||||
|
nargs=0,
|
||||||
|
default=False,
|
||||||
|
help='Set this parameter if you want to generate a Google Earth (KMZ) rendering of the orthophoto. '
|
||||||
|
'Default: %(default)s')
|
||||||
|
|
||||||
|
|
||||||
parser.add_argument('--orthophoto-compression',
|
parser.add_argument('--orthophoto-compression',
|
||||||
metavar='<string>',
|
metavar='<string>',
|
||||||
|
|
|
@ -8,8 +8,6 @@ root_path, _ = os.path.split(current_path)
|
||||||
|
|
||||||
superbuild_path = os.path.join(root_path, 'SuperBuild')
|
superbuild_path = os.path.join(root_path, 'SuperBuild')
|
||||||
superbuild_bin_path = os.path.join(superbuild_path, 'install', 'bin')
|
superbuild_bin_path = os.path.join(superbuild_path, 'install', 'bin')
|
||||||
tests_path = os.path.join(root_path, 'tests')
|
|
||||||
tests_data_path = os.path.join(root_path, 'tests/test_data')
|
|
||||||
|
|
||||||
# add opencv,opensfm to python path
|
# add opencv,opensfm to python path
|
||||||
python_packages_paths = [os.path.join(superbuild_path, p) for p in [
|
python_packages_paths = [os.path.join(superbuild_path, p) for p in [
|
||||||
|
@ -24,18 +22,16 @@ for p in python_packages_paths:
|
||||||
# define opensfm path
|
# define opensfm path
|
||||||
opensfm_path = os.path.join(superbuild_path, "src/opensfm")
|
opensfm_path = os.path.join(superbuild_path, "src/opensfm")
|
||||||
|
|
||||||
# define orb_slam2 path
|
poisson_recon_path = os.path.join(superbuild_bin_path, 'PoissonRecon')
|
||||||
orb_slam2_path = os.path.join(superbuild_path, "src/orb_slam2")
|
dem2mesh_path = os.path.join(superbuild_bin_path, 'dem2mesh')
|
||||||
|
dem2points_path = os.path.join(superbuild_path, 'dem2points')
|
||||||
poisson_recon_path = os.path.join(superbuild_path, 'src', 'PoissonRecon', 'Bin', 'Linux', 'PoissonRecon')
|
|
||||||
dem2mesh_path = os.path.join(superbuild_path, 'src', 'dem2mesh', 'dem2mesh')
|
|
||||||
dem2points_path = os.path.join(superbuild_path, 'src', 'dem2points', 'dem2points')
|
|
||||||
|
|
||||||
# define mvstex path
|
# define mvstex path
|
||||||
mvstex_path = os.path.join(superbuild_path, "install/bin/texrecon")
|
mvstex_path = os.path.join(superbuild_bin_path, "texrecon")
|
||||||
|
|
||||||
# openmvs paths
|
# openmvs paths
|
||||||
omvs_densify_path = os.path.join(superbuild_path, "install/bin/OpenMVS/DensifyPointCloud")
|
omvs_densify_path = os.path.join(superbuild_bin_path, "OpenMVS", "DensifyPointCloud")
|
||||||
|
omvs_reconstructmesh_path = os.path.join(superbuild_bin_path, "OpenMVS", "ReconstructMesh")
|
||||||
|
|
||||||
# define txt2las path
|
# define txt2las path
|
||||||
txt2las_path = os.path.join(superbuild_path, 'src/las-tools/bin')
|
txt2las_path = os.path.join(superbuild_path, 'src/las-tools/bin')
|
||||||
|
|
|
@ -11,7 +11,7 @@ def has_gpus():
|
||||||
try:
|
try:
|
||||||
import pyopencl
|
import pyopencl
|
||||||
except:
|
except:
|
||||||
log.ODM_INFO("PyOpenCL is missing (not a GPU build)")
|
log.ODM_INFO("Not using the GPU")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -117,17 +117,18 @@ def dem_to_mesh_gridded(inGeotiff, outMesh, maxVertexCount, verbose=False, maxCo
|
||||||
# Cleanup and reduce vertex count if necessary
|
# Cleanup and reduce vertex count if necessary
|
||||||
# (as dem2mesh cannot guarantee that we'll have the target vertex count)
|
# (as dem2mesh cannot guarantee that we'll have the target vertex count)
|
||||||
cleanupArgs = {
|
cleanupArgs = {
|
||||||
'bin': context.odm_modules_path,
|
'reconstructmesh': context.omvs_reconstructmesh_path,
|
||||||
'outfile': outMesh,
|
'outfile': outMesh,
|
||||||
'infile': outMeshDirty,
|
'infile': outMeshDirty,
|
||||||
'max_vertex': maxVertexCount,
|
'max_faces': maxVertexCount * 2,
|
||||||
'verbose': '-verbose' if verbose else ''
|
'verbose': '-verbose' if verbose else ''
|
||||||
}
|
}
|
||||||
|
|
||||||
system.run('{bin}/odm_cleanmesh -inputFile {infile} '
|
system.run('{reconstructmesh} --mesh-file "{infile}" '
|
||||||
'-outputFile {outfile} '
|
'-o "{outfile}" '
|
||||||
'-removeIslands '
|
'--remove-spikes 0 --remove-spurious 0 --smooth 0 '
|
||||||
'-decimateMesh {max_vertex} {verbose} '.format(**cleanupArgs))
|
'--target-face-num {max_faces} '
|
||||||
|
'{verbose} '.format(**cleanupArgs))
|
||||||
|
|
||||||
# Delete intermediate results
|
# Delete intermediate results
|
||||||
os.remove(outMeshDirty)
|
os.remove(outMeshDirty)
|
||||||
|
@ -170,17 +171,18 @@ def screened_poisson_reconstruction(inPointCloud, outMesh, depth = 8, samples =
|
||||||
|
|
||||||
# Cleanup and reduce vertex count if necessary
|
# Cleanup and reduce vertex count if necessary
|
||||||
cleanupArgs = {
|
cleanupArgs = {
|
||||||
'bin': context.odm_modules_path,
|
'reconstructmesh': context.omvs_reconstructmesh_path,
|
||||||
'outfile': outMesh,
|
'outfile': outMesh,
|
||||||
'infile': outMeshDirty,
|
'infile': outMeshDirty,
|
||||||
'max_vertex': maxVertexCount,
|
'max_faces': maxVertexCount * 2,
|
||||||
'verbose': '-verbose' if verbose else ''
|
'verbose': '-verbose' if verbose else ''
|
||||||
}
|
}
|
||||||
|
|
||||||
system.run('{bin}/odm_cleanmesh -inputFile {infile} '
|
system.run('{reconstructmesh} --mesh-file "{infile}" '
|
||||||
'-outputFile {outfile} '
|
'-o "{outfile}" '
|
||||||
'-removeIslands '
|
'--remove-spikes 0 --remove-spurious 0 --smooth 0 '
|
||||||
'-decimateMesh {max_vertex} {verbose} '.format(**cleanupArgs))
|
'--target-face-num {max_faces} '
|
||||||
|
'{verbose} '.format(**cleanupArgs))
|
||||||
|
|
||||||
# Delete intermediate results
|
# Delete intermediate results
|
||||||
os.remove(outMeshDirty)
|
os.remove(outMeshDirty)
|
||||||
|
|
|
@ -54,7 +54,20 @@ def generate_png(orthophoto_file, output_file=None, outsize=None):
|
||||||
system.run('gdal_translate -of png "%s" "%s" %s %s '
|
system.run('gdal_translate -of png "%s" "%s" %s %s '
|
||||||
'--config GDAL_CACHEMAX %s%% ' % (orthophoto_file, output_file, osparam, bandparam, get_max_memory()))
|
'--config GDAL_CACHEMAX %s%% ' % (orthophoto_file, output_file, osparam, bandparam, get_max_memory()))
|
||||||
|
|
||||||
|
def generate_kmz(orthophoto_file, output_file=None, outsize=None):
|
||||||
|
if output_file is None:
|
||||||
|
base, ext = os.path.splitext(orthophoto_file)
|
||||||
|
output_file = base + '.kmz'
|
||||||
|
|
||||||
|
# See if we need to select top three bands
|
||||||
|
bandparam = ""
|
||||||
|
gtif = gdal.Open(orthophoto_file)
|
||||||
|
if gtif.RasterCount > 4:
|
||||||
|
bandparam = "-b 1 -b 2 -b 3 -a_nodata 0"
|
||||||
|
|
||||||
|
system.run('gdal_translate -of KMLSUPEROVERLAY -co FORMAT=JPEG "%s" "%s" %s '
|
||||||
|
'--config GDAL_CACHEMAX %s%% ' % (orthophoto_file, output_file, bandparam, get_max_memory()))
|
||||||
|
|
||||||
def post_orthophoto_steps(args, bounds_file_path, orthophoto_file, orthophoto_tiles_dir):
|
def post_orthophoto_steps(args, bounds_file_path, orthophoto_file, orthophoto_tiles_dir):
|
||||||
if args.crop > 0:
|
if args.crop > 0:
|
||||||
Cropper.crop(bounds_file_path, orthophoto_file, get_orthophoto_vars(args), keep_original=not args.optimize_disk_space, warp_options=['-dstalpha'])
|
Cropper.crop(bounds_file_path, orthophoto_file, get_orthophoto_vars(args), keep_original=not args.optimize_disk_space, warp_options=['-dstalpha'])
|
||||||
|
@ -64,6 +77,9 @@ def post_orthophoto_steps(args, bounds_file_path, orthophoto_file, orthophoto_ti
|
||||||
|
|
||||||
if args.orthophoto_png:
|
if args.orthophoto_png:
|
||||||
generate_png(orthophoto_file)
|
generate_png(orthophoto_file)
|
||||||
|
|
||||||
|
if args.orthophoto_kmz:
|
||||||
|
generate_kmz(orthophoto_file)
|
||||||
|
|
||||||
if args.tiles:
|
if args.tiles:
|
||||||
generate_orthophoto_tiles(orthophoto_file, orthophoto_tiles_dir, args.max_concurrency)
|
generate_orthophoto_tiles(orthophoto_file, orthophoto_tiles_dir, args.max_concurrency)
|
||||||
|
|
|
@ -157,7 +157,7 @@ class OSFMContext:
|
||||||
# Compute feature_process_size
|
# Compute feature_process_size
|
||||||
feature_process_size = 2048 # default
|
feature_process_size = 2048 # default
|
||||||
|
|
||||||
if 'resize_to_is_set' in args:
|
if ('resize_to_is_set' in args) and args.resize_to > 0:
|
||||||
# Legacy
|
# Legacy
|
||||||
log.ODM_WARNING("Legacy option --resize-to (this might be removed in a future version). Use --feature-quality instead.")
|
log.ODM_WARNING("Legacy option --resize-to (this might be removed in a future version). Use --feature-quality instead.")
|
||||||
feature_process_size = int(args.resize_to)
|
feature_process_size = int(args.resize_to)
|
||||||
|
@ -175,6 +175,7 @@ class OSFMContext:
|
||||||
if max_dim > 0:
|
if max_dim > 0:
|
||||||
log.ODM_INFO("Maximum photo dimensions: %spx" % str(max_dim))
|
log.ODM_INFO("Maximum photo dimensions: %spx" % str(max_dim))
|
||||||
feature_process_size = int(max_dim * feature_quality_scale[args.feature_quality])
|
feature_process_size = int(max_dim * feature_quality_scale[args.feature_quality])
|
||||||
|
log.ODM_INFO("Photo dimensions for feature extraction: %ipx" % feature_process_size)
|
||||||
else:
|
else:
|
||||||
log.ODM_WARNING("Cannot compute max image dimensions, going with defaults")
|
log.ODM_WARNING("Cannot compute max image dimensions, going with defaults")
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,6 @@ parts:
|
||||||
- libswscale-dev
|
- libswscale-dev
|
||||||
- libtbb-dev
|
- libtbb-dev
|
||||||
- libtiff-dev
|
- libtiff-dev
|
||||||
- libvtk6-dev
|
|
||||||
- libxext-dev
|
- libxext-dev
|
||||||
- proj-bin
|
- proj-bin
|
||||||
stage-packages:
|
stage-packages:
|
||||||
|
@ -109,7 +108,6 @@ parts:
|
||||||
- libswscale5
|
- libswscale5
|
||||||
- libtbb2
|
- libtbb2
|
||||||
- libtiff5
|
- libtiff5
|
||||||
- libvtk6.3
|
|
||||||
- libwebpdemux2
|
- libwebpdemux2
|
||||||
- libxext6
|
- libxext6
|
||||||
|
|
||||||
|
@ -213,7 +211,9 @@ parts:
|
||||||
- -odm/SuperBuild/src/pcl
|
- -odm/SuperBuild/src/pcl
|
||||||
- -odm/SuperBuild/src/pdal
|
- -odm/SuperBuild/src/pdal
|
||||||
- -odm/SuperBuild/src/vcg
|
- -odm/SuperBuild/src/vcg
|
||||||
- -odm/SuperBuild/src/zstd
|
- -odm/SuperBuild/src/dem2mesh
|
||||||
|
- -odm/SuperBuild/src/dem2points
|
||||||
|
- -odm/SuperBuild/src/PoissonRecon
|
||||||
prime:
|
prime:
|
||||||
# remove any static-libraries
|
# remove any static-libraries
|
||||||
- -**/*.a
|
- -**/*.a
|
||||||
|
|
|
@ -17,6 +17,7 @@ class ODMOpenMVSStage(types.ODM_Stage):
|
||||||
tree = outputs['tree']
|
tree = outputs['tree']
|
||||||
reconstruction = outputs['reconstruction']
|
reconstruction = outputs['reconstruction']
|
||||||
photos = reconstruction.photos
|
photos = reconstruction.photos
|
||||||
|
octx = OSFMContext(tree.opensfm)
|
||||||
|
|
||||||
if not photos:
|
if not photos:
|
||||||
log.ODM_ERROR('Not enough photos in photos array to start OpenMVS')
|
log.ODM_ERROR('Not enough photos in photos array to start OpenMVS')
|
||||||
|
@ -31,7 +32,6 @@ class ODMOpenMVSStage(types.ODM_Stage):
|
||||||
# export reconstruction from opensfm
|
# export reconstruction from opensfm
|
||||||
openmvs_scene_file = os.path.join(tree.openmvs, "scene.mvs")
|
openmvs_scene_file = os.path.join(tree.openmvs, "scene.mvs")
|
||||||
if not io.file_exists(openmvs_scene_file) or self.rerun():
|
if not io.file_exists(openmvs_scene_file) or self.rerun():
|
||||||
octx = OSFMContext(tree.opensfm)
|
|
||||||
cmd = 'export_openmvs'
|
cmd = 'export_openmvs'
|
||||||
octx.run(cmd)
|
octx.run(cmd)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -28,8 +28,6 @@ class ODMOpenSfMStage(types.ODM_Stage):
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
octx = OSFMContext(tree.opensfm)
|
octx = OSFMContext(tree.opensfm)
|
||||||
# TODO REMOVE
|
|
||||||
# octx.setup(args, tree.dataset_raw, reconstruction=reconstruction, rerun=False)
|
|
||||||
octx.setup(args, tree.dataset_raw, reconstruction=reconstruction, rerun=self.rerun())
|
octx.setup(args, tree.dataset_raw, reconstruction=reconstruction, rerun=self.rerun())
|
||||||
octx.extract_metadata(self.rerun())
|
octx.extract_metadata(self.rerun())
|
||||||
self.update_progress(20)
|
self.update_progress(20)
|
||||||
|
|
|
@ -15,3 +15,4 @@ boost-signals2
|
||||||
boost-interprocess
|
boost-interprocess
|
||||||
boost-graph
|
boost-graph
|
||||||
boost-asio
|
boost-asio
|
||||||
|
libgeotiff
|
Ładowanie…
Reference in New Issue