├── src ├── auxiliary │ ├── ocv_tools.h │ ├── CMakeLists.txt │ ├── plywriter.h │ ├── memory.hpp │ ├── memory.cpp │ ├── ocv_tools.cpp │ ├── threadpool.h │ ├── debug.hpp │ ├── threadpool.cpp │ ├── multivector.h │ └── debug.cpp ├── camerautils │ ├── CMakeLists.txt │ └── camerautils.hpp ├── fusion │ ├── treeandbrick_incremental_recursive.hpp │ ├── CMakeLists.txt │ ├── geometryfusion_aos.hpp │ ├── mesh_interleaved.hpp │ ├── geometryfusion_aos.cpp │ ├── treeandbrick_indexed.hpp │ ├── mesh_interleaved_meshcell.hpp │ ├── inline_functions.hpp │ ├── mesh_interleaved.cpp │ ├── treeandbrick.hpp │ ├── definitions.h │ ├── mesh.hpp │ └── loopclosure.cpp ├── tclap │ ├── Makefile.am │ ├── Visitor.h │ ├── IgnoreRestVisitor.h │ ├── OptionalUnlabeledTracker.h │ ├── Constraint.h │ ├── CmdLineOutput.h │ ├── HelpVisitor.h │ ├── VersionVisitor.h │ ├── ArgTraits.h │ ├── ValuesConstraint.h │ ├── CmdLineInterface.h │ ├── XorHandler.h │ ├── StandardTraits.h │ ├── ArgException.h │ ├── MultiSwitchArg.h │ ├── SwitchArg.h │ ├── ZshCompletionOutput.h │ ├── DocBookOutput.h │ ├── StdOutput.h │ ├── UnlabeledMultiArg.h │ └── UnlabeledValueArg.h ├── CMakeLists.txt └── onlinefusionviewer.hpp ├── CMakeLists.txt └── README.md /src/auxiliary/ocv_tools.h: -------------------------------------------------------------------------------- 1 | #ifndef OCV_TOOLS_H 2 | #define OCV_TOOLS_H 3 | 4 | #include 5 | #include 6 | 7 | std::string type_to_string(cv::Mat m); 8 | 9 | #endif // OCV_TOOLS_H 10 | -------------------------------------------------------------------------------- /src/auxiliary/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(auxiliary ${CPU_LIBRARY_TYPE} 2 | debug.cpp memory.cpp threadpool.cpp plywriter.cpp ocv_tools.cpp) 3 | #cuda_add_library(auxiliaryGPU ${GPU_LIBRARY_TYPE} 4 | #cuda_basic.cu 5 | #OPTIONS ${CUDAOPTIONS}) 6 | -------------------------------------------------------------------------------- /src/camerautils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(camerautils_SOURCES camerautils.cpp) 2 | 3 | include_directories(${PROJECT_SOURCE_DIR}/src/camerautils) 4 | include_directories("/usr/include/eigen3") 5 | 6 | add_library(camerautils ${camerautils_SOURCES}) 7 | target_link_libraries(camerautils 8 | ) 9 | -------------------------------------------------------------------------------- /src/fusion/treeandbrick_incremental_recursive.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TREEANDBRICK_INCREMENTAL_RECURSIVE_HPP 2 | #define TREEANDBRICK_INCREMENTAL_RECURSIVE_HPP 3 | 4 | 5 | void addInterior_incremental 6 | ( 7 | leafstack leaves, 8 | treeinfo info, 9 | volumetype index, sidetype size, 10 | sidetype ox, sidetype oy, sidetype oz, 11 | volumetype lastLeaf, 12 | const MarchingCubesIndexed &mc, 13 | const ParentArray &leafParent, 14 | std::vector *meshCells = NULL 15 | ); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/auxiliary/plywriter.h: -------------------------------------------------------------------------------- 1 | #ifndef WRITEPLY_H 2 | #define WRITEPLY_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | bool writePLY(const std::string& filename, const cv::Mat &disparity,cv::Mat img, const cv::Mat &Q, const cv::Mat &rH); 14 | bool writePLYBinary(const std::string& filename, const cv::Mat &disparity,cv::Mat img, const cv::Mat &Q, const cv::Mat &rH); 15 | bool writePLYVerticesOnly(const std::string& filename, const cv::Mat &disparity, const cv::Mat &img, const cv::Mat &Q, const cv::Mat &rH); 16 | 17 | 18 | #endif // WRITEPLY_H 19 | -------------------------------------------------------------------------------- /src/tclap/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | libtclapincludedir = $(includedir)/tclap 3 | 4 | libtclapinclude_HEADERS = \ 5 | CmdLineInterface.h \ 6 | ArgException.h \ 7 | CmdLine.h \ 8 | XorHandler.h \ 9 | MultiArg.h \ 10 | UnlabeledMultiArg.h \ 11 | ValueArg.h \ 12 | UnlabeledValueArg.h \ 13 | Visitor.h Arg.h \ 14 | HelpVisitor.h \ 15 | SwitchArg.h \ 16 | MultiSwitchArg.h \ 17 | VersionVisitor.h \ 18 | IgnoreRestVisitor.h \ 19 | CmdLineOutput.h \ 20 | StdOutput.h \ 21 | DocBookOutput.h \ 22 | ZshCompletionOutput.h \ 23 | OptionalUnlabeledTracker.h \ 24 | Constraint.h \ 25 | ValuesConstraint.h \ 26 | ArgTraits.h \ 27 | StandardTraits.h 28 | 29 | -------------------------------------------------------------------------------- /src/auxiliary/memory.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * memory.hpp 3 | * 4 | * Created on: Feb 27, 2013 5 | * Author: steinbrf 6 | */ 7 | 8 | #ifndef MEMORY_HPP_ 9 | #define MEMORY_HPP_ 10 | 11 | #include 12 | 13 | 14 | long long getTotalSystemMemory(); 15 | long long getAvailableSystemMemory(); 16 | 17 | typedef struct ProcessMemoryStats_ { 18 | size_t size; 19 | size_t resident; 20 | size_t shared; 21 | size_t trs; 22 | size_t drs; 23 | size_t lrs; 24 | size_t dt; 25 | size_t pageSize; 26 | } ProcessMemoryStats; 27 | 28 | ProcessMemoryStats getProcessMemory(); 29 | inline void printProcessMemory(FILE *stream = stderr) 30 | { 31 | ProcessMemoryStats usedMemory = getProcessMemory(); 32 | fprintf(stream,"\nUsed Memory: %li Pages, %li Bytes/Page := %li Bytes", 33 | usedMemory.size,usedMemory.pageSize,usedMemory.size*usedMemory.pageSize); 34 | } 35 | 36 | 37 | #endif /* MEMORY_HPP_ */ 38 | -------------------------------------------------------------------------------- /src/auxiliary/memory.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * memory.cpp 3 | * 4 | * Created on: Feb 27, 2013 5 | * Author: steinbrf 6 | */ 7 | 8 | #include "memory.hpp" 9 | #include 10 | #include 11 | #include 12 | long long getTotalSystemMemory() 13 | { 14 | long long pages = sysconf(_SC_PHYS_PAGES); 15 | long long page_size = sysconf(_SC_PAGE_SIZE); 16 | return pages * page_size; 17 | } 18 | 19 | long long getAvailableSystemMemory() 20 | { 21 | long long pages = sysconf(_SC_AVPHYS_PAGES); 22 | long long page_size = sysconf(_SC_PAGE_SIZE); 23 | return pages * page_size; 24 | } 25 | 26 | ProcessMemoryStats getProcessMemory(){ 27 | std::fstream file("/proc/self/statm"); 28 | ProcessMemoryStats result; 29 | file >> result.size; 30 | file >> result.resident; 31 | file >> result.shared; 32 | file >> result.trs; 33 | file >> result.drs; 34 | file >> result.lrs; 35 | file >> result.dt; 36 | result.pageSize = sysconf(_SC_PAGE_SIZE); 37 | return result; 38 | } 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/auxiliary/ocv_tools.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | std::string type_to_string(cv::Mat m) 4 | { 5 | if(m.type() == cv::DataType::type) 6 | { 7 | return "uchar"; 8 | } 9 | if(m.type() == cv::DataType::type) 10 | { 11 | return "ushort"; 12 | } 13 | if(m.type() == cv::DataType::type) 14 | { 15 | return "short"; 16 | } 17 | if(m.type() == cv::DataType::type) 18 | { 19 | return "char"; 20 | } 21 | if(m.type() == cv::DataType::type) 22 | { 23 | return "float"; 24 | } 25 | if(m.type() == cv::DataType::type) 26 | { 27 | return "double"; 28 | } 29 | if(m.type() == cv::DataType::type) 30 | { 31 | return "uint"; 32 | } 33 | if(m.type() == cv::DataType::type) 34 | { 35 | return "int"; 36 | } 37 | if(m.type() == cv::DataType::type) 38 | { 39 | return "float3"; 40 | } 41 | return "unknown"; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/fusion/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories("/usr/include/nvidia-current/cuda") 3 | include_directories("/work/sdks/cudaversions/cuda50/cuda/include") 4 | include_directories("/home/steinbrf/sdks/cudaversions/cuda50/cuda/include") 5 | #find_package(Qt REQUIRED) 6 | 7 | #INCLUDE(${QT_USE_FILE}) 8 | include_directories("/usr/include/qt4/QtXml") 9 | include_directories("/usr/include/qt4") 10 | include_directories("/usr/include/qt4/Qt") 11 | include_directories("/usr/include/qt4/QtCore") 12 | include_directories("/usr/include/qt4/QtXml") 13 | include_directories("/usr/include/qt4/QtGui") 14 | include_directories("/usr/include/qt4/QtOpenGL") 15 | ADD_DEFINITIONS(${QT_DEFINITIONS}) 16 | 17 | include_directories("..") 18 | 19 | add_library(geometryfusion_aos STATIC 20 | geometryfusion_aos.cpp 21 | treeandbrick.cpp 22 | treeandbrick_indexed.cpp 23 | treeandbrick_incremental.cpp 24 | treeandbrick_incremental_recursive.cpp 25 | mesh.cpp 26 | #meshcelltraversal.cpp 27 | mesh_interleaved.cpp 28 | mesh_interleaved_meshcell.cpp 29 | ) 30 | 31 | add_library(geometryfusion_mipmap_cpu STATIC 32 | geometryfusion_mipmap_cpu.cpp 33 | loopclosure.cpp 34 | ) 35 | 36 | -------------------------------------------------------------------------------- /src/tclap/Visitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: Visitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_VISITOR_H 24 | #define TCLAP_VISITOR_H 25 | 26 | namespace TCLAP { 27 | 28 | /** 29 | * A base class that defines the interface for visitors. 30 | */ 31 | class Visitor 32 | { 33 | public: 34 | 35 | /** 36 | * Constructor. Does nothing. 37 | */ 38 | Visitor() { } 39 | 40 | /** 41 | * Destructor. Does nothing. 42 | */ 43 | virtual ~Visitor() { } 44 | 45 | /** 46 | * Does nothing. Should be overridden by child. 47 | */ 48 | virtual void visit() { } 49 | }; 50 | 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/fusion/geometryfusion_aos.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * geometryfusion.hpp 3 | * 4 | * Created on: May 21, 2013 5 | * Author: steinbrf 6 | */ 7 | 8 | #ifndef GEOMETRYFUSION_HPP_ 9 | #define GEOMETRYFUSION_HPP_ 10 | 11 | 12 | //#include 13 | #include 14 | #include 15 | #include "definitions.h" 16 | #include "mesh.hpp" 17 | 18 | //#include 19 | 20 | class Fusion_AoS 21 | { 22 | public: 23 | Fusion_AoS(float offsetX, float offsetY, float offsetZ, float scale, 24 | float distanceThreshold = DISTANCETHRESHOLD, 25 | sidetype n = 0, bool color = true); 26 | Fusion_AoS(float offsetX, float offsetY, float offsetZ, bool color = true, 27 | float maxX = UNENDLICH, float maxY = UNENDLICH, float maxZ = UNENDLICH, sidetype n = SIDELENGTH); 28 | virtual ~Fusion_AoS(); 29 | virtual int addMap(cv::Mat &image, CameraInfo caminfo, 30 | std::vector rgb = std::vector(3)) = 0; 31 | virtual MeshSeparate getMeshSeparateMarchingCubes(MeshSeparate mesh = MeshSeparate(3)) = 0; 32 | virtual MeshSeparate getMeshStructural(unsigned int structureType = 0,MeshSeparate mesh = MeshSeparate(4)) = 0; 33 | float3 offset(); 34 | float size(); 35 | sidetype n(); 36 | 37 | protected: 38 | float3 _offset; 39 | sidetype _n; 40 | float _scale; 41 | bool _useColor; 42 | float _distanceThreshold; 43 | float _distanceWeightSigma; 44 | float _distanceWeightEpsilon; 45 | unsigned int _framesAdded; 46 | double _sumTimeOfAllFrames; 47 | bool _verbose; 48 | }; 49 | 50 | 51 | #endif /* GEOMETRYFUSION_HPP_ */ 52 | -------------------------------------------------------------------------------- /src/tclap/IgnoreRestVisitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: IgnoreRestVisitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_IGNORE_REST_VISITOR_H 24 | #define TCLAP_IGNORE_REST_VISITOR_H 25 | 26 | #include 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | /** 32 | * A Vistor that tells the CmdLine to begin ignoring arguments after 33 | * this one is parsed. 34 | */ 35 | class IgnoreRestVisitor: public Visitor 36 | { 37 | public: 38 | 39 | /** 40 | * Constructor. 41 | */ 42 | IgnoreRestVisitor() : Visitor() {} 43 | 44 | /** 45 | * Sets Arg::_ignoreRest. 46 | */ 47 | void visit() { Arg::beginIgnoring(); } 48 | }; 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/fusion/mesh_interleaved.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * mesh_interleaved.hpp 3 | * 4 | * Created on: Sep 18, 2013 5 | * Author: steinbrf 6 | */ 7 | 8 | #ifndef MESH_INTERLEAVED_HPP_ 9 | #define MESH_INTERLEAVED_HPP_ 10 | 11 | #include "definitions.h" 12 | #include "mesh.hpp" 13 | #include 14 | #include 15 | #include 16 | 17 | class Vertex2f{ 18 | public: 19 | Vertex2f(float x_p, float y_p); 20 | float x; float y; 21 | }; 22 | 23 | //class Vertex3f{ 24 | //public: 25 | // Vertex3f(float x_p, float y_p, float z_p); 26 | // float x; float y; float z; 27 | //}; 28 | 29 | class Color3b{ 30 | public: 31 | Color3b(uchar r_p, uchar g_p, uchar b_p); 32 | uchar r; uchar g; uchar b; 33 | }; 34 | 35 | class MeshInterleaved 36 | { 37 | public: 38 | MeshInterleaved(unsigned int verticesPerFace 39 | // ,size_t reservedVertices = 0, size_t reservedIndices = 0 40 | ); 41 | std::vector vertices; 42 | std::vector faces; 43 | std::vector normals; 44 | std::vector colors; 45 | std::vector edges; 46 | 47 | bool writeOBJ(std::string filename); 48 | bool writePLY(std::string filename, bool binary = true); 49 | 50 | size_t size(); 51 | size_t emptysize(); 52 | 53 | // MeshInterleaved reduce(bool verbose = true); 54 | 55 | MeshInterleaved &operator+=(const MeshInterleaved &mesh); 56 | 57 | // MeshInterleaved &operator=(const MeshInterleaved &mesh); 58 | 59 | // MeshInterleaved sortConnectedComponents(); 60 | // MeshInterleaved componentsOfSize(unsigned int nv); 61 | 62 | uchar _verticesPerFace; 63 | //Texture Coordinates 64 | std::vector texcoords; 65 | 66 | protected: 67 | std::vector materialIndices; 68 | std::vector textures; 69 | }; 70 | 71 | 72 | #endif /* MESH_INTERLEAVED_HPP_ */ 73 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(camerautils) 2 | add_subdirectory(auxiliary) 3 | #add_subdirectory(auxiliaryGPU) 4 | #add_subdirectory(libelas) 5 | #add_subdirectory(output) 6 | add_subdirectory(fusion) 7 | #add_subdirectory(fusionGPU) 8 | #add_subdirectory(sophus) 9 | #add_subdirectory(filesystem) 10 | 11 | 12 | include_directories("/usr/include/qt4/QtXml") 13 | include_directories("/usr/include/qt4") 14 | include_directories("/usr/include/qt4/Qt") 15 | include_directories("/usr/include/qt4/QtCore") 16 | include_directories("/usr/include/qt4/QtXml") 17 | include_directories("/usr/include/qt4/QtGui") 18 | include_directories("/usr/include/qt4/QtOpenGL") 19 | ADD_DEFINITIONS(${QT_DEFINITIONS}) 20 | 21 | if(EXISTS "${ROOT}/usr/lib/x86_64-linux-gnu/libQGLViewer.so") 22 | message(STATUS "Found qglviewer2, linking QGLViewer") 23 | set(QGLVIEWER QGLViewer) 24 | else() 25 | message(STATUS "Did not find qglviewer2, linking qglviewer-qt4") 26 | set(QGLVIEWER qglviewer-qt4) 27 | endif() 28 | 29 | 30 | # add_executable(cameracalibration cameracalib_main.cpp) 31 | # target_link_libraries(cameracalibration 32 | # opencv_core opencv_imgproc opencv_highgui opencv_features2d opencv_calib3d 33 | # ) 34 | # 35 | # add_executable(rectify_known rectify_stereo_known_main.cpp) 36 | # target_link_libraries(rectify_known 37 | # opencv_core opencv_imgproc opencv_highgui opencv_features2d opencv_calib3d 38 | # ) 39 | 40 | 41 | FIND_PACKAGE(Qt4 REQUIRED) 42 | QT4_WRAP_CPP(onlinefusion_HEADERS_MOC onlinefusionviewer.hpp) 43 | 44 | add_executable(onlinefusion 45 | onlinefusionviewer_main.cpp 46 | onlinefusionviewer.cpp 47 | ${onlinefusion_HEADERS_MOC} 48 | ) 49 | target_link_libraries(onlinefusion 50 | geometryfusion_mipmap_cpu geometryfusion_aos 51 | camerautils 52 | auxiliary 53 | ${OpenCV_LIBS} 54 | ${QGLVIEWER} 55 | QtCore QtGui QtOpenGL 56 | GL GLU glut GLEW 57 | boost_thread 58 | boost_system 59 | ) -------------------------------------------------------------------------------- /src/tclap/OptionalUnlabeledTracker.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: OptionalUnlabeledTracker.h 6 | * 7 | * Copyright (c) 2005, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H 25 | #define TCLAP_OPTIONAL_UNLABELED_TRACKER_H 26 | 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | class OptionalUnlabeledTracker 32 | { 33 | 34 | public: 35 | 36 | static void check( bool req, const std::string& argName ); 37 | 38 | static void gotOptional() { alreadyOptionalRef() = true; } 39 | 40 | static bool& alreadyOptional() { return alreadyOptionalRef(); } 41 | 42 | private: 43 | 44 | static bool& alreadyOptionalRef() { static bool ct = false; return ct; } 45 | }; 46 | 47 | 48 | inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName ) 49 | { 50 | if ( OptionalUnlabeledTracker::alreadyOptional() ) 51 | throw( SpecificationException( 52 | "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg", 53 | argName ) ); 54 | 55 | if ( !req ) 56 | OptionalUnlabeledTracker::gotOptional(); 57 | } 58 | 59 | 60 | } // namespace TCLAP 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/tclap/Constraint.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: Constraint.h 5 | * 6 | * Copyright (c) 2005, Michael E. Smoot 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | #ifndef TCLAP_CONSTRAINT_H 23 | #define TCLAP_CONSTRAINT_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * The interface that defines the interaction between the Arg and Constraint. 36 | */ 37 | template 38 | class Constraint 39 | { 40 | 41 | public: 42 | /** 43 | * Returns a description of the Constraint. 44 | */ 45 | virtual std::string description() const =0; 46 | 47 | /** 48 | * Returns the short ID for the Constraint. 49 | */ 50 | virtual std::string shortID() const =0; 51 | 52 | /** 53 | * The method used to verify that the value parsed from the command 54 | * line meets the constraint. 55 | * \param value - The value that will be checked. 56 | */ 57 | virtual bool check(const T& value) const =0; 58 | 59 | /** 60 | * Destructor. 61 | * Silences warnings about Constraint being a base class with virtual 62 | * functions but without a virtual destructor. 63 | */ 64 | virtual ~Constraint() { ; } 65 | }; 66 | 67 | } //namespace TCLAP 68 | #endif 69 | -------------------------------------------------------------------------------- /src/fusion/geometryfusion_aos.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * geometryfusion_aos.cpp 3 | * 4 | * Created on: May 21, 2013 5 | * Author: steinbrf 6 | */ 7 | 8 | #include "geometryfusion_aos.hpp" 9 | 10 | Fusion_AoS::Fusion_AoS(float offsetX, float offsetY, float offsetZ, bool color, 11 | float maxX, float maxY, float maxZ, sidetype n) 12 | : _offset(make_float3(offsetX,offsetY,offsetZ)), _n(n), _useColor(color), 13 | _distanceThreshold(DISTANCETHRESHOLD), 14 | _distanceWeightSigma(DISTANCEWEIGHTSIGMA), _distanceWeightEpsilon(DISTANCEWEIGHTEPSILON), 15 | _framesAdded(0),_sumTimeOfAllFrames(0.0), _verbose(true) 16 | { 17 | float sx = std::isfinite(maxX) && maxX>offsetX ? (maxX-offsetX) : 0.0; 18 | float sy = std::isfinite(maxY) && maxY>offsetY ? (maxY-offsetY) : 0.0; 19 | float sz = std::isfinite(maxZ) && maxZ>offsetZ ? (maxZ-offsetZ) : 0.0; 20 | _scale = std::isfinite(maxX) || std::isfinite(maxY) || std::isfinite(maxZ) ? 21 | (sx>sy ? (sx>sz ? sx : sz) : (sy>sz ? sy : sz))/(float)_n : 1.0f; 22 | } 23 | 24 | Fusion_AoS::Fusion_AoS(float offsetX, float offsetY, float offsetZ, 25 | float scale, float distanceThreshold, sidetype n, bool color) 26 | : _offset(make_float3(offsetX,offsetY,offsetZ)), _n(n), _scale(scale), _useColor(color), 27 | _distanceThreshold(distanceThreshold), 28 | _distanceWeightSigma(DISTANCEWEIGHTSIGMA), _distanceWeightEpsilon(DISTANCEWEIGHTEPSILON), 29 | _framesAdded(0),_sumTimeOfAllFrames(0.0), _verbose(true) 30 | { 31 | if(_n) fprintf(stderr,"\nWARNING: Fusion is given Size %i at Constructor!",_n); 32 | } 33 | Fusion_AoS::~Fusion_AoS() 34 | { 35 | if(_verbose) fprintf(stderr,"\nTotal Time for Array of Structs Fusion: %f", 36 | _sumTimeOfAllFrames/cv::getTickFrequency()); 37 | if(_verbose) fprintf(stderr,"\nAverage Total Time per Frame for Array of Structs Fusion: %f\n\n", 38 | _sumTimeOfAllFrames/(cv::getTickFrequency()*_framesAdded)); 39 | } 40 | 41 | float3 Fusion_AoS::offset(){return _offset;} 42 | float Fusion_AoS::size(){return _n*_scale;} 43 | sidetype Fusion_AoS::n(){return _n;} 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/fusion/treeandbrick_indexed.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TREEANDBRICK_INDEXED_HPP 2 | #define TREEANDBRICK_INDEXED_HPP 3 | 4 | 5 | #include "treeandbrick.hpp" 6 | 7 | 8 | void addBrickEdgeX_indexed 9 | ( 10 | treeinfo info, 11 | sidetype ox, sidetype oy, sidetype oz, 12 | sidetype size, 13 | leafstack leaves0, leafstack leaves1, leafstack leaves2, leafstack leaves3, 14 | const MarchingCubesIndexed &mc 15 | ); 16 | 17 | void addBrickEdgeY_indexed 18 | ( 19 | treeinfo info, 20 | sidetype ox, sidetype oy, sidetype oz, 21 | sidetype size, 22 | leafstack leaves0, leafstack leaves1, leafstack leaves2, leafstack leaves3, 23 | const MarchingCubesIndexed &mc 24 | ); 25 | 26 | void addBrickEdgeZ_indexed 27 | ( 28 | treeinfo info, 29 | sidetype ox, sidetype oy, sidetype oz, 30 | sidetype size, 31 | leafstack leaves0, leafstack leaves1, leafstack leaves2, leafstack leaves3, 32 | const MarchingCubesIndexed &mc 33 | ); 34 | 35 | void addBrickWallX_indexed 36 | ( 37 | treeinfo info, 38 | sidetype ox, sidetype oy, sidetype oz, 39 | sidetype size, 40 | leafstack leaves0, 41 | leafstack leaves1, 42 | const MarchingCubesIndexed &mc 43 | ); 44 | 45 | void addBrickWallY_indexed 46 | ( 47 | treeinfo info, 48 | sidetype ox, sidetype oy, sidetype oz, 49 | sidetype size, 50 | leafstack leaves0, 51 | leafstack leaves1, 52 | const MarchingCubesIndexed &mc 53 | ); 54 | void addBrickWallZ_indexed 55 | ( 56 | treeinfo info, 57 | sidetype ox, sidetype oy, sidetype oz, 58 | sidetype size, 59 | leafstack leaves0, 60 | leafstack leaves1, 61 | const MarchingCubesIndexed &mc 62 | ); 63 | 64 | 65 | 66 | void addBrickInterior_indexed 67 | ( 68 | leafstack leaves, 69 | sidetype ox, sidetype oy, sidetype oz, 70 | sidetype size, 71 | treeinfo info, 72 | const MarchingCubesIndexed &mc 73 | ); 74 | 75 | void addBrickMiddle_indexed 76 | ( 77 | treeinfo info, 78 | sidetype ox, sidetype oy, sidetype oz, 79 | sidetype size, 80 | leafstack leaves0, leafstack leaves1, leafstack leaves2, leafstack leaves3, 81 | leafstack leaves4, leafstack leaves5, leafstack leaves6, leafstack leaves7, 82 | const MarchingCubesIndexed &mc 83 | ); 84 | 85 | 86 | #endif 87 | 88 | 89 | -------------------------------------------------------------------------------- /src/tclap/CmdLineOutput.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: CmdLineOutput.h 6 | * 7 | * Copyright (c) 2004, Michael E. Smoot 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_CMDLINEOUTPUT_H 24 | #define TCLAP_CMDLINEOUTPUT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | namespace TCLAP { 34 | 35 | class CmdLineInterface; 36 | class ArgException; 37 | 38 | /** 39 | * The interface that any output object must implement. 40 | */ 41 | class CmdLineOutput 42 | { 43 | 44 | public: 45 | 46 | /** 47 | * Virtual destructor. 48 | */ 49 | virtual ~CmdLineOutput() {} 50 | 51 | /** 52 | * Generates some sort of output for the USAGE. 53 | * \param c - The CmdLine object the output is generated for. 54 | */ 55 | virtual void usage(CmdLineInterface& c)=0; 56 | 57 | /** 58 | * Generates some sort of output for the version. 59 | * \param c - The CmdLine object the output is generated for. 60 | */ 61 | virtual void version(CmdLineInterface& c)=0; 62 | 63 | /** 64 | * Generates some sort of output for a failure. 65 | * \param c - The CmdLine object the output is generated for. 66 | * \param e - The ArgException that caused the failure. 67 | */ 68 | virtual void failure( CmdLineInterface& c, 69 | ArgException& e )=0; 70 | 71 | }; 72 | 73 | } //namespace TCLAP 74 | #endif 75 | -------------------------------------------------------------------------------- /src/tclap/HelpVisitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: HelpVisitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | #ifndef TCLAP_HELP_VISITOR_H 23 | #define TCLAP_HELP_VISITOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | /** 32 | * A Visitor object that calls the usage method of the given CmdLineOutput 33 | * object for the specified CmdLine object. 34 | */ 35 | class HelpVisitor: public Visitor 36 | { 37 | private: 38 | /** 39 | * Prevent accidental copying. 40 | */ 41 | HelpVisitor(const HelpVisitor& rhs); 42 | HelpVisitor& operator=(const HelpVisitor& rhs); 43 | 44 | protected: 45 | 46 | /** 47 | * The CmdLine the output will be generated for. 48 | */ 49 | CmdLineInterface* _cmd; 50 | 51 | /** 52 | * The output object. 53 | */ 54 | CmdLineOutput** _out; 55 | 56 | public: 57 | 58 | /** 59 | * Constructor. 60 | * \param cmd - The CmdLine the output will be generated for. 61 | * \param out - The type of output. 62 | */ 63 | HelpVisitor(CmdLineInterface* cmd, CmdLineOutput** out) 64 | : Visitor(), _cmd( cmd ), _out( out ) { } 65 | 66 | /** 67 | * Calls the usage method of the CmdLineOutput for the 68 | * specified CmdLine. 69 | */ 70 | void visit() { (*_out)->usage(*_cmd); throw ExitException(0); } 71 | 72 | }; 73 | 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /src/tclap/VersionVisitor.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: VersionVisitor.h 6 | * 7 | * Copyright (c) 2003, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_VERSION_VISITOR_H 25 | #define TCLAP_VERSION_VISITOR_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace TCLAP { 32 | 33 | /** 34 | * A Vistor that will call the version method of the given CmdLineOutput 35 | * for the specified CmdLine object and then exit. 36 | */ 37 | class VersionVisitor: public Visitor 38 | { 39 | private: 40 | /** 41 | * Prevent accidental copying 42 | */ 43 | VersionVisitor(const VersionVisitor& rhs); 44 | VersionVisitor& operator=(const VersionVisitor& rhs); 45 | 46 | protected: 47 | 48 | /** 49 | * The CmdLine of interest. 50 | */ 51 | CmdLineInterface* _cmd; 52 | 53 | /** 54 | * The output object. 55 | */ 56 | CmdLineOutput** _out; 57 | 58 | public: 59 | 60 | /** 61 | * Constructor. 62 | * \param cmd - The CmdLine the output is generated for. 63 | * \param out - The type of output. 64 | */ 65 | VersionVisitor( CmdLineInterface* cmd, CmdLineOutput** out ) 66 | : Visitor(), _cmd( cmd ), _out( out ) { } 67 | 68 | /** 69 | * Calls the version method of the output object using the 70 | * specified CmdLine. 71 | */ 72 | void visit() { 73 | (*_out)->version(*_cmd); 74 | throw ExitException(0); 75 | } 76 | 77 | }; 78 | 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/fusion/mesh_interleaved_meshcell.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MESH_INTERLEAVED_MESHCELL_HPP 2 | #define MESH_INTERLEAVED_MESHCELL_HPP 3 | 4 | //#define BRICKVISUALIZATION 5 | //#define COLORINVERSION 6 | 7 | void addBrickInterior_indexed_incremental_optimized 8 | ( 9 | volumetype lastleaf, const ParentArray &leafParent, 10 | sidetype ox, sidetype oy, sidetype oz, 11 | sidetype size, 12 | treeinfo info, 13 | const MarchingCubesIndexed &mc, 14 | MeshInterleaved *pmesh 15 | ); 16 | 17 | void addBrickWallX_indexed_incremental 18 | ( 19 | treeinfo info, 20 | sidetype ox, sidetype oy, sidetype oz, 21 | sidetype size, 22 | volumetype lastleaf0, volumetype lastleaf1, 23 | const ParentArray &leafParent, 24 | const MarchingCubesIndexed &mc, 25 | MeshInterleaved *pmesh 26 | ); 27 | 28 | 29 | void addBrickWallY_indexed_incremental 30 | ( 31 | treeinfo info, 32 | sidetype ox, sidetype oy, sidetype oz, 33 | sidetype size, 34 | volumetype lastleaf0, volumetype lastleaf1, 35 | const ParentArray &leafParent, 36 | const MarchingCubesIndexed &mc, 37 | MeshInterleaved *pmesh 38 | ); 39 | 40 | 41 | void addBrickWallZ_indexed_incremental 42 | ( 43 | treeinfo info, 44 | sidetype ox, sidetype oy, sidetype oz, 45 | sidetype size, 46 | volumetype lastleaf0, volumetype lastleaf1, 47 | const ParentArray &leafParent, 48 | const MarchingCubesIndexed &mc, 49 | MeshInterleaved *pmesh 50 | ); 51 | 52 | void addBrickEdgeX_indexed_incremental 53 | ( 54 | treeinfo info, 55 | sidetype ox, sidetype oy, sidetype oz, 56 | sidetype size, 57 | volumetype lastleaf0, volumetype lastleaf1, volumetype lastleaf2, volumetype lastleaf3, 58 | const ParentArray &leafParent, 59 | const MarchingCubesIndexed &mc, 60 | MeshInterleaved *pmesh 61 | ); 62 | 63 | void addBrickEdgeY_indexed_incremental 64 | ( 65 | treeinfo info, 66 | sidetype ox, sidetype oy, sidetype oz, 67 | sidetype size, 68 | volumetype lastleaf0, volumetype lastleaf1, volumetype lastleaf2, volumetype lastleaf3, 69 | const ParentArray &leafParent, 70 | const MarchingCubesIndexed &mc, 71 | MeshInterleaved *pmesh 72 | ); 73 | 74 | void addBrickEdgeZ_indexed_incremental 75 | ( 76 | treeinfo info, 77 | sidetype ox, sidetype oy, sidetype oz, 78 | sidetype size, 79 | volumetype lastleaf0, volumetype lastleaf1, volumetype lastleaf2, volumetype lastleaf3, 80 | const ParentArray &leafParent, 81 | const MarchingCubesIndexed &mc, 82 | MeshInterleaved *pmesh 83 | ); 84 | 85 | //TODO: Das ist noch nicht wirklich indiziert 86 | void addBrickMiddle_indexed_incremental 87 | ( 88 | treeinfo info, 89 | sidetype ox, sidetype oy, sidetype oz, 90 | sidetype size, 91 | volumetype lastleaf0, volumetype lastleaf1, volumetype lastleaf2, volumetype lastleaf3, 92 | volumetype lastleaf4, volumetype lastleaf5, volumetype lastleaf6, volumetype lastleaf7, 93 | const ParentArray &leafParent, 94 | const MarchingCubesIndexed &mc, 95 | MeshInterleaved *pmesh 96 | ); 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /src/tclap/ArgTraits.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ArgTraits.h 6 | * 7 | * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | // This is an internal tclap file, you should probably not have to 24 | // include this directly 25 | 26 | #ifndef TCLAP_ARGTRAITS_H 27 | #define TCLAP_ARGTRAITS_H 28 | 29 | namespace TCLAP { 30 | 31 | // We use two empty structs to get compile type specialization 32 | // function to work 33 | 34 | /** 35 | * A value like argument value type is a value that can be set using 36 | * operator>>. This is the default value type. 37 | */ 38 | struct ValueLike { 39 | typedef ValueLike ValueCategory; 40 | virtual ~ValueLike() {} 41 | }; 42 | 43 | /** 44 | * A string like argument value type is a value that can be set using 45 | * operator=(string). Usefull if the value type contains spaces which 46 | * will be broken up into individual tokens by operator>>. 47 | */ 48 | struct StringLike { 49 | virtual ~StringLike() {} 50 | }; 51 | 52 | /** 53 | * A class can inherit from this object to make it have string like 54 | * traits. This is a compile time thing and does not add any overhead 55 | * to the inherenting class. 56 | */ 57 | struct StringLikeTrait { 58 | typedef StringLike ValueCategory; 59 | virtual ~StringLikeTrait() {} 60 | }; 61 | 62 | /** 63 | * A class can inherit from this object to make it have value like 64 | * traits. This is a compile time thing and does not add any overhead 65 | * to the inherenting class. 66 | */ 67 | struct ValueLikeTrait { 68 | typedef ValueLike ValueCategory; 69 | virtual ~ValueLikeTrait() {} 70 | }; 71 | 72 | /** 73 | * Arg traits are used to get compile type specialization when parsing 74 | * argument values. Using an ArgTraits you can specify the way that 75 | * values gets assigned to any particular type during parsing. The two 76 | * supported types are StringLike and ValueLike. 77 | */ 78 | template 79 | struct ArgTraits { 80 | typedef typename T::ValueCategory ValueCategory; 81 | virtual ~ArgTraits() {} 82 | //typedef ValueLike ValueCategory; 83 | }; 84 | 85 | #endif 86 | 87 | } // namespace 88 | -------------------------------------------------------------------------------- /src/camerautils/camerautils.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * camerautils.hpp 3 | * 4 | * Created on: Nov 8, 2012 5 | * Author: steinbrf 6 | */ 7 | 8 | 9 | #ifndef CAMERAUTILS_HPP_ 10 | #define CAMERAUTILS_HPP_ 11 | 12 | #include 13 | #include 14 | #include 15 | //#include "CCamera.h" 16 | //#include 17 | //#include 18 | //#include 19 | 20 | 21 | 22 | class CameraInfo 23 | { 24 | public: 25 | CameraInfo(const cv::Mat &projection = cv::Mat(),int decompositionMethod = 1); 26 | CameraInfo(const CameraInfo &info); 27 | ~CameraInfo(); 28 | bool setIntrinsic(const cv::Mat &intrinsic); 29 | bool setExtrinsic(const cv::Mat &extrinsic); 30 | bool setRotation(const cv::Mat &rotation); 31 | bool setRotationLogarithm(const cv::Mat &rotationLogarithm); 32 | void setTranslation(const cv::Mat &translation); 33 | bool setProjection(const cv::Mat &projection); 34 | cv::Mat getIntrinsic() const; 35 | cv::Mat getExtrinsic() const; 36 | cv::Mat getExtrinsicInverse() const; 37 | cv::Mat getProjection() const; 38 | cv::Mat getRotation() const; 39 | cv::Mat getRotationQuaternion() const; 40 | cv::Mat getRotationLogarithm() const; 41 | cv::Mat getTranslation() const; 42 | void scale(double scale); 43 | cv::Mat getQuaternion() const; 44 | CameraInfo &operator=(const CameraInfo &info); 45 | void projectTo(CameraInfo other, cv::Mat &A, cv::Mat &b); 46 | protected: 47 | cv::Mat _intrinsic; 48 | cv::Mat _rotation; 49 | cv::Mat _translation; 50 | int _decompositionMethod; 51 | // bool decomposeProjectionMatrixBrox 52 | // (const cv::Mat& P, cv::Mat& cam, cv::Mat& rot, cv::Mat& trans); 53 | bool decomposeAndFixProjectionMatrixOpenCV 54 | (const cv::Mat& P, cv::Mat& cam, cv::Mat& rot, cv::Mat& trans); 55 | void CalculateRotation(double& x, double& y, double & z, double& w) const; 56 | }; 57 | 58 | class Frustum 59 | { 60 | public: 61 | //Left Normal 62 | float lx; float ly; float lz; 63 | //Left Offset 64 | float lo; 65 | //Right Normal 66 | float rx; float ry; float rz; 67 | //Right Offset 68 | float ro; 69 | //Top Normal 70 | float tx; float ty; float tz; 71 | //Top Offset 72 | float to; 73 | //Bottom Normal 74 | float bx; float by; float bz; 75 | //Bottom Offset 76 | float bo; 77 | //Far Normal 78 | float fx; float fy; float fz; 79 | //Far Offset 80 | float fo; 81 | 82 | Frustum( 83 | float p_lx, float p_ly, float p_lz, 84 | float p_lo, 85 | float p_rx, float p_ry, float p_rz, 86 | float p_ro, 87 | float p_tx, float p_ty, float p_tz, 88 | float p_to, 89 | float p_bx, float p_by, float p_bz, 90 | float p_bo, 91 | float p_fx, float p_fy, float p_fz, 92 | float p_fo); 93 | Frustum(const CameraInfo &info, float w, float h, float far); 94 | inline bool inside(float px, float py, float pz) 95 | { 96 | return 97 | (px*lx + py*ly + pz*lz >= lo) && 98 | (px*rx + py*ry + pz*rz >= ro) && 99 | (px*tx + py*ty + pz*tz >= to) && 100 | (px*bx + py*by + pz*bz >= bo) 101 | // && (px*fx + py*fy + pz*fz >= fo) 102 | ; 103 | } 104 | }; 105 | 106 | 107 | 108 | #endif /* CAMERAUTILS_HPP_ */ 109 | -------------------------------------------------------------------------------- /src/onlinefusionviewer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * onlinefusionviewer.hpp 3 | * 4 | * Created on: Jun 23, 2013 5 | * Author: steinbrf 6 | */ 7 | 8 | #ifndef ONLINEFUSIONVIEWER_HPP_ 9 | #define ONLINEFUSIONVIEWER_HPP_ 10 | 11 | #include 12 | #include 13 | //#include 14 | #include 15 | #include 16 | #include 17 | 18 | class OnlineFusionViewerManipulated : public QGLViewer 19 | { 20 | Q_OBJECT 21 | public: 22 | OnlineFusionViewerManipulated(bool createMeshList = true); 23 | ~OnlineFusionViewerManipulated(); 24 | std::vector _boundingBox; 25 | std::vector > _poses; 26 | std::vector > _depthNames; 27 | std::vector > _rgbNames; 28 | // std::vector _meshes; 29 | MeshSeparate *_currentMeshForSave; 30 | MeshInterleaved *_currentMeshInterleaved; 31 | std::vector _pointermeshes; 32 | FusionMipMapCPU* _fusion; 33 | float _imageDepthScale; 34 | float _maxCamDistance; 35 | long int _currentFrame; 36 | long int _currentTrajectory; 37 | long int _firstFrame; 38 | long int _nextStopFrame; 39 | 40 | bool _threadFusion; 41 | boost::thread *_fusionThread; 42 | bool _newMesh; 43 | bool _fusionActive; 44 | bool _fusionAlive; 45 | 46 | bool _threadImageReading; 47 | 48 | protected slots: 49 | void updateSlot(); 50 | 51 | 52 | protected : 53 | virtual void init(); 54 | virtual void draw(); 55 | virtual void fastDraw(); 56 | void drawMeshPointer(); 57 | void drawMeshInterleaved(); 58 | void drawCameraFrustum(CameraInfo pose,std::string imageName); 59 | virtual void keyPressEvent(QKeyEvent *e); 60 | void drawGridFrame(float ox, float oy, float oz, float sx, float sy, float sz); 61 | void setScenePosition(CameraInfo pose); 62 | 63 | void enableLighting(); 64 | void disableLighting(); 65 | 66 | 67 | long long _lastComputedFrame; 68 | 69 | bool _verbose; 70 | bool _showCameraFrustum; 71 | bool _showGridBoundingbox; 72 | bool _showDepthImage; 73 | bool _showColor; 74 | int _displayMode; 75 | 76 | unsigned int _meshNumber; 77 | unsigned int _fusionNumber; 78 | float _cx; float _cy; float _cz; 79 | 80 | std::vector _meshesDraw; 81 | PointerMeshDraw *_currentMesh; 82 | unsigned int _currentNV; 83 | unsigned int _currentNF; 84 | int _currentMeshType; 85 | 86 | GLuint _vertexBuffer; 87 | GLuint _faceBuffer; 88 | GLuint _edgeBuffer; 89 | GLuint _normalBuffer; 90 | GLuint _colorBuffer; 91 | unsigned int _vertexBufferSize; 92 | unsigned int _faceBufferSize; 93 | unsigned int _edgeBufferSize; 94 | 95 | bool _onTrack; 96 | bool _onInterpolation; 97 | bool _saving; 98 | 99 | qglviewer::KeyFrameInterpolator _interpolator; 100 | std::vector _keyFrames; 101 | 102 | bool _runFusion; 103 | bool _createMeshList; 104 | bool _lightingEnabled; 105 | bool _colorEnabled; 106 | 107 | bool _lightingInternal; 108 | 109 | 110 | 111 | QTimer *_timer; 112 | 113 | void generateBuffers(); 114 | bool _buffersGenerated; 115 | 116 | }; 117 | 118 | 119 | #endif /* ONLINEFUSIONVIEWER_HPP_ */ 120 | -------------------------------------------------------------------------------- /src/auxiliary/threadpool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, seidel.florian 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Technische Universitaet Muenchen nor the names 14 | * of its contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | * POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef THREADPOOL_H 31 | #define THREADPOOL_H 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | /** 40 | * @brief Very simple thread pool class which allows to execute workers 41 | */ 42 | class ThreadPool 43 | { 44 | public: 45 | 46 | class Worker { 47 | public: 48 | virtual void run()=0; 49 | virtual ~Worker(){} 50 | }; 51 | 52 | class Thread { 53 | public: 54 | Thread(ThreadPool& pool); 55 | ~Thread(); 56 | void startWorker(Worker * worker); 57 | void setBoostThread(boost::thread * thread); 58 | void operator()(); 59 | bool dont_stop; 60 | boost::thread* thread; 61 | private: 62 | Worker * worker; 63 | ThreadPool& pool; 64 | 65 | }; 66 | 67 | ThreadPool(int max_threads); 68 | ~ThreadPool(); 69 | 70 | /** 71 | * @brief hasFreeThread 72 | * @return true if there is a free thread which can execute a worker 73 | */ 74 | bool hasFreeThread(); 75 | 76 | /** 77 | * @brief startWorker calls workers run method and deletes worker after execution 78 | * @param worker 79 | * @return false if worker can't be executed 80 | */ 81 | bool startWorker(Worker * worker); 82 | 83 | /** 84 | * @brief joinAll block until all workers have finished 85 | */ 86 | void joinAll(); 87 | 88 | private: 89 | 90 | void markAsFree(Thread* thread); 91 | 92 | std::vector free; 93 | 94 | boost::mutex m; 95 | 96 | }; 97 | 98 | #endif // THREADPOOL_H 99 | -------------------------------------------------------------------------------- /src/auxiliary/debug.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cuda_debug.hpp 3 | * 4 | * Created on: Apr 18, 2012 5 | * Author: steinbrf 6 | */ 7 | 8 | #ifndef CUDA_DEBUG_HPP_ 9 | #define CUDA_DEBUG_HPP_ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | std::string memoryInfo(long long bytes); 16 | 17 | void saveFloatImage 18 | ( 19 | std::string savename, 20 | float *image, 21 | int width, 22 | int height, 23 | int channels, 24 | float minimum = 0.0f, 25 | float maximum = 255.0f 26 | ); 27 | 28 | //template 29 | //void saveFloatImageWeighted 30 | //( 31 | // std::string savename, 32 | // float *image, 33 | // T *weight, 34 | // int width, 35 | // int height, 36 | // int channels, 37 | // float minimum, 38 | // float maximum 39 | //); 40 | 41 | template 42 | void saveFloatImageWeighted 43 | ( 44 | std::string savename, 45 | float *image, 46 | T *weight, 47 | int width, 48 | int height, 49 | int channels, 50 | float minimum, 51 | float maximum 52 | ) 53 | { 54 | cv::Mat outImage(cv::Size(width,height),CV_32FC4); 55 | if(channels==3){ 56 | for(int x=0;x ((float*)(outImage.data))[4*x+y]) newmin = ((float*)(outImage.data))[4*x+y]; 82 | } 83 | } 84 | avg /= (float)(width*height*3); 85 | maximum = newmax; 86 | if(minimum > 0.0f) { 87 | minimum = newmin; 88 | } 89 | for(int x=0;x 27 | #include 28 | #include 29 | 30 | #ifdef HAVE_CONFIG_H 31 | #include 32 | #else 33 | #define HAVE_SSTREAM 34 | #endif 35 | 36 | #if defined(HAVE_SSTREAM) 37 | #include 38 | #elif defined(HAVE_STRSTREAM) 39 | #include 40 | #else 41 | #error "Need a stringstream (sstream or strstream) to compile!" 42 | #endif 43 | 44 | namespace TCLAP { 45 | 46 | /** 47 | * A Constraint that constrains the Arg to only those values specified 48 | * in the constraint. 49 | */ 50 | template 51 | class ValuesConstraint : public Constraint 52 | { 53 | 54 | public: 55 | 56 | /** 57 | * Constructor. 58 | * \param allowed - vector of allowed values. 59 | */ 60 | ValuesConstraint(std::vector& allowed); 61 | 62 | /** 63 | * Virtual destructor. 64 | */ 65 | virtual ~ValuesConstraint() {} 66 | 67 | /** 68 | * Returns a description of the Constraint. 69 | */ 70 | virtual std::string description() const; 71 | 72 | /** 73 | * Returns the short ID for the Constraint. 74 | */ 75 | virtual std::string shortID() const; 76 | 77 | /** 78 | * The method used to verify that the value parsed from the command 79 | * line meets the constraint. 80 | * \param value - The value that will be checked. 81 | */ 82 | virtual bool check(const T& value) const; 83 | 84 | protected: 85 | 86 | /** 87 | * The list of valid values. 88 | */ 89 | std::vector _allowed; 90 | 91 | /** 92 | * The string used to describe the allowed values of this constraint. 93 | */ 94 | std::string _typeDesc; 95 | 96 | }; 97 | 98 | template 99 | ValuesConstraint::ValuesConstraint(std::vector& allowed) 100 | : _allowed(allowed), 101 | _typeDesc("") 102 | { 103 | for ( unsigned int i = 0; i < _allowed.size(); i++ ) 104 | { 105 | 106 | #if defined(HAVE_SSTREAM) 107 | std::ostringstream os; 108 | #elif defined(HAVE_STRSTREAM) 109 | std::ostrstream os; 110 | #else 111 | #error "Need a stringstream (sstream or strstream) to compile!" 112 | #endif 113 | 114 | os << _allowed[i]; 115 | 116 | std::string temp( os.str() ); 117 | 118 | if ( i > 0 ) 119 | _typeDesc += "|"; 120 | _typeDesc += temp; 121 | } 122 | } 123 | 124 | template 125 | bool ValuesConstraint::check( const T& val ) const 126 | { 127 | if ( std::find(_allowed.begin(),_allowed.end(),val) == _allowed.end() ) 128 | return false; 129 | else 130 | return true; 131 | } 132 | 133 | template 134 | std::string ValuesConstraint::shortID() const 135 | { 136 | return _typeDesc; 137 | } 138 | 139 | template 140 | std::string ValuesConstraint::description() const 141 | { 142 | return _typeDesc; 143 | } 144 | 145 | 146 | } //namespace TCLAP 147 | #endif 148 | 149 | -------------------------------------------------------------------------------- /src/tclap/CmdLineInterface.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: CmdLineInterface.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_COMMANDLINE_INTERFACE_H 24 | #define TCLAP_COMMANDLINE_INTERFACE_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | namespace TCLAP { 34 | 35 | class Arg; 36 | class CmdLineOutput; 37 | class XorHandler; 38 | 39 | /** 40 | * The base class that manages the command line definition and passes 41 | * along the parsing to the appropriate Arg classes. 42 | */ 43 | class CmdLineInterface 44 | { 45 | public: 46 | 47 | /** 48 | * Destructor 49 | */ 50 | virtual ~CmdLineInterface() {} 51 | 52 | /** 53 | * Adds an argument to the list of arguments to be parsed. 54 | * \param a - Argument to be added. 55 | */ 56 | virtual void add( Arg& a )=0; 57 | 58 | /** 59 | * An alternative add. Functionally identical. 60 | * \param a - Argument to be added. 61 | */ 62 | virtual void add( Arg* a )=0; 63 | 64 | /** 65 | * Add two Args that will be xor'd. 66 | * If this method is used, add does 67 | * not need to be called. 68 | * \param a - Argument to be added and xor'd. 69 | * \param b - Argument to be added and xor'd. 70 | */ 71 | virtual void xorAdd( Arg& a, Arg& b )=0; 72 | 73 | /** 74 | * Add a list of Args that will be xor'd. If this method is used, 75 | * add does not need to be called. 76 | * \param xors - List of Args to be added and xor'd. 77 | */ 78 | virtual void xorAdd( std::vector& xors )=0; 79 | 80 | /** 81 | * Parses the command line. 82 | * \param argc - Number of arguments. 83 | * \param argv - Array of arguments. 84 | */ 85 | virtual void parse(int argc, const char * const * argv)=0; 86 | 87 | /** 88 | * Parses the command line. 89 | * \param args - A vector of strings representing the args. 90 | * args[0] is still the program name. 91 | */ 92 | void parse(std::vector& args); 93 | 94 | /** 95 | * Returns the CmdLineOutput object. 96 | */ 97 | virtual CmdLineOutput* getOutput()=0; 98 | 99 | /** 100 | * \param co - CmdLineOutput object that we want to use instead. 101 | */ 102 | virtual void setOutput(CmdLineOutput* co)=0; 103 | 104 | /** 105 | * Returns the version string. 106 | */ 107 | virtual std::string& getVersion()=0; 108 | 109 | /** 110 | * Returns the program name string. 111 | */ 112 | virtual std::string& getProgramName()=0; 113 | 114 | /** 115 | * Returns the argList. 116 | */ 117 | virtual std::list& getArgList()=0; 118 | 119 | /** 120 | * Returns the XorHandler. 121 | */ 122 | virtual XorHandler& getXorHandler()=0; 123 | 124 | /** 125 | * Returns the delimiter string. 126 | */ 127 | virtual char getDelimiter()=0; 128 | 129 | /** 130 | * Returns the message string. 131 | */ 132 | virtual std::string& getMessage()=0; 133 | 134 | /** 135 | * Indicates whether or not the help and version switches were created 136 | * automatically. 137 | */ 138 | virtual bool hasHelpAndVersion()=0; 139 | 140 | /** 141 | * Resets the instance as if it had just been constructed so that the 142 | * instance can be reused. 143 | */ 144 | virtual void reset()=0; 145 | }; 146 | 147 | } //namespace 148 | 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui opencv_calib3d) 3 | 4 | set(CMAKE_BUILD_TYPE Release) 5 | #set(CMAKE_BUILD_TYPE RelWithDebInfo) 6 | #set(ROS_BUILD_TYPE RelWithDebInfo) 7 | #set(CMAKE_BUILD_TYPE Debug) 8 | #set(ROS_BUILD_TYPE Debug) 9 | 10 | #FIND_PACKAGE(Qt4 REQUIRED) 11 | find_package(OpenCV REQUIRED) 12 | #find_package(TBB) 13 | 14 | #if(NOT TBB_FOUND) 15 | #MESSAGE(STATUS "TBB not found!"); 16 | #else(NOT TBB_FOUND) 17 | #include_directories(${TBB_INCLUDE_DIRS}) 18 | #link_directories(${TBB_LIBRARY_DIRS}) 19 | #endif(NOT TBB_FOUND) 20 | 21 | 22 | if (CMAKE_COMPILER_IS_GNUCC) 23 | execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion 24 | OUTPUT_VARIABLE GCC_VERSION) 25 | string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION}) 26 | list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR) 27 | list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR) 28 | 29 | message(STATUS "GCC Major Version is " ${GCC_MAJOR}) 30 | message(STATUS "GCC Major Version is " ${GCC_MINOR}) 31 | endif() 32 | 33 | set(CMAKE_C_FLAGS 34 | -frounding-math 35 | #-Wall 36 | ) 37 | 38 | execute_process(COMMAND cat /proc/cpuinfo OUTPUT_VARIABLE CPU_INFO) 39 | string(REGEX MATCHALL "avx2" AVX_STRING ${CPU_INFO}) 40 | list(LENGTH AVX_STRING AVX_STRING_LENGTH) 41 | # message(STATUS "AVX_STRING: " ${AVX_STRING}) 42 | message(STATUS "Number of avx2 occurrences in /proc/cpuinfo: " ${AVX_STRING_LENGTH}) 43 | 44 | 45 | if(${AVX_STRING_LENGTH} GREATER 0) 46 | message(STATUS "Compiling with AVX2 support") 47 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -mavx2 -funroll-loops -DOWNAVX") 48 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -mavx2 -funroll-loops -DOWNAVX") 49 | else() 50 | message(STATUS "Compiling without AVX2 support") 51 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -msse4.2 -funroll-loops") 52 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -msse4.2 -funroll-loops") 53 | endif() 54 | 55 | 56 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") 57 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp") 58 | 59 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPRINT_DEBUG") 60 | #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPRINT_DEBUG") 61 | 62 | set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) 63 | set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) 64 | 65 | 66 | 67 | include_directories(${PROJECT_SOURCE_DIR}/src) 68 | message(STATUS "PROJECT_SOURCE_DIR is " ${PROJECT_SOURCE_DIR}) 69 | 70 | #set(Boost_DEBUG 0) 71 | #set(BOOST_USE_STATIC_LIBS OFF) 72 | #set(BOOST_USE_MULTITHREADED ON) 73 | #set(BOOST_USE_STATIC_RUNTIME OFF) 74 | #find_package(Boost COMPONENTS thread system tr1) 75 | #include_directories(${Boost_INCLUDE_DIRS}) 76 | 77 | #find_package(Eigen3 REQUIRED) 78 | #include_directories(EIGEN3_INCLUDE_DIR) 79 | include_directories("/usr/include/eigen3") 80 | 81 | 82 | ## CUDA 83 | 84 | #set(CUDA_TOOLKIT_ROOT_DIR "/work/sdks/cudaversions/cuda50/") 85 | # find_package(CUDA 5.0 REQUIRED) 86 | # if(CUDA_FOUND) 87 | # message("Found CUDA") 88 | # else(CUDA_FOUND) 89 | # message("CUDA is not installed on this system.") 90 | # endif() 91 | # execute_process( COMMAND nvcc --version ) 92 | # include_directories(${CUDA_TOOLKIT_ROOT_DIR}/include) 93 | # set(TEST_CUDA_ARCH $ENV{CUDA_ARCH}) 94 | # if(TEST_CUDA_ARCH) 95 | # message(STATUS "The GPU Architecture is set to $ENV{CUDA_ARCH} in an Environment Variable") 96 | # set(CUDA_ARCH $ENV{CUDA_ARCH}) 97 | # else(TEST_CUDA_ARCH) 98 | # message(STATUS "No GPU Architecture set, setting to sm_13") 99 | # set(CUDA_ARCH sm_11) 100 | # endif(TEST_CUDA_ARCH) 101 | # #if(${CUDA_ARCH} matches sm_11) 102 | # #set(CUDAARCHNUMBER 11) 103 | # #elseif(${CUDA_ARCH} matches sm_13) 104 | # #set(CUDAARCHNUMBER 13) 105 | # #elseif(${CUDA_ARCH} matches sm_20) 106 | # #set(CUDAARCHNUMBER 20) 107 | # #endif(${CUDA_ARCH} matches sm_11) 108 | # set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -arch=${CUDA_ARCH}) 109 | 110 | 111 | 112 | 113 | 114 | 115 | #include_directories(${PROJECT_SOURCE_DIR}/external) 116 | #include_directories(${PROJECT_SOURCE_DIR}/external/math) 117 | #include_directories(${PROJECT_SOURCE_DIR}/include) 118 | #include_directories(${PROJECT_SOURCE_DIR}/build/src) 119 | #include_directories("/usr/include/nvidia-current/cuda") 120 | 121 | # find_package(PCL 1.5 REQUIRED COMPONENTS common io filters) 122 | # include_directories(${PCL_INCLUDE_DIRS}) 123 | # link_directories(${PCL_LIBRARY_DIRS}) 124 | # add_definitions(${PCL_DEFINITIONS}) 125 | 126 | 127 | 128 | #include(${QT_USE_FILE}) 129 | #add_definitions(${QT_DEFINITIONS}) 130 | 131 | # Doxygen integration 132 | find_package(Doxygen) 133 | if(DOXYGEN_FOUND) 134 | #this adds the correct folder to INPUT= : 135 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) 136 | 137 | #add doc target 138 | add_custom_target(doc 139 | ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile 140 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 141 | COMMENT "generating docs with Doxygen" VERBATIM 142 | ) 143 | endif(DOXYGEN_FOUND) 144 | 145 | add_subdirectory(src) 146 | 147 | -------------------------------------------------------------------------------- /src/tclap/XorHandler.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: XorHandler.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_XORHANDLER_H 24 | #define TCLAP_XORHANDLER_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * This class handles lists of Arg's that are to be XOR'd on the command 36 | * line. This is used by CmdLine and you shouldn't ever use it. 37 | */ 38 | class XorHandler 39 | { 40 | protected: 41 | 42 | /** 43 | * The list of of lists of Arg's to be or'd together. 44 | */ 45 | std::vector< std::vector > _orList; 46 | 47 | public: 48 | 49 | /** 50 | * Constructor. Does nothing. 51 | */ 52 | XorHandler( ) : _orList(std::vector< std::vector >()) {} 53 | 54 | /** 55 | * Add a list of Arg*'s that will be orred together. 56 | * \param ors - list of Arg* that will be xor'd. 57 | */ 58 | void add( std::vector& ors ); 59 | 60 | /** 61 | * Checks whether the specified Arg is in one of the xor lists and 62 | * if it does match one, returns the size of the xor list that the 63 | * Arg matched. If the Arg matches, then it also sets the rest of 64 | * the Arg's in the list. You shouldn't use this. 65 | * \param a - The Arg to be checked. 66 | */ 67 | int check( const Arg* a ); 68 | 69 | /** 70 | * Returns the XOR specific short usage. 71 | */ 72 | std::string shortUsage(); 73 | 74 | /** 75 | * Prints the XOR specific long usage. 76 | * \param os - Stream to print to. 77 | */ 78 | void printLongUsage(std::ostream& os); 79 | 80 | /** 81 | * Simply checks whether the Arg is contained in one of the arg 82 | * lists. 83 | * \param a - The Arg to be checked. 84 | */ 85 | bool contains( const Arg* a ); 86 | 87 | std::vector< std::vector >& getXorList(); 88 | 89 | }; 90 | 91 | 92 | ////////////////////////////////////////////////////////////////////// 93 | //BEGIN XOR.cpp 94 | ////////////////////////////////////////////////////////////////////// 95 | inline void XorHandler::add( std::vector& ors ) 96 | { 97 | _orList.push_back( ors ); 98 | } 99 | 100 | inline int XorHandler::check( const Arg* a ) 101 | { 102 | // iterate over each XOR list 103 | for ( int i = 0; static_cast(i) < _orList.size(); i++ ) 104 | { 105 | // if the XOR list contains the arg.. 106 | ArgVectorIterator ait = std::find( _orList[i].begin(), 107 | _orList[i].end(), a ); 108 | if ( ait != _orList[i].end() ) 109 | { 110 | // first check to see if a mutually exclusive switch 111 | // has not already been set 112 | for ( ArgVectorIterator it = _orList[i].begin(); 113 | it != _orList[i].end(); 114 | it++ ) 115 | if ( a != (*it) && (*it)->isSet() ) 116 | throw(CmdLineParseException( 117 | "Mutually exclusive argument already set!", 118 | (*it)->toString())); 119 | 120 | // go through and set each arg that is not a 121 | for ( ArgVectorIterator it = _orList[i].begin(); 122 | it != _orList[i].end(); 123 | it++ ) 124 | if ( a != (*it) ) 125 | (*it)->xorSet(); 126 | 127 | // return the number of required args that have now been set 128 | if ( (*ait)->allowMore() ) 129 | return 0; 130 | else 131 | return static_cast(_orList[i].size()); 132 | } 133 | } 134 | 135 | if ( a->isRequired() ) 136 | return 1; 137 | else 138 | return 0; 139 | } 140 | 141 | inline bool XorHandler::contains( const Arg* a ) 142 | { 143 | for ( int i = 0; static_cast(i) < _orList.size(); i++ ) 144 | for ( ArgVectorIterator it = _orList[i].begin(); 145 | it != _orList[i].end(); 146 | it++ ) 147 | if ( a == (*it) ) 148 | return true; 149 | 150 | return false; 151 | } 152 | 153 | inline std::vector< std::vector >& XorHandler::getXorList() 154 | { 155 | return _orList; 156 | } 157 | 158 | 159 | 160 | ////////////////////////////////////////////////////////////////////// 161 | //END XOR.cpp 162 | ////////////////////////////////////////////////////////////////////// 163 | 164 | } //namespace TCLAP 165 | 166 | #endif 167 | -------------------------------------------------------------------------------- /src/fusion/inline_functions.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * inline_functions.hpp 3 | * 4 | * Created on: Apr 15, 2013 5 | * Author: steinbrf 6 | */ 7 | 8 | #ifndef INLINE_FUNCTIONS_HPP_ 9 | #define INLINE_FUNCTIONS_HPP_ 10 | 11 | #include "definitions.h" 12 | 13 | 14 | 15 | inline float computeDistanceValue_AoS_h 16 | ( 17 | const float3 &q, 18 | const float &fx, 19 | const float &fy, 20 | const float &cx, 21 | const float &cy, 22 | int &imx, 23 | int &imy, 24 | const cv::Mat &image 25 | ) 26 | { 27 | imx = (int)floor(q.x/q.z*fx+cx); 28 | imy = (int)floor(q.y/q.z*fy+cy); 29 | #ifdef DISTANCE_POINT_FAST 30 | return q.z-image.at(std::max(std::min(imy,image.rows-1),0), 31 | std::max(std::min(imx,image.cols-1),0)); 32 | #endif 33 | #ifdef DISTANCE_POINT_TRUE 34 | const float length = sqrtf(q.x*q.x+q.y*q.y+q.z*q.z); 35 | return length - length/q.z* image.at(std::max(std::min(imy,image.rows-1),0), 36 | std::max(std::min(imx,image.cols-1),0)); 37 | #endif 38 | #ifdef DISTANCE_PLANE 39 | //FIXME: Das funktioniert noch nicht richtig, und ich habe das Gefuehl, 40 | //in der GPU Variante auch nicht 41 | const float length = sqrtf(q.x*q.x+q.y*q.y+q.z*q.z); 42 | float q1z = image.at(std::max(std::min(imy,image.rows-1),0), 43 | std::max(std::min(imx,image.cols-1),0)); 44 | float q2z = image.at(std::max(std::min(imy,image.rows-1),0), 45 | std::max(std::min(imx+1,image.cols-1),0)); 46 | float q3z = image.at(std::max(std::min(imy+1,image.rows-1),0), 47 | std::max(std::min(imx,image.cols-1),0)); 48 | 49 | float q1x = q.x/q.z*q1z; 50 | float q1y = q.y/q.z*q1z; 51 | 52 | float q2x = (imx+1.0f-cx)/fx*q2z; 53 | float q2y = (imy-cy)/fy*q2z; 54 | 55 | float q3x = (imx-cx)/fx*q3z; 56 | float q3y = (imy+1.0f-cy)/fy*q3z; 57 | 58 | float nx = (q2y-q1y)*(q3z-q1z)-(q3y-q.y)*(q2z-q1z); 59 | float ny = (q2z-q1z)*(q3x-q1x)-(q3z-q.z)*(q2x-q1x); 60 | float nz = (q2x-q1x)*(q3y-q1y)-(q3x-q.x)*(q2y-q1y); 61 | float norm = sqrtf(nx*nx+ny*ny+nz*nz); 62 | nx /= norm; ny /= norm; nz /= norm; 63 | // return fabs(nz) > fabs(nx) && fabs(nz) > fabs(ny) ? (q1x*nx+q1y*ny+q1z*nz)*(q.z/q1z-1.0f) : length - length/q.z* q1z; 64 | return nz < nx && nz < ny ? (q1x*nx+q1y*ny+q1z*nz)*(q.z/q1z-1.0f) : length - length/q.z* q1z; 65 | // return (q1x*nx+q1y*ny+q1z*nz)*(q.z/q1z-1.0f); 66 | // return length - length/q.z* q1z; 67 | #endif 68 | } 69 | 70 | inline float processDistanceValue_AoS_h(const float &distance, const float &threshold) 71 | { 72 | #ifdef DISTANCE_TEST 73 | float sqrtf((x-128)*(x-128)+(y-128)*(y-128)+(z-128)*(z-128))-40; 74 | #endif 75 | #ifdef DISTANCE_NORMAL 76 | return distance; 77 | #endif 78 | #ifdef DISTANCE_TRUNCATED 79 | return std::max(-threshold,std::min(threshold,distance)); 80 | #endif 81 | } 82 | 83 | inline weighttype getDistanceWeight_AoS_variables_h 84 | ( 85 | const float &distance, 86 | const float &threshold, 87 | const float &distanceWeightEpsilon, 88 | const float &distanceWeightSigma 89 | ) 90 | { 91 | #ifdef WEIGHT_ONE 92 | return 1.0f; 93 | #endif 94 | #ifdef WEIGHT_CONSTANT 95 | return (distance < threshold); 96 | #endif 97 | #ifdef WEIGHT_CONSTANT_NARROW 98 | return (fabs(distance)=distanceWeightEpsilon && distancedistanceWeightEpsilon && distabs=distanceWeightEpsilon && distance=distanceWeightEpsilon && distance 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * * Neither the name of the Technische Universitaet Muenchen nor the names 14 | * of its contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | * POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #include "threadpool.h" 31 | 32 | ThreadPool::ThreadPool(int max_threads) 33 | { 34 | m.lock(); 35 | for(int i=0;isetBoostThread(bThread); 40 | free.push_back(thread); 41 | } 42 | m.unlock(); 43 | } 44 | 45 | ThreadPool::~ThreadPool() 46 | { 47 | m.lock(); 48 | for(unsigned int i=0;istartWorker(worker); 79 | ok=true; 80 | } 81 | m.unlock(); 82 | return ok; 83 | } 84 | 85 | ThreadPool::Thread::Thread(ThreadPool& threadPool):dont_stop(true),thread(NULL),worker(NULL),pool(threadPool) 86 | { 87 | 88 | } 89 | 90 | ThreadPool::Thread::~Thread() 91 | { 92 | if(thread!=NULL) 93 | delete thread; 94 | } 95 | 96 | void ThreadPool::Thread::operator ()() 97 | { 98 | while(dont_stop) 99 | { 100 | while(worker==NULL) 101 | { 102 | boost::this_thread::sleep(boost::posix_time::milliseconds(10)); 103 | } 104 | std::cerr<<"Running worker"<run(); 107 | // }catch(...) 108 | // { 109 | // std::cerr<<"\n\n\n======================================================================="<worker=worker; 130 | } 131 | 132 | void ThreadPool::joinAll() 133 | { 134 | m.lock(); 135 | for(unsigned int i=0;idont_stop=false; 137 | free[i]->thread->join(); 138 | } 139 | m.unlock(); 140 | } 141 | 142 | void ThreadPool::Thread::setBoostThread(boost::thread* thread) 143 | { 144 | this->thread=thread; 145 | } 146 | -------------------------------------------------------------------------------- /src/tclap/StandardTraits.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: StandardTraits.h 6 | * 7 | * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | // This is an internal tclap file, you should probably not have to 24 | // include this directly 25 | 26 | #ifndef TCLAP_STANDARD_TRAITS_H 27 | #define TCLAP_STANDARD_TRAITS_H 28 | 29 | #ifdef HAVE_CONFIG_H 30 | #include // To check for long long 31 | #endif 32 | 33 | // If Microsoft has already typedef'd wchar_t as an unsigned 34 | // short, then compiles will break because it's as if we're 35 | // creating ArgTraits twice for unsigned short. Thus... 36 | #ifdef _MSC_VER 37 | #ifndef _NATIVE_WCHAR_T_DEFINED 38 | #define TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS 39 | #endif 40 | #endif 41 | 42 | namespace TCLAP { 43 | 44 | // ====================================================================== 45 | // Integer types 46 | // ====================================================================== 47 | 48 | /** 49 | * longs have value-like semantics. 50 | */ 51 | template<> 52 | struct ArgTraits { 53 | typedef ValueLike ValueCategory; 54 | }; 55 | 56 | /** 57 | * ints have value-like semantics. 58 | */ 59 | template<> 60 | struct ArgTraits { 61 | typedef ValueLike ValueCategory; 62 | }; 63 | 64 | /** 65 | * shorts have value-like semantics. 66 | */ 67 | template<> 68 | struct ArgTraits { 69 | typedef ValueLike ValueCategory; 70 | }; 71 | 72 | /** 73 | * chars have value-like semantics. 74 | */ 75 | template<> 76 | struct ArgTraits { 77 | typedef ValueLike ValueCategory; 78 | }; 79 | 80 | #ifdef HAVE_LONG_LONG 81 | /** 82 | * long longs have value-like semantics. 83 | */ 84 | template<> 85 | struct ArgTraits { 86 | typedef ValueLike ValueCategory; 87 | }; 88 | #endif 89 | 90 | // ====================================================================== 91 | // Unsigned integer types 92 | // ====================================================================== 93 | 94 | /** 95 | * unsigned longs have value-like semantics. 96 | */ 97 | template<> 98 | struct ArgTraits { 99 | typedef ValueLike ValueCategory; 100 | }; 101 | 102 | /** 103 | * unsigned ints have value-like semantics. 104 | */ 105 | template<> 106 | struct ArgTraits { 107 | typedef ValueLike ValueCategory; 108 | }; 109 | 110 | /** 111 | * unsigned shorts have value-like semantics. 112 | */ 113 | template<> 114 | struct ArgTraits { 115 | typedef ValueLike ValueCategory; 116 | }; 117 | 118 | /** 119 | * unsigned chars have value-like semantics. 120 | */ 121 | template<> 122 | struct ArgTraits { 123 | typedef ValueLike ValueCategory; 124 | }; 125 | 126 | // Microsoft implements size_t awkwardly. 127 | #if defined(_MSC_VER) && defined(_M_X64) 128 | /** 129 | * size_ts have value-like semantics. 130 | */ 131 | template<> 132 | struct ArgTraits { 133 | typedef ValueLike ValueCategory; 134 | }; 135 | #endif 136 | 137 | 138 | #ifdef HAVE_LONG_LONG 139 | /** 140 | * unsigned long longs have value-like semantics. 141 | */ 142 | template<> 143 | struct ArgTraits { 144 | typedef ValueLike ValueCategory; 145 | }; 146 | #endif 147 | 148 | // ====================================================================== 149 | // Float types 150 | // ====================================================================== 151 | 152 | /** 153 | * floats have value-like semantics. 154 | */ 155 | template<> 156 | struct ArgTraits { 157 | typedef ValueLike ValueCategory; 158 | }; 159 | 160 | /** 161 | * doubles have value-like semantics. 162 | */ 163 | template<> 164 | struct ArgTraits { 165 | typedef ValueLike ValueCategory; 166 | }; 167 | 168 | // ====================================================================== 169 | // Other types 170 | // ====================================================================== 171 | 172 | /** 173 | * bools have value-like semantics. 174 | */ 175 | template<> 176 | struct ArgTraits { 177 | typedef ValueLike ValueCategory; 178 | }; 179 | 180 | 181 | /** 182 | * wchar_ts have value-like semantics. 183 | */ 184 | #ifndef TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS 185 | template<> 186 | struct ArgTraits { 187 | typedef ValueLike ValueCategory; 188 | }; 189 | #endif 190 | 191 | /** 192 | * Strings have string like argument traits. 193 | */ 194 | template<> 195 | struct ArgTraits { 196 | typedef StringLike ValueCategory; 197 | }; 198 | 199 | template 200 | void SetString(T &dst, const std::string &src) 201 | { 202 | dst = src; 203 | } 204 | 205 | } // namespace 206 | 207 | #endif 208 | 209 | -------------------------------------------------------------------------------- /src/tclap/ArgException.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ArgException.h 6 | * 7 | * Copyright (c) 2003, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_ARG_EXCEPTION_H 25 | #define TCLAP_ARG_EXCEPTION_H 26 | 27 | #include 28 | #include 29 | 30 | namespace TCLAP { 31 | 32 | /** 33 | * A simple class that defines and argument exception. Should be caught 34 | * whenever a CmdLine is created and parsed. 35 | */ 36 | class ArgException : public std::exception 37 | { 38 | public: 39 | 40 | /** 41 | * Constructor. 42 | * \param text - The text of the exception. 43 | * \param id - The text identifying the argument source. 44 | * \param td - Text describing the type of ArgException it is. 45 | * of the exception. 46 | */ 47 | ArgException( const std::string& text = "undefined exception", 48 | const std::string& id = "undefined", 49 | const std::string& td = "Generic ArgException") 50 | : std::exception(), 51 | _errorText(text), 52 | _argId( id ), 53 | _typeDescription(td) 54 | { } 55 | 56 | /** 57 | * Destructor. 58 | */ 59 | virtual ~ArgException() throw() { } 60 | 61 | /** 62 | * Returns the error text. 63 | */ 64 | std::string error() const { return ( _errorText ); } 65 | 66 | /** 67 | * Returns the argument id. 68 | */ 69 | std::string argId() const 70 | { 71 | if ( _argId == "undefined" ) 72 | return " "; 73 | else 74 | return ( "Argument: " + _argId ); 75 | } 76 | 77 | /** 78 | * Returns the arg id and error text. 79 | */ 80 | const char* what() const throw() 81 | { 82 | static std::string ex; 83 | ex = _argId + " -- " + _errorText; 84 | return ex.c_str(); 85 | } 86 | 87 | /** 88 | * Returns the type of the exception. Used to explain and distinguish 89 | * between different child exceptions. 90 | */ 91 | std::string typeDescription() const 92 | { 93 | return _typeDescription; 94 | } 95 | 96 | 97 | private: 98 | 99 | /** 100 | * The text of the exception message. 101 | */ 102 | std::string _errorText; 103 | 104 | /** 105 | * The argument related to this exception. 106 | */ 107 | std::string _argId; 108 | 109 | /** 110 | * Describes the type of the exception. Used to distinguish 111 | * between different child exceptions. 112 | */ 113 | std::string _typeDescription; 114 | 115 | }; 116 | 117 | /** 118 | * Thrown from within the child Arg classes when it fails to properly 119 | * parse the argument it has been passed. 120 | */ 121 | class ArgParseException : public ArgException 122 | { 123 | public: 124 | /** 125 | * Constructor. 126 | * \param text - The text of the exception. 127 | * \param id - The text identifying the argument source 128 | * of the exception. 129 | */ 130 | ArgParseException( const std::string& text = "undefined exception", 131 | const std::string& id = "undefined" ) 132 | : ArgException( text, 133 | id, 134 | std::string( "Exception found while parsing " ) + 135 | std::string( "the value the Arg has been passed." )) 136 | { } 137 | }; 138 | 139 | /** 140 | * Thrown from CmdLine when the arguments on the command line are not 141 | * properly specified, e.g. too many arguments, required argument missing, etc. 142 | */ 143 | class CmdLineParseException : public ArgException 144 | { 145 | public: 146 | /** 147 | * Constructor. 148 | * \param text - The text of the exception. 149 | * \param id - The text identifying the argument source 150 | * of the exception. 151 | */ 152 | CmdLineParseException( const std::string& text = "undefined exception", 153 | const std::string& id = "undefined" ) 154 | : ArgException( text, 155 | id, 156 | std::string( "Exception found when the values ") + 157 | std::string( "on the command line do not meet ") + 158 | std::string( "the requirements of the defined ") + 159 | std::string( "Args." )) 160 | { } 161 | }; 162 | 163 | /** 164 | * Thrown from Arg and CmdLine when an Arg is improperly specified, e.g. 165 | * same flag as another Arg, same name, etc. 166 | */ 167 | class SpecificationException : public ArgException 168 | { 169 | public: 170 | /** 171 | * Constructor. 172 | * \param text - The text of the exception. 173 | * \param id - The text identifying the argument source 174 | * of the exception. 175 | */ 176 | SpecificationException( const std::string& text = "undefined exception", 177 | const std::string& id = "undefined" ) 178 | : ArgException( text, 179 | id, 180 | std::string("Exception found when an Arg object ")+ 181 | std::string("is improperly defined by the ") + 182 | std::string("developer." )) 183 | { } 184 | 185 | }; 186 | 187 | class ExitException { 188 | public: 189 | ExitException(int estat) : _estat(estat) {} 190 | 191 | int getExitStatus() const { return _estat; } 192 | 193 | private: 194 | int _estat; 195 | }; 196 | 197 | } // namespace TCLAP 198 | 199 | #endif 200 | 201 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | fastfusion 2 | ========== 3 | 4 | Volumetric 3D Mapping in Real-Time on a CPU 5 | 6 | This code implements the approach for real-time 3D mapping on a CPU as 7 | described in the following research paper: 8 | 9 | http://vision.in.tum.de/_media/spezial/bib/steinbruecker_etal_icra2014.pdf 10 | 11 | Volumetric 3D Mapping in Real-Time on a CPU (F. Steinbruecker, J. Sturm, D. Cremers), 12 | In Int. Conf. on Robotics and Automation, 2014. 13 | 14 | ![alt tag](http://vision.in.tum.de/_media/data/software/fastfusion_small.png) 15 | 16 | Demo video: 17 | http://youtu.be/7s9JePSln-M 18 | 19 | ``` 20 | @string{icra="Int. Conf. on Robotics and Automation"} 21 | @inproceedings{Steinbruecker-etal-icra14, 22 | author = {F. Steinbruecker and J. Sturm and D. Cremers}, 23 | title = {Volumetric 3D Mapping in Real-Time on a CPU}, 24 | booktitle = icra, 25 | year = {2014}, 26 | address = {Hongkong, China}, 27 | titleurl = {steinbruecker_etal_icra2014.pdf}, 28 | topic = {3D Reconstruction}, 29 | keywords = {RGB-D,Fusion,3d-reconstruction} 30 | } 31 | ``` 32 | 33 | Installation 34 | ============ 35 | 36 | $ git clone https://github.com/tum-vision/fastfusion.git` 37 | 38 | $ cd fastfusion 39 | 40 | $ cmake . 41 | 42 | $ make 43 | 44 | Preparation of the data 45 | ====================== 46 | 47 | The software takes a text file as input which contains per file 48 | - the camera pose 49 | - the depth image filename 50 | - the color image filename 51 | 52 | You can either generate such a file yourself (e.g., by running 53 | Christan Kerl's DVO SLAM: 54 | 55 | http://vision.in.tum.de/data/software/dvo 56 | 57 | available as open source on our homepage) or you can download 58 | sequences from the TUM RGB-D benchmark: 59 | 60 | http://vision.in.tum.de/data/datasets/rgbd-dataset/ 61 | 62 | For simplicity, we take a pre-recorded sequence from the TUM 63 | RGB-D benchmark. 64 | 65 | $ mkdir ~/data 66 | 67 | $ cd ~/data 68 | 69 | $ wget http://vision.in.tum.de/rgbd/dataset/freiburg3/rgbd_dataset_freiburg3_long_office_household.tgz 70 | 71 | $ tar xvzf rgbd_dataset_freiburg3_long_office_household.tgz 72 | 73 | Now we need to generate the text file. For this, we use the associate.py tool from 74 | the RGB-D benchmark website. We need to run it twice, as we join the 75 | camera poses, the depth image list and the color image list into a single file: 76 | 77 | $ cd ~/fastfusion/ 78 | 79 | $ ./associate.py ~/data/rgbd_dataset_freiburg3_long_office_household/groundtruth.txt ~/data/rgbd_dataset_freiburg3_long_office_household/depth.txt > tmp.txt 80 | 81 | $ ./associate.py tmp.txt ~/data/rgbd_dataset_freiburg3_long_office_household/rgb.txt > ~/data/rgbd_dataset_freiburg3_long_office_household/associate.txt 82 | 83 | The resulting text file should look as follows: 84 | 85 | $ head ~/data/rgbd_dataset_freiburg3_long_office_household/associate.txt 86 | 87 | ``` 88 | 1341847980.790000 -0.6832 2.6909 1.7373 0.0003 0.8617 -0.5072 -0.0145 1341847980.786879 depth/1341847980.786879.png 1341847980.786856 rgb/1341847980.786856.png 89 | 1341847980.820100 -0.6821 2.6914 1.7371 0.0003 0.8609 -0.5085 -0.0151 1341847980.822989 depth/1341847980.822989.png 1341847980.822978 rgb/1341847980.822978.png 90 | 1341847980.850000 -0.6811 2.6918 1.7371 0.0001 0.8610 -0.5084 -0.0159 1341847980.854690 depth/1341847980.854690.png 1341847980.854676 rgb/1341847980.854676.png 91 | [..] 92 | ``` 93 | 94 | Running the code 95 | ================ 96 | 97 | $ ./bin/onlinefusion ~/data/rgbd_dataset_freiburg3_long_office_household/associate.txt --thread-fusion 98 | 99 | After some debugging output on the console, a window with a 3D viewer should open. To start the 100 | reconstruction process, press "S". 101 | 102 | If you run the program for the first time, press and hold the CTRL key and turn your scroll wheel. 103 | This is only needed once to "free" the camera viewpoint. After this, you can pan (right click) and 104 | rotate (left click) the view as you wish using your mouse. 105 | 106 | Further options 107 | =============== 108 | 109 | ``` 110 | ./bin/onlinefusion [--intrinsics ] [--imagescale ] 111 | [--threshold ] [--scale ] 112 | [--max-camera-distance ] 113 | [--consistency-checks ] [-k ] [-e ] 114 | [-s ] [--incremental-meshing] [-c] [-b] [-v] 115 | [--thread-image] [--thread-fusion] 116 | [--thread-meshing] [-l ] [--] [--version] 117 | [-h] ... 118 | 119 | 120 | Where: 121 | 122 | --intrinsics 123 | File with Camera Matrix 124 | 125 | --imagescale 126 | Image Depth Scale 127 | 128 | --threshold 129 | Threshold 130 | 131 | --scale 132 | Size of the Voxel 133 | 134 | --max-camera-distance 135 | Maximum Camera Distance to Surface 136 | 137 | --consistency-checks 138 | Number of Depth Consistency Checks 139 | 140 | -k , --imagestep 141 | Use every kth step 142 | 143 | -e , --endimage 144 | Number of the End Image 145 | 146 | -s , --startimage 147 | Number of the Start Image 148 | 149 | --incremental-meshing 150 | Perform incremental Meshing 151 | 152 | -c, --loopclosures 153 | Read Multiple Trajectories and perform Loop Closures 154 | 155 | -b, --buffer 156 | Buffer all Images 157 | 158 | -v, --viewer 159 | Show a Viewer after Fusion 160 | 161 | --thread-image 162 | Thread reading the Images from Hard Disk 163 | 164 | --thread-fusion 165 | Thread the Fusion inside the Viewer 166 | 167 | --thread-meshing 168 | Thread the Meshing inside the Fusion 169 | 170 | -l , --loadmesh 171 | Loads this mesh 172 | 173 | --, --ignore_rest 174 | Ignores the rest of the labeled arguments following this flag. 175 | 176 | --version 177 | Displays version information and exits. 178 | 179 | -h, --help 180 | Displays usage information and exits. 181 | 182 | (accepted multiple times) 183 | The File Names 184 | ``` 185 | ![alt tag](http://vision.in.tum.de/_media/data/software/screenshot_fastfusion.png) 186 | 187 | -------------------------------------------------------------------------------- /src/tclap/MultiSwitchArg.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: MultiSwitchArg.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * Copyright (c) 2005, Michael E. Smoot, Daniel Aarno, Erik Zeek. 9 | * All rights reverved. 10 | * 11 | * See the file COPYING in the top directory of this distribution for 12 | * more information. 13 | * 14 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | * 22 | *****************************************************************************/ 23 | 24 | 25 | #ifndef TCLAP_MULTI_SWITCH_ARG_H 26 | #define TCLAP_MULTI_SWITCH_ARG_H 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | namespace TCLAP { 34 | 35 | /** 36 | * A multiple switch argument. If the switch is set on the command line, then 37 | * the getValue method will return the number of times the switch appears. 38 | */ 39 | class MultiSwitchArg : public SwitchArg 40 | { 41 | protected: 42 | 43 | /** 44 | * The value of the switch. 45 | */ 46 | int _value; 47 | 48 | /** 49 | * Used to support the reset() method so that ValueArg can be 50 | * reset to their constructed value. 51 | */ 52 | int _default; 53 | 54 | public: 55 | 56 | /** 57 | * MultiSwitchArg constructor. 58 | * \param flag - The one character flag that identifies this 59 | * argument on the command line. 60 | * \param name - A one word name for the argument. Can be 61 | * used as a long flag on the command line. 62 | * \param desc - A description of what the argument is for or 63 | * does. 64 | * \param init - Optional. The initial/default value of this Arg. 65 | * Defaults to 0. 66 | * \param v - An optional visitor. You probably should not 67 | * use this unless you have a very good reason. 68 | */ 69 | MultiSwitchArg(const std::string& flag, 70 | const std::string& name, 71 | const std::string& desc, 72 | int init = 0, 73 | Visitor* v = NULL); 74 | 75 | 76 | /** 77 | * MultiSwitchArg constructor. 78 | * \param flag - The one character flag that identifies this 79 | * argument on the command line. 80 | * \param name - A one word name for the argument. Can be 81 | * used as a long flag on the command line. 82 | * \param desc - A description of what the argument is for or 83 | * does. 84 | * \param parser - A CmdLine parser object to add this Arg to 85 | * \param init - Optional. The initial/default value of this Arg. 86 | * Defaults to 0. 87 | * \param v - An optional visitor. You probably should not 88 | * use this unless you have a very good reason. 89 | */ 90 | MultiSwitchArg(const std::string& flag, 91 | const std::string& name, 92 | const std::string& desc, 93 | CmdLineInterface& parser, 94 | int init = 0, 95 | Visitor* v = NULL); 96 | 97 | 98 | /** 99 | * Handles the processing of the argument. 100 | * This re-implements the SwitchArg version of this method to set the 101 | * _value of the argument appropriately. 102 | * \param i - Pointer the the current argument in the list. 103 | * \param args - Mutable list of strings. Passed 104 | * in from main(). 105 | */ 106 | virtual bool processArg(int* i, std::vector& args); 107 | 108 | /** 109 | * Returns int, the number of times the switch has been set. 110 | */ 111 | int getValue(); 112 | 113 | /** 114 | * Returns the shortID for this Arg. 115 | */ 116 | std::string shortID(const std::string& val) const; 117 | 118 | /** 119 | * Returns the longID for this Arg. 120 | */ 121 | std::string longID(const std::string& val) const; 122 | 123 | void reset(); 124 | 125 | }; 126 | 127 | ////////////////////////////////////////////////////////////////////// 128 | //BEGIN MultiSwitchArg.cpp 129 | ////////////////////////////////////////////////////////////////////// 130 | inline MultiSwitchArg::MultiSwitchArg(const std::string& flag, 131 | const std::string& name, 132 | const std::string& desc, 133 | int init, 134 | Visitor* v ) 135 | : SwitchArg(flag, name, desc, false, v), 136 | _value( init ), 137 | _default( init ) 138 | { } 139 | 140 | inline MultiSwitchArg::MultiSwitchArg(const std::string& flag, 141 | const std::string& name, 142 | const std::string& desc, 143 | CmdLineInterface& parser, 144 | int init, 145 | Visitor* v ) 146 | : SwitchArg(flag, name, desc, false, v), 147 | _value( init ), 148 | _default( init ) 149 | { 150 | parser.add( this ); 151 | } 152 | 153 | inline int MultiSwitchArg::getValue() { return _value; } 154 | 155 | inline bool MultiSwitchArg::processArg(int *i, std::vector& args) 156 | { 157 | if ( _ignoreable && Arg::ignoreRest() ) 158 | return false; 159 | 160 | if ( argMatches( args[*i] )) 161 | { 162 | // so the isSet() method will work 163 | _alreadySet = true; 164 | 165 | // Matched argument: increment value. 166 | ++_value; 167 | 168 | _checkWithVisitor(); 169 | 170 | return true; 171 | } 172 | else if ( combinedSwitchesMatch( args[*i] ) ) 173 | { 174 | // so the isSet() method will work 175 | _alreadySet = true; 176 | 177 | // Matched argument: increment value. 178 | ++_value; 179 | 180 | // Check for more in argument and increment value. 181 | while ( combinedSwitchesMatch( args[*i] ) ) 182 | ++_value; 183 | 184 | _checkWithVisitor(); 185 | 186 | return false; 187 | } 188 | else 189 | return false; 190 | } 191 | 192 | inline std::string 193 | MultiSwitchArg::shortID(const std::string& val) const 194 | { 195 | return Arg::shortID(val) + " ... "; 196 | } 197 | 198 | inline std::string 199 | MultiSwitchArg::longID(const std::string& val) const 200 | { 201 | return Arg::longID(val) + " (accepted multiple times)"; 202 | } 203 | 204 | inline void 205 | MultiSwitchArg::reset() 206 | { 207 | MultiSwitchArg::_value = MultiSwitchArg::_default; 208 | } 209 | 210 | ////////////////////////////////////////////////////////////////////// 211 | //END MultiSwitchArg.cpp 212 | ////////////////////////////////////////////////////////////////////// 213 | 214 | } //namespace TCLAP 215 | 216 | #endif 217 | -------------------------------------------------------------------------------- /src/auxiliary/multivector.h: -------------------------------------------------------------------------------- 1 | #ifndef MULTIVECTOR_H 2 | #define MULTIVECTOR_H 3 | 4 | #include 5 | #include 6 | 7 | #define MULTIVECTOR_OLD_SORT 8 | 9 | #ifdef MULTIVECTOR_OLD_SORT 10 | #include 11 | #endif 12 | 13 | namespace stb{ 14 | 15 | /*! 16 | * Implements a doublevector. The empty vector has size 17 | * 4*sizeof(size_t) instead of 6*sizeof(size_t) for two separate vectors 18 | * The vector always accesses elements in pairs 19 | */ 20 | template 21 | class doublevector_soa{ 22 | public: 23 | doublevector_soa(): 24 | a_(NULL), b_(NULL), size_(0), capacity_(0){} 25 | doublevector_soa(size_t size, A a = A(), B b = B()){ 26 | resize(a,b); 27 | } 28 | ~doublevector_soa(){} 29 | std::pair operator[](size_t i){ 30 | return std::pair(a_[i],b_[i]); 31 | } 32 | std::pair operator[](size_t i) const{ 33 | return std::pair(a_[i],b_[i]); 34 | } 35 | void push_back(const A &a, const B &b){ 36 | // fprintf(stderr,"\ndoublevector push_back size %li",size_); 37 | if (size_>=capacity_) { 38 | // fprintf(stderr,"\nReallocating for size %li, capacity %li",size_,capacity_); 39 | capacity_ = capacity_ ? highest_twopower(capacity_)*2 : 2; 40 | reallocate_and_copy(size_); 41 | // fprintf(stderr," ... new capacity %li",capacity_); 42 | } 43 | a_[size_] = a; 44 | b_[size_] = b; 45 | size_++; 46 | } 47 | void pop_back(){ 48 | if (!size_) { 49 | fprintf(stderr,"\nERROR: doublevector already empty"); 50 | return; 51 | } 52 | size_--; 53 | if (size_ && size_<=capacity_/4) { 54 | capacity_ = highest_twopower(size_)*2; 55 | reallocate_and_copy(size_); 56 | } else { 57 | // delete (a_ + (size_+1)); 58 | // delete (b_ + (size_+1)); 59 | } 60 | } 61 | void reserve(size_t capacity){ 62 | if(capacity>capacity_){ 63 | capacity_ = capacity; 64 | reallocate_and_copy(size_); 65 | } 66 | } 67 | void resize(size_t size, const A a = A(), const B &b = B()){ 68 | if (size>size_) { 69 | if (size>=capacity_) { 70 | capacity_ = capacity_ ? highest_twopower(size)*2 : 2; 71 | reallocate_and_copy(size_); 72 | for (size_t i=size_;i=size;i--) { 82 | delete a_[i]; 83 | delete b_[i]; 84 | } 85 | } 86 | size_ = size; 87 | 88 | } 89 | } 90 | size_t size() const { return size_;} 91 | size_t capacity() const { return capacity_;} 92 | void clear(){ 93 | if(a_) delete [] a_; 94 | if(b_) delete [] b_; 95 | size_ = 0; 96 | capacity_ = 0; 97 | a_ = NULL; 98 | b_ = NULL; 99 | } 100 | 101 | class iterator{ 102 | friend class doublevector_soa; 103 | public: 104 | iterator():a_(NULL),b_(NULL),dummypair_(NULL){} 105 | std::pair operator*(){ 106 | return std::pair(*a_,*b_); 107 | } 108 | //TODO: This cannot be good... 109 | std::pair *operator->(){ 110 | // if(dummypair_) delete dummypair_; 111 | // dummypair_ = new std::pair(*a_,*b_); 112 | if(!dummypair_) dummypair_ = new std::pair(*a_,*b_); 113 | else {dummypair_->first = *a_; dummypair_->second=*b_;} 114 | return dummypair_; 115 | } 116 | bool operator==(const iterator &it){return it.a_==a_&&it.b_==b_;} 117 | bool operator!=(const iterator &it){return it.a_!=a_||it.b_!=b_;} 118 | iterator operator++(){ 119 | a_++; b_++; 120 | return *this; 121 | } 122 | iterator operator++(int){ 123 | iterator result = *this; 124 | a_++; b_++; 125 | return result; 126 | } 127 | iterator operator--(){ 128 | a_--; b_--; 129 | return *this; 130 | } 131 | iterator operator--(int){ 132 | iterator result = *this; 133 | a_--; b_--; 134 | return result; 135 | } 136 | private: 137 | iterator(A *a, B*b):a_(a),b_(b),dummypair_(NULL){} 138 | A *a_; 139 | B *b_; 140 | //TODO: This cannot be good... 141 | std::pair *dummypair_; 142 | }; 143 | 144 | iterator begin(){return iterator(a_,b_);} 145 | iterator end(){ 146 | iterator result; 147 | result.a_ = a_+size_; 148 | result.b_ = b_+size_; 149 | return result;} 150 | 151 | #ifdef MULTIVECTOR_OLD_SORT 152 | struct compareFirst { 153 | bool operator() (const std::pair &p0, const std::pair &p1){ 154 | return p0.first != p1.first ? p0.first < p1.first : p0.second < p1.second; 155 | } 156 | }; 157 | 158 | struct compareSecond { 159 | bool operator() (const std::pair &p0, const std::pair &p1){ 160 | return p0.second < p1.second ? p0.second < p1.second : p0.first < p1.first; 161 | } 162 | }; 163 | 164 | inline void sort(unsigned char order = 0){ 165 | if (order==0) { 166 | std::set, compareFirst> set; 167 | for(size_t i=0;i(a_[i],b_[i])); 169 | } 170 | typename std::set, compareFirst>::iterator it = set.begin(); 171 | for(size_t i=0;ifirst; b_[i] = it->second; it++; 173 | } 174 | } else { 175 | std::set, compareSecond> set; 176 | for(size_t i=0;i(a_[i],b_[i])); 178 | } 179 | typename std::set, compareSecond>::iterator it = set.begin(); 180 | for(size_t i=0;ifirst; b_[i] = it->second; it++; 182 | } 183 | } 184 | } 185 | 186 | #endif 187 | private: 188 | inline size_t highest_twopower(size_t size){ 189 | size_t result = 0; 190 | // fprintf(stderr,"\nHighest power of %li",size); 191 | for (size_t bit=0;bit 9 | #include 10 | #include 11 | #include "debug.hpp" 12 | 13 | 14 | #ifdef CIMGDEBUG 15 | #include "CImg.h" 16 | using namespace cimg_library; 17 | #endif 18 | 19 | std::string memoryInfo(long long bytes) 20 | { 21 | long long kB = 1024, MB = 1048576, 22 | GB = 1073741824, TB = 1099511627776; 23 | std::stringstream stream; 24 | if(bytes/TB) stream << bytes/TB << " TB "; bytes %= TB; 25 | if(bytes/GB) stream << bytes/GB << " GB "; bytes %= GB; 26 | if(bytes/MB) stream << bytes/MB << " MB "; bytes %= MB; 27 | if(bytes/kB) stream << bytes/kB << " kB "; bytes %= kB; 28 | if(bytes) stream << bytes << " B"; 29 | return stream.str(); 30 | } 31 | 32 | void saveFloatImage 33 | ( 34 | std::string savename, 35 | float *image, 36 | int width, 37 | int height, 38 | int channels, 39 | float minimum, 40 | float maximum 41 | ) 42 | { 43 | cv::Mat outImage(cv::Size(width,height),((channels==3) ? CV_32FC3 : CV_32FC1)); 44 | for(int x=0;x ((float*)(outImage.data))[x]) newmin = ((float*)(outImage.data))[x]; 61 | } 62 | avg /= (float)(width*height*channels); 63 | maximum = newmax; 64 | if(minimum > 0.0f) { 65 | minimum = newmin; 66 | } 67 | fprintf(stderr,"\nDebug Image %s Minimum: %f Maximum: %f Average: %f",savename.c_str(),minimum,maximum,avg); 68 | } 69 | 70 | cv::imwrite(savename.c_str(),(outImage-minimum)*(255.0f/(maximum-minimum))); 71 | } 72 | 73 | //template 74 | //void saveFloatImageWeighted 75 | //( 76 | // std::string savename, 77 | // float *image, 78 | // T *weight, 79 | // int width, 80 | // int height, 81 | // int channels, 82 | // float minimum, 83 | // float maximum 84 | //) 85 | //{ 86 | // cv::Mat outImage(cv::Size(width,height),CV_32FC4); 87 | // if(channels==3){ 88 | // for(int x=0;x ((float*)(outImage.data))[4*x+y]) newmin = ((float*)(outImage.data))[4*x+y]; 114 | // } 115 | // } 116 | // avg /= (float)(width*height*3); 117 | // maximum = newmax; 118 | // if(minimum > 0.0f) { 119 | // minimum = newmin; 120 | // } 121 | // for(int x=0;x ((float*)(outImage.data))[x]) newmin = ((float*)(outImage.data))[x]; 161 | } 162 | avg /= (float)(width*height*channels); 163 | maximum = newmax; 164 | if(minimum > 0.0f) { 165 | minimum = newmin; 166 | } 167 | fprintf(stderr,"\nDebug Image %s Minimum: %f Maximum: %f Average: %f",showname.c_str(),minimum,maximum,avg); 168 | } 169 | 170 | cv::imshow(showname.c_str(),(outImage-minimum)*(1.0f/(maximum-minimum))); 171 | } 172 | 173 | void showCharImage(std::string showname, 174 | unsigned char * image, 175 | int rows, 176 | int cols) 177 | { 178 | float * floatImage =new float[rows*cols]; 179 | for(int y=0;y 10 | 11 | Vertex2f::Vertex2f(float x_p, float y_p):x(x_p),y(y_p){} 12 | //Vertex3f::Vertex3f(float x_p, float y_p, float z_p):x(x_p),y(y_p),z(z_p){} 13 | Color3b::Color3b(uchar r_p, uchar g_p, uchar b_p):r(r_p),g(g_p),b(b_p){} 14 | 15 | 16 | MeshInterleaved::MeshInterleaved(unsigned int verticesPerFace) 17 | :_verticesPerFace(verticesPerFace){} 18 | 19 | bool MeshInterleaved::writeOBJ(std::string filename) 20 | { 21 | std::string prefix = filename.substr(0,filename.find_last_of('/')+1); 22 | std::string stem = filename.substr(prefix.size(),filename.size()); 23 | std::string filenameObject = filename + ".obj"; 24 | std::string filenameMaterial = filename + ".mtl"; 25 | std::string filenameMaterialRelative = stem + ".mtl"; 26 | 27 | 28 | std::fstream file; 29 | file.open(filenameObject.c_str(),std::ios::out); 30 | if(!file.is_open()){ 31 | fprintf(stderr,"\nERROR: Could not open File %s for writing!",filenameObject.c_str()); 32 | return false; 33 | } 34 | 35 | std::vector materialNames; 36 | bool useTexture = textures.size() > 0 37 | && texcoords.size() == faces.size(); 38 | if(useTexture){ 39 | fprintf(stderr,"\nThe Mesh has %li Textures of the following Sizes:\n",textures.size()); 40 | for(size_t i=0;icurrentMaterialNumber ? 91 | materialIndices[currentMaterialNumber] : faces.size(); 92 | } 93 | file << "\nf"; 94 | for(unsigned int j=0;j<_verticesPerFace;j++) 95 | file << " " << faces[i+j]+1 << "/" << (i+j+1); 96 | } 97 | } 98 | else{ 99 | //No Texture, No Normals 100 | for(unsigned int i=0;i 28 | #include 29 | 30 | #include 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * A simple switch argument. If the switch is set on the command line, then 36 | * the getValue method will return the opposite of the default value for the 37 | * switch. 38 | */ 39 | class SwitchArg : public Arg 40 | { 41 | protected: 42 | 43 | /** 44 | * The value of the switch. 45 | */ 46 | bool _value; 47 | 48 | /** 49 | * Used to support the reset() method so that ValueArg can be 50 | * reset to their constructed value. 51 | */ 52 | bool _default; 53 | 54 | public: 55 | 56 | /** 57 | * SwitchArg constructor. 58 | * \param flag - The one character flag that identifies this 59 | * argument on the command line. 60 | * \param name - A one word name for the argument. Can be 61 | * used as a long flag on the command line. 62 | * \param desc - A description of what the argument is for or 63 | * does. 64 | * \param def - The default value for this Switch. 65 | * \param v - An optional visitor. You probably should not 66 | * use this unless you have a very good reason. 67 | */ 68 | SwitchArg(const std::string& flag, 69 | const std::string& name, 70 | const std::string& desc, 71 | bool def = false, 72 | Visitor* v = NULL); 73 | 74 | 75 | /** 76 | * SwitchArg constructor. 77 | * \param flag - The one character flag that identifies this 78 | * argument on the command line. 79 | * \param name - A one word name for the argument. Can be 80 | * used as a long flag on the command line. 81 | * \param desc - A description of what the argument is for or 82 | * does. 83 | * \param parser - A CmdLine parser object to add this Arg to 84 | * \param def - The default value for this Switch. 85 | * \param v - An optional visitor. You probably should not 86 | * use this unless you have a very good reason. 87 | */ 88 | SwitchArg(const std::string& flag, 89 | const std::string& name, 90 | const std::string& desc, 91 | CmdLineInterface& parser, 92 | bool def = false, 93 | Visitor* v = NULL); 94 | 95 | 96 | /** 97 | * Handles the processing of the argument. 98 | * This re-implements the Arg version of this method to set the 99 | * _value of the argument appropriately. 100 | * \param i - Pointer the the current argument in the list. 101 | * \param args - Mutable list of strings. Passed 102 | * in from main(). 103 | */ 104 | virtual bool processArg(int* i, std::vector& args); 105 | 106 | /** 107 | * Checks a string to see if any of the chars in the string 108 | * match the flag for this Switch. 109 | */ 110 | bool combinedSwitchesMatch(std::string& combined); 111 | 112 | /** 113 | * Returns bool, whether or not the switch has been set. 114 | */ 115 | bool getValue(); 116 | 117 | virtual void reset(); 118 | 119 | private: 120 | /** 121 | * Checks to see if we've found the last match in 122 | * a combined string. 123 | */ 124 | bool lastCombined(std::string& combined); 125 | 126 | /** 127 | * Does the common processing of processArg. 128 | */ 129 | void commonProcessing(); 130 | }; 131 | 132 | ////////////////////////////////////////////////////////////////////// 133 | //BEGIN SwitchArg.cpp 134 | ////////////////////////////////////////////////////////////////////// 135 | inline SwitchArg::SwitchArg(const std::string& flag, 136 | const std::string& name, 137 | const std::string& desc, 138 | bool default_val, 139 | Visitor* v ) 140 | : Arg(flag, name, desc, false, false, v), 141 | _value( default_val ), 142 | _default( default_val ) 143 | { } 144 | 145 | inline SwitchArg::SwitchArg(const std::string& flag, 146 | const std::string& name, 147 | const std::string& desc, 148 | CmdLineInterface& parser, 149 | bool default_val, 150 | Visitor* v ) 151 | : Arg(flag, name, desc, false, false, v), 152 | _value( default_val ), 153 | _default(default_val) 154 | { 155 | parser.add( this ); 156 | } 157 | 158 | inline bool SwitchArg::getValue() { return _value; } 159 | 160 | inline bool SwitchArg::lastCombined(std::string& combinedSwitches ) 161 | { 162 | for ( unsigned int i = 1; i < combinedSwitches.length(); i++ ) 163 | if ( combinedSwitches[i] != Arg::blankChar() ) 164 | return false; 165 | 166 | return true; 167 | } 168 | 169 | inline bool SwitchArg::combinedSwitchesMatch(std::string& combinedSwitches ) 170 | { 171 | // make sure this is actually a combined switch 172 | if ( combinedSwitches.length() > 0 && 173 | combinedSwitches[0] != Arg::flagStartString()[0] ) 174 | return false; 175 | 176 | // make sure it isn't a long name 177 | if ( combinedSwitches.substr( 0, Arg::nameStartString().length() ) == 178 | Arg::nameStartString() ) 179 | return false; 180 | 181 | // make sure the delimiter isn't in the string 182 | if ( combinedSwitches.find_first_of( Arg::delimiter() ) != std::string::npos ) 183 | return false; 184 | 185 | // ok, we're not specifying a ValueArg, so we know that we have 186 | // a combined switch list. 187 | for ( unsigned int i = 1; i < combinedSwitches.length(); i++ ) 188 | if ( _flag.length() > 0 && 189 | combinedSwitches[i] == _flag[0] && 190 | _flag[0] != Arg::flagStartString()[0] ) 191 | { 192 | // update the combined switches so this one is no longer present 193 | // this is necessary so that no unlabeled args are matched 194 | // later in the processing. 195 | //combinedSwitches.erase(i,1); 196 | combinedSwitches[i] = Arg::blankChar(); 197 | return true; 198 | } 199 | 200 | // none of the switches passed in the list match. 201 | return false; 202 | } 203 | 204 | inline void SwitchArg::commonProcessing() 205 | { 206 | if ( _xorSet ) 207 | throw(CmdLineParseException( 208 | "Mutually exclusive argument already set!", toString())); 209 | 210 | if ( _alreadySet ) 211 | throw(CmdLineParseException("Argument already set!", toString())); 212 | 213 | _alreadySet = true; 214 | 215 | if ( _value == true ) 216 | _value = false; 217 | else 218 | _value = true; 219 | 220 | _checkWithVisitor(); 221 | } 222 | 223 | inline bool SwitchArg::processArg(int *i, std::vector& args) 224 | { 225 | if ( _ignoreable && Arg::ignoreRest() ) 226 | return false; 227 | 228 | // if the whole string matches the flag or name string 229 | if ( argMatches( args[*i] ) ) 230 | { 231 | commonProcessing(); 232 | 233 | return true; 234 | } 235 | // if a substring matches the flag as part of a combination 236 | else if ( combinedSwitchesMatch( args[*i] ) ) 237 | { 238 | // check again to ensure we don't misinterpret 239 | // this as a MultiSwitchArg 240 | if ( combinedSwitchesMatch( args[*i] ) ) 241 | throw(CmdLineParseException("Argument already set!", 242 | toString())); 243 | 244 | commonProcessing(); 245 | 246 | // We only want to return true if we've found the last combined 247 | // match in the string, otherwise we return true so that other 248 | // switches in the combination will have a chance to match. 249 | return lastCombined( args[*i] ); 250 | } 251 | else 252 | return false; 253 | } 254 | 255 | inline void SwitchArg::reset() 256 | { 257 | Arg::reset(); 258 | _value = _default; 259 | } 260 | ////////////////////////////////////////////////////////////////////// 261 | //End SwitchArg.cpp 262 | ////////////////////////////////////////////////////////////////////// 263 | 264 | } //namespace TCLAP 265 | 266 | #endif 267 | -------------------------------------------------------------------------------- /src/tclap/ZshCompletionOutput.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ZshCompletionOutput.h 6 | * 7 | * Copyright (c) 2006, Oliver Kiddle 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_ZSHCOMPLETIONOUTPUT_H 24 | #define TCLAP_ZSHCOMPLETIONOUTPUT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace TCLAP { 38 | 39 | /** 40 | * A class that generates a Zsh completion function as output from the usage() 41 | * method for the given CmdLine and its Args. 42 | */ 43 | class ZshCompletionOutput : public CmdLineOutput 44 | { 45 | 46 | public: 47 | 48 | ZshCompletionOutput(); 49 | 50 | /** 51 | * Prints the usage to stdout. Can be overridden to 52 | * produce alternative behavior. 53 | * \param c - The CmdLine object the output is generated for. 54 | */ 55 | virtual void usage(CmdLineInterface& c); 56 | 57 | /** 58 | * Prints the version to stdout. Can be overridden 59 | * to produce alternative behavior. 60 | * \param c - The CmdLine object the output is generated for. 61 | */ 62 | virtual void version(CmdLineInterface& c); 63 | 64 | /** 65 | * Prints (to stderr) an error message, short usage 66 | * Can be overridden to produce alternative behavior. 67 | * \param c - The CmdLine object the output is generated for. 68 | * \param e - The ArgException that caused the failure. 69 | */ 70 | virtual void failure(CmdLineInterface& c, 71 | ArgException& e ); 72 | 73 | protected: 74 | 75 | void basename( std::string& s ); 76 | void quoteSpecialChars( std::string& s ); 77 | 78 | std::string getMutexList( CmdLineInterface& _cmd, Arg* a ); 79 | void printOption( Arg* it, std::string mutex ); 80 | void printArg( Arg* it ); 81 | 82 | std::map common; 83 | char theDelimiter; 84 | }; 85 | 86 | ZshCompletionOutput::ZshCompletionOutput() 87 | : common(std::map()), 88 | theDelimiter('=') 89 | { 90 | common["host"] = "_hosts"; 91 | common["hostname"] = "_hosts"; 92 | common["file"] = "_files"; 93 | common["filename"] = "_files"; 94 | common["user"] = "_users"; 95 | common["username"] = "_users"; 96 | common["directory"] = "_directories"; 97 | common["path"] = "_directories"; 98 | common["url"] = "_urls"; 99 | } 100 | 101 | inline void ZshCompletionOutput::version(CmdLineInterface& _cmd) 102 | { 103 | std::cout << _cmd.getVersion() << std::endl; 104 | } 105 | 106 | inline void ZshCompletionOutput::usage(CmdLineInterface& _cmd ) 107 | { 108 | std::list argList = _cmd.getArgList(); 109 | std::string progName = _cmd.getProgramName(); 110 | std::string xversion = _cmd.getVersion(); 111 | theDelimiter = _cmd.getDelimiter(); 112 | basename(progName); 113 | 114 | std::cout << "#compdef " << progName << std::endl << std::endl << 115 | "# " << progName << " version " << _cmd.getVersion() << std::endl << std::endl << 116 | "_arguments -s -S"; 117 | 118 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 119 | { 120 | if ( (*it)->shortID().at(0) == '<' ) 121 | printArg((*it)); 122 | else if ( (*it)->getFlag() != "-" ) 123 | printOption((*it), getMutexList(_cmd, *it)); 124 | } 125 | 126 | std::cout << std::endl; 127 | } 128 | 129 | inline void ZshCompletionOutput::failure( CmdLineInterface& _cmd, 130 | ArgException& e ) 131 | { 132 | static_cast(_cmd); // unused 133 | std::cout << e.what() << std::endl; 134 | } 135 | 136 | inline void ZshCompletionOutput::quoteSpecialChars( std::string& s ) 137 | { 138 | size_t idx = s.find_last_of(':'); 139 | while ( idx != std::string::npos ) 140 | { 141 | s.insert(idx, 1, '\\'); 142 | idx = s.find_last_of(':', idx); 143 | } 144 | idx = s.find_last_of('\''); 145 | while ( idx != std::string::npos ) 146 | { 147 | s.insert(idx, "'\\'"); 148 | if (idx == 0) 149 | idx = std::string::npos; 150 | else 151 | idx = s.find_last_of('\'', --idx); 152 | } 153 | } 154 | 155 | inline void ZshCompletionOutput::basename( std::string& s ) 156 | { 157 | size_t p = s.find_last_of('/'); 158 | if ( p != std::string::npos ) 159 | { 160 | s.erase(0, p + 1); 161 | } 162 | } 163 | 164 | inline void ZshCompletionOutput::printArg(Arg* a) 165 | { 166 | static int count = 1; 167 | 168 | std::cout << " \\" << std::endl << " '"; 169 | if ( a->acceptsMultipleValues() ) 170 | std::cout << '*'; 171 | else 172 | std::cout << count++; 173 | std::cout << ':'; 174 | if ( !a->isRequired() ) 175 | std::cout << ':'; 176 | 177 | std::cout << a->getName() << ':'; 178 | std::map::iterator compArg = common.find(a->getName()); 179 | if ( compArg != common.end() ) 180 | { 181 | std::cout << compArg->second; 182 | } 183 | else 184 | { 185 | std::cout << "_guard \"^-*\" " << a->getName(); 186 | } 187 | std::cout << '\''; 188 | } 189 | 190 | inline void ZshCompletionOutput::printOption(Arg* a, std::string mutex) 191 | { 192 | std::string flag = a->flagStartChar() + a->getFlag(); 193 | std::string name = a->nameStartString() + a->getName(); 194 | std::string desc = a->getDescription(); 195 | 196 | // remove full stop and capitalisation from description as 197 | // this is the convention for zsh function 198 | if (!desc.compare(0, 12, "(required) ")) 199 | { 200 | desc.erase(0, 12); 201 | } 202 | if (!desc.compare(0, 15, "(OR required) ")) 203 | { 204 | desc.erase(0, 15); 205 | } 206 | size_t len = desc.length(); 207 | if (len && desc.at(--len) == '.') 208 | { 209 | desc.erase(len); 210 | } 211 | if (len) 212 | { 213 | desc.replace(0, 1, 1, tolower(desc.at(0))); 214 | } 215 | 216 | std::cout << " \\" << std::endl << " '" << mutex; 217 | 218 | if ( a->getFlag().empty() ) 219 | { 220 | std::cout << name; 221 | } 222 | else 223 | { 224 | std::cout << "'{" << flag << ',' << name << "}'"; 225 | } 226 | if ( theDelimiter == '=' && a->isValueRequired() ) 227 | std::cout << "=-"; 228 | quoteSpecialChars(desc); 229 | std::cout << '[' << desc << ']'; 230 | 231 | if ( a->isValueRequired() ) 232 | { 233 | std::string arg = a->shortID(); 234 | arg.erase(0, arg.find_last_of(theDelimiter) + 1); 235 | if ( arg.at(arg.length()-1) == ']' ) 236 | arg.erase(arg.length()-1); 237 | if ( arg.at(arg.length()-1) == ']' ) 238 | { 239 | arg.erase(arg.length()-1); 240 | } 241 | if ( arg.at(0) == '<' ) 242 | { 243 | arg.erase(arg.length()-1); 244 | arg.erase(0, 1); 245 | } 246 | size_t p = arg.find('|'); 247 | if ( p != std::string::npos ) 248 | { 249 | do 250 | { 251 | arg.replace(p, 1, 1, ' '); 252 | } 253 | while ( (p = arg.find_first_of('|', p)) != std::string::npos ); 254 | quoteSpecialChars(arg); 255 | std::cout << ": :(" << arg << ')'; 256 | } 257 | else 258 | { 259 | std::cout << ':' << arg; 260 | std::map::iterator compArg = common.find(arg); 261 | if ( compArg != common.end() ) 262 | { 263 | std::cout << ':' << compArg->second; 264 | } 265 | } 266 | } 267 | 268 | std::cout << '\''; 269 | } 270 | 271 | inline std::string ZshCompletionOutput::getMutexList( CmdLineInterface& _cmd, Arg* a) 272 | { 273 | XorHandler xorHandler = _cmd.getXorHandler(); 274 | std::vector< std::vector > xorList = xorHandler.getXorList(); 275 | 276 | if (a->getName() == "help" || a->getName() == "version") 277 | { 278 | return "(-)"; 279 | } 280 | 281 | std::ostringstream list; 282 | if ( a->acceptsMultipleValues() ) 283 | { 284 | list << '*'; 285 | } 286 | 287 | for ( int i = 0; static_cast(i) < xorList.size(); i++ ) 288 | { 289 | for ( ArgVectorIterator it = xorList[i].begin(); 290 | it != xorList[i].end(); 291 | it++) 292 | if ( a == (*it) ) 293 | { 294 | list << '('; 295 | for ( ArgVectorIterator iu = xorList[i].begin(); 296 | iu != xorList[i].end(); 297 | iu++ ) 298 | { 299 | bool notCur = (*iu) != a; 300 | bool hasFlag = !(*iu)->getFlag().empty(); 301 | if ( iu != xorList[i].begin() && (notCur || hasFlag) ) 302 | list << ' '; 303 | if (hasFlag) 304 | list << (*iu)->flagStartChar() << (*iu)->getFlag() << ' '; 305 | if ( notCur || hasFlag ) 306 | list << (*iu)->nameStartString() << (*iu)->getName(); 307 | } 308 | list << ')'; 309 | return list.str(); 310 | } 311 | } 312 | 313 | // wasn't found in xor list 314 | if (!a->getFlag().empty()) { 315 | list << "(" << a->flagStartChar() << a->getFlag() << ' ' << 316 | a->nameStartString() << a->getName() << ')'; 317 | } 318 | 319 | return list.str(); 320 | } 321 | 322 | } //namespace TCLAP 323 | #endif 324 | -------------------------------------------------------------------------------- /src/fusion/treeandbrick.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * treeandbrick.hpp 3 | * 4 | * Created on: Mar 1, 2013 5 | * Author: steinbrf 6 | */ 7 | 8 | #ifndef TREEANDBRICK_HPP_ 9 | #define TREEANDBRICK_HPP_ 10 | 11 | #include "mesh.hpp" 12 | #include 13 | 14 | 15 | typedef std::vector leafstack; 16 | 17 | 18 | 19 | typedef struct treeinfo_ { 20 | treeinfo_(MeshSeparate *pmesh,sidetype pbrickLength, sidetype pbrickSize, float pminWeight, 21 | float3 poffset, float pscale, unsigned int *pdegenerate_faces, 22 | volumetype pmaxBranches, volumetype pmaxLeaves,const volumetype *ptree, 23 | const sidetype3 *pleafPos, const sidetype *pleafScale, 24 | const float *pdistance, const weighttype *pweights, const colortype3 *pcolor) 25 | : mesh(pmesh), brickLength(pbrickLength), brickSize(pbrickSize), minWeight(pminWeight), 26 | offset(poffset), scale(pscale), degenerate_faces(pdegenerate_faces), 27 | maxBranches(pmaxBranches), maxLeaves(pmaxLeaves), tree(ptree), 28 | leafPos(pleafPos), leafScale(pleafScale), distance(pdistance), 29 | weights(pweights), color(pcolor){} 30 | MeshSeparate *mesh; 31 | sidetype brickLength; 32 | sidetype brickSize; 33 | float minWeight; 34 | float3 offset; 35 | float scale; 36 | unsigned int *degenerate_faces; 37 | volumetype maxBranches; 38 | volumetype maxLeaves; 39 | const volumetype *tree; 40 | const sidetype3 *leafPos; 41 | const sidetype *leafScale; 42 | const float *distance; 43 | const weighttype *weights; 44 | const colortype3 *color; 45 | } treeinfo; 46 | 47 | 48 | #include "treeandbrick_incremental.hpp" 49 | 50 | void shiftBranches 51 | ( 52 | volumetype *tree, 53 | volumetype index, 54 | sidetype sideLength, 55 | sidetype brickLength, 56 | volumetype nullValue, 57 | volumetype shiftValue 58 | ); 59 | 60 | void shiftBranchesMultiscale 61 | ( 62 | volumetype *tree, 63 | volumetype index, 64 | volumetype maxNumberBranches, 65 | volumetype shiftValue 66 | ); 67 | 68 | void shiftBranchesMipMap 69 | ( 70 | volumetype *tree, 71 | volumetype index, 72 | sidetype sideLength, 73 | sidetype brickLength, 74 | volumetype nullValue, 75 | volumetype shiftValue 76 | ); 77 | 78 | std::string getMaximalNumberOfLeavesForDynamicTree 79 | ( 80 | long long availableBytes, 81 | sidetype brickLength, 82 | long long bytesForDistance, 83 | long long bytesForWeight, 84 | long long bytesForColor, 85 | volumetype *nLeaves, 86 | volumetype *nBranches 87 | ); 88 | 89 | std::string getMaximalNumberOfLeavesForDynamicTreeMultiscale 90 | ( 91 | long long availableBytes, 92 | sidetype brickLength, 93 | long long bytesForDistance, 94 | long long bytesForWeight, 95 | long long bytesForColor, 96 | volumetype *nLeaves, 97 | volumetype *nBranches, 98 | bool useMultiscale 99 | ); 100 | 101 | std::string getMaximalNumberOfLeavesForDynamicTreeMipMap 102 | ( 103 | long long availableBytes, 104 | sidetype brickLength, 105 | long long bytesForDistance, 106 | long long bytesForWeight, 107 | long long bytesForColor, 108 | volumetype *nLeaves, 109 | volumetype *nBranches 110 | ); 111 | 112 | std::string getMaximalNumberOfLeavesForDynamicTreeMultiscale 113 | ( 114 | long long availableBytes, 115 | sidetype brickLength, 116 | long long bytesForDistance, 117 | long long bytesForWeight, 118 | long long bytesForColor, 119 | volumetype *nLeaves, 120 | volumetype *nBranches 121 | ); 122 | 123 | 124 | std::string getMaximalNumberOfLeavesForFixedTree 125 | ( 126 | long long availableBytes, 127 | sidetype sideLength, 128 | sidetype brickLength, 129 | long long bytesForDistance, 130 | long long bytesForWeight, 131 | long long bytesForColor, 132 | volumetype *maxNLeaves, 133 | volumetype *maxnBranches, 134 | volumetype *nLeavesFullTree = NULL 135 | ); 136 | 137 | void printTreeStatistics(volumetype *tree, sidetype start, sidetype end, bool printwholetree = false); 138 | 139 | volumetype getBrickIndex( 140 | sidetype x, sidetype y, sidetype z, 141 | sidetype n, sidetype brickLength, sidetype brickSize, 142 | volumetype nNodes, volumetype nAllocatedLeaves, 143 | volumetype *tree); 144 | 145 | volumetype getBrickIndexMultiscale( 146 | sidetype x, sidetype y, sidetype z, 147 | sidetype n, sidetype brickLength, sidetype brickSize, 148 | volumetype nNodes, volumetype nAllocatedLeaves, 149 | volumetype *tree, sidetype *leafScale 150 | ); 151 | 152 | volumetype getBrickIndexMipMap( 153 | sidetype x, sidetype y, sidetype z, 154 | sidetype n, sidetype brickLength, 155 | sidetype brickSize, 156 | volumetype nNodes, volumetype nAllocatedLeaves, 157 | volumetype *tree, sidetype *leafScale 158 | ); 159 | 160 | volumetype getBrickIndex( 161 | sidetype x, sidetype y, sidetype z, float *distance, 162 | sidetype n, sidetype brickLength, sidetype brickSize, 163 | volumetype nNodes, volumetype nAllocatedLeaves, 164 | volumetype *tree, float *distanceField); 165 | 166 | volumetype getIndexFromTree( 167 | sidetype x, sidetype y, sidetype z, 168 | sidetype n, sidetype brickLength, sidetype brickSize, 169 | volumetype nNodes, volumetype nAllocatedLeaves, 170 | volumetype *tree); 171 | 172 | volumetype getBrickIndexMipMap2 173 | ( 174 | sidetype x, sidetype y, sidetype z, 175 | sidetype n, sidetype brickLength, 176 | sidetype brickSize, 177 | volumetype nNodes, volumetype nLeaves, 178 | volumetype *tree, volumetype nullValue 179 | ); 180 | 181 | 182 | void addBrickToMesh 183 | ( 184 | MeshSeparate &mesh, 185 | float offsetX, 186 | float offsetY, 187 | float offsetZ, 188 | float scale, 189 | sidetype ox, 190 | sidetype oy, 191 | sidetype oz, 192 | volumetype brickIdx, 193 | sidetype brickLength, 194 | volumetype brickSize, 195 | sidetype blp1, 196 | sidetype blm1, 197 | volumetype *tree, 198 | float *distance, 199 | weighttype *weights, 200 | volumetype nNodes, 201 | sidetype n, 202 | volumetype nLeavesUsed, 203 | float *distanceBrick, 204 | weighttype *weightsBrick, 205 | bool useColor, 206 | colortype *color, 207 | colortype *r, 208 | colortype *g, 209 | colortype *b, 210 | colortype *rBrick, 211 | colortype *gBrick, 212 | colortype *bBrick, 213 | unsigned int framesAdded, 214 | unsigned int *degenerateFaces = NULL 215 | ); 216 | 217 | void addBrickToMeshMultiscale 218 | ( 219 | MeshSeparate &mesh, 220 | float offsetX, 221 | float offsetY, 222 | float offsetZ, 223 | float scaleToBrick, 224 | sidetype leafScale, 225 | sidetype ox, 226 | sidetype oy, 227 | sidetype oz, 228 | volumetype brickIdx, 229 | sidetype brickLength, 230 | volumetype brickSize, 231 | sidetype blp1, 232 | sidetype blm1, 233 | volumetype *tree, 234 | float *distance, 235 | weighttype *weights, 236 | volumetype nNodes, 237 | sidetype n, 238 | volumetype nLeavesUsed, 239 | float *distanceBrick, 240 | weighttype *weightsBrick, 241 | bool useColor, 242 | colortype *color, 243 | colortype *r, 244 | colortype *g, 245 | colortype *b, 246 | colortype *rBrick, 247 | colortype *gBrick, 248 | colortype *bBrick, 249 | unsigned int framesAdded, 250 | unsigned int *degenerateFaces = NULL 251 | ); 252 | 253 | void addBrickToMeshMipMap 254 | ( 255 | MeshSeparate &mesh, 256 | float offsetX, 257 | float offsetY, 258 | float offsetZ, 259 | float scaleToBrick, 260 | sidetype leafScale, 261 | sidetype ox, 262 | sidetype oy, 263 | sidetype oz, 264 | volumetype brickIdx, 265 | sidetype brickLength, 266 | volumetype brickSize, 267 | sidetype blp1, 268 | sidetype blm1, 269 | volumetype *tree, 270 | float *distance, 271 | weighttype *weights, 272 | volumetype nNodes, 273 | sidetype n, 274 | volumetype nLeavesUsed, 275 | float *distanceBrick, 276 | weighttype *weightsBrick, 277 | bool useColor, 278 | colortype *color, 279 | colortype *r, 280 | colortype *g, 281 | colortype *b, 282 | colortype *rBrick, 283 | colortype *gBrick, 284 | colortype *bBrick, 285 | unsigned int framesAdded, 286 | unsigned int *degenerateFaces 287 | ); 288 | 289 | 290 | 291 | void getTreeLinesMiddle(volumetype *tree, volumetype idx, sidetype brickLength, 292 | sidetype half, sidetype ox, sidetype oy, sidetype oz, MeshSeparate &mesh); 293 | 294 | void getTreeLinesBox(volumetype *tree, volumetype idx, sidetype brickLength, 295 | volumetype nBranchesTotal, 296 | sidetype half, sidetype ox, sidetype oy, sidetype oz, MeshSeparate &mesh, float width); 297 | 298 | void getTreeLinesBoxMipMap(volumetype *tree, volumetype idx, sidetype brickLength, 299 | volumetype nBranchesTotal, 300 | sidetype half, sidetype ox, sidetype oy, sidetype oz, MeshSeparate &mesh, float width); 301 | 302 | void getTreeQuads(volumetype *tree, volumetype idx, sidetype brickLength, 303 | sidetype half, sidetype ox, sidetype oy, sidetype oz, 304 | MeshSeparate &mesh); 305 | 306 | bool weightInfluence(float minWeight, 307 | weighttype w0, weighttype w1, weighttype w2, weighttype w3, 308 | weighttype w4, weighttype w5, weighttype w6, weighttype w7 309 | ); 310 | 311 | 312 | 313 | void addBrickWallZ 314 | ( 315 | treeinfo info, 316 | sidetype ox, sidetype oy, sidetype oz, 317 | sidetype size, 318 | leafstack leaves0, 319 | leafstack leaves1 320 | ); 321 | 322 | 323 | void addInterior 324 | ( 325 | leafstack leaves, 326 | treeinfo info, 327 | volumetype index, sidetype size, 328 | sidetype ox, sidetype oy, sidetype oz, 329 | volumetype lastLeaf, 330 | const MarchingCubesIndexed &mc 331 | ); 332 | 333 | 334 | void addBrickInterior 335 | ( 336 | leafstack leaves, 337 | sidetype ox, sidetype oy, sidetype oz, 338 | sidetype size, 339 | treeinfo info, 340 | const MarchingCubesIndexed &mc 341 | ); 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | #endif /* TREEANDBRICK_HPP_ */ 355 | -------------------------------------------------------------------------------- /src/tclap/DocBookOutput.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: DocBookOutput.h 6 | * 7 | * Copyright (c) 2004, Michael E. Smoot 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_DOCBOOKOUTPUT_H 24 | #define TCLAP_DOCBOOKOUTPUT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace TCLAP { 38 | 39 | /** 40 | * A class that generates DocBook output for usage() method for the 41 | * given CmdLine and its Args. 42 | */ 43 | class DocBookOutput : public CmdLineOutput 44 | { 45 | 46 | public: 47 | 48 | /** 49 | * Prints the usage to stdout. Can be overridden to 50 | * produce alternative behavior. 51 | * \param c - The CmdLine object the output is generated for. 52 | */ 53 | virtual void usage(CmdLineInterface& c); 54 | 55 | /** 56 | * Prints the version to stdout. Can be overridden 57 | * to produce alternative behavior. 58 | * \param c - The CmdLine object the output is generated for. 59 | */ 60 | virtual void version(CmdLineInterface& c); 61 | 62 | /** 63 | * Prints (to stderr) an error message, short usage 64 | * Can be overridden to produce alternative behavior. 65 | * \param c - The CmdLine object the output is generated for. 66 | * \param e - The ArgException that caused the failure. 67 | */ 68 | virtual void failure(CmdLineInterface& c, 69 | ArgException& e ); 70 | 71 | protected: 72 | 73 | /** 74 | * Substitutes the char r for string x in string s. 75 | * \param s - The string to operate on. 76 | * \param r - The char to replace. 77 | * \param x - What to replace r with. 78 | */ 79 | void substituteSpecialChars( std::string& s, char r, std::string& x ); 80 | void removeChar( std::string& s, char r); 81 | void basename( std::string& s ); 82 | 83 | void printShortArg(Arg* it); 84 | void printLongArg(Arg* it); 85 | 86 | char theDelimiter; 87 | }; 88 | 89 | 90 | inline void DocBookOutput::version(CmdLineInterface& _cmd) 91 | { 92 | std::cout << _cmd.getVersion() << std::endl; 93 | } 94 | 95 | inline void DocBookOutput::usage(CmdLineInterface& _cmd ) 96 | { 97 | std::list argList = _cmd.getArgList(); 98 | std::string progName = _cmd.getProgramName(); 99 | std::string xversion = _cmd.getVersion(); 100 | theDelimiter = _cmd.getDelimiter(); 101 | XorHandler xorHandler = _cmd.getXorHandler(); 102 | std::vector< std::vector > xorList = xorHandler.getXorList(); 103 | basename(progName); 104 | 105 | std::cout << "" << std::endl; 106 | std::cout << "" << std::endl << std::endl; 108 | 109 | std::cout << "" << std::endl; 110 | 111 | std::cout << "" << std::endl; 112 | std::cout << "" << progName << "" << std::endl; 113 | std::cout << "1" << std::endl; 114 | std::cout << "" << std::endl; 115 | 116 | std::cout << "" << std::endl; 117 | std::cout << "" << progName << "" << std::endl; 118 | std::cout << "" << _cmd.getMessage() << "" << std::endl; 119 | std::cout << "" << std::endl; 120 | 121 | std::cout << "" << std::endl; 122 | std::cout << "" << std::endl; 123 | 124 | std::cout << "" << progName << "" << std::endl; 125 | 126 | // xor 127 | for ( int i = 0; (unsigned int)i < xorList.size(); i++ ) 128 | { 129 | std::cout << "" << std::endl; 130 | for ( ArgVectorIterator it = xorList[i].begin(); 131 | it != xorList[i].end(); it++ ) 132 | printShortArg((*it)); 133 | 134 | std::cout << "" << std::endl; 135 | } 136 | 137 | // rest of args 138 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 139 | if ( !xorHandler.contains( (*it) ) ) 140 | printShortArg((*it)); 141 | 142 | std::cout << "" << std::endl; 143 | std::cout << "" << std::endl; 144 | 145 | std::cout << "" << std::endl; 146 | std::cout << "Description" << std::endl; 147 | std::cout << "" << std::endl; 148 | std::cout << _cmd.getMessage() << std::endl; 149 | std::cout << "" << std::endl; 150 | std::cout << "" << std::endl; 151 | 152 | std::cout << "" << std::endl; 153 | std::cout << "Options" << std::endl; 154 | 155 | std::cout << "" << std::endl; 156 | 157 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 158 | printLongArg((*it)); 159 | 160 | std::cout << "" << std::endl; 161 | std::cout << "" << std::endl; 162 | 163 | std::cout << "" << std::endl; 164 | std::cout << "Version" << std::endl; 165 | std::cout << "" << std::endl; 166 | std::cout << xversion << std::endl; 167 | std::cout << "" << std::endl; 168 | std::cout << "" << std::endl; 169 | 170 | std::cout << "" << std::endl; 171 | 172 | } 173 | 174 | inline void DocBookOutput::failure( CmdLineInterface& _cmd, 175 | ArgException& e ) 176 | { 177 | static_cast(_cmd); // unused 178 | std::cout << e.what() << std::endl; 179 | throw ExitException(1); 180 | } 181 | 182 | inline void DocBookOutput::substituteSpecialChars( std::string& s, 183 | char r, 184 | std::string& x ) 185 | { 186 | size_t p; 187 | while ( (p = s.find_first_of(r)) != std::string::npos ) 188 | { 189 | s.erase(p,1); 190 | s.insert(p,x); 191 | } 192 | } 193 | 194 | inline void DocBookOutput::removeChar( std::string& s, char r) 195 | { 196 | size_t p; 197 | while ( (p = s.find_first_of(r)) != std::string::npos ) 198 | { 199 | s.erase(p,1); 200 | } 201 | } 202 | 203 | inline void DocBookOutput::basename( std::string& s ) 204 | { 205 | size_t p = s.find_last_of('/'); 206 | if ( p != std::string::npos ) 207 | { 208 | s.erase(0, p + 1); 209 | } 210 | } 211 | 212 | inline void DocBookOutput::printShortArg(Arg* a) 213 | { 214 | std::string lt = "<"; 215 | std::string gt = ">"; 216 | 217 | std::string id = a->shortID(); 218 | substituteSpecialChars(id,'<',lt); 219 | substituteSpecialChars(id,'>',gt); 220 | removeChar(id,'['); 221 | removeChar(id,']'); 222 | 223 | std::string choice = "opt"; 224 | if ( a->isRequired() ) 225 | choice = "plain"; 226 | 227 | std::cout << "acceptsMultipleValues() ) 229 | std::cout << " rep='repeat'"; 230 | 231 | 232 | std::cout << '>'; 233 | if ( !a->getFlag().empty() ) 234 | std::cout << a->flagStartChar() << a->getFlag(); 235 | else 236 | std::cout << a->nameStartString() << a->getName(); 237 | if ( a->isValueRequired() ) 238 | { 239 | std::string arg = a->shortID(); 240 | removeChar(arg,'['); 241 | removeChar(arg,']'); 242 | removeChar(arg,'<'); 243 | removeChar(arg,'>'); 244 | arg.erase(0, arg.find_last_of(theDelimiter) + 1); 245 | std::cout << theDelimiter; 246 | std::cout << "" << arg << ""; 247 | } 248 | std::cout << "" << std::endl; 249 | 250 | } 251 | 252 | inline void DocBookOutput::printLongArg(Arg* a) 253 | { 254 | std::string lt = "<"; 255 | std::string gt = ">"; 256 | 257 | std::string desc = a->getDescription(); 258 | substituteSpecialChars(desc,'<',lt); 259 | substituteSpecialChars(desc,'>',gt); 260 | 261 | std::cout << "" << std::endl; 262 | 263 | if ( !a->getFlag().empty() ) 264 | { 265 | std::cout << "" << std::endl; 266 | std::cout << "" << std::endl; 269 | std::cout << "" << std::endl; 270 | } 271 | 272 | std::cout << "" << std::endl; 273 | std::cout << "" << std::endl; 287 | std::cout << "" << std::endl; 288 | 289 | std::cout << "" << std::endl; 290 | std::cout << "" << std::endl; 291 | std::cout << desc << std::endl; 292 | std::cout << "" << std::endl; 293 | std::cout << "" << std::endl; 294 | 295 | std::cout << "" << std::endl; 296 | } 297 | 298 | } //namespace TCLAP 299 | #endif 300 | -------------------------------------------------------------------------------- /src/tclap/StdOutput.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: StdOutput.h 6 | * 7 | * Copyright (c) 2004, Michael E. Smoot 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_STDCMDLINEOUTPUT_H 24 | #define TCLAP_STDCMDLINEOUTPUT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace TCLAP { 38 | 39 | /** 40 | * A class that isolates any output from the CmdLine object so that it 41 | * may be easily modified. 42 | */ 43 | class StdOutput : public CmdLineOutput 44 | { 45 | 46 | public: 47 | 48 | /** 49 | * Prints the usage to stdout. Can be overridden to 50 | * produce alternative behavior. 51 | * \param c - The CmdLine object the output is generated for. 52 | */ 53 | virtual void usage(CmdLineInterface& c); 54 | 55 | /** 56 | * Prints the version to stdout. Can be overridden 57 | * to produce alternative behavior. 58 | * \param c - The CmdLine object the output is generated for. 59 | */ 60 | virtual void version(CmdLineInterface& c); 61 | 62 | /** 63 | * Prints (to stderr) an error message, short usage 64 | * Can be overridden to produce alternative behavior. 65 | * \param c - The CmdLine object the output is generated for. 66 | * \param e - The ArgException that caused the failure. 67 | */ 68 | virtual void failure(CmdLineInterface& c, 69 | ArgException& e ); 70 | 71 | protected: 72 | 73 | /** 74 | * Writes a brief usage message with short args. 75 | * \param c - The CmdLine object the output is generated for. 76 | * \param os - The stream to write the message to. 77 | */ 78 | void _shortUsage( CmdLineInterface& c, std::ostream& os ) const; 79 | 80 | /** 81 | * Writes a longer usage message with long and short args, 82 | * provides descriptions and prints message. 83 | * \param c - The CmdLine object the output is generated for. 84 | * \param os - The stream to write the message to. 85 | */ 86 | void _longUsage( CmdLineInterface& c, std::ostream& os ) const; 87 | 88 | /** 89 | * This function inserts line breaks and indents long strings 90 | * according the params input. It will only break lines at spaces, 91 | * commas and pipes. 92 | * \param os - The stream to be printed to. 93 | * \param s - The string to be printed. 94 | * \param maxWidth - The maxWidth allowed for the output line. 95 | * \param indentSpaces - The number of spaces to indent the first line. 96 | * \param secondLineOffset - The number of spaces to indent the second 97 | * and all subsequent lines in addition to indentSpaces. 98 | */ 99 | void spacePrint( std::ostream& os, 100 | const std::string& s, 101 | int maxWidth, 102 | int indentSpaces, 103 | int secondLineOffset ) const; 104 | 105 | }; 106 | 107 | 108 | inline void StdOutput::version(CmdLineInterface& _cmd) 109 | { 110 | std::string progName = _cmd.getProgramName(); 111 | std::string xversion = _cmd.getVersion(); 112 | 113 | std::cout << std::endl << progName << " version: " 114 | << xversion << std::endl << std::endl; 115 | } 116 | 117 | inline void StdOutput::usage(CmdLineInterface& _cmd ) 118 | { 119 | std::cout << std::endl << "USAGE: " << std::endl << std::endl; 120 | 121 | _shortUsage( _cmd, std::cout ); 122 | 123 | std::cout << std::endl << std::endl << "Where: " << std::endl << std::endl; 124 | 125 | _longUsage( _cmd, std::cout ); 126 | 127 | std::cout << std::endl; 128 | 129 | } 130 | 131 | inline void StdOutput::failure( CmdLineInterface& _cmd, 132 | ArgException& e ) 133 | { 134 | std::string progName = _cmd.getProgramName(); 135 | 136 | std::cerr << "PARSE ERROR: " << e.argId() << std::endl 137 | << " " << e.error() << std::endl << std::endl; 138 | 139 | if ( _cmd.hasHelpAndVersion() ) 140 | { 141 | std::cerr << "Brief USAGE: " << std::endl; 142 | 143 | _shortUsage( _cmd, std::cerr ); 144 | 145 | std::cerr << std::endl << "For complete USAGE and HELP type: " 146 | << std::endl << " " << progName << " --help" 147 | << std::endl << std::endl; 148 | } 149 | else 150 | usage(_cmd); 151 | 152 | throw ExitException(1); 153 | } 154 | 155 | inline void 156 | StdOutput::_shortUsage( CmdLineInterface& _cmd, 157 | std::ostream& os ) const 158 | { 159 | std::list argList = _cmd.getArgList(); 160 | std::string progName = _cmd.getProgramName(); 161 | XorHandler xorHandler = _cmd.getXorHandler(); 162 | std::vector< std::vector > xorList = xorHandler.getXorList(); 163 | 164 | std::string s = progName + " "; 165 | 166 | // first the xor 167 | for ( int i = 0; static_cast(i) < xorList.size(); i++ ) 168 | { 169 | s += " {"; 170 | for ( ArgVectorIterator it = xorList[i].begin(); 171 | it != xorList[i].end(); it++ ) 172 | s += (*it)->shortID() + "|"; 173 | 174 | s[s.length()-1] = '}'; 175 | } 176 | 177 | // then the rest 178 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 179 | if ( !xorHandler.contains( (*it) ) ) 180 | s += " " + (*it)->shortID(); 181 | 182 | // if the program name is too long, then adjust the second line offset 183 | int secondLineOffset = static_cast(progName.length()) + 2; 184 | if ( secondLineOffset > 75/2 ) 185 | secondLineOffset = static_cast(75/2); 186 | 187 | spacePrint( os, s, 75, 3, secondLineOffset ); 188 | } 189 | 190 | inline void 191 | StdOutput::_longUsage( CmdLineInterface& _cmd, 192 | std::ostream& os ) const 193 | { 194 | std::list argList = _cmd.getArgList(); 195 | std::string message = _cmd.getMessage(); 196 | XorHandler xorHandler = _cmd.getXorHandler(); 197 | std::vector< std::vector > xorList = xorHandler.getXorList(); 198 | 199 | // first the xor 200 | for ( int i = 0; static_cast(i) < xorList.size(); i++ ) 201 | { 202 | for ( ArgVectorIterator it = xorList[i].begin(); 203 | it != xorList[i].end(); 204 | it++ ) 205 | { 206 | spacePrint( os, (*it)->longID(), 75, 3, 3 ); 207 | spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); 208 | 209 | if ( it+1 != xorList[i].end() ) 210 | spacePrint(os, "-- OR --", 75, 9, 0); 211 | } 212 | os << std::endl << std::endl; 213 | } 214 | 215 | // then the rest 216 | for (ArgListIterator it = argList.begin(); it != argList.end(); it++) 217 | if ( !xorHandler.contains( (*it) ) ) 218 | { 219 | spacePrint( os, (*it)->longID(), 75, 3, 3 ); 220 | spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); 221 | os << std::endl; 222 | } 223 | 224 | os << std::endl; 225 | 226 | spacePrint( os, message, 75, 3, 0 ); 227 | } 228 | 229 | inline void StdOutput::spacePrint( std::ostream& os, 230 | const std::string& s, 231 | int maxWidth, 232 | int indentSpaces, 233 | int secondLineOffset ) const 234 | { 235 | int len = static_cast(s.length()); 236 | 237 | if ( (len + indentSpaces > maxWidth) && maxWidth > 0 ) 238 | { 239 | int allowedLen = maxWidth - indentSpaces; 240 | int start = 0; 241 | while ( start < len ) 242 | { 243 | // find the substring length 244 | // int stringLen = std::min( len - start, allowedLen ); 245 | // doing it this way to support a VisualC++ 2005 bug 246 | using namespace std; 247 | int stringLen = min( len - start, allowedLen ); 248 | 249 | // trim the length so it doesn't end in middle of a word 250 | if ( stringLen == allowedLen ) 251 | while ( stringLen >= 0 && 252 | s[stringLen+start] != ' ' && 253 | s[stringLen+start] != ',' && 254 | s[stringLen+start] != '|' ) 255 | stringLen--; 256 | 257 | // ok, the word is longer than the line, so just split 258 | // wherever the line ends 259 | if ( stringLen <= 0 ) 260 | stringLen = allowedLen; 261 | 262 | // check for newlines 263 | for ( int i = 0; i < stringLen; i++ ) 264 | if ( s[start+i] == '\n' ) 265 | stringLen = i+1; 266 | 267 | // print the indent 268 | for ( int i = 0; i < indentSpaces; i++ ) 269 | os << " "; 270 | 271 | if ( start == 0 ) 272 | { 273 | // handle second line offsets 274 | indentSpaces += secondLineOffset; 275 | 276 | // adjust allowed len 277 | allowedLen -= secondLineOffset; 278 | } 279 | 280 | os << s.substr(start,stringLen) << std::endl; 281 | 282 | // so we don't start a line with a space 283 | while ( s[stringLen+start] == ' ' && start < len ) 284 | start++; 285 | 286 | start += stringLen; 287 | } 288 | } 289 | else 290 | { 291 | for ( int i = 0; i < indentSpaces; i++ ) 292 | os << " "; 293 | os << s << std::endl; 294 | } 295 | } 296 | 297 | } //namespace TCLAP 298 | #endif 299 | -------------------------------------------------------------------------------- /src/fusion/definitions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * definitions.h 3 | * 4 | * Created on: Feb 27, 2013 5 | * Author: steinbrf 6 | */ 7 | 8 | #ifndef DEFINITIONS_H_ 9 | #define DEFINITIONS_H_ 10 | 11 | 12 | #define UNENDLICH std::numeric_limits::infinity() 13 | 14 | //#define CRAPPY_LAPPY 15 | 16 | 17 | #define READ_DISTANCE_PER_BRICK 18 | 19 | //############################### CUDA ############################## 20 | 21 | #define TEXTUREOFFSET 0.5f 22 | #define FU_BW 16 23 | #define FU_BH 16 24 | #define FU_BS 256 25 | 26 | //########################## Data Types #################################### 27 | 28 | 29 | #ifndef uint 30 | typedef unsigned int uint; 31 | #endif 32 | 33 | #ifndef uchar 34 | typedef unsigned char uchar; 35 | #endif 36 | 37 | #ifndef weighttype 38 | typedef float weighttype; 39 | #endif 40 | 41 | #ifndef sidetype 42 | typedef unsigned short sidetype; 43 | #endif 44 | 45 | #ifndef volumetype 46 | typedef unsigned int volumetype; 47 | #define VOLUMETYPE_MAX 4294967295 48 | #endif 49 | 50 | #ifndef uchar 51 | typedef unsigned char uchar; 52 | #endif 53 | 54 | #ifndef colortype 55 | typedef unsigned short colortype; 56 | #define COLOR_MULTIPLICATOR 256 57 | #endif 58 | 59 | #ifndef sidetype3 60 | typedef struct sidetype3_{ sidetype x; sidetype y; sidetype z;} sidetype3; 61 | #endif 62 | //#ifndef sidetype4 63 | //typedef struct sidetype4_{ sidetype x; sidetype y; sidetype z; sidetype s;} sidetype4; 64 | //#endif 65 | 66 | #ifndef colortype3 67 | typedef struct colortype3_{ colortype x; colortype y; colortype z;} colortype3; 68 | #endif 69 | 70 | #ifndef camPamsFloat 71 | typedef struct camPamsFloat_{ 72 | camPamsFloat_( float pr11, float pr12, float pr13, 73 | float pr21, float pr22, float pr23, 74 | float pr31, float pr32, float pr33, 75 | float pt1, float pt2, float pt3, 76 | float pfx, float pfy, float pcx, float pcy){ 77 | r11 = pr11; r12 = pr12; r13 = pr13; 78 | r21 = pr21; r22 = pr22; r23 = pr23; 79 | r31 = pr31; r32 = pr32; r33 = pr33; 80 | t1 = pt1; t2 = pt2; t3 = pt3; 81 | fx = pfx; fy = pfy; cx = pcx; cy = pcy; 82 | } 83 | float r11; float r12; float r13; 84 | float r21; float r22; float r23; 85 | float r31; float r32; float r33; 86 | float t1; float t2; float t3; 87 | float fx; float fy; float cx; float cy; 88 | } camPamsFloat; 89 | #endif 90 | 91 | #ifndef __VECTOR_TYPES_H__ 92 | typedef struct float3_ { float x; float y; float z;} float3; 93 | #endif 94 | #ifndef __VECTOR_FUNCTIONS_H__ 95 | inline float3 make_float3(float px, float py, float pz){ 96 | float3 result; result.x = px; result.y = py; result.z = pz; 97 | return result;} 98 | #endif 99 | 100 | #ifndef __VECTOR_TYPES_H__ 101 | typedef struct int3_ { int x; int y; int z;} int3; 102 | #endif 103 | 104 | 105 | //############################ CPU ###################### 106 | 107 | //#define PREPROCESS_IMAGES 108 | 109 | #define USE_OPENMP_IMAGEBUFFERING 110 | //#define USE_OPENMP_TRAVERSAL 111 | #define USE_OPENMP_DISTANCEUPDATE 112 | #define USE_OPENMP_MARCHINGCUBES 113 | #define USE_OPENMP_MARCHINGCUBESSLOW 114 | //#define OPENMP_DYNAMIC 115 | #define OPENMP_THREADS 8 116 | 117 | #define USE_SSE 118 | 119 | #define USE_THREADS false 120 | #define THREAD_MESHING true 121 | 122 | //############################ Loop Closure ###################### 123 | 124 | #define MAX_LOOP_CLOSURE_LEAVES 100000 125 | #define MAX_NUMBER_POSES_PER_LOOP 50 126 | 127 | //########################## Mutex ############################# 128 | 129 | #define MUTEXVALUE 4294967295 130 | #define BRANCHINIT 4294967294 131 | #define DEADBRANCH 4294967293 132 | #define MAXCELLINDEX 343597383520 133 | //#define MUTEXVALUE 1 134 | 135 | #define MAXDEPTH 20 136 | 137 | 138 | //########################### Tree #################################### 139 | 140 | //#define SIDELENGTH 64 141 | //#define MAXLEAFNUMBER 512 // 8^3 142 | //#define MAXINDEX 262144 //MAXLEAFNUMBER*BRICKLENGTH^3 143 | 144 | //#define SIDELENGTH 128 145 | //#define MAXLEAFNUMBER 4096 // 8^4 146 | //#define MAXINDEX 2097152 //MAXLEAFNUMBER*BRICKLENGTH^3 147 | 148 | //#define SIDELENGTH 256 149 | //#define MAXLEAFNUMBER 32768 // 8^5 150 | //#define MAXINDEX 16777216 //MAXLEAFNUMBER*BRICKLENGTH^3 151 | 152 | //#define SIDELENGTH 512 153 | //#define MAXLEAFNUMBER 262144 // 8^6 154 | //#define MAXINDEX 134217728 //MAXLEAFNUMBER*BRICKLENGTH^3 155 | 156 | //#define SIDELENGTH 1024 157 | //#define MAXLEAFNUMBER 2097152 // 8^7 158 | //#define MAXINDEX 1073741824 //MAXLEAFNUMBER*BRICKLENGTH^3 159 | 160 | //#define SIDELENGTH 2048 161 | ////#define MAXLEAFNUMBER 16777216 // 8^8 162 | //#define MAXLEAFNUMBER 400000 // 8^8 163 | 164 | #define SIDELENGTH 1024 165 | 166 | //GTX 580 167 | #define MAXLEAFNUMBER 10000000 168 | //#define MAXINDEX 5120000000 169 | #define MAXINDEX VOLUMETYPE_MAX 170 | //#define CHECK_MEMORY 171 | 172 | //For Tesla 173 | //#define MAXLEAFNUMBER 890000 174 | //#define MAXINDEX 455680000 175 | 176 | 177 | 178 | 179 | //#define RETRAVERSE_OUTLIERS 180 | 181 | //########################### Distance and Weighting Functions ############### 182 | 183 | //#define DEBUG_NO_MESHES 184 | 185 | #define MESHCELLINDICES_SPLIT 186 | //#define MESHCELLINDICES_COMPACT 187 | 188 | #ifdef MESHCELLINDICES_SPLIT 189 | #define BRANCHNEIGHBORHOOD_REFERECE 190 | #endif 191 | 192 | #if defined MESHCELLINDICES_SPLIT && not defined MESHCELLINDICES_COMPACT 193 | #define SWITCH_MESHCELLS_SPLIT 194 | #endif 195 | #if not defined MESHCELLINDICES_SPLIT && defined MESHCELLINDICES_COMPACT 196 | #undef SWITCH_MESHCELLS_SPLIT 197 | #endif 198 | #if defined MESHCELLINDICES_SPLIT && defined MESHCELLINDICES_COMPACT 199 | //#define SWITCH_MESHCELLS_SPLIT 200 | #endif 201 | 202 | #define MAXCAMDISTANCE 10.0 203 | #define MIN_WEIGHT_FOR_SURFACE 0.0 204 | #define ADD_WEIGHTS_TRANSITION_140424 205 | //#define MAXCAMDISTANCE 6.0 206 | //#define MIN_WEIGHT_FOR_SURFACE 0.0 207 | #define FRUSTUM_FAR 1.0 208 | 209 | #define REFERENCE_DEPTH 1.0f 210 | //#define SCALE_VARIANCE 211 | //#define SCALE_DEVIATION 212 | #define SCALE_LINEAR 213 | //#define SCALE_CONSTANT 214 | 215 | //#define DISTANCE_POINT_FAST 216 | #define DISTANCE_POINT_TRUE 217 | //#define DISTANCE_PLANE 218 | 219 | //#define DISTANCE_TEST 220 | //#define DISTANCE_NORMAL 221 | #define DISTANCE_TRUNCATED 222 | 223 | #define ROUND_PROJECTED_POSITIONS_GPU 224 | 225 | 226 | //#define DISTANCETHRESHOLD 0.5f // stable 227 | //#define DISTANCETHRESHOLD 0.05f // current 228 | //#define DISTANCETHRESHOLD 0.02f // current 229 | #define DISTANCETHRESHOLD 0.01f // test 230 | //#define DISTANCETHRESHOLD 0.002f // test 231 | //#define DISTANCETHRESHOLD 1.0f 232 | 233 | #define BANDWIDTHFACTOR 1.0 234 | #define BRICKLENGTH 8 235 | 236 | 237 | //#define BANDWIDTH 10 238 | 239 | //#define DEFAULT_SCALE 0.05 240 | //#define DEFAULT_SCALE 0.01 241 | #define DEFAULT_SCALE 0.005 242 | 243 | //#define WEIGHT_ONE 244 | //#define WEIGHT_CONSTANT 245 | //#define WEIGHT_CONSTANT_NARROW 246 | #define WEIGHT_LINEAR 247 | //#define WEIGHT_LINEAR_NARROW 248 | //#define WEIGHT_GAUSS 249 | //#define WEIGHT_GAUSS_NARROW 250 | #define DISTANCEWEIGHTSIGMA 0.05f 251 | #define DISTANCEWEIGHTEPSILON 0.005f 252 | #define DISTANCEMINEXPWEIGHT 0.000001f 253 | 254 | #define WEIGHT_FACTOR 3.0f 255 | 256 | //float cutoff = expf(-distanceWeightSigma*(threshold-distanceWeightEpsilon)*(threshold-distanceWeightEpsilon)); 257 | //return (float)(distance=distanceWeightEpsilon && distance>1)>=_brickLength)*8) 277 | 278 | //#define SEQUENCE 279 | //#define TEDDY1 280 | //#define TEDDY3 281 | //#define FRANKFACE 282 | //#define FRANK 283 | //#define DESK 284 | //#define SYNTHETIC 285 | //#define FLIGHT1 286 | #define OFFICE 287 | //#define ROOM1 288 | //#define GARCHING1 289 | //#define DEFAULTSCENE 290 | 291 | 292 | #if defined (FRANK) || defined (FRANKFACE) 293 | #define DEPTHSCALE 10000.0f 294 | #else 295 | #if defined (FLIGHT1) 296 | #define DEPTHSCALE 2617.80 297 | #else 298 | #if defined (GARCHING1) 299 | #define DEPTHSCALE 1000.0f 300 | #else 301 | #if defined (SEQUENCE) 302 | #define DEPTHSCALE 5000.0f 303 | #else 304 | #define DEPTHSCALE 5000.0f 305 | #endif 306 | #endif 307 | #endif 308 | #endif 309 | 310 | //#ifndef DEBUG_OUTPUT_DEFINED 311 | //#define DEBUG_OUTPUT_DEFINED 312 | //#ifdef PRINT_DEBUG 313 | //#define DEBUG(X) (X) 314 | //#else 315 | //#define DEBUG(X) 316 | //#endif 317 | //#endif 318 | 319 | #ifndef DEBUG_OUTPUT_DEFINED 320 | #define DEBUG_OUTPUT_DEFINED 321 | #ifdef PRINT_DEBUG 322 | //#define WHERESTR "[file %s, line %d]: " 323 | //#define WHEREARG __FILE__, __LINE__ 324 | //#define DEBUGPRINT2(...) fprintf(stderr, __VA_ARGS__) 325 | //#define DEBUGPRINT(_fmt, ...) DEBUGPRINT2(WHERESTR _fmt, WHEREARG, __VA_ARGS__) 326 | #define eprintf( ...) fprintf(stderr, __VA_ARGS__) 327 | #else 328 | #define eprintf(...) 329 | #endif 330 | #endif 331 | 332 | #define DEBUG bla 333 | 334 | 335 | //#define IMAGEINFINITE 1000000.0f 336 | //#define FILTERMODE cudaFilterModePoint 337 | //#define FUSIONHEIGHTFINITE (fabs(distance) < IMAGEINFINITE) 338 | //#define TRAVERSALHEIGHTFINITE (pz < IMAGEINFINITE) 339 | 340 | #define IMAGEINFINITE std::numeric_limits::quiet_NaN() 341 | #define FILTERMODE cudaFilterModePoint 342 | #define FUSIONHEIGHTFINITECPU (std::isfinite(distance)) 343 | #define FUSIONHEIGHTFINITEGPU (isfinite(distance)) 344 | #define TRAVERSALHEIGHTFINITECPU (std::isfinite(pz)) 345 | #define TRAVERSALHEIGHTFINITEGPU (isfinite(pz)) 346 | 347 | #ifdef OWNAVX 348 | #define ALIGNED __attribute__ ((aligned (32))) 349 | #else 350 | #define ALIGNED __attribute__ ((aligned (16))) 351 | #endif 352 | 353 | #endif /* DEFINITIONS_H_ */ 354 | -------------------------------------------------------------------------------- /src/fusion/mesh.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * mesh.hpp 3 | * 4 | * Created on: Jan 14, 2013 5 | * Author: steinbrf 6 | */ 7 | 8 | #ifndef MESH_HPP_ 9 | #define MESH_HPP_ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "mesh.hpp" 18 | //#include "mesh_interleaved.hpp" 19 | 20 | 21 | //#define DISTZEROEPSILON 0.0000000000001 22 | #define DISTZEROEPSILON 1e-40 23 | 24 | 25 | #ifndef vertexcolortype 26 | typedef unsigned short vertexcolortype; 27 | #define VCMUL 256 28 | #endif 29 | 30 | #ifndef textype 31 | typedef unsigned short textype; 32 | #define cvtextype CV_8UC3 33 | #define TEX_MULTIPLICATOR 256 34 | #endif 35 | 36 | 37 | //#include "geometryfusion_single_soa.cuh" 38 | //#include "texturefusion.cuh" 39 | 40 | 41 | 42 | #ifndef uchar 43 | typedef unsigned char uchar; 44 | #endif 45 | 46 | 47 | #ifndef Vertex3f 48 | typedef struct _Vertex3f 49 | { 50 | _Vertex3f(float px=0.0f , float py=0.0f, float pz=0.0f){x=px;y=py;z=pz;} 51 | float x; float y; float z; 52 | } Vertex3f; 53 | #endif 54 | //#ifndef VertexUchar 55 | //typedef struct _VertexUchar 56 | //{ 57 | // _VertexUchar(uchar px=0 , uchar py=0, uchar pz=0){x=px;y=py;z=pz;} 58 | // uchar x; uchar y; uchar z; 59 | //} VertexUchar; 60 | //#endif 61 | 62 | #ifndef VertexColor 63 | typedef struct _VertexColor 64 | { 65 | _VertexColor(colortype px=0 , colortype py=0, colortype pz=0){x=px;y=py;z=pz;} 66 | colortype x; colortype y; colortype z; 67 | } VertexColor; 68 | #endif 69 | 70 | 71 | 72 | 73 | //int getCubeIndex(float d000, float d001, float d010, float d011, 74 | // float d100, float d101, float d110, float d111, 75 | // weighttype w000, weighttype w001, weighttype w010, weighttype w011, 76 | // weighttype w100, weighttype w101, weighttype w110, weighttype w111, 77 | // float isolevel = 0.0f); 78 | // 79 | //int getCubeIndex(float d000, float d001, float d010, float d011, 80 | // float d100, float d101, float d110, float d111, 81 | // float isolevel = 0.0f); 82 | 83 | //#define BINARY true 84 | 85 | #define VDISTTH 0.000001 86 | 87 | typedef class vertex3d_ { 88 | public: 89 | vertex3d_(double px = 0, double py = 0, double pz = 0): x(px), y(py), z(pz){} 90 | double x; double y; double z; 91 | } Vertex; 92 | 93 | #define VMR 0.005 94 | class VertexMap 95 | { 96 | public: 97 | VertexMap(); 98 | typedef std::pair > entry; 99 | void insert(float x, float y, float z, unsigned int index, bool verbose=true); 100 | std::vector _branches; 101 | std::vector > leaves; 102 | Vertex _offset; Vertex _minimum; Vertex _maximum; 103 | double _size; 104 | int _root; 105 | }; 106 | 107 | 108 | #include "mesh_interleaved.hpp" 109 | 110 | 111 | class MeshSeparate 112 | { 113 | public: 114 | MeshSeparate(unsigned int verticesPerFace 115 | // ,size_t reservedVertices = 0, size_t reservedIndices = 0 116 | ); 117 | std::vector x; 118 | std::vector y; 119 | std::vector z; 120 | std::vector f; 121 | std::vector nx; 122 | std::vector ny; 123 | std::vector nz; 124 | std::vector r; 125 | std::vector g; 126 | std::vector b; 127 | std::vector e; 128 | std::vector ew; 129 | 130 | std::vector cc; 131 | 132 | 133 | bool writeOBJ(std::string filename); 134 | bool writePLY(std::string filename, bool binary = true); 135 | MeshSeparate reduce(bool verbose = true); 136 | void addGridFace(int dim, float ox, float oy, float oz, float sx, float sy, float sz); 137 | void addAlignedLineCube(float ox, float oy, float oz, float sx, float sy, float sz, float edgeWidth = 2.0f); 138 | cv::Mat &addTexture(const cv::Mat &texture); 139 | cv::Mat &getLastTexture(); 140 | 141 | MeshSeparate &operator+=(const MeshSeparate &mesh); 142 | 143 | MeshSeparate &operator=(const MeshSeparate &mesh); 144 | 145 | MeshSeparate sortConnectedComponents(); 146 | MeshSeparate componentsOfSize(unsigned int nv); 147 | 148 | uchar _verticesPerFace; 149 | //Texture Coordinates 150 | std::vector tx; 151 | std::vector ty; 152 | 153 | std::vector edge; 154 | protected: 155 | std::vector materialIndices; 156 | std::vector textures; 157 | }; 158 | 159 | class PointerMeshFusion 160 | { 161 | public: 162 | PointerMeshFusion(const MeshSeparate &mesh); 163 | ~PointerMeshFusion(); 164 | float *x; float *y; float *z; 165 | unsigned int *f; 166 | vertexcolortype *r; vertexcolortype *g; vertexcolortype *b; 167 | unsigned int nv; 168 | unsigned int nf; 169 | }; 170 | 171 | class MeshInterleaved; 172 | 173 | class PointerMeshDraw 174 | { 175 | public: 176 | PointerMeshDraw(const MeshSeparate &mesh, int typeParameter = 0); 177 | PointerMeshDraw(const MeshInterleaved &mesh, int typeParameter = 0); 178 | PointerMeshDraw(const PointerMeshDraw &mesh, int typeParameter = 0); 179 | ~PointerMeshDraw(); 180 | // float *x; float *y; float *z; 181 | char *v; 182 | char *c; 183 | char *n; 184 | 185 | unsigned int *f; 186 | unsigned int *e; 187 | float *ew; 188 | // uchar *r; uchar *g; uchar *b; 189 | unsigned int nv; 190 | unsigned int nf; 191 | unsigned int ne; 192 | unsigned int nn; 193 | bool colored; 194 | 195 | int type; 196 | }; 197 | 198 | 199 | class MarchingCubes 200 | { 201 | public: 202 | MarchingCubes(); 203 | ~MarchingCubes(); 204 | int *getVertexList(Vertex3f *vertlist, 205 | sidetype x, sidetype y, sidetype z, 206 | float ox, float oy, float oz, float scale, 207 | float val0,float val1, float val2, float val3, 208 | float val4, float val5, float val6, float val7,uchar *cubeindex_return = 0); 209 | int *getVertexColors(VertexColor *collist, 210 | uchar cubeindex, 211 | float val0,float val1, float val2, float val3, 212 | float val4, float val5, float val6, float val7, 213 | VertexColor c0, VertexColor c1, VertexColor c2, VertexColor c3, 214 | VertexColor c4, VertexColor c5, VertexColor c6, VertexColor c7); 215 | int *getColoredTrianglesForCube( 216 | Vertex3f *vertlist, VertexColor *collist, 217 | sidetype x, sidetype y, sidetype z, 218 | float ox, float oy, float oz, float scale, 219 | volumetype idx0, volumetype idx1, volumetype idx2, volumetype idx3, 220 | volumetype idx4, volumetype idx5, volumetype idx6, volumetype idx7, 221 | float *values, weighttype *weights, colortype *r, colortype *g, colortype *b); 222 | int *getInterleavedColoredTrianglesForCube( 223 | Vertex3f *vertlist, VertexColor *collist, 224 | sidetype x, sidetype y, sidetype z, 225 | float ox, float oy, float oz, float scale, 226 | volumetype idx0, volumetype idx1, volumetype idx2, volumetype idx3, 227 | volumetype idx4, volumetype idx5, volumetype idx6, volumetype idx7, 228 | const float *values, const weighttype *weights, const colortype3 *color); 229 | int *getColoredTrianglesForCubePrecomputed( 230 | Vertex3f *vertlist,VertexColor *collist, 231 | sidetype x, sidetype y, sidetype z, 232 | float ox, float oy, float oz, float sx, float sy, float sz, 233 | float val0, float val1, float val2, float val3, 234 | float val4, float val5, float val6, float val7, 235 | weighttype w0, weighttype w1, weighttype w2, weighttype w3, 236 | weighttype w4, weighttype w5, weighttype w6, weighttype w7, 237 | VertexColor c0, VertexColor c1, VertexColor c2, VertexColor c3, 238 | VertexColor c4, VertexColor c5, VertexColor c6, VertexColor c7, 239 | const colortype3 *color) const; 240 | 241 | static Vertex3f VertexInterp(Vertex3f p1,Vertex3f p2,double valp1,double valp2, double isolevel = 0.0f); 242 | static VertexColor VertexInterp(VertexColor p1,VertexColor p2,float valp1,float valp2, float isolevel = 0.0f); 243 | 244 | static int getCubeIndex(float d000, float d001, float d010, float d011, 245 | float d100, float d101, float d110, float d111, 246 | float isolevel = 0.0f); 247 | 248 | // static int getCubeIndex(float d000, float d001, float d010, float d011, 249 | // float d100, float d101, float d110, float d111, 250 | // weighttype w000, weighttype w001, weighttype w010, weighttype w011, 251 | // weighttype w100, weighttype w101, weighttype w110, weighttype w111, 252 | // float isolevel = 0.0f); 253 | // static int getCubeIndex(const float &d000, const float &d001, const float &d010, const float &d011, 254 | // const float &d100, const float &d101, const float &d110, const float &d111, 255 | // const weighttype &w000, const weighttype &w001, const weighttype &w010, const weighttype &w011, 256 | // const weighttype &w100, const weighttype &w101, const weighttype &w110, const weighttype &w111, 257 | // float isolevel = 0.0f); 258 | 259 | inline int getCubeIndex(float d000, float d001, float d010, float d011, 260 | float d100, float d101, float d110, float d111, 261 | weighttype w000, weighttype w001, weighttype w010, weighttype w011, 262 | weighttype w100, weighttype w101, weighttype w110, weighttype w111, 263 | float isolevel = 0.0f) const { 264 | // inline int getCubeIndex(const float &d000, const float &d001, const float &d010, const float &d011, 265 | // const float &d100, const float &d101, const float &d110, const float &d111, 266 | // const weighttype &w000, const weighttype &w001, const weighttype &w010, const weighttype &w011, 267 | // const weighttype &w100, const weighttype &w101, const weighttype &w110, const weighttype &w111, 268 | // float isolevel = 0.0f) const { 269 | if(w000==0 || w001==0 || w010==0 || w011==0 || 270 | w100==0 || w101==0 || w110==0 || w111==0 ) 271 | return 0; 272 | int cubeindex = 0; 273 | if (d000 < isolevel) cubeindex |= 1; 274 | if (d001 < isolevel) cubeindex |= 2; 275 | if (d010 < isolevel) cubeindex |= 4; 276 | if (d011 < isolevel) cubeindex |= 8; 277 | if (d100 < isolevel) cubeindex |= 16; 278 | if (d101 < isolevel) cubeindex |= 32; 279 | if (d110 < isolevel) cubeindex |= 64; 280 | if (d111 < isolevel) cubeindex |= 128; 281 | return cubeindex; 282 | // return 283 | // (d000 < isolevel) | 284 | // (d001 < isolevel)<<1 | 285 | // (d010 < isolevel)<<2 | 286 | // (d011 < isolevel)<<3 | 287 | // (d100 < isolevel)<<4 | 288 | // (d101 < isolevel)<<5 | 289 | // (d110 < isolevel)<<6 | 290 | // (d111 < isolevel)<<7 ; 291 | } 292 | 293 | int *edgeTable; 294 | int **triTable; 295 | 296 | int *numberOfFaces; 297 | 298 | }; 299 | 300 | class MarchingCubesIndexed : public MarchingCubes 301 | { 302 | public: 303 | MarchingCubesIndexed(sidetype brickLength, sidetype brickHeight); 304 | ~MarchingCubesIndexed(); 305 | int **offsetTable; 306 | }; 307 | 308 | 309 | 310 | 311 | #endif /* MESH_HPP_ */ 312 | -------------------------------------------------------------------------------- /src/tclap/UnlabeledMultiArg.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: UnlabeledMultiArg.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot. 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H 24 | #define TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * Just like a MultiArg, except that the arguments are unlabeled. Basically, 36 | * this Arg will slurp up everything that hasn't been matched to another 37 | * Arg. 38 | */ 39 | template 40 | class UnlabeledMultiArg : public MultiArg 41 | { 42 | 43 | // If compiler has two stage name lookup (as gcc >= 3.4 does) 44 | // this is requried to prevent undef. symbols 45 | using MultiArg::_ignoreable; 46 | using MultiArg::_hasBlanks; 47 | using MultiArg::_extractValue; 48 | using MultiArg::_typeDesc; 49 | using MultiArg::_name; 50 | using MultiArg::_description; 51 | using MultiArg::_alreadySet; 52 | using MultiArg::toString; 53 | 54 | public: 55 | 56 | /** 57 | * Constructor. 58 | * \param name - The name of the Arg. Note that this is used for 59 | * identification, not as a long flag. 60 | * \param desc - A description of what the argument is for or 61 | * does. 62 | * \param req - Whether the argument is required on the command 63 | * line. 64 | * \param typeDesc - A short, human readable description of the 65 | * type that this object expects. This is used in the generation 66 | * of the USAGE statement. The goal is to be helpful to the end user 67 | * of the program. 68 | * \param ignoreable - Whether or not this argument can be ignored 69 | * using the "--" flag. 70 | * \param v - An optional visitor. You probably should not 71 | * use this unless you have a very good reason. 72 | */ 73 | UnlabeledMultiArg( const std::string& name, 74 | const std::string& desc, 75 | bool req, 76 | const std::string& typeDesc, 77 | bool ignoreable = false, 78 | Visitor* v = NULL ); 79 | /** 80 | * Constructor. 81 | * \param name - The name of the Arg. Note that this is used for 82 | * identification, not as a long flag. 83 | * \param desc - A description of what the argument is for or 84 | * does. 85 | * \param req - Whether the argument is required on the command 86 | * line. 87 | * \param typeDesc - A short, human readable description of the 88 | * type that this object expects. This is used in the generation 89 | * of the USAGE statement. The goal is to be helpful to the end user 90 | * of the program. 91 | * \param parser - A CmdLine parser object to add this Arg to 92 | * \param ignoreable - Whether or not this argument can be ignored 93 | * using the "--" flag. 94 | * \param v - An optional visitor. You probably should not 95 | * use this unless you have a very good reason. 96 | */ 97 | UnlabeledMultiArg( const std::string& name, 98 | const std::string& desc, 99 | bool req, 100 | const std::string& typeDesc, 101 | CmdLineInterface& parser, 102 | bool ignoreable = false, 103 | Visitor* v = NULL ); 104 | 105 | /** 106 | * Constructor. 107 | * \param name - The name of the Arg. Note that this is used for 108 | * identification, not as a long flag. 109 | * \param desc - A description of what the argument is for or 110 | * does. 111 | * \param req - Whether the argument is required on the command 112 | * line. 113 | * \param constraint - A pointer to a Constraint object used 114 | * to constrain this Arg. 115 | * \param ignoreable - Whether or not this argument can be ignored 116 | * using the "--" flag. 117 | * \param v - An optional visitor. You probably should not 118 | * use this unless you have a very good reason. 119 | */ 120 | UnlabeledMultiArg( const std::string& name, 121 | const std::string& desc, 122 | bool req, 123 | Constraint* constraint, 124 | bool ignoreable = false, 125 | Visitor* v = NULL ); 126 | 127 | /** 128 | * Constructor. 129 | * \param name - The name of the Arg. Note that this is used for 130 | * identification, not as a long flag. 131 | * \param desc - A description of what the argument is for or 132 | * does. 133 | * \param req - Whether the argument is required on the command 134 | * line. 135 | * \param constraint - A pointer to a Constraint object used 136 | * to constrain this Arg. 137 | * \param parser - A CmdLine parser object to add this Arg to 138 | * \param ignoreable - Whether or not this argument can be ignored 139 | * using the "--" flag. 140 | * \param v - An optional visitor. You probably should not 141 | * use this unless you have a very good reason. 142 | */ 143 | UnlabeledMultiArg( const std::string& name, 144 | const std::string& desc, 145 | bool req, 146 | Constraint* constraint, 147 | CmdLineInterface& parser, 148 | bool ignoreable = false, 149 | Visitor* v = NULL ); 150 | 151 | /** 152 | * Handles the processing of the argument. 153 | * This re-implements the Arg version of this method to set the 154 | * _value of the argument appropriately. It knows the difference 155 | * between labeled and unlabeled. 156 | * \param i - Pointer the the current argument in the list. 157 | * \param args - Mutable list of strings. Passed from main(). 158 | */ 159 | virtual bool processArg(int* i, std::vector& args); 160 | 161 | /** 162 | * Returns the a short id string. Used in the usage. 163 | * \param val - value to be used. 164 | */ 165 | virtual std::string shortID(const std::string& val="val") const; 166 | 167 | /** 168 | * Returns the a long id string. Used in the usage. 169 | * \param val - value to be used. 170 | */ 171 | virtual std::string longID(const std::string& val="val") const; 172 | 173 | /** 174 | * Opertor ==. 175 | * \param a - The Arg to be compared to this. 176 | */ 177 | virtual bool operator==(const Arg& a) const; 178 | 179 | /** 180 | * Pushes this to back of list rather than front. 181 | * \param argList - The list this should be added to. 182 | */ 183 | virtual void addToList( std::list& argList ) const; 184 | }; 185 | 186 | template 187 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, 188 | const std::string& desc, 189 | bool req, 190 | const std::string& typeDesc, 191 | bool ignoreable, 192 | Visitor* v) 193 | : MultiArg("", name, desc, req, typeDesc, v) 194 | { 195 | _ignoreable = ignoreable; 196 | OptionalUnlabeledTracker::check(true, toString()); 197 | } 198 | 199 | template 200 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, 201 | const std::string& desc, 202 | bool req, 203 | const std::string& typeDesc, 204 | CmdLineInterface& parser, 205 | bool ignoreable, 206 | Visitor* v) 207 | : MultiArg("", name, desc, req, typeDesc, v) 208 | { 209 | _ignoreable = ignoreable; 210 | OptionalUnlabeledTracker::check(true, toString()); 211 | parser.add( this ); 212 | } 213 | 214 | 215 | template 216 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, 217 | const std::string& desc, 218 | bool req, 219 | Constraint* constraint, 220 | bool ignoreable, 221 | Visitor* v) 222 | : MultiArg("", name, desc, req, constraint, v) 223 | { 224 | _ignoreable = ignoreable; 225 | OptionalUnlabeledTracker::check(true, toString()); 226 | } 227 | 228 | template 229 | UnlabeledMultiArg::UnlabeledMultiArg(const std::string& name, 230 | const std::string& desc, 231 | bool req, 232 | Constraint* constraint, 233 | CmdLineInterface& parser, 234 | bool ignoreable, 235 | Visitor* v) 236 | : MultiArg("", name, desc, req, constraint, v) 237 | { 238 | _ignoreable = ignoreable; 239 | OptionalUnlabeledTracker::check(true, toString()); 240 | parser.add( this ); 241 | } 242 | 243 | 244 | template 245 | bool UnlabeledMultiArg::processArg(int *i, std::vector& args) 246 | { 247 | 248 | if ( _hasBlanks( args[*i] ) ) 249 | return false; 250 | 251 | // never ignore an unlabeled multi arg 252 | 253 | 254 | // always take the first value, regardless of the start string 255 | _extractValue( args[(*i)] ); 256 | 257 | /* 258 | // continue taking args until we hit the end or a start string 259 | while ( (unsigned int)(*i)+1 < args.size() && 260 | args[(*i)+1].find_first_of( Arg::flagStartString() ) != 0 && 261 | args[(*i)+1].find_first_of( Arg::nameStartString() ) != 0 ) 262 | _extractValue( args[++(*i)] ); 263 | */ 264 | 265 | _alreadySet = true; 266 | 267 | return true; 268 | } 269 | 270 | template 271 | std::string UnlabeledMultiArg::shortID(const std::string& val) const 272 | { 273 | static_cast(val); // Ignore input, don't warn 274 | return std::string("<") + _typeDesc + "> ..."; 275 | } 276 | 277 | template 278 | std::string UnlabeledMultiArg::longID(const std::string& val) const 279 | { 280 | static_cast(val); // Ignore input, don't warn 281 | return std::string("<") + _typeDesc + "> (accepted multiple times)"; 282 | } 283 | 284 | template 285 | bool UnlabeledMultiArg::operator==(const Arg& a) const 286 | { 287 | if ( _name == a.getName() || _description == a.getDescription() ) 288 | return true; 289 | else 290 | return false; 291 | } 292 | 293 | template 294 | void UnlabeledMultiArg::addToList( std::list& argList ) const 295 | { 296 | argList.push_back( const_cast(static_cast(this)) ); 297 | } 298 | 299 | } 300 | 301 | #endif 302 | -------------------------------------------------------------------------------- /src/fusion/loopclosure.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * loopclosure.cpp 3 | * 4 | * Created on: Aug 25, 2013 5 | * Author: steinbrf 6 | */ 7 | 8 | #include "loopclosure.hpp" 9 | #include // SSE intrinsics 10 | #include // SSE2 intrinsics 11 | #include // SSE3 intrinsics 12 | #include 13 | 14 | 15 | void update8AddLoopSSESingleDeleteloop 16 | ( 17 | const float *depth, const uchar *red, const uchar *green, const uchar *blue, 18 | int imageWidth, int imageHeight, 19 | float &m11, float &m12, float &m13, float &m14, 20 | float &m21, float &m22, float &m23, float &m24, 21 | float &m31, float &m32, float &m33, float &m34, 22 | float &fx, float &fy, float &cx, float &cy, 23 | float &scale, float &distanceThreshold, 24 | volumetype &threadOffset, 25 | sidetype3 &o, 26 | sidetype &leafScale, 27 | float *_distance, 28 | float *_weights, 29 | colortype3 *_color 30 | ) 31 | { 32 | float fleafScale = (float)(leafScale)*scale; 33 | float ox = (m11*o.x+m12*o.y+m13*o.z)*scale + m14; 34 | float oy = (m21*o.x+m22*o.y+m23*o.z)*scale + m24; 35 | float oz = (m31*o.x+m32*o.y+m33*o.z)*scale + m34; 36 | float pxx, pxy, pxz, pyx, pyy, pyz, pzx, pzy, pzz; 37 | 38 | 39 | float d11 = m11*fleafScale; 40 | float d21 = m21*fleafScale; 41 | float d31 = m31*fleafScale; 42 | 43 | __m128 d11_SSE = _mm_setr_ps(0.0f, d11, 2.0f*d11, 3.0f*d11); 44 | __m128 d21_SSE = _mm_setr_ps(0.0f, d21, 2.0f*d21, 3.0f*d21); 45 | __m128 d31_SSE = _mm_setr_ps(0.0f, d31, 2.0f*d31, 3.0f*d31); 46 | __m128 thresholdDistance = _mm_set1_ps(distanceThreshold*leafScale); 47 | __m128 thresholdWeight = _mm_set1_ps(WEIGHT_FACTOR*distanceThreshold*leafScale); 48 | d11*=4.0f; d21*=4.0f; d31*=4.0f; 49 | 50 | float d12 = m12*fleafScale; 51 | float d22 = m22*fleafScale; 52 | float d32 = m32*fleafScale; 53 | 54 | float d13 = m13*fleafScale; 55 | float d23 = m23*fleafScale; 56 | float d33 = m33*fleafScale; 57 | 58 | pzx=ox;pzy=oy;pzz=oz; 59 | for(int z=0;z<8;z++,pzx+=d13,pzy+=d23,pzz+=d33){ 60 | pyx=pzx;pyy=pzy;pyz=pzz; 61 | for(int y=0;y<8;y++,pyx+=d12,pyy+=d22,pyz+=d32){ 62 | 63 | pxx=pyx;pxy=pyy;pxz=pyz; 64 | 65 | for(int x=0;x<2;x++,pxx+=d11,pxy+=d21,pxz+=d31){ 66 | volumetype idx = threadOffset; threadOffset+=4; 67 | __m128 pxx_SSE = _mm_add_ps(_mm_set1_ps(pxx),d11_SSE); 68 | __m128 pxy_SSE = _mm_add_ps(_mm_set1_ps(pxy),d21_SSE); 69 | __m128 pxz_SSE = _mm_add_ps(_mm_set1_ps(pxz),d31_SSE); 70 | 71 | // float length = sqrtf(pxx*pxx+pxy*pxy+pxz*pxz); 72 | __m128 length = _mm_sqrt_ps(_mm_add_ps(_mm_add_ps( 73 | _mm_mul_ps(pxx_SSE,pxx_SSE),_mm_mul_ps(pxy_SSE,pxy_SSE)),_mm_mul_ps(pxz_SSE,pxz_SSE))); 74 | 75 | __m128 reciprocal = _mm_rcp_ps(pxz_SSE); 76 | // int imx = (int)floor(pxx/pxz*fx+cx); 77 | __m128i imx = _mm_cvtps_epi32(_mm_add_ps(_mm_set1_ps(cx),_mm_mul_ps(_mm_set1_ps(fx),_mm_mul_ps(pxx_SSE,reciprocal)))); 78 | // int imy = (int)floor(pxy/pxz*fy+cy); 79 | __m128i imy = _mm_cvtps_epi32(_mm_add_ps(_mm_set1_ps(cy),_mm_mul_ps(_mm_set1_ps(fy),_mm_mul_ps(pxy_SSE,reciprocal)))); 80 | 81 | 82 | // int imageIndex = imy*(imy>=0 && imy=0 && imx 0.0f && imx>=0 && imy>=0 && imx=DISTANCEWEIGHTEPSILON && dInc=*_nLeavesMapped){ 287 | if(*_nLeavesMapped>=_nLeavesTotal) return false; 288 | //TODO: Optimieren 289 | threadOffset = _leafMapLoop[brickIdx] = (*_nLeavesMapped); (*_nLeavesMapped)++; 290 | } 291 | fprintf(stderr,"%i %i]",brickIdx,threadOffset); 292 | //TODO: Optimieren mit Shift 293 | threadOffset*=512; 294 | sidetype3 o = _leafPos[brickIdx]; 295 | sidetype leafScale = _leafScale[brickIdx]; 296 | 297 | fprintf(stderr,"?"); 298 | update8AddLoopSSESingleDeleteloop(depth,red,green,blue,imageWidth,imageHeight, 299 | m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,fx,fy,cx,cy, 300 | scale,distanceThreshold,threadOffset,o,leafScale, 301 | _distance,_weights,_color); 302 | fprintf(stderr,"!"); 303 | 304 | } 305 | l1 = nLeavesQueued; 306 | } 307 | fprintf(stderr,"\nLeaves mapped after queue: %i",*_nLeavesMapped); 308 | 309 | if(rnd_mode != _MM_ROUND_TOWARD_ZERO) _MM_SET_ROUNDING_MODE(rnd_mode); 310 | return true; 311 | } 312 | -------------------------------------------------------------------------------- /src/tclap/UnlabeledValueArg.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: UnlabeledValueArg.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_UNLABELED_VALUE_ARGUMENT_H 25 | #define TCLAP_UNLABELED_VALUE_ARGUMENT_H 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | 34 | namespace TCLAP { 35 | 36 | /** 37 | * The basic unlabeled argument that parses a value. 38 | * This is a template class, which means the type T defines the type 39 | * that a given object will attempt to parse when an UnlabeledValueArg 40 | * is reached in the list of args that the CmdLine iterates over. 41 | */ 42 | template 43 | class UnlabeledValueArg : public ValueArg 44 | { 45 | 46 | // If compiler has two stage name lookup (as gcc >= 3.4 does) 47 | // this is requried to prevent undef. symbols 48 | using ValueArg::_ignoreable; 49 | using ValueArg::_hasBlanks; 50 | using ValueArg::_extractValue; 51 | using ValueArg::_typeDesc; 52 | using ValueArg::_name; 53 | using ValueArg::_description; 54 | using ValueArg::_alreadySet; 55 | using ValueArg::toString; 56 | 57 | public: 58 | 59 | /** 60 | * UnlabeledValueArg constructor. 61 | * \param name - A one word name for the argument. Note that this is used for 62 | * identification, not as a long flag. 63 | * \param desc - A description of what the argument is for or 64 | * does. 65 | * \param req - Whether the argument is required on the command 66 | * line. 67 | * \param value - The default value assigned to this argument if it 68 | * is not present on the command line. 69 | * \param typeDesc - A short, human readable description of the 70 | * type that this object expects. This is used in the generation 71 | * of the USAGE statement. The goal is to be helpful to the end user 72 | * of the program. 73 | * \param ignoreable - Allows you to specify that this argument can be 74 | * ignored if the '--' flag is set. This defaults to false (cannot 75 | * be ignored) and should generally stay that way unless you have 76 | * some special need for certain arguments to be ignored. 77 | * \param v - Optional Vistor. You should leave this blank unless 78 | * you have a very good reason. 79 | */ 80 | UnlabeledValueArg( const std::string& name, 81 | const std::string& desc, 82 | bool req, 83 | T value, 84 | const std::string& typeDesc, 85 | bool ignoreable = false, 86 | Visitor* v = NULL); 87 | 88 | /** 89 | * UnlabeledValueArg constructor. 90 | * \param name - A one word name for the argument. Note that this is used for 91 | * identification, not as a long flag. 92 | * \param desc - A description of what the argument is for or 93 | * does. 94 | * \param req - Whether the argument is required on the command 95 | * line. 96 | * \param value - The default value assigned to this argument if it 97 | * is not present on the command line. 98 | * \param typeDesc - A short, human readable description of the 99 | * type that this object expects. This is used in the generation 100 | * of the USAGE statement. The goal is to be helpful to the end user 101 | * of the program. 102 | * \param parser - A CmdLine parser object to add this Arg to 103 | * \param ignoreable - Allows you to specify that this argument can be 104 | * ignored if the '--' flag is set. This defaults to false (cannot 105 | * be ignored) and should generally stay that way unless you have 106 | * some special need for certain arguments to be ignored. 107 | * \param v - Optional Vistor. You should leave this blank unless 108 | * you have a very good reason. 109 | */ 110 | UnlabeledValueArg( const std::string& name, 111 | const std::string& desc, 112 | bool req, 113 | T value, 114 | const std::string& typeDesc, 115 | CmdLineInterface& parser, 116 | bool ignoreable = false, 117 | Visitor* v = NULL ); 118 | 119 | /** 120 | * UnlabeledValueArg constructor. 121 | * \param name - A one word name for the argument. Note that this is used for 122 | * identification, not as a long flag. 123 | * \param desc - A description of what the argument is for or 124 | * does. 125 | * \param req - Whether the argument is required on the command 126 | * line. 127 | * \param value - The default value assigned to this argument if it 128 | * is not present on the command line. 129 | * \param constraint - A pointer to a Constraint object used 130 | * to constrain this Arg. 131 | * \param ignoreable - Allows you to specify that this argument can be 132 | * ignored if the '--' flag is set. This defaults to false (cannot 133 | * be ignored) and should generally stay that way unless you have 134 | * some special need for certain arguments to be ignored. 135 | * \param v - Optional Vistor. You should leave this blank unless 136 | * you have a very good reason. 137 | */ 138 | UnlabeledValueArg( const std::string& name, 139 | const std::string& desc, 140 | bool req, 141 | T value, 142 | Constraint* constraint, 143 | bool ignoreable = false, 144 | Visitor* v = NULL ); 145 | 146 | 147 | /** 148 | * UnlabeledValueArg constructor. 149 | * \param name - A one word name for the argument. Note that this is used for 150 | * identification, not as a long flag. 151 | * \param desc - A description of what the argument is for or 152 | * does. 153 | * \param req - Whether the argument is required on the command 154 | * line. 155 | * \param value - The default value assigned to this argument if it 156 | * is not present on the command line. 157 | * \param constraint - A pointer to a Constraint object used 158 | * to constrain this Arg. 159 | * \param parser - A CmdLine parser object to add this Arg to 160 | * \param ignoreable - Allows you to specify that this argument can be 161 | * ignored if the '--' flag is set. This defaults to false (cannot 162 | * be ignored) and should generally stay that way unless you have 163 | * some special need for certain arguments to be ignored. 164 | * \param v - Optional Vistor. You should leave this blank unless 165 | * you have a very good reason. 166 | */ 167 | UnlabeledValueArg( const std::string& name, 168 | const std::string& desc, 169 | bool req, 170 | T value, 171 | Constraint* constraint, 172 | CmdLineInterface& parser, 173 | bool ignoreable = false, 174 | Visitor* v = NULL); 175 | 176 | /** 177 | * Handles the processing of the argument. 178 | * This re-implements the Arg version of this method to set the 179 | * _value of the argument appropriately. Handling specific to 180 | * unlabled arguments. 181 | * \param i - Pointer the the current argument in the list. 182 | * \param args - Mutable list of strings. 183 | */ 184 | virtual bool processArg(int* i, std::vector& args); 185 | 186 | /** 187 | * Overrides shortID for specific behavior. 188 | */ 189 | virtual std::string shortID(const std::string& val="val") const; 190 | 191 | /** 192 | * Overrides longID for specific behavior. 193 | */ 194 | virtual std::string longID(const std::string& val="val") const; 195 | 196 | /** 197 | * Overrides operator== for specific behavior. 198 | */ 199 | virtual bool operator==(const Arg& a ) const; 200 | 201 | /** 202 | * Instead of pushing to the front of list, push to the back. 203 | * \param argList - The list to add this to. 204 | */ 205 | virtual void addToList( std::list& argList ) const; 206 | 207 | }; 208 | 209 | /** 210 | * Constructor implemenation. 211 | */ 212 | template 213 | UnlabeledValueArg::UnlabeledValueArg(const std::string& name, 214 | const std::string& desc, 215 | bool req, 216 | T val, 217 | const std::string& typeDesc, 218 | bool ignoreable, 219 | Visitor* v) 220 | : ValueArg("", name, desc, req, val, typeDesc, v) 221 | { 222 | _ignoreable = ignoreable; 223 | 224 | OptionalUnlabeledTracker::check(req, toString()); 225 | 226 | } 227 | 228 | template 229 | UnlabeledValueArg::UnlabeledValueArg(const std::string& name, 230 | const std::string& desc, 231 | bool req, 232 | T val, 233 | const std::string& typeDesc, 234 | CmdLineInterface& parser, 235 | bool ignoreable, 236 | Visitor* v) 237 | : ValueArg("", name, desc, req, val, typeDesc, v) 238 | { 239 | _ignoreable = ignoreable; 240 | OptionalUnlabeledTracker::check(req, toString()); 241 | parser.add( this ); 242 | } 243 | 244 | /** 245 | * Constructor implemenation. 246 | */ 247 | template 248 | UnlabeledValueArg::UnlabeledValueArg(const std::string& name, 249 | const std::string& desc, 250 | bool req, 251 | T val, 252 | Constraint* constraint, 253 | bool ignoreable, 254 | Visitor* v) 255 | : ValueArg("", name, desc, req, val, constraint, v) 256 | { 257 | _ignoreable = ignoreable; 258 | OptionalUnlabeledTracker::check(req, toString()); 259 | } 260 | 261 | template 262 | UnlabeledValueArg::UnlabeledValueArg(const std::string& name, 263 | const std::string& desc, 264 | bool req, 265 | T val, 266 | Constraint* constraint, 267 | CmdLineInterface& parser, 268 | bool ignoreable, 269 | Visitor* v) 270 | : ValueArg("", name, desc, req, val, constraint, v) 271 | { 272 | _ignoreable = ignoreable; 273 | OptionalUnlabeledTracker::check(req, toString()); 274 | parser.add( this ); 275 | } 276 | 277 | /** 278 | * Implementation of processArg(). 279 | */ 280 | template 281 | bool UnlabeledValueArg::processArg(int *i, std::vector& args) 282 | { 283 | 284 | if ( _alreadySet ) 285 | return false; 286 | 287 | if ( _hasBlanks( args[*i] ) ) 288 | return false; 289 | 290 | // never ignore an unlabeled arg 291 | 292 | _extractValue( args[*i] ); 293 | _alreadySet = true; 294 | return true; 295 | } 296 | 297 | /** 298 | * Overriding shortID for specific output. 299 | */ 300 | template 301 | std::string UnlabeledValueArg::shortID(const std::string& val) const 302 | { 303 | static_cast(val); // Ignore input, don't warn 304 | return std::string("<") + _typeDesc + ">"; 305 | } 306 | 307 | /** 308 | * Overriding longID for specific output. 309 | */ 310 | template 311 | std::string UnlabeledValueArg::longID(const std::string& val) const 312 | { 313 | static_cast(val); // Ignore input, don't warn 314 | 315 | // Ideally we would like to be able to use RTTI to return the name 316 | // of the type required for this argument. However, g++ at least, 317 | // doesn't appear to return terribly useful "names" of the types. 318 | return std::string("<") + _typeDesc + ">"; 319 | } 320 | 321 | /** 322 | * Overriding operator== for specific behavior. 323 | */ 324 | template 325 | bool UnlabeledValueArg::operator==(const Arg& a ) const 326 | { 327 | if ( _name == a.getName() || _description == a.getDescription() ) 328 | return true; 329 | else 330 | return false; 331 | } 332 | 333 | template 334 | void UnlabeledValueArg::addToList( std::list& argList ) const 335 | { 336 | argList.push_back( const_cast(static_cast(this)) ); 337 | } 338 | 339 | } 340 | #endif 341 | --------------------------------------------------------------------------------