├── .gitignore ├── CMakeLists.txt ├── LICENSE.md ├── README.md ├── app ├── pdpcComputeMultiScaleFeatures.cpp ├── pdpcPostProcess.cpp └── pdpcSegmentation.cpp ├── data ├── lans.ply ├── stairs.ply └── triangles.ply ├── figures ├── generate.sh ├── generate_fig_05.sh ├── generate_fig_09b.sh ├── generate_fig_09c.sh ├── generate_fig_15b.sh ├── preprocess_lans.sh ├── preprocess_stairs.sh └── preprocess_triangles.sh ├── img ├── fig_15b_005.jpg ├── fig_15b_015.jpg ├── fig_15b_020.jpg ├── fig_15b_025.jpg └── representative.png ├── replicate.sh └── src ├── Eigen ├── Cholesky ├── CholmodSupport ├── Core ├── Dense ├── Eigen ├── Eigenvalues ├── Geometry ├── Householder ├── IterativeLinearSolvers ├── Jacobi ├── KLUSupport ├── LU ├── MetisSupport ├── OrderingMethods ├── PaStiXSupport ├── PardisoSupport ├── QR ├── QtAlignedMalloc ├── SPQRSupport ├── SVD ├── Sparse ├── SparseCholesky ├── SparseCore ├── SparseLU ├── SparseQR ├── StdDeque ├── StdList ├── StdVector ├── SuperLUSupport ├── UmfPackSupport └── src │ ├── Cholesky │ ├── LDLT.h │ ├── LLT.h │ └── LLT_LAPACKE.h │ ├── CholmodSupport │ └── CholmodSupport.h │ ├── Core │ ├── ArithmeticSequence.h │ ├── Array.h │ ├── ArrayBase.h │ ├── ArrayWrapper.h │ ├── Assign.h │ ├── AssignEvaluator.h │ ├── Assign_MKL.h │ ├── BandMatrix.h │ ├── Block.h │ ├── BooleanRedux.h │ ├── CommaInitializer.h │ ├── ConditionEstimator.h │ ├── CoreEvaluators.h │ ├── CoreIterators.h │ ├── CwiseBinaryOp.h │ ├── CwiseNullaryOp.h │ ├── CwiseTernaryOp.h │ ├── CwiseUnaryOp.h │ ├── CwiseUnaryView.h │ ├── DenseBase.h │ ├── DenseCoeffsBase.h │ ├── DenseStorage.h │ ├── Diagonal.h │ ├── DiagonalMatrix.h │ ├── DiagonalProduct.h │ ├── Dot.h │ ├── EigenBase.h │ ├── ForceAlignedAccess.h │ ├── Fuzzy.h │ ├── GeneralProduct.h │ ├── GenericPacketMath.h │ ├── GlobalFunctions.h │ ├── IO.h │ ├── IndexedView.h │ ├── Inverse.h │ ├── Map.h │ ├── MapBase.h │ ├── MathFunctions.h │ ├── MathFunctionsImpl.h │ ├── Matrix.h │ ├── MatrixBase.h │ ├── NestByValue.h │ ├── NoAlias.h │ ├── NumTraits.h │ ├── PartialReduxEvaluator.h │ ├── PermutationMatrix.h │ ├── PlainObjectBase.h │ ├── Product.h │ ├── ProductEvaluators.h │ ├── Random.h │ ├── Redux.h │ ├── Ref.h │ ├── Replicate.h │ ├── Reshaped.h │ ├── ReturnByValue.h │ ├── Reverse.h │ ├── Select.h │ ├── SelfAdjointView.h │ ├── SelfCwiseBinaryOp.h │ ├── Solve.h │ ├── SolveTriangular.h │ ├── SolverBase.h │ ├── StableNorm.h │ ├── StlIterators.h │ ├── Stride.h │ ├── Swap.h │ ├── Transpose.h │ ├── Transpositions.h │ ├── TriangularMatrix.h │ ├── VectorBlock.h │ ├── VectorwiseOp.h │ ├── Visitor.h │ ├── arch │ │ ├── AVX │ │ │ ├── Complex.h │ │ │ ├── MathFunctions.h │ │ │ ├── PacketMath.h │ │ │ └── TypeCasting.h │ │ ├── AVX512 │ │ │ ├── Complex.h │ │ │ ├── MathFunctions.h │ │ │ ├── PacketMath.h │ │ │ └── TypeCasting.h │ │ ├── AltiVec │ │ │ ├── Complex.h │ │ │ ├── MathFunctions.h │ │ │ └── PacketMath.h │ │ ├── CUDA │ │ │ └── Complex.h │ │ ├── Default │ │ │ ├── ConjHelper.h │ │ │ ├── GenericPacketMathFunctions.h │ │ │ ├── GenericPacketMathFunctionsFwd.h │ │ │ ├── Half.h │ │ │ ├── Settings.h │ │ │ └── TypeCasting.h │ │ ├── GPU │ │ │ ├── MathFunctions.h │ │ │ ├── PacketMath.h │ │ │ └── TypeCasting.h │ │ ├── HIP │ │ │ └── hcc │ │ │ │ └── math_constants.h │ │ ├── MSA │ │ │ ├── Complex.h │ │ │ ├── MathFunctions.h │ │ │ └── PacketMath.h │ │ ├── NEON │ │ │ ├── Complex.h │ │ │ ├── MathFunctions.h │ │ │ ├── PacketMath.h │ │ │ └── TypeCasting.h │ │ ├── SSE │ │ │ ├── Complex.h │ │ │ ├── MathFunctions.h │ │ │ ├── PacketMath.h │ │ │ └── TypeCasting.h │ │ ├── SYCL │ │ │ ├── InteropHeaders.h │ │ │ ├── MathFunctions.h │ │ │ ├── PacketMath.h │ │ │ ├── SyclMemoryModel.h │ │ │ └── TypeCasting.h │ │ └── ZVector │ │ │ ├── Complex.h │ │ │ ├── MathFunctions.h │ │ │ └── PacketMath.h │ ├── functors │ │ ├── AssignmentFunctors.h │ │ ├── BinaryFunctors.h │ │ ├── NullaryFunctors.h │ │ ├── StlFunctors.h │ │ ├── TernaryFunctors.h │ │ └── UnaryFunctors.h │ ├── products │ │ ├── GeneralBlockPanelKernel.h │ │ ├── GeneralMatrixMatrix.h │ │ ├── GeneralMatrixMatrixTriangular.h │ │ ├── GeneralMatrixMatrixTriangular_BLAS.h │ │ ├── GeneralMatrixMatrix_BLAS.h │ │ ├── GeneralMatrixVector.h │ │ ├── GeneralMatrixVector_BLAS.h │ │ ├── Parallelizer.h │ │ ├── SelfadjointMatrixMatrix.h │ │ ├── SelfadjointMatrixMatrix_BLAS.h │ │ ├── SelfadjointMatrixVector.h │ │ ├── SelfadjointMatrixVector_BLAS.h │ │ ├── SelfadjointProduct.h │ │ ├── SelfadjointRank2Update.h │ │ ├── TriangularMatrixMatrix.h │ │ ├── TriangularMatrixMatrix_BLAS.h │ │ ├── TriangularMatrixVector.h │ │ ├── TriangularMatrixVector_BLAS.h │ │ ├── TriangularSolverMatrix.h │ │ ├── TriangularSolverMatrix_BLAS.h │ │ └── TriangularSolverVector.h │ └── util │ │ ├── BlasUtil.h │ │ ├── ConfigureVectorization.h │ │ ├── Constants.h │ │ ├── DisableStupidWarnings.h │ │ ├── ForwardDeclarations.h │ │ ├── IndexedViewHelper.h │ │ ├── IntegralConstant.h │ │ ├── MKL_support.h │ │ ├── Macros.h │ │ ├── Memory.h │ │ ├── Meta.h │ │ ├── NonMPL2.h │ │ ├── ReenableStupidWarnings.h │ │ ├── ReshapedHelper.h │ │ ├── StaticAssert.h │ │ ├── SymbolicIndex.h │ │ └── XprHelper.h │ ├── Eigenvalues │ ├── ComplexEigenSolver.h │ ├── ComplexSchur.h │ ├── ComplexSchur_LAPACKE.h │ ├── EigenSolver.h │ ├── GeneralizedEigenSolver.h │ ├── GeneralizedSelfAdjointEigenSolver.h │ ├── HessenbergDecomposition.h │ ├── MatrixBaseEigenvalues.h │ ├── RealQZ.h │ ├── RealSchur.h │ ├── RealSchur_LAPACKE.h │ ├── SelfAdjointEigenSolver.h │ ├── SelfAdjointEigenSolver_LAPACKE.h │ └── Tridiagonalization.h │ ├── Geometry │ ├── AlignedBox.h │ ├── AngleAxis.h │ ├── EulerAngles.h │ ├── Homogeneous.h │ ├── Hyperplane.h │ ├── OrthoMethods.h │ ├── ParametrizedLine.h │ ├── Quaternion.h │ ├── Rotation2D.h │ ├── RotationBase.h │ ├── Scaling.h │ ├── Transform.h │ ├── Translation.h │ ├── Umeyama.h │ └── arch │ │ └── Geometry_SSE.h │ ├── Householder │ ├── BlockHouseholder.h │ ├── Householder.h │ └── HouseholderSequence.h │ ├── IterativeLinearSolvers │ ├── BasicPreconditioners.h │ ├── BiCGSTAB.h │ ├── ConjugateGradient.h │ ├── IncompleteCholesky.h │ ├── IncompleteLUT.h │ ├── IterativeSolverBase.h │ ├── LeastSquareConjugateGradient.h │ └── SolveWithGuess.h │ ├── Jacobi │ └── Jacobi.h │ ├── KLUSupport │ └── KLUSupport.h │ ├── LU │ ├── Determinant.h │ ├── FullPivLU.h │ ├── InverseImpl.h │ ├── PartialPivLU.h │ ├── PartialPivLU_LAPACKE.h │ └── arch │ │ └── Inverse_SSE.h │ ├── MetisSupport │ └── MetisSupport.h │ ├── OrderingMethods │ ├── Amd.h │ ├── Eigen_Colamd.h │ └── Ordering.h │ ├── PaStiXSupport │ └── PaStiXSupport.h │ ├── PardisoSupport │ └── PardisoSupport.h │ ├── QR │ ├── ColPivHouseholderQR.h │ ├── ColPivHouseholderQR_LAPACKE.h │ ├── CompleteOrthogonalDecomposition.h │ ├── FullPivHouseholderQR.h │ ├── HouseholderQR.h │ └── HouseholderQR_LAPACKE.h │ ├── SPQRSupport │ └── SuiteSparseQRSupport.h │ ├── SVD │ ├── BDCSVD.h │ ├── JacobiSVD.h │ ├── JacobiSVD_LAPACKE.h │ ├── SVDBase.h │ └── UpperBidiagonalization.h │ ├── SparseCholesky │ ├── SimplicialCholesky.h │ └── SimplicialCholesky_impl.h │ ├── SparseCore │ ├── AmbiVector.h │ ├── CompressedStorage.h │ ├── ConservativeSparseSparseProduct.h │ ├── MappedSparseMatrix.h │ ├── SparseAssign.h │ ├── SparseBlock.h │ ├── SparseColEtree.h │ ├── SparseCompressedBase.h │ ├── SparseCwiseBinaryOp.h │ ├── SparseCwiseUnaryOp.h │ ├── SparseDenseProduct.h │ ├── SparseDiagonalProduct.h │ ├── SparseDot.h │ ├── SparseFuzzy.h │ ├── SparseMap.h │ ├── SparseMatrix.h │ ├── SparseMatrixBase.h │ ├── SparsePermutation.h │ ├── SparseProduct.h │ ├── SparseRedux.h │ ├── SparseRef.h │ ├── SparseSelfAdjointView.h │ ├── SparseSolverBase.h │ ├── SparseSparseProductWithPruning.h │ ├── SparseTranspose.h │ ├── SparseTriangularView.h │ ├── SparseUtil.h │ ├── SparseVector.h │ ├── SparseView.h │ └── TriangularSolver.h │ ├── SparseLU │ ├── SparseLU.h │ ├── SparseLUImpl.h │ ├── SparseLU_Memory.h │ ├── SparseLU_Structs.h │ ├── SparseLU_SupernodalMatrix.h │ ├── SparseLU_Utils.h │ ├── SparseLU_column_bmod.h │ ├── SparseLU_column_dfs.h │ ├── SparseLU_copy_to_ucol.h │ ├── SparseLU_gemm_kernel.h │ ├── SparseLU_heap_relax_snode.h │ ├── SparseLU_kernel_bmod.h │ ├── SparseLU_panel_bmod.h │ ├── SparseLU_panel_dfs.h │ ├── SparseLU_pivotL.h │ ├── SparseLU_pruneL.h │ └── SparseLU_relax_snode.h │ ├── SparseQR │ └── SparseQR.h │ ├── StlSupport │ ├── StdDeque.h │ ├── StdList.h │ ├── StdVector.h │ └── details.h │ ├── SuperLUSupport │ └── SuperLUSupport.h │ ├── UmfPackSupport │ └── UmfPackSupport.h │ ├── misc │ ├── Image.h │ ├── Kernel.h │ ├── RealSvd2x2.h │ ├── blas.h │ ├── lapack.h │ ├── lapacke.h │ └── lapacke_mangling.h │ └── plugins │ ├── ArrayCwiseBinaryOps.h │ ├── ArrayCwiseUnaryOps.h │ ├── BlockMethods.h │ ├── CommonCwiseBinaryOps.h │ ├── CommonCwiseUnaryOps.h │ ├── IndexedViewMethods.h │ ├── MatrixCwiseBinaryOps.h │ ├── MatrixCwiseUnaryOps.h │ └── ReshapedMethods.h ├── PDPC ├── Common │ ├── Algorithms │ │ └── has_duplicate.h │ ├── Assert.h │ ├── Colors.h │ ├── Containers │ │ ├── PropertyMap.cpp │ │ ├── PropertyMap.h │ │ ├── internal │ │ │ ├── AbstractVector.cpp │ │ │ ├── AbstractVector.h │ │ │ ├── AbstractVector.inl │ │ │ ├── PolyVector.cpp │ │ │ ├── PolyVector.h │ │ │ ├── PolyVector.inl │ │ │ ├── abstract_vector_index_iterator.cpp │ │ │ └── abstract_vector_index_iterator.h │ │ ├── limited_priority_queue.h │ │ └── static_stack.h │ ├── DebugTrap.h │ ├── Defines.h │ ├── File.cpp │ ├── File.h │ ├── IO.h │ ├── Log.h │ ├── Log.inl │ ├── Macro.h │ ├── Option.cpp │ ├── Option.h │ ├── Option.hpp │ ├── Progress.cpp │ ├── Progress.h │ ├── String.cpp │ ├── String.h │ ├── Timer.cpp │ ├── Timer.h │ ├── Timer.inl │ ├── internal │ │ ├── OptionArgument.cpp │ │ ├── OptionArgument.h │ │ ├── OptionArgumentT.h │ │ ├── OptionArgumentT.hpp │ │ ├── OptionVectorArgumentT.h │ │ └── OptionVectorArgumentT.hpp │ └── std_vector_algo.h ├── Graph │ ├── Edge.h │ ├── Graph.cpp │ ├── Graph.h │ ├── HierarchicalGraph.cpp │ ├── HierarchicalGraph.h │ └── Node.h ├── MultiScaleFeatures │ ├── MultiScaleFeatures.cpp │ ├── MultiScaleFeatures.h │ └── MultiScaleFeatures.inl ├── Persistence │ ├── Component.cpp │ ├── Component.h │ ├── ComponentDataSet.cpp │ ├── ComponentDataSet.h │ ├── ComponentSet.cpp │ └── ComponentSet.h ├── PointCloud │ ├── Loader.cpp │ ├── Loader.h │ ├── OBJ.cpp │ ├── OBJ.h │ ├── PLY.cpp │ ├── PLY.h │ ├── Point.cpp │ ├── Point.h │ ├── PointCloud.cpp │ ├── PointCloud.h │ ├── internal │ │ ├── plyio.cpp │ │ └── plyio.h │ ├── orthonormal_basis.h │ └── triangle_area.h ├── RIMLS │ ├── RIMLSOperator.cpp │ ├── RIMLSOperator.h │ ├── RIMLSPoint.h │ ├── RIMLSWeightFunc.h │ └── RIMLSWeightFunc.hpp ├── ScaleSpace │ ├── ScaleSampling.cpp │ ├── ScaleSampling.h │ ├── ScaleSampling.inl │ └── ScaleSpaceStack.h ├── Segmentation │ ├── MSSegmentation.cpp │ ├── MSSegmentation.h │ ├── MSSegmentationGraph.cpp │ ├── MSSegmentationGraph.h │ ├── RegionSet.cpp │ ├── RegionSet.h │ ├── SeededKNNGraphRegionGrowing.h │ ├── SeededKNNGraphRegionGrowing.hpp │ ├── Segmentation.cpp │ ├── Segmentation.h │ ├── Segmentation.inl │ ├── SegmentationIterators.cpp │ └── SegmentationIterators.h └── SpacePartitioning │ ├── KdTree.cpp │ ├── KdTree.h │ ├── KdTree │ ├── Iterator │ │ ├── KdTreeKNearestIndexIterator.cpp │ │ ├── KdTreeKNearestIndexIterator.h │ │ ├── KdTreeKNearestPointIterator.cpp │ │ ├── KdTreeKNearestPointIterator.h │ │ ├── KdTreeNearestIndexIterator.cpp │ │ ├── KdTreeNearestIndexIterator.h │ │ ├── KdTreeNearestPointIterator.cpp │ │ ├── KdTreeNearestPointIterator.h │ │ ├── KdTreeRangeIndexIterator.cpp │ │ ├── KdTreeRangeIndexIterator.h │ │ ├── KdTreeRangePointIterator.cpp │ │ └── KdTreeRangePointIterator.h │ ├── KdTreeNode.h │ └── Query │ │ ├── KdTreeKNearestIndexQuery.cpp │ │ ├── KdTreeKNearestIndexQuery.h │ │ ├── KdTreeKNearestPointQuery.cpp │ │ ├── KdTreeKNearestPointQuery.h │ │ ├── KdTreeNearestIndexQuery.cpp │ │ ├── KdTreeNearestIndexQuery.h │ │ ├── KdTreeNearestPointQuery.cpp │ │ ├── KdTreeNearestPointQuery.h │ │ ├── KdTreeQuery.cpp │ │ ├── KdTreeQuery.h │ │ ├── KdTreeRangeIndexQuery.cpp │ │ ├── KdTreeRangeIndexQuery.h │ │ ├── KdTreeRangePointQuery.cpp │ │ └── KdTreeRangePointQuery.h │ ├── KnnGraph.cpp │ ├── KnnGraph.h │ ├── KnnGraph │ ├── Iterator │ │ ├── KnnGraphRangeIterator.cpp │ │ └── KnnGraphRangeIterator.h │ └── Query │ │ ├── KnnGraphQuery.cpp │ │ ├── KnnGraphQuery.h │ │ ├── KnnGraphRangeQuery.cpp │ │ └── KnnGraphRangeQuery.h │ ├── Query │ ├── IndexQuery.cpp │ ├── IndexQuery.h │ ├── KNearestIndexQuery.cpp │ ├── KNearestIndexQuery.h │ ├── KNearestPointQuery.cpp │ ├── KNearestPointQuery.h │ ├── KNearestQuery.cpp │ ├── KNearestQuery.h │ ├── NearestIndexQuery.cpp │ ├── NearestIndexQuery.h │ ├── NearestPointQuery.cpp │ ├── NearestPointQuery.h │ ├── NearestQuery.cpp │ ├── NearestQuery.h │ ├── PointQuery.cpp │ ├── PointQuery.h │ ├── RangeIndexQuery.cpp │ ├── RangeIndexQuery.h │ ├── RangePointQuery.cpp │ ├── RangePointQuery.h │ ├── RangeQuery.cpp │ └── RangeQuery.h │ └── internal │ ├── IndexSquaredDistance.cpp │ └── IndexSquaredDistance.h └── Ponca ├── Core ├── algebraicEllipsoid.h ├── algebraicEllipsoid.hpp ├── algebraicSphere.h ├── algebraicSphere.hpp ├── basket.h ├── covariancePlaneFit.h ├── covariancePlaneFit.hpp ├── curvature.h ├── curvature.hpp ├── curvatureEstimation.h ├── curvatureEstimation.hpp ├── defines.h ├── enums.h ├── gls.h ├── gls.hpp ├── meanPlaneFit.h ├── meanPlaneFit.hpp ├── mlsSphereFitDer.h ├── mlsSphereFitDer.hpp ├── mongePatch.h ├── mongePatch.hpp ├── orientedEllipsoidFit.h ├── orientedEllipsoidFit.hpp ├── orientedSphereFit.h ├── orientedSphereFit.hpp ├── plane.h ├── primitive.h ├── sphereFit.h ├── sphereFit.hpp ├── unorientedSphereFit.h ├── unorientedSphereFit.hpp ├── weightFunc.h ├── weightFunc.hpp └── weightKernel.h └── core.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Other 35 | CMakeLists.txt.user 36 | build* 37 | work/ 38 | test/ 39 | figures/*.txt 40 | figures/*.ply -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(Plane-Detection-Point-Cloud) 3 | 4 | option(PDPC_USE_OMP "Use OpenMP" ON) 5 | 6 | set(CMAKE_CXX_FLAGS "-Wall -Wextra") 7 | set(CMAKE_CXX_FLAGS_DEBUG "-DPDPC_DEBUG -g3 -ggdb") 8 | set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3") 9 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DNDEBUG -O2 -g3") 10 | 11 | # Enable helpfull warnings and C++14 for all files 12 | set(CMAKE_CXX_STANDARD 14) 13 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 14 | 15 | if(PDPC_USE_OMP) 16 | find_package(OpenMP) 17 | if(OPENMP_FOUND) 18 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 20 | else() 21 | message(WARNING "OpenMP ON but not found!") 22 | endif() 23 | endif() 24 | 25 | find_package(CGAL REQUIRED) 26 | set(CGAL_DO_NOT_WARN_ABOUT_CMAKE_BUILD_TYPE true) 27 | set(CGAL_DISABLE_ROUNDING_MATH_CHECK true) # for valgrind ? 28 | 29 | file(GLOB_RECURSE lib_headers src/*.hpp src/*.h) 30 | file(GLOB_RECURSE lib_sources src/*.cpp) 31 | file(GLOB_RECURSE lib_inlines src/*.inl) 32 | set(lib_files ${lib_headers} ${lib_sources} ${lib_inlines}) 33 | 34 | add_library(pdpclib STATIC ${lib_files}) 35 | target_include_directories(pdpclib PUBLIC src) 36 | 37 | file(GLOB_RECURSE app_sources app/*.cpp) 38 | foreach(file ${app_sources}) 39 | get_filename_component(name ${file} NAME_WE) 40 | message(STATUS "Build app ${name}") 41 | add_executable(${name} ${file}) 42 | add_dependencies(${name} pdpclib) 43 | target_link_libraries(${name} pdpclib CGAL::CGAL) 44 | install(TARGETS ${name} DESTINATION bin) 45 | endforeach() 46 | -------------------------------------------------------------------------------- /data/lans.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STORM-IRIT/Plane-Detection-Point-Cloud/7d0b489502d2bf3c3e7b21ab956ec48cb63c5022/data/lans.ply -------------------------------------------------------------------------------- /data/stairs.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STORM-IRIT/Plane-Detection-Point-Cloud/7d0b489502d2bf3c3e7b21ab956ec48cb63c5022/data/stairs.ply -------------------------------------------------------------------------------- /data/triangles.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STORM-IRIT/Plane-Detection-Point-Cloud/7d0b489502d2bf3c3e7b21ab956ec48cb63c5022/data/triangles.ply -------------------------------------------------------------------------------- /figures/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | ./preprocess_triangles.sh 6 | ./generate_fig_05.sh 7 | 8 | ./preprocess_stairs.sh 9 | ./generate_fig_09b.sh 10 | 11 | ./preprocess_lans.sh 12 | ./generate_fig_09c.sh 13 | ./generate_fig_15b.sh 14 | -------------------------------------------------------------------------------- /figures/generate_fig_05.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | mkdir -p fig_05 6 | ../build/pdpcPostProcess -i ../data/triangles.ply -s data_triangles_seg.txt -c data_triangles_comp.txt -o fig_05/fig_05 -col -v -range 20 24 25 30 40 42 7 | -------------------------------------------------------------------------------- /figures/generate_fig_09b.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | mkdir -p fig_09b 6 | ../build/pdpcPostProcess -i ../data/stairs.ply -s data_stairs_seg.txt -c data_stairs_comp.txt -o fig_09b/fig_09b -col -v -pers 15 20 25 7 | -------------------------------------------------------------------------------- /figures/generate_fig_09c.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | mkdir -p fig_09c 6 | ../build/pdpcPostProcess -i ../data/lans.ply -s data_lans_seg.txt -c data_lans_comp.txt -o fig_09c/fig_09c -col -v -pers 5 10 15 7 | -------------------------------------------------------------------------------- /figures/generate_fig_15b.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | mkdir -p fig_15b 6 | ../build/pdpcPostProcess -i ../data/lans.ply -s data_lans_seg.txt -c data_lans_comp.txt -o fig_15b/fig_15b -col -v -scales 5 15 20 25 7 | -------------------------------------------------------------------------------- /figures/preprocess_lans.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | ../build/pdpcComputeMultiScaleFeatures -i ../data/lans.ply -o data_lans -v 6 | ../build/pdpcSegmentation -i ../data/lans.ply -s data_lans_scales.txt -f data_lans_features.txt -o data_lans -v 7 | -------------------------------------------------------------------------------- /figures/preprocess_stairs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | ../build/pdpcComputeMultiScaleFeatures -i ../data/stairs.ply -o data_stairs -v 6 | ../build/pdpcSegmentation -i ../data/stairs.ply -s data_stairs_scales.txt -f data_stairs_features.txt -o data_stairs -v 7 | -------------------------------------------------------------------------------- /figures/preprocess_triangles.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | ../build/pdpcComputeMultiScaleFeatures -i ../data/triangles.ply -o data_triangles -v 6 | ../build/pdpcSegmentation -i ../data/triangles.ply -s data_triangles_scales.txt -f data_triangles_features.txt -o data_triangles -v 7 | -------------------------------------------------------------------------------- /img/fig_15b_005.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STORM-IRIT/Plane-Detection-Point-Cloud/7d0b489502d2bf3c3e7b21ab956ec48cb63c5022/img/fig_15b_005.jpg -------------------------------------------------------------------------------- /img/fig_15b_015.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STORM-IRIT/Plane-Detection-Point-Cloud/7d0b489502d2bf3c3e7b21ab956ec48cb63c5022/img/fig_15b_015.jpg -------------------------------------------------------------------------------- /img/fig_15b_020.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STORM-IRIT/Plane-Detection-Point-Cloud/7d0b489502d2bf3c3e7b21ab956ec48cb63c5022/img/fig_15b_020.jpg -------------------------------------------------------------------------------- /img/fig_15b_025.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STORM-IRIT/Plane-Detection-Point-Cloud/7d0b489502d2bf3c3e7b21ab956ec48cb63c5022/img/fig_15b_025.jpg -------------------------------------------------------------------------------- /img/representative.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STORM-IRIT/Plane-Detection-Point-Cloud/7d0b489502d2bf3c3e7b21ab956ec48cb63c5022/img/representative.png -------------------------------------------------------------------------------- /replicate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | # CGAL is the only required dependency 6 | sudo apt-get install libcgal-dev 7 | 8 | # compile the code 9 | mkdir build 10 | cd build 11 | cmake -DCMAKE_BUILD_TYPE=Release .. 12 | make -j 13 | cd .. 14 | 15 | # generate figures 16 | cd figures 17 | ./generate.sh 18 | -------------------------------------------------------------------------------- /src/Eigen/Cholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLESKY_MODULE_H 9 | #define EIGEN_CHOLESKY_MODULE_H 10 | 11 | #include "Core" 12 | #include "Jacobi" 13 | 14 | #include "src/Core/util/DisableStupidWarnings.h" 15 | 16 | /** \defgroup Cholesky_Module Cholesky module 17 | * 18 | * 19 | * 20 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 21 | * Those decompositions are also accessible via the following methods: 22 | * - MatrixBase::llt() 23 | * - MatrixBase::ldlt() 24 | * - SelfAdjointView::llt() 25 | * - SelfAdjointView::ldlt() 26 | * 27 | * \code 28 | * #include 29 | * \endcode 30 | */ 31 | 32 | #include "src/Cholesky/LLT.h" 33 | #include "src/Cholesky/LDLT.h" 34 | #ifdef EIGEN_USE_LAPACKE 35 | #ifdef EIGEN_USE_MKL 36 | #include "mkl_lapacke.h" 37 | #else 38 | #include "src/misc/lapacke.h" 39 | #endif 40 | #include "src/Cholesky/LLT_LAPACKE.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_CHOLESKY_MODULE_H 46 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 47 | -------------------------------------------------------------------------------- /src/Eigen/CholmodSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H 9 | #define EIGEN_CHOLMODSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup CholmodSupport_Module CholmodSupport module 21 | * 22 | * This module provides an interface to the Cholmod library which is part of the suitesparse package. 23 | * It provides the two following main factorization classes: 24 | * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization. 25 | * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial). 26 | * 27 | * For the sake of completeness, this module also propose the two following classes: 28 | * - class CholmodSimplicialLLT 29 | * - class CholmodSimplicialLDLT 30 | * Note that these classes does not bring any particular advantage compared to the built-in 31 | * SimplicialLLT and SimplicialLDLT factorization classes. 32 | * 33 | * \code 34 | * #include 35 | * \endcode 36 | * 37 | * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies. 38 | * The dependencies depend on how cholmod has been compiled. 39 | * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task. 40 | * 41 | */ 42 | 43 | #include "src/CholmodSupport/CholmodSupport.h" 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_CHOLMODSUPPORT_MODULE_H 48 | 49 | -------------------------------------------------------------------------------- /src/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /src/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | #include "Sparse" 3 | -------------------------------------------------------------------------------- /src/Eigen/Eigenvalues: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_EIGENVALUES_MODULE_H 9 | #define EIGEN_EIGENVALUES_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "Cholesky" 14 | #include "Jacobi" 15 | #include "Householder" 16 | #include "LU" 17 | #include "Geometry" 18 | 19 | #include "src/Core/util/DisableStupidWarnings.h" 20 | 21 | /** \defgroup Eigenvalues_Module Eigenvalues module 22 | * 23 | * 24 | * 25 | * This module mainly provides various eigenvalue solvers. 26 | * This module also provides some MatrixBase methods, including: 27 | * - MatrixBase::eigenvalues(), 28 | * - MatrixBase::operatorNorm() 29 | * 30 | * \code 31 | * #include 32 | * \endcode 33 | */ 34 | 35 | #include "src/misc/RealSvd2x2.h" 36 | #include "src/Eigenvalues/Tridiagonalization.h" 37 | #include "src/Eigenvalues/RealSchur.h" 38 | #include "src/Eigenvalues/EigenSolver.h" 39 | #include "src/Eigenvalues/SelfAdjointEigenSolver.h" 40 | #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" 41 | #include "src/Eigenvalues/HessenbergDecomposition.h" 42 | #include "src/Eigenvalues/ComplexSchur.h" 43 | #include "src/Eigenvalues/ComplexEigenSolver.h" 44 | #include "src/Eigenvalues/RealQZ.h" 45 | #include "src/Eigenvalues/GeneralizedEigenSolver.h" 46 | #include "src/Eigenvalues/MatrixBaseEigenvalues.h" 47 | #ifdef EIGEN_USE_LAPACKE 48 | #ifdef EIGEN_USE_MKL 49 | #include "mkl_lapacke.h" 50 | #else 51 | #include "src/misc/lapacke.h" 52 | #endif 53 | #include "src/Eigenvalues/RealSchur_LAPACKE.h" 54 | #include "src/Eigenvalues/ComplexSchur_LAPACKE.h" 55 | #include "src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h" 56 | #endif 57 | 58 | #include "src/Core/util/ReenableStupidWarnings.h" 59 | 60 | #endif // EIGEN_EIGENVALUES_MODULE_H 61 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 62 | -------------------------------------------------------------------------------- /src/Eigen/Geometry: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_GEOMETRY_MODULE_H 9 | #define EIGEN_GEOMETRY_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "SVD" 14 | #include "LU" 15 | #include 16 | 17 | #include "src/Core/util/DisableStupidWarnings.h" 18 | 19 | /** \defgroup Geometry_Module Geometry module 20 | * 21 | * This module provides support for: 22 | * - fixed-size homogeneous transformations 23 | * - translation, scaling, 2D and 3D rotations 24 | * - \link Quaternion quaternions \endlink 25 | * - cross products (\ref MatrixBase::cross, \ref MatrixBase::cross3) 26 | * - orthognal vector generation (\ref MatrixBase::unitOrthogonal) 27 | * - some linear components: \link ParametrizedLine parametrized-lines \endlink and \link Hyperplane hyperplanes \endlink 28 | * - \link AlignedBox axis aligned bounding boxes \endlink 29 | * - \link umeyama least-square transformation fitting \endlink 30 | * 31 | * \code 32 | * #include 33 | * \endcode 34 | */ 35 | 36 | #include "src/Geometry/OrthoMethods.h" 37 | #include "src/Geometry/EulerAngles.h" 38 | 39 | #include "src/Geometry/Homogeneous.h" 40 | #include "src/Geometry/RotationBase.h" 41 | #include "src/Geometry/Rotation2D.h" 42 | #include "src/Geometry/Quaternion.h" 43 | #include "src/Geometry/AngleAxis.h" 44 | #include "src/Geometry/Transform.h" 45 | #include "src/Geometry/Translation.h" 46 | #include "src/Geometry/Scaling.h" 47 | #include "src/Geometry/Hyperplane.h" 48 | #include "src/Geometry/ParametrizedLine.h" 49 | #include "src/Geometry/AlignedBox.h" 50 | #include "src/Geometry/Umeyama.h" 51 | 52 | // Use the SSE optimized version whenever possible. 53 | #if defined EIGEN_VECTORIZE_SSE 54 | #include "src/Geometry/arch/Geometry_SSE.h" 55 | #endif 56 | 57 | #include "src/Core/util/ReenableStupidWarnings.h" 58 | 59 | #endif // EIGEN_GEOMETRY_MODULE_H 60 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 61 | -------------------------------------------------------------------------------- /src/Eigen/Householder: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 9 | #define EIGEN_HOUSEHOLDER_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Householder_Module Householder module 16 | * This module provides Householder transformations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/Householder/Householder.h" 24 | #include "src/Householder/HouseholderSequence.h" 25 | #include "src/Householder/BlockHouseholder.h" 26 | 27 | #include "src/Core/util/ReenableStupidWarnings.h" 28 | 29 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 30 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 31 | -------------------------------------------------------------------------------- /src/Eigen/IterativeLinearSolvers: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 9 | #define EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | 14 | #include "src/Core/util/DisableStupidWarnings.h" 15 | 16 | /** 17 | * \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module 18 | * 19 | * This module currently provides iterative methods to solve problems of the form \c A \c x = \c b, where \c A is a squared matrix, usually very large and sparse. 20 | * Those solvers are accessible via the following classes: 21 | * - ConjugateGradient for selfadjoint (hermitian) matrices, 22 | * - LeastSquaresConjugateGradient for rectangular least-square problems, 23 | * - BiCGSTAB for general square matrices. 24 | * 25 | * These iterative solvers are associated with some preconditioners: 26 | * - IdentityPreconditioner - not really useful 27 | * - DiagonalPreconditioner - also called Jacobi preconditioner, work very well on diagonal dominant matrices. 28 | * - IncompleteLUT - incomplete LU factorization with dual thresholding 29 | * 30 | * Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport. 31 | * 32 | \code 33 | #include 34 | \endcode 35 | */ 36 | 37 | #include "src/IterativeLinearSolvers/SolveWithGuess.h" 38 | #include "src/IterativeLinearSolvers/IterativeSolverBase.h" 39 | #include "src/IterativeLinearSolvers/BasicPreconditioners.h" 40 | #include "src/IterativeLinearSolvers/ConjugateGradient.h" 41 | #include "src/IterativeLinearSolvers/LeastSquareConjugateGradient.h" 42 | #include "src/IterativeLinearSolvers/BiCGSTAB.h" 43 | #include "src/IterativeLinearSolvers/IncompleteLUT.h" 44 | #include "src/IterativeLinearSolvers/IncompleteCholesky.h" 45 | 46 | #include "src/Core/util/ReenableStupidWarnings.h" 47 | 48 | #endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 49 | -------------------------------------------------------------------------------- /src/Eigen/Jacobi: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_JACOBI_MODULE_H 9 | #define EIGEN_JACOBI_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Jacobi_Module Jacobi module 16 | * This module provides Jacobi and Givens rotations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | * 22 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 23 | * - MatrixBase::applyOnTheLeft() 24 | * - MatrixBase::applyOnTheRight(). 25 | */ 26 | 27 | #include "src/Jacobi/Jacobi.h" 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif // EIGEN_JACOBI_MODULE_H 32 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 33 | 34 | -------------------------------------------------------------------------------- /src/Eigen/KLUSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_KLUSUPPORT_MODULE_H 9 | #define EIGEN_KLUSUPPORT_MODULE_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | extern "C" { 16 | #include 17 | #include 18 | } 19 | 20 | /** \ingroup Support_modules 21 | * \defgroup KLUSupport_Module KLUSupport module 22 | * 23 | * This module provides an interface to the KLU library which is part of the suitesparse package. 24 | * It provides the following factorization class: 25 | * - class KLU: a sparse LU factorization, well-suited for circuit simulation. 26 | * 27 | * \code 28 | * #include 29 | * \endcode 30 | * 31 | * In order to use this module, the klu and btf headers must be accessible from the include paths, and your binary must be linked to the klu library and its dependencies. 32 | * The dependencies depend on how umfpack has been compiled. 33 | * For a cmake based project, you can use our FindKLU.cmake module to help you in this task. 34 | * 35 | */ 36 | 37 | #include "src/KLUSupport/KLUSupport.h" 38 | 39 | #include 40 | 41 | #endif // EIGEN_KLUSUPPORT_MODULE_H 42 | -------------------------------------------------------------------------------- /src/Eigen/LU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_LU_MODULE_H 9 | #define EIGEN_LU_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup LU_Module LU module 16 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 17 | * This module defines the following MatrixBase methods: 18 | * - MatrixBase::inverse() 19 | * - MatrixBase::determinant() 20 | * 21 | * \code 22 | * #include 23 | * \endcode 24 | */ 25 | 26 | #include "src/misc/Kernel.h" 27 | #include "src/misc/Image.h" 28 | #include "src/LU/FullPivLU.h" 29 | #include "src/LU/PartialPivLU.h" 30 | #ifdef EIGEN_USE_LAPACKE 31 | #ifdef EIGEN_USE_MKL 32 | #include "mkl_lapacke.h" 33 | #else 34 | #include "src/misc/lapacke.h" 35 | #endif 36 | #include "src/LU/PartialPivLU_LAPACKE.h" 37 | #endif 38 | #include "src/LU/Determinant.h" 39 | #include "src/LU/InverseImpl.h" 40 | 41 | // Use the SSE optimized version whenever possible. At the moment the 42 | // SSE version doesn't compile when AVX is enabled 43 | #if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX 44 | #include "src/LU/arch/Inverse_SSE.h" 45 | #endif 46 | 47 | #include "src/Core/util/ReenableStupidWarnings.h" 48 | 49 | #endif // EIGEN_LU_MODULE_H 50 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 51 | -------------------------------------------------------------------------------- /src/Eigen/MetisSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_METISSUPPORT_MODULE_H 9 | #define EIGEN_METISSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | 20 | /** \ingroup Support_modules 21 | * \defgroup MetisSupport_Module MetisSupport module 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). 27 | * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink 28 | */ 29 | 30 | 31 | #include "src/MetisSupport/MetisSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_METISSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /src/Eigen/PaStiXSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PASTIXSUPPORT_MODULE_H 9 | #define EIGEN_PASTIXSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | #include 18 | } 19 | 20 | #ifdef complex 21 | #undef complex 22 | #endif 23 | 24 | /** \ingroup Support_modules 25 | * \defgroup PaStiXSupport_Module PaStiXSupport module 26 | * 27 | * This module provides an interface to the PaSTiX library. 28 | * PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver. 29 | * It provides the two following main factorization classes: 30 | * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization. 31 | * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization. 32 | * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern). 33 | * 34 | * \code 35 | * #include 36 | * \endcode 37 | * 38 | * In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies. 39 | * This wrapper resuires PaStiX version 5.x compiled without MPI support. 40 | * The dependencies depend on how PaSTiX has been compiled. 41 | * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task. 42 | * 43 | */ 44 | 45 | #include "src/PaStiXSupport/PaStiXSupport.h" 46 | 47 | #include "src/Core/util/ReenableStupidWarnings.h" 48 | 49 | #endif // EIGEN_PASTIXSUPPORT_MODULE_H 50 | -------------------------------------------------------------------------------- /src/Eigen/PardisoSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PARDISOSUPPORT_MODULE_H 9 | #define EIGEN_PARDISOSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup PardisoSupport_Module PardisoSupport module 19 | * 20 | * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies. 27 | * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration. 28 | * 29 | */ 30 | 31 | #include "src/PardisoSupport/PardisoSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_PARDISOSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /src/Eigen/QR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QR_MODULE_H 9 | #define EIGEN_QR_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "Cholesky" 14 | #include "Jacobi" 15 | #include "Householder" 16 | 17 | #include "src/Core/util/DisableStupidWarnings.h" 18 | 19 | /** \defgroup QR_Module QR module 20 | * 21 | * 22 | * 23 | * This module provides various QR decompositions 24 | * This module also provides some MatrixBase methods, including: 25 | * - MatrixBase::householderQr() 26 | * - MatrixBase::colPivHouseholderQr() 27 | * - MatrixBase::fullPivHouseholderQr() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/QR/HouseholderQR.h" 35 | #include "src/QR/FullPivHouseholderQR.h" 36 | #include "src/QR/ColPivHouseholderQR.h" 37 | #include "src/QR/CompleteOrthogonalDecomposition.h" 38 | #ifdef EIGEN_USE_LAPACKE 39 | #ifdef EIGEN_USE_MKL 40 | #include "mkl_lapacke.h" 41 | #else 42 | #include "src/misc/lapacke.h" 43 | #endif 44 | #include "src/QR/HouseholderQR_LAPACKE.h" 45 | #include "src/QR/ColPivHouseholderQR_LAPACKE.h" 46 | #endif 47 | 48 | #include "src/Core/util/ReenableStupidWarnings.h" 49 | 50 | #endif // EIGEN_QR_MODULE_H 51 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 52 | -------------------------------------------------------------------------------- /src/Eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QTMALLOC_MODULE_H 9 | #define EIGEN_QTMALLOC_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | void *qMalloc(std::size_t size) 18 | { 19 | return Eigen::internal::aligned_malloc(size); 20 | } 21 | 22 | void qFree(void *ptr) 23 | { 24 | Eigen::internal::aligned_free(ptr); 25 | } 26 | 27 | void *qRealloc(void *ptr, std::size_t size) 28 | { 29 | void* newPtr = Eigen::internal::aligned_malloc(size); 30 | std::memcpy(newPtr, ptr, size); 31 | Eigen::internal::aligned_free(ptr); 32 | return newPtr; 33 | } 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | 39 | #endif // EIGEN_QTMALLOC_MODULE_H 40 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 41 | -------------------------------------------------------------------------------- /src/Eigen/SPQRSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPQRSUPPORT_MODULE_H 9 | #define EIGEN_SPQRSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "SuiteSparseQR.hpp" 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup SPQRSupport_Module SuiteSparseQR module 19 | * 20 | * This module provides an interface to the SPQR library, which is part of the suitesparse package. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...). 27 | * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules 28 | * 29 | */ 30 | 31 | #include "src/CholmodSupport/CholmodSupport.h" 32 | #include "src/SPQRSupport/SuiteSparseQRSupport.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/Eigen/SVD: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SVD_MODULE_H 9 | #define EIGEN_SVD_MODULE_H 10 | 11 | #include "QR" 12 | #include "Householder" 13 | #include "Jacobi" 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | /** \defgroup SVD_Module SVD module 18 | * 19 | * 20 | * 21 | * This module provides SVD decomposition for matrices (both real and complex). 22 | * Two decomposition algorithms are provided: 23 | * - JacobiSVD implementing two-sided Jacobi iterations is numerically very accurate, fast for small matrices, but very slow for larger ones. 24 | * - BDCSVD implementing a recursive divide & conquer strategy on top of an upper-bidiagonalization which remains fast for large problems. 25 | * These decompositions are accessible via the respective classes and following MatrixBase methods: 26 | * - MatrixBase::jacobiSvd() 27 | * - MatrixBase::bdcSvd() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/misc/RealSvd2x2.h" 35 | #include "src/SVD/UpperBidiagonalization.h" 36 | #include "src/SVD/SVDBase.h" 37 | #include "src/SVD/JacobiSVD.h" 38 | #include "src/SVD/BDCSVD.h" 39 | #if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT) 40 | #ifdef EIGEN_USE_MKL 41 | #include "mkl_lapacke.h" 42 | #else 43 | #include "src/misc/lapacke.h" 44 | #endif 45 | #include "src/SVD/JacobiSVD_LAPACKE.h" 46 | #endif 47 | 48 | #include "src/Core/util/ReenableStupidWarnings.h" 49 | 50 | #endif // EIGEN_SVD_MODULE_H 51 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 52 | -------------------------------------------------------------------------------- /src/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSE_MODULE_H 9 | #define EIGEN_SPARSE_MODULE_H 10 | 11 | /** \defgroup Sparse_Module Sparse meta-module 12 | * 13 | * Meta-module including all related modules: 14 | * - \ref SparseCore_Module 15 | * - \ref OrderingMethods_Module 16 | * - \ref SparseCholesky_Module 17 | * - \ref SparseLU_Module 18 | * - \ref SparseQR_Module 19 | * - \ref IterativeLinearSolvers_Module 20 | * 21 | \code 22 | #include 23 | \endcode 24 | */ 25 | 26 | #include "SparseCore" 27 | #include "OrderingMethods" 28 | #include "SparseCholesky" 29 | #include "SparseLU" 30 | #include "SparseQR" 31 | #include "IterativeLinearSolvers" 32 | 33 | #endif // EIGEN_SPARSE_MODULE_H 34 | 35 | -------------------------------------------------------------------------------- /src/Eigen/SparseCholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2013 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSECHOLESKY_MODULE_H 11 | #define EIGEN_SPARSECHOLESKY_MODULE_H 12 | 13 | #include "SparseCore" 14 | #include "OrderingMethods" 15 | 16 | #include "src/Core/util/DisableStupidWarnings.h" 17 | 18 | /** 19 | * \defgroup SparseCholesky_Module SparseCholesky module 20 | * 21 | * This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices. 22 | * Those decompositions are accessible via the following classes: 23 | * - SimplicialLLt, 24 | * - SimplicialLDLt 25 | * 26 | * Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module. 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #include "src/SparseCholesky/SimplicialCholesky.h" 34 | #include "src/SparseCholesky/SimplicialCholesky_impl.h" 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif // EIGEN_SPARSECHOLESKY_MODULE_H 38 | -------------------------------------------------------------------------------- /src/Eigen/SparseCore: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSECORE_MODULE_H 9 | #define EIGEN_SPARSECORE_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | /** 22 | * \defgroup SparseCore_Module SparseCore module 23 | * 24 | * This module provides a sparse matrix representation, and basic associated matrix manipulations 25 | * and operations. 26 | * 27 | * See the \ref TutorialSparse "Sparse tutorial" 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | * 33 | * This module depends on: Core. 34 | */ 35 | 36 | #include "src/SparseCore/SparseUtil.h" 37 | #include "src/SparseCore/SparseMatrixBase.h" 38 | #include "src/SparseCore/SparseAssign.h" 39 | #include "src/SparseCore/CompressedStorage.h" 40 | #include "src/SparseCore/AmbiVector.h" 41 | #include "src/SparseCore/SparseCompressedBase.h" 42 | #include "src/SparseCore/SparseMatrix.h" 43 | #include "src/SparseCore/SparseMap.h" 44 | #include "src/SparseCore/MappedSparseMatrix.h" 45 | #include "src/SparseCore/SparseVector.h" 46 | #include "src/SparseCore/SparseRef.h" 47 | #include "src/SparseCore/SparseCwiseUnaryOp.h" 48 | #include "src/SparseCore/SparseCwiseBinaryOp.h" 49 | #include "src/SparseCore/SparseTranspose.h" 50 | #include "src/SparseCore/SparseBlock.h" 51 | #include "src/SparseCore/SparseDot.h" 52 | #include "src/SparseCore/SparseRedux.h" 53 | #include "src/SparseCore/SparseView.h" 54 | #include "src/SparseCore/SparseDiagonalProduct.h" 55 | #include "src/SparseCore/ConservativeSparseSparseProduct.h" 56 | #include "src/SparseCore/SparseSparseProductWithPruning.h" 57 | #include "src/SparseCore/SparseProduct.h" 58 | #include "src/SparseCore/SparseDenseProduct.h" 59 | #include "src/SparseCore/SparseSelfAdjointView.h" 60 | #include "src/SparseCore/SparseTriangularView.h" 61 | #include "src/SparseCore/TriangularSolver.h" 62 | #include "src/SparseCore/SparsePermutation.h" 63 | #include "src/SparseCore/SparseFuzzy.h" 64 | #include "src/SparseCore/SparseSolverBase.h" 65 | 66 | #include "src/Core/util/ReenableStupidWarnings.h" 67 | 68 | #endif // EIGEN_SPARSECORE_MODULE_H 69 | 70 | -------------------------------------------------------------------------------- /src/Eigen/SparseLU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // Copyright (C) 2012 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_SPARSELU_MODULE_H 12 | #define EIGEN_SPARSELU_MODULE_H 13 | 14 | #include "SparseCore" 15 | 16 | /** 17 | * \defgroup SparseLU_Module SparseLU module 18 | * This module defines a supernodal factorization of general sparse matrices. 19 | * The code is fully optimized for supernode-panel updates with specialized kernels. 20 | * Please, see the documentation of the SparseLU class for more details. 21 | */ 22 | 23 | // Ordering interface 24 | #include "OrderingMethods" 25 | 26 | #include "src/Core/util/DisableStupidWarnings.h" 27 | 28 | #include "src/SparseLU/SparseLU_gemm_kernel.h" 29 | 30 | #include "src/SparseLU/SparseLU_Structs.h" 31 | #include "src/SparseLU/SparseLU_SupernodalMatrix.h" 32 | #include "src/SparseLU/SparseLUImpl.h" 33 | #include "src/SparseCore/SparseColEtree.h" 34 | #include "src/SparseLU/SparseLU_Memory.h" 35 | #include "src/SparseLU/SparseLU_heap_relax_snode.h" 36 | #include "src/SparseLU/SparseLU_relax_snode.h" 37 | #include "src/SparseLU/SparseLU_pivotL.h" 38 | #include "src/SparseLU/SparseLU_panel_dfs.h" 39 | #include "src/SparseLU/SparseLU_kernel_bmod.h" 40 | #include "src/SparseLU/SparseLU_panel_bmod.h" 41 | #include "src/SparseLU/SparseLU_column_dfs.h" 42 | #include "src/SparseLU/SparseLU_column_bmod.h" 43 | #include "src/SparseLU/SparseLU_copy_to_ucol.h" 44 | #include "src/SparseLU/SparseLU_pruneL.h" 45 | #include "src/SparseLU/SparseLU_Utils.h" 46 | #include "src/SparseLU/SparseLU.h" 47 | 48 | #include "src/Core/util/ReenableStupidWarnings.h" 49 | 50 | #endif // EIGEN_SPARSELU_MODULE_H 51 | -------------------------------------------------------------------------------- /src/Eigen/SparseQR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSEQR_MODULE_H 9 | #define EIGEN_SPARSEQR_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup SparseQR_Module SparseQR module 16 | * \brief Provides QR decomposition for sparse matrices 17 | * 18 | * This module provides a simplicial version of the left-looking Sparse QR decomposition. 19 | * The columns of the input matrix should be reordered to limit the fill-in during the 20 | * decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end. 21 | * See the \link OrderingMethods_Module OrderingMethods\endlink module for the list 22 | * of built-in and external ordering methods. 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | * 28 | * 29 | */ 30 | 31 | #include "src/SparseCore/SparseColEtree.h" 32 | #include "src/SparseQR/SparseQR.h" 33 | 34 | #include "src/Core/util/ReenableStupidWarnings.h" 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/Eigen/StdDeque: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDDEQUE_MODULE_H 12 | #define EIGEN_STDDEQUE_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdDeque.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDDEQUE_MODULE_H 28 | -------------------------------------------------------------------------------- /src/Eigen/StdList: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Hauke Heibel 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_STDLIST_MODULE_H 11 | #define EIGEN_STDLIST_MODULE_H 12 | 13 | #include "Core" 14 | #include 15 | 16 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 17 | 18 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 19 | 20 | #else 21 | 22 | #include "src/StlSupport/StdList.h" 23 | 24 | #endif 25 | 26 | #endif // EIGEN_STDLIST_MODULE_H 27 | -------------------------------------------------------------------------------- /src/Eigen/StdVector: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDVECTOR_MODULE_H 12 | #define EIGEN_STDVECTOR_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdVector.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDVECTOR_MODULE_H 28 | -------------------------------------------------------------------------------- /src/Eigen/SuperLUSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SUPERLUSUPPORT_MODULE_H 9 | #define EIGEN_SUPERLUSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #ifdef EMPTY 16 | #define EIGEN_EMPTY_WAS_ALREADY_DEFINED 17 | #endif 18 | 19 | typedef int int_t; 20 | #include 21 | #include 22 | #include 23 | 24 | // slu_util.h defines a preprocessor token named EMPTY which is really polluting, 25 | // so we remove it in favor of a SUPERLU_EMPTY token. 26 | // If EMPTY was already defined then we don't undef it. 27 | 28 | #if defined(EIGEN_EMPTY_WAS_ALREADY_DEFINED) 29 | # undef EIGEN_EMPTY_WAS_ALREADY_DEFINED 30 | #elif defined(EMPTY) 31 | # undef EMPTY 32 | #endif 33 | 34 | #define SUPERLU_EMPTY (-1) 35 | 36 | namespace Eigen { struct SluMatrix; } 37 | 38 | /** \ingroup Support_modules 39 | * \defgroup SuperLUSupport_Module SuperLUSupport module 40 | * 41 | * This module provides an interface to the SuperLU library. 42 | * It provides the following factorization class: 43 | * - class SuperLU: a supernodal sequential LU factorization. 44 | * - class SuperILU: a supernodal sequential incomplete LU factorization (to be used as a preconditioner for iterative methods). 45 | * 46 | * \warning This wrapper requires at least versions 4.0 of SuperLU. The 3.x versions are not supported. 47 | * 48 | * \warning When including this module, you have to use SUPERLU_EMPTY instead of EMPTY which is no longer defined because it is too polluting. 49 | * 50 | * \code 51 | * #include 52 | * \endcode 53 | * 54 | * In order to use this module, the superlu headers must be accessible from the include paths, and your binary must be linked to the superlu library and its dependencies. 55 | * The dependencies depend on how superlu has been compiled. 56 | * For a cmake based project, you can use our FindSuperLU.cmake module to help you in this task. 57 | * 58 | */ 59 | 60 | #include "src/SuperLUSupport/SuperLUSupport.h" 61 | 62 | #include "src/Core/util/ReenableStupidWarnings.h" 63 | 64 | #endif // EIGEN_SUPERLUSUPPORT_MODULE_H 65 | -------------------------------------------------------------------------------- /src/Eigen/UmfPackSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_UMFPACKSUPPORT_MODULE_H 9 | #define EIGEN_UMFPACKSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup UmfPackSupport_Module UmfPackSupport module 21 | * 22 | * This module provides an interface to the UmfPack library which is part of the suitesparse package. 23 | * It provides the following factorization class: 24 | * - class UmfPackLU: a multifrontal sequential LU factorization. 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | * 30 | * In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies. 31 | * The dependencies depend on how umfpack has been compiled. 32 | * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task. 33 | * 34 | */ 35 | 36 | #include "src/UmfPackSupport/UmfPackSupport.h" 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_UMFPACKSUPPORT_MODULE_H 41 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/DiagonalProduct.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2007-2009 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_DIAGONALPRODUCT_H 12 | #define EIGEN_DIAGONALPRODUCT_H 13 | 14 | namespace Eigen { 15 | 16 | /** \returns the diagonal matrix product of \c *this by the diagonal matrix \a diagonal. 17 | */ 18 | template 19 | template 20 | EIGEN_DEVICE_FUNC inline const Product 21 | MatrixBase::operator*(const DiagonalBase &a_diagonal) const 22 | { 23 | return Product(derived(),a_diagonal.derived()); 24 | } 25 | 26 | } // end namespace Eigen 27 | 28 | #endif // EIGEN_DIAGONALPRODUCT_H 29 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/SelfCwiseBinaryOp.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SELFCWISEBINARYOP_H 11 | #define EIGEN_SELFCWISEBINARYOP_H 12 | 13 | namespace Eigen { 14 | 15 | // TODO generalize the scalar type of 'other' 16 | 17 | template 18 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator*=(const Scalar& other) 19 | { 20 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::mul_assign_op()); 21 | return derived(); 22 | } 23 | 24 | template 25 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase::operator+=(const Scalar& other) 26 | { 27 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::add_assign_op()); 28 | return derived(); 29 | } 30 | 31 | template 32 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase::operator-=(const Scalar& other) 33 | { 34 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::sub_assign_op()); 35 | return derived(); 36 | } 37 | 38 | template 39 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator/=(const Scalar& other) 40 | { 41 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::div_assign_op()); 42 | return derived(); 43 | } 44 | 45 | } // end namespace Eigen 46 | 47 | #endif // EIGEN_SELFCWISEBINARYOP_H 48 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/AVX/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2015 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_AVX_H 11 | #define EIGEN_TYPE_CASTING_AVX_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | // For now we use SSE to handle integers, so we can't use AVX instructions to cast 18 | // from int to float 19 | template <> 20 | struct type_casting_traits { 21 | enum { 22 | VectorizedCast = 0, 23 | SrcCoeffRatio = 1, 24 | TgtCoeffRatio = 1 25 | }; 26 | }; 27 | 28 | template <> 29 | struct type_casting_traits { 30 | enum { 31 | VectorizedCast = 0, 32 | SrcCoeffRatio = 1, 33 | TgtCoeffRatio = 1 34 | }; 35 | }; 36 | 37 | 38 | 39 | template<> EIGEN_STRONG_INLINE Packet8i pcast(const Packet8f& a) { 40 | return _mm256_cvttps_epi32(a); 41 | } 42 | 43 | template<> EIGEN_STRONG_INLINE Packet8f pcast(const Packet8i& a) { 44 | return _mm256_cvtepi32_ps(a); 45 | } 46 | 47 | template<> EIGEN_STRONG_INLINE Packet8i preinterpret(const Packet8f& a) { 48 | return _mm256_castps_si256(a); 49 | } 50 | 51 | template<> EIGEN_STRONG_INLINE Packet8f preinterpret(const Packet8i& a) { 52 | return _mm256_castsi256_ps(a); 53 | } 54 | 55 | #ifndef EIGEN_VECTORIZE_AVX512 56 | 57 | template <> 58 | struct type_casting_traits { 59 | enum { 60 | VectorizedCast = 1, 61 | SrcCoeffRatio = 1, 62 | TgtCoeffRatio = 1 63 | }; 64 | }; 65 | 66 | template<> EIGEN_STRONG_INLINE Packet8f pcast(const Packet8h& a) { 67 | return half2float(a); 68 | } 69 | 70 | template <> 71 | struct type_casting_traits { 72 | enum { 73 | VectorizedCast = 1, 74 | SrcCoeffRatio = 1, 75 | TgtCoeffRatio = 1 76 | }; 77 | }; 78 | 79 | #endif // EIGEN_VECTORIZE_AVX512 80 | 81 | template<> EIGEN_STRONG_INLINE Packet8h pcast(const Packet8f& a) { 82 | return float2half(a); 83 | } 84 | 85 | } // end namespace internal 86 | 87 | } // end namespace Eigen 88 | 89 | #endif // EIGEN_TYPE_CASTING_AVX_H 90 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/AVX512/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2019 Rasmus Munk Larsen 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_AVX512_H 11 | #define EIGEN_TYPE_CASTING_AVX512_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | template <> 18 | struct type_casting_traits { 19 | enum { 20 | VectorizedCast = 1, 21 | SrcCoeffRatio = 1, 22 | TgtCoeffRatio = 1 23 | }; 24 | }; 25 | 26 | template<> EIGEN_STRONG_INLINE Packet16f pcast(const Packet16h& a) { 27 | return half2float(a); 28 | } 29 | 30 | template <> 31 | struct type_casting_traits { 32 | enum { 33 | VectorizedCast = 1, 34 | SrcCoeffRatio = 1, 35 | TgtCoeffRatio = 1 36 | }; 37 | }; 38 | 39 | template<> EIGEN_STRONG_INLINE Packet16h pcast(const Packet16f& a) { 40 | return float2half(a); 41 | } 42 | 43 | } // end namespace internal 44 | 45 | } // end namespace Eigen 46 | 47 | #endif // EIGEN_TYPE_CASTING_AVX512_H 48 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/AltiVec/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2007 Julien Pommier 5 | // Copyright (C) 2009 Gael Guennebaud 6 | // Copyright (C) 2016 Konstantinos Margaritis 7 | // 8 | // This Source Code Form is subject to the terms of the Mozilla 9 | // Public License v. 2.0. If a copy of the MPL was not distributed 10 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 11 | 12 | #ifndef EIGEN_MATH_FUNCTIONS_ALTIVEC_H 13 | #define EIGEN_MATH_FUNCTIONS_ALTIVEC_H 14 | 15 | namespace Eigen { 16 | 17 | namespace internal { 18 | 19 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 20 | Packet4f plog(const Packet4f& _x) 21 | { 22 | return plog_float(_x); 23 | } 24 | 25 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 26 | Packet4f pexp(const Packet4f& _x) 27 | { 28 | return pexp_float(_x); 29 | } 30 | 31 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 32 | Packet4f psin(const Packet4f& _x) 33 | { 34 | return psin_float(_x); 35 | } 36 | 37 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 38 | Packet4f pcos(const Packet4f& _x) 39 | { 40 | return pcos_float(_x); 41 | } 42 | 43 | #ifndef EIGEN_COMP_CLANG 44 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 45 | Packet4f prsqrt(const Packet4f& x) 46 | { 47 | return vec_rsqrt(x); 48 | } 49 | #endif 50 | 51 | #ifdef __VSX__ 52 | #ifndef EIGEN_COMP_CLANG 53 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 54 | Packet2d prsqrt(const Packet2d& x) 55 | { 56 | return vec_rsqrt(x); 57 | } 58 | #endif 59 | 60 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 61 | Packet4f psqrt(const Packet4f& x) 62 | { 63 | return vec_sqrt(x); 64 | } 65 | 66 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 67 | Packet2d psqrt(const Packet2d& x) 68 | { 69 | return vec_sqrt(x); 70 | } 71 | 72 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 73 | Packet2d pexp(const Packet2d& _x) 74 | { 75 | return pexp_double(_x); 76 | } 77 | #endif 78 | 79 | // Hyperbolic Tangent function. 80 | template <> 81 | EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet4f 82 | ptanh(const Packet4f& x) { 83 | return internal::generic_fast_tanh_float(x); 84 | } 85 | 86 | } // end namespace internal 87 | 88 | } // end namespace Eigen 89 | 90 | #endif // EIGEN_MATH_FUNCTIONS_ALTIVEC_H 91 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/Default/ConjHelper.h: -------------------------------------------------------------------------------- 1 | 2 | // This file is part of Eigen, a lightweight C++ template library 3 | // for linear algebra. 4 | // 5 | // Copyright (C) 2017 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_ARCH_CONJ_HELPER_H 12 | #define EIGEN_ARCH_CONJ_HELPER_H 13 | 14 | #define EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(PACKET_CPLX, PACKET_REAL) \ 15 | template<> struct conj_helper { \ 16 | EIGEN_STRONG_INLINE PACKET_CPLX pmadd(const PACKET_REAL& x, const PACKET_CPLX& y, const PACKET_CPLX& c) const \ 17 | { return padd(c, pmul(x,y)); } \ 18 | EIGEN_STRONG_INLINE PACKET_CPLX pmul(const PACKET_REAL& x, const PACKET_CPLX& y) const \ 19 | { return PACKET_CPLX(Eigen::internal::pmul(x, y.v)); } \ 20 | }; \ 21 | \ 22 | template<> struct conj_helper { \ 23 | EIGEN_STRONG_INLINE PACKET_CPLX pmadd(const PACKET_CPLX& x, const PACKET_REAL& y, const PACKET_CPLX& c) const \ 24 | { return padd(c, pmul(x,y)); } \ 25 | EIGEN_STRONG_INLINE PACKET_CPLX pmul(const PACKET_CPLX& x, const PACKET_REAL& y) const \ 26 | { return PACKET_CPLX(Eigen::internal::pmul(x.v, y)); } \ 27 | }; 28 | 29 | #endif // EIGEN_ARCH_CONJ_HELPER_H 30 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2019 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_ARCH_GENERIC_PACKET_MATH_FUNCTIONS_FWD_H 11 | #define EIGEN_ARCH_GENERIC_PACKET_MATH_FUNCTIONS_FWD_H 12 | 13 | namespace Eigen { 14 | namespace internal { 15 | 16 | // Forward declarations of the generic math functions 17 | // implemented in GenericPacketMathFunctions.h 18 | // This is needed to workaround a circular dependency. 19 | 20 | template EIGEN_STRONG_INLINE Packet 21 | pfrexp_float(const Packet& a, Packet& exponent); 22 | 23 | template EIGEN_STRONG_INLINE Packet 24 | pldexp_float(Packet a, Packet exponent); 25 | 26 | /** \internal \returns log(x) for single precision float */ 27 | template 28 | EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS 29 | EIGEN_UNUSED 30 | Packet plog_float(const Packet _x); 31 | 32 | /** \internal \returns log(1 + x) */ 33 | template 34 | Packet generic_plog1p(const Packet& x); 35 | 36 | /** \internal \returns exp(x)-1 */ 37 | template 38 | Packet generic_expm1(const Packet& x); 39 | 40 | /** \internal \returns exp(x) for single precision float */ 41 | template 42 | EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS 43 | EIGEN_UNUSED 44 | Packet pexp_float(const Packet _x); 45 | 46 | /** \internal \returns exp(x) for double precision real numbers */ 47 | template 48 | EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS 49 | EIGEN_UNUSED 50 | Packet pexp_double(const Packet _x); 51 | 52 | /** \internal \returns sin(x) for single precision float */ 53 | template 54 | EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS 55 | EIGEN_UNUSED 56 | Packet psin_float(const Packet& x); 57 | 58 | /** \internal \returns cos(x) for single precision float */ 59 | template 60 | EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS 61 | EIGEN_UNUSED 62 | Packet pcos_float(const Packet& x); 63 | 64 | template struct ppolevl; 65 | 66 | } // end namespace internal 67 | } // end namespace Eigen 68 | 69 | #endif // EIGEN_ARCH_GENERIC_PACKET_MATH_FUNCTIONS_FWD_H 70 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/Default/Settings.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | 12 | /* All the parameters defined in this file can be specialized in the 13 | * architecture specific files, and/or by the user. 14 | * More to come... */ 15 | 16 | #ifndef EIGEN_DEFAULT_SETTINGS_H 17 | #define EIGEN_DEFAULT_SETTINGS_H 18 | 19 | /** Defines the maximal loop size to enable meta unrolling of loops. 20 | * Note that the value here is expressed in Eigen's own notion of "number of FLOPS", 21 | * it does not correspond to the number of iterations or the number of instructions 22 | */ 23 | #ifndef EIGEN_UNROLLING_LIMIT 24 | #define EIGEN_UNROLLING_LIMIT 110 25 | #endif 26 | 27 | /** Defines the threshold between a "small" and a "large" matrix. 28 | * This threshold is mainly used to select the proper product implementation. 29 | */ 30 | #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 31 | #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 32 | #endif 33 | 34 | /** Defines the maximal width of the blocks used in the triangular product and solver 35 | * for vectors (level 2 blas xTRMV and xTRSV). The default is 8. 36 | */ 37 | #ifndef EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 38 | #define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 8 39 | #endif 40 | 41 | 42 | /** Defines the default number of registers available for that architecture. 43 | * Currently it must be 8 or 16. Other values will fail. 44 | */ 45 | #ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 46 | #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 8 47 | #endif 48 | 49 | #endif // EIGEN_DEFAULT_SETTINGS_H 50 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/GPU/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_GPU_H 11 | #define EIGEN_TYPE_CASTING_GPU_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | #if (defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300) || \ 18 | (defined(EIGEN_HAS_HIP_FP16) && defined(EIGEN_HIP_DEVICE_COMPILE)) 19 | 20 | template <> 21 | struct type_casting_traits { 22 | enum { 23 | VectorizedCast = 1, 24 | SrcCoeffRatio = 2, 25 | TgtCoeffRatio = 1 26 | }; 27 | }; 28 | 29 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pcast(const half2& a, const half2& b) { 30 | float2 r1 = __half22float2(a); 31 | float2 r2 = __half22float2(b); 32 | return make_float4(r1.x, r1.y, r2.x, r2.y); 33 | } 34 | 35 | template <> 36 | struct type_casting_traits { 37 | enum { 38 | VectorizedCast = 1, 39 | SrcCoeffRatio = 1, 40 | TgtCoeffRatio = 2 41 | }; 42 | }; 43 | 44 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE half2 pcast(const float4& a) { 45 | // Simply discard the second half of the input 46 | return __floats2half2_rn(a.x, a.y); 47 | } 48 | 49 | #endif 50 | 51 | } // end namespace internal 52 | 53 | } // end namespace Eigen 54 | 55 | #endif // EIGEN_TYPE_CASTING_GPU_H 56 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/HIP/hcc/math_constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * math_constants.h - 3 | * HIP equivalent of the CUDA header of the same name 4 | */ 5 | 6 | #ifndef __MATH_CONSTANTS_H__ 7 | #define __MATH_CONSTANTS_H__ 8 | 9 | /* single precision constants */ 10 | 11 | #define HIPRT_INF_F __int_as_float(0x7f800000) 12 | #define HIPRT_NAN_F __int_as_float(0x7fffffff) 13 | #define HIPRT_MIN_DENORM_F __int_as_float(0x00000001) 14 | #define HIPRT_MAX_NORMAL_F __int_as_float(0x7f7fffff) 15 | #define HIPRT_NEG_ZERO_F __int_as_float(0x80000000) 16 | #define HIPRT_ZERO_F 0.0f 17 | #define HIPRT_ONE_F 1.0f 18 | 19 | /* double precision constants */ 20 | #define HIPRT_INF __hiloint2double(0x7ff00000, 0x00000000) 21 | #define HIPRT_NAN __hiloint2double(0xfff80000, 0x00000000) 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/NEON/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_MATH_FUNCTIONS_NEON_H 9 | #define EIGEN_MATH_FUNCTIONS_NEON_H 10 | 11 | namespace Eigen { 12 | 13 | namespace internal { 14 | 15 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 16 | Packet4f pexp(const Packet4f& x) 17 | { 18 | return pexp_float(x); 19 | } 20 | 21 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 22 | Packet4f plog(const Packet4f& x) 23 | { 24 | return plog_float(x); 25 | } 26 | 27 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 28 | Packet4f psin(const Packet4f& x) 29 | { 30 | return psin_float(x); 31 | } 32 | 33 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 34 | Packet4f pcos(const Packet4f& x) 35 | { 36 | return pcos_float(x); 37 | } 38 | 39 | // Hyperbolic Tangent function. 40 | template <> 41 | EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet4f 42 | ptanh(const Packet4f& x) { 43 | return internal::generic_fast_tanh_float(x); 44 | } 45 | 46 | } // end namespace internal 47 | 48 | } // end namespace Eigen 49 | 50 | #endif // EIGEN_MATH_FUNCTIONS_NEON_H 51 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/NEON/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2018 Rasmus Munk Larsen 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_NEON_H 11 | #define EIGEN_TYPE_CASTING_NEON_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | template <> 18 | struct type_casting_traits { 19 | enum { 20 | VectorizedCast = 1, 21 | SrcCoeffRatio = 1, 22 | TgtCoeffRatio = 1 23 | }; 24 | }; 25 | 26 | template <> 27 | struct type_casting_traits { 28 | enum { 29 | VectorizedCast = 1, 30 | SrcCoeffRatio = 1, 31 | TgtCoeffRatio = 1 32 | }; 33 | }; 34 | 35 | 36 | template<> EIGEN_STRONG_INLINE Packet4i pcast(const Packet4f& a) { 37 | return vcvtq_s32_f32(a); 38 | } 39 | 40 | template<> EIGEN_STRONG_INLINE Packet4f pcast(const Packet4i& a) { 41 | return vcvtq_f32_s32(a); 42 | } 43 | 44 | template<> EIGEN_STRONG_INLINE Packet4i preinterpret(const Packet4f& a) { 45 | return vreinterpretq_s32_f32(a); 46 | } 47 | 48 | template<> EIGEN_STRONG_INLINE Packet4f preinterpret(const Packet4i& a) { 49 | return vreinterpretq_f32_s32(a); 50 | } 51 | 52 | } // end namespace internal 53 | 54 | } // end namespace Eigen 55 | 56 | #endif // EIGEN_TYPE_CASTING_NEON_H 57 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/functors/TernaryFunctors.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Eugene Brevdo 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TERNARY_FUNCTORS_H 11 | #define EIGEN_TERNARY_FUNCTORS_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | //---------- associative ternary functors ---------- 18 | 19 | 20 | 21 | } // end namespace internal 22 | 23 | } // end namespace Eigen 24 | 25 | #endif // EIGEN_TERNARY_FUNCTORS_H 26 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/util/NonMPL2.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_MPL2_ONLY 2 | #error Including non-MPL2 code in EIGEN_MPL2_ONLY mode 3 | #endif 4 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED_2 2 | // "DisableStupidWarnings.h" was included twice recursively: Do not reenable warnings yet! 3 | # undef EIGEN_WARNINGS_DISABLED_2 4 | 5 | #elif defined(EIGEN_WARNINGS_DISABLED) 6 | #undef EIGEN_WARNINGS_DISABLED 7 | 8 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 9 | #ifdef _MSC_VER 10 | #pragma warning( pop ) 11 | #elif defined __INTEL_COMPILER 12 | #pragma warning pop 13 | #elif defined __clang__ 14 | #pragma clang diagnostic pop 15 | #elif defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) 16 | #pragma GCC diagnostic pop 17 | #endif 18 | 19 | #if defined __NVCC__ 20 | // Don't reenable the diagnostic messages, as it turns out these messages need 21 | // to be disabled at the point of the template instantiation (i.e the user code) 22 | // otherwise they'll be triggered by nvcc. 23 | // #pragma diag_default code_is_unreachable 24 | // #pragma diag_default initialization_not_reachable 25 | // #pragma diag_default 2651 26 | // #pragma diag_default 2653 27 | #endif 28 | 29 | #endif 30 | 31 | #endif // EIGEN_WARNINGS_DISABLED 32 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/util/ReshapedHelper.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2017 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | 11 | #ifndef EIGEN_RESHAPED_HELPER_H 12 | #define EIGEN_RESHAPED_HELPER_H 13 | 14 | namespace Eigen { 15 | 16 | enum AutoSize_t { AutoSize }; 17 | const int AutoOrder = 2; 18 | 19 | namespace internal { 20 | 21 | template 22 | struct get_compiletime_reshape_size { 23 | enum { value = get_fixed_value::value }; 24 | }; 25 | 26 | template 27 | Index get_runtime_reshape_size(SizeType size, Index /*other*/, Index /*total*/) { 28 | return internal::get_runtime_value(size); 29 | } 30 | 31 | template 32 | struct get_compiletime_reshape_size { 33 | enum { 34 | other_size = get_fixed_value::value, 35 | value = (TotalSize==Dynamic || other_size==Dynamic) ? Dynamic : TotalSize / other_size }; 36 | }; 37 | 38 | inline Index get_runtime_reshape_size(AutoSize_t /*size*/, Index other, Index total) { 39 | return total/other; 40 | } 41 | 42 | template 43 | struct get_compiletime_reshape_order { 44 | enum { value = Order == AutoOrder ? Flags & RowMajorBit : Order }; 45 | }; 46 | 47 | } 48 | 49 | } // end namespace Eigen 50 | 51 | #endif // EIGEN_RESHAPED_HELPER_H 52 | -------------------------------------------------------------------------------- /src/Eigen/src/SparseCore/MappedSparseMatrix.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MAPPED_SPARSEMATRIX_H 11 | #define EIGEN_MAPPED_SPARSEMATRIX_H 12 | 13 | namespace Eigen { 14 | 15 | /** \deprecated Use Map > 16 | * \class MappedSparseMatrix 17 | * 18 | * \brief Sparse matrix 19 | * 20 | * \param _Scalar the scalar type, i.e. the type of the coefficients 21 | * 22 | * See http://www.netlib.org/linalg/html_templates/node91.html for details on the storage scheme. 23 | * 24 | */ 25 | namespace internal { 26 | template 27 | struct traits > : traits > 28 | {}; 29 | } // end namespace internal 30 | 31 | template 32 | class MappedSparseMatrix 33 | : public Map > 34 | { 35 | typedef Map > Base; 36 | 37 | public: 38 | 39 | typedef typename Base::StorageIndex StorageIndex; 40 | typedef typename Base::Scalar Scalar; 41 | 42 | inline MappedSparseMatrix(Index rows, Index cols, Index nnz, StorageIndex* outerIndexPtr, StorageIndex* innerIndexPtr, Scalar* valuePtr, StorageIndex* innerNonZeroPtr = 0) 43 | : Base(rows, cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZeroPtr) 44 | {} 45 | 46 | /** Empty destructor */ 47 | inline ~MappedSparseMatrix() {} 48 | }; 49 | 50 | namespace internal { 51 | 52 | template 53 | struct evaluator > 54 | : evaluator > > 55 | { 56 | typedef MappedSparseMatrix<_Scalar,_Options,_StorageIndex> XprType; 57 | typedef evaluator > Base; 58 | 59 | evaluator() : Base() {} 60 | explicit evaluator(const XprType &mat) : Base(mat) {} 61 | }; 62 | 63 | } 64 | 65 | } // end namespace Eigen 66 | 67 | #endif // EIGEN_MAPPED_SPARSEMATRIX_H 68 | -------------------------------------------------------------------------------- /src/Eigen/src/SparseCore/SparseFuzzy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSE_FUZZY_H 11 | #define EIGEN_SPARSE_FUZZY_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | template 17 | bool SparseMatrixBase::isApprox(const SparseMatrixBase& other, const RealScalar &prec) const 18 | { 19 | const typename internal::nested_eval::type actualA(derived()); 20 | typename internal::conditional::type, 22 | const PlainObject>::type actualB(other.derived()); 23 | 24 | return (actualA - actualB).squaredNorm() <= prec * prec * numext::mini(actualA.squaredNorm(), actualB.squaredNorm()); 25 | } 26 | 27 | } // end namespace Eigen 28 | 29 | #endif // EIGEN_SPARSE_FUZZY_H 30 | -------------------------------------------------------------------------------- /src/Eigen/src/SparseCore/SparseRedux.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSEREDUX_H 11 | #define EIGEN_SPARSEREDUX_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | typename internal::traits::Scalar 17 | SparseMatrixBase::sum() const 18 | { 19 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 20 | Scalar res(0); 21 | internal::evaluator thisEval(derived()); 22 | for (Index j=0; j::InnerIterator iter(thisEval,j); iter; ++iter) 24 | res += iter.value(); 25 | return res; 26 | } 27 | 28 | template 29 | typename internal::traits >::Scalar 30 | SparseMatrix<_Scalar,_Options,_Index>::sum() const 31 | { 32 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 33 | if(this->isCompressed()) 34 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 35 | else 36 | return Base::sum(); 37 | } 38 | 39 | template 40 | typename internal::traits >::Scalar 41 | SparseVector<_Scalar,_Options,_Index>::sum() const 42 | { 43 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 44 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 45 | } 46 | 47 | } // end namespace Eigen 48 | 49 | #endif // EIGEN_SPARSEREDUX_H 50 | -------------------------------------------------------------------------------- /src/Eigen/src/SparseLU/SparseLU_Utils.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | 11 | #ifndef EIGEN_SPARSELU_UTILS_H 12 | #define EIGEN_SPARSELU_UTILS_H 13 | 14 | namespace Eigen { 15 | namespace internal { 16 | 17 | /** 18 | * \brief Count Nonzero elements in the factors 19 | */ 20 | template 21 | void SparseLUImpl::countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu) 22 | { 23 | nnzL = 0; 24 | nnzU = (glu.xusub)(n); 25 | Index nsuper = (glu.supno)(n); 26 | Index jlen; 27 | Index i, j, fsupc; 28 | if (n <= 0 ) return; 29 | // For each supernode 30 | for (i = 0; i <= nsuper; i++) 31 | { 32 | fsupc = glu.xsup(i); 33 | jlen = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); 34 | 35 | for (j = fsupc; j < glu.xsup(i+1); j++) 36 | { 37 | nnzL += jlen; 38 | nnzU += j - fsupc + 1; 39 | jlen--; 40 | } 41 | } 42 | } 43 | 44 | /** 45 | * \brief Fix up the data storage lsub for L-subscripts. 46 | * 47 | * It removes the subscripts sets for structural pruning, 48 | * and applies permutation to the remaining subscripts 49 | * 50 | */ 51 | template 52 | void SparseLUImpl::fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu) 53 | { 54 | Index fsupc, i, j, k, jstart; 55 | 56 | StorageIndex nextl = 0; 57 | Index nsuper = (glu.supno)(n); 58 | 59 | // For each supernode 60 | for (i = 0; i <= nsuper; i++) 61 | { 62 | fsupc = glu.xsup(i); 63 | jstart = glu.xlsub(fsupc); 64 | glu.xlsub(fsupc) = nextl; 65 | for (j = jstart; j < glu.xlsub(fsupc + 1); j++) 66 | { 67 | glu.lsub(nextl) = perm_r(glu.lsub(j)); // Now indexed into P*A 68 | nextl++; 69 | } 70 | for (k = fsupc+1; k < glu.xsup(i+1); k++) 71 | glu.xlsub(k) = nextl; // other columns in supernode i 72 | } 73 | 74 | glu.xlsub(n) = nextl; 75 | } 76 | 77 | } // end namespace internal 78 | 79 | } // end namespace Eigen 80 | #endif // EIGEN_SPARSELU_UTILS_H 81 | -------------------------------------------------------------------------------- /src/Eigen/src/misc/RealSvd2x2.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Benoit Jacob 5 | // Copyright (C) 2013-2016 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_REALSVD2X2_H 12 | #define EIGEN_REALSVD2X2_H 13 | 14 | namespace Eigen { 15 | 16 | namespace internal { 17 | 18 | template 19 | void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q, 20 | JacobiRotation *j_left, 21 | JacobiRotation *j_right) 22 | { 23 | using std::sqrt; 24 | using std::abs; 25 | Matrix m; 26 | m << numext::real(matrix.coeff(p,p)), numext::real(matrix.coeff(p,q)), 27 | numext::real(matrix.coeff(q,p)), numext::real(matrix.coeff(q,q)); 28 | JacobiRotation rot1; 29 | RealScalar t = m.coeff(0,0) + m.coeff(1,1); 30 | RealScalar d = m.coeff(1,0) - m.coeff(0,1); 31 | 32 | if(abs(d) < (std::numeric_limits::min)()) 33 | { 34 | rot1.s() = RealScalar(0); 35 | rot1.c() = RealScalar(1); 36 | } 37 | else 38 | { 39 | // If d!=0, then t/d cannot overflow because the magnitude of the 40 | // entries forming d are not too small compared to the ones forming t. 41 | RealScalar u = t / d; 42 | RealScalar tmp = sqrt(RealScalar(1) + numext::abs2(u)); 43 | rot1.s() = RealScalar(1) / tmp; 44 | rot1.c() = u / tmp; 45 | } 46 | m.applyOnTheLeft(0,1,rot1); 47 | j_right->makeJacobi(m,0,1); 48 | *j_left = rot1 * j_right->transpose(); 49 | } 50 | 51 | } // end namespace internal 52 | 53 | } // end namespace Eigen 54 | 55 | #endif // EIGEN_REALSVD2X2_H 56 | -------------------------------------------------------------------------------- /src/Eigen/src/misc/lapacke_mangling.h: -------------------------------------------------------------------------------- 1 | #ifndef LAPACK_HEADER_INCLUDED 2 | #define LAPACK_HEADER_INCLUDED 3 | 4 | #ifndef LAPACK_GLOBAL 5 | #if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_) 6 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 7 | #elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER) 8 | #define LAPACK_GLOBAL(lcname,UCNAME) UCNAME 9 | #elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE) 10 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname 11 | #else 12 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 13 | #endif 14 | #endif 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /src/PDPC/Common/Algorithms/has_duplicate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | //! 8 | //! \brief has_duplicate checks if the given container contains duplicated items 9 | //! 10 | //! Complexity = O(n^2) 11 | //! 12 | template 13 | bool has_duplicate(ContainerT container); 14 | 15 | template 16 | bool has_duplicate(RandomIt first, RandomIt last); 17 | 18 | //////////////////////////////////////////////////////////////////////////////// 19 | //////////////////////////////////////////////////////////////////////////////// 20 | //////////////////////////////////////////////////////////////////////////////// 21 | 22 | template 23 | bool has_duplicate(ContainerT container) 24 | { 25 | return has_duplicate(std::begin(container), std::end(container)); 26 | } 27 | 28 | template 29 | bool has_duplicate(RandomIt first, RandomIt last) 30 | { 31 | return std::any_of(first, last, [&](const auto& cur)->bool 32 | { 33 | // next is the iterator pointing after the current value cur 34 | RandomIt next = first + (&cur - &(*first)) + 1; 35 | return std::find(next, last, cur) != last; 36 | }); 37 | } 38 | 39 | } // namespace pdpc 40 | -------------------------------------------------------------------------------- /src/PDPC/Common/Assert.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define PDPC_ERROR \ 6 | PDPC_MACRO_START \ 7 | PDPC_PRINT_ERROR(""); \ 8 | PDPC_CRASH; \ 9 | PDPC_MACRO_END 10 | 11 | #define PDPC_ERROR_MSG(MSG) \ 12 | PDPC_MACRO_START \ 13 | PDPC_PRINT_ERROR(MSG); \ 14 | PDPC_CRASH; \ 15 | PDPC_MACRO_END 16 | 17 | #define PDPC_ASSERT(EXPR) \ 18 | PDPC_MACRO_START \ 19 | if(!(EXPR)) { \ 20 | PDPC_ERROR_MSG(PDPC_STR(EXPR)); \ 21 | } \ 22 | PDPC_MACRO_END 23 | 24 | #define PDPC_ASSERT_MSG(EXPR,MSG) \ 25 | PDPC_MACRO_START \ 26 | if(!(EXPR)) { \ 27 | PDPC_ERROR_MSG(MSG); \ 28 | } \ 29 | PDPC_MACRO_END 30 | 31 | #ifdef PDPC_DEBUG 32 | #define PDPC_DEBUG_ASSERT(EXPR) PDPC_ASSERT(EXPR) 33 | #define PDPC_DEBUG_ASSERT_MSG(EXPR,MSG) PDPC_ASSERT_MSG(EXPR,MSG) 34 | #define PDPC_DEBUG_ERROR_MSG(MSG) PDPC_ERROR_MSG(MSG) 35 | #define PDPC_DEBUG_ERROR PDPC_ERROR 36 | #else 37 | #define PDPC_DEBUG_ASSERT(EXPR) 38 | #define PDPC_DEBUG_ASSERT_MSG(EXPR,MSG) 39 | #define PDPC_DEBUG_ERROR_MSG(MSG) 40 | #define PDPC_DEBUG_ERROR 41 | #endif 42 | -------------------------------------------------------------------------------- /src/PDPC/Common/Containers/internal/AbstractVector.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | 6 | // ============================================================================= 7 | 8 | // explicit template instanciation 9 | template class concrete_vector; 10 | template class concrete_vector; 11 | template class concrete_vector; 12 | template class concrete_vector; 13 | template class concrete_vector; 14 | 15 | } // namespace pdpc 16 | -------------------------------------------------------------------------------- /src/PDPC/Common/Containers/internal/abstract_vector_index_iterator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | abstract_vector_index_iterator::abstract_vector_index_iterator() : 6 | m_index(0) 7 | { 8 | } 9 | 10 | abstract_vector_index_iterator::abstract_vector_index_iterator(const abstract_vector_index_iterator& other) : 11 | m_index(other.m_index) 12 | { 13 | } 14 | 15 | abstract_vector_index_iterator::abstract_vector_index_iterator(int current) : 16 | m_index(current) 17 | { 18 | } 19 | 20 | abstract_vector_index_iterator& abstract_vector_index_iterator::operator += (int n) 21 | { 22 | m_index += n; 23 | return *this; 24 | } 25 | 26 | abstract_vector_index_iterator& abstract_vector_index_iterator::operator -= (int n) 27 | { 28 | m_index -= n; 29 | return *this; 30 | } 31 | 32 | abstract_vector_index_iterator& abstract_vector_index_iterator::operator ++ () 33 | { 34 | ++m_index; 35 | return *this; 36 | } 37 | 38 | abstract_vector_index_iterator& abstract_vector_index_iterator::operator -- () 39 | { 40 | --m_index; 41 | return *this; 42 | } 43 | 44 | abstract_vector_index_iterator abstract_vector_index_iterator::operator + (int n) const 45 | { 46 | abstract_vector_index_iterator copy(*this); 47 | copy += n; 48 | return copy; 49 | } 50 | 51 | abstract_vector_index_iterator abstract_vector_index_iterator::operator - (int n) const 52 | { 53 | abstract_vector_index_iterator copy(*this); 54 | copy -= n; 55 | return copy; 56 | } 57 | 58 | bool abstract_vector_index_iterator::operator == (const abstract_vector_index_iterator& other) const 59 | { 60 | return m_index == other.m_index; 61 | } 62 | 63 | bool abstract_vector_index_iterator::operator != (const abstract_vector_index_iterator& other) const 64 | { 65 | return m_index != other.m_index; 66 | } 67 | 68 | int abstract_vector_index_iterator::operator * () const 69 | { 70 | return m_index; 71 | } 72 | 73 | int abstract_vector_index_iterator::index() const 74 | { 75 | return m_index; 76 | } 77 | 78 | } // namespace pdpc 79 | -------------------------------------------------------------------------------- /src/PDPC/Common/Containers/internal/abstract_vector_index_iterator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | class abstract_vector_index_iterator 6 | { 7 | public: 8 | abstract_vector_index_iterator(); 9 | abstract_vector_index_iterator(const abstract_vector_index_iterator& other); 10 | abstract_vector_index_iterator(int index); 11 | 12 | abstract_vector_index_iterator& operator += (int n); 13 | abstract_vector_index_iterator& operator -= (int n); 14 | abstract_vector_index_iterator& operator ++ (); 15 | abstract_vector_index_iterator& operator -- (); 16 | 17 | abstract_vector_index_iterator operator + (int n) const; 18 | abstract_vector_index_iterator operator - (int n) const; 19 | 20 | bool operator == (const abstract_vector_index_iterator& other) const; 21 | bool operator != (const abstract_vector_index_iterator& other) const; 22 | 23 | int operator * () const; 24 | int index() const; 25 | 26 | protected: 27 | int m_index; 28 | }; 29 | 30 | } // namespace pdpc 31 | -------------------------------------------------------------------------------- /src/PDPC/Common/Containers/static_stack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | template 8 | class static_stack 9 | { 10 | public: 11 | inline static_stack(); 12 | 13 | inline const T& top() const; 14 | inline T& top(); 15 | 16 | inline bool empty() const; 17 | inline bool full() const; 18 | inline int size() const; 19 | 20 | inline void push(const T& value); 21 | inline void push(); 22 | inline void pop(); 23 | inline void clear(); 24 | 25 | protected: 26 | int m_size; 27 | T m_data[N]; 28 | }; 29 | 30 | //////////////////////////////////////////////////////////////////////////////// 31 | //////////////////////////////////////////////////////////////////////////////// 32 | //////////////////////////////////////////////////////////////////////////////// 33 | 34 | template 35 | static_stack::static_stack() : 36 | m_size(0), 37 | m_data() 38 | { 39 | } 40 | 41 | template 42 | const T& static_stack::top() const 43 | { 44 | PDPC_DEBUG_ASSERT(!empty()); 45 | return m_data[m_size-1]; 46 | } 47 | 48 | template 49 | T& static_stack::top() 50 | { 51 | PDPC_DEBUG_ASSERT(!empty()); 52 | return m_data[m_size-1]; 53 | } 54 | 55 | template 56 | bool static_stack::empty() const 57 | { 58 | return m_size == 0; 59 | } 60 | 61 | template 62 | bool static_stack::full() const 63 | { 64 | return m_size == N; 65 | } 66 | 67 | template 68 | int static_stack::size() const 69 | { 70 | return m_size; 71 | } 72 | 73 | template 74 | void static_stack::push(const T& value) 75 | { 76 | PDPC_DEBUG_ASSERT(!full()); 77 | m_data[m_size] = value; 78 | ++m_size; 79 | } 80 | 81 | template 82 | void static_stack::push() 83 | { 84 | PDPC_DEBUG_ASSERT(!full()); 85 | m_data[m_size] = T(); 86 | ++m_size; 87 | } 88 | 89 | template 90 | void static_stack::pop() 91 | { 92 | PDPC_DEBUG_ASSERT(!empty()); 93 | --m_size; 94 | } 95 | 96 | template 97 | void static_stack::clear() 98 | { 99 | m_size = 0; 100 | } 101 | 102 | } // namespace pdpc 103 | -------------------------------------------------------------------------------- /src/PDPC/Common/Defines.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace pdpc 8 | { 9 | 10 | using Scalar = float; 11 | using Vector2 = Eigen::Matrix; 12 | using Vector3 = Eigen::Matrix; 13 | using Vector4 = Eigen::Matrix; 14 | using Vector3i = Eigen::Matrix; 15 | using Vector2Array = std::vector; 16 | using Vector3Array = std::vector; 17 | using Vector4Array = std::vector; 18 | using Vector3iArray = std::vector; 19 | using Matrix3 = Eigen::Matrix; 20 | using Aabb = Eigen::AlignedBox; 21 | using Aabb3 = Eigen::AlignedBox; 22 | using Aabb2 = Eigen::AlignedBox; 23 | 24 | } // namespace pdpc 25 | -------------------------------------------------------------------------------- /src/PDPC/Common/File.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | std::string get_extension(const std::string& path) 6 | { 7 | const auto dot = path.find_last_of('.'); 8 | const auto slash = path.find_last_of('/'); 9 | 10 | const bool has_slash = (slash != std::string::npos); 11 | const bool has_dot = (dot != std::string::npos); 12 | 13 | if(!has_dot && !has_slash) return ""; 14 | else if(!has_dot && has_slash) return ""; 15 | else if( has_dot && !has_slash) return path.substr(dot+1); 16 | else// if( has_dot && has_slash) 17 | { 18 | if(slash < dot) return path.substr(dot+1); 19 | else return ""; 20 | } 21 | } 22 | 23 | std::string get_filename(const std::string& path) 24 | { 25 | const auto slash = path.find_last_of('/'); 26 | const auto dot = path.find_last_of('.'); 27 | 28 | const bool has_slash = (slash != std::string::npos); 29 | const bool has_dot = (dot != std::string::npos); 30 | 31 | if(!has_dot && !has_slash) return path; 32 | else if(!has_dot && has_slash) return path.substr(slash+1); 33 | else if( has_dot && !has_slash) return path.substr(0, dot); 34 | else// if( has_dot && has_slash) 35 | { 36 | if(dot < slash) return path.substr(slash+1); 37 | else return path.substr(slash+1, dot-slash-1); 38 | } 39 | } 40 | 41 | } // namespace pdpc 42 | -------------------------------------------------------------------------------- /src/PDPC/Common/File.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | std::string get_extension(const std::string& path); 8 | std::string get_filename(const std::string& path); 9 | 10 | } // namespace pdpc 11 | -------------------------------------------------------------------------------- /src/PDPC/Common/Log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace pdpc { 10 | 11 | class LogMessage; 12 | 13 | enum LogLevel : int 14 | { 15 | Critical = 0, 16 | Error, // 1 17 | Warning, // 2 18 | Info, // 3 19 | Debug // 4 20 | // Debug1 // 5 (Debug+1) 21 | // Debug2 // 6 (Debug+2) 22 | // ... 23 | }; 24 | 25 | inline LogMessage log(int level, const std::string& context = ""); 26 | inline LogMessage log(const std::string& context = "", int level = Info); 27 | 28 | inline LogMessage critical(const std::string& context = ""); 29 | inline LogMessage error(const std::string& context = ""); 30 | inline LogMessage warning(const std::string& context = ""); 31 | inline LogMessage info(const std::string& context = ""); 32 | 33 | inline LogMessage debug(const std::string& context = "", int debug_level = 0); 34 | inline LogMessage debug(int debug_level, const std::string& context = ""); 35 | 36 | class LogMessage 37 | { 38 | public: 39 | inline LogMessage(int level, const std::string& context); 40 | inline LogMessage(const LogMessage& other); 41 | inline ~LogMessage(); 42 | 43 | template 44 | inline LogMessage& operator << (const T& val); 45 | template 46 | inline LogMessage& operator << (T& val); 47 | 48 | inline LogMessage& iff(bool b); 49 | 50 | protected: 51 | int m_level; 52 | bool m_on; 53 | std::ostringstream m_os; 54 | }; 55 | 56 | } // namespace pdpc 57 | 58 | #include 59 | -------------------------------------------------------------------------------- /src/PDPC/Common/Log.inl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | LogMessage log(int level, const std::string& context) {return LogMessage(level, context);} 6 | LogMessage log(const std::string& context, int level) {return LogMessage(level, context);} 7 | 8 | LogMessage critical(const std::string& context) {return LogMessage(Critical, context);} 9 | LogMessage error(const std::string& context) {return LogMessage(Error, context);} 10 | LogMessage warning(const std::string& context) {return LogMessage(Warning, context);} 11 | LogMessage info(const std::string& context) {return LogMessage(Info, context);} 12 | 13 | LogMessage debug(const std::string& context, int debug_level){return LogMessage(Debug + debug_level, context);} 14 | LogMessage debug(int debug_level, const std::string& context){return LogMessage(Debug + debug_level, context);} 15 | 16 | LogMessage::LogMessage(int level, const std::string& context) : 17 | m_level(level), 18 | m_on(true), 19 | m_os() 20 | { 21 | m_os << "PDPC - " << Timer::date() << " - "; 22 | 23 | if(m_level == Critical) m_os << "[critical] "; 24 | else if(m_level == Error) m_os << "[error] "; 25 | else if(m_level == Warning) m_os << "[warning] "; 26 | else if(m_level >= Debug) m_os << "[debug] "; 27 | 28 | if(!context.empty()) 29 | { 30 | m_os << context << ": "; 31 | } 32 | } 33 | 34 | LogMessage::LogMessage(const LogMessage& other) : 35 | m_level(other.m_level), 36 | m_on(other.m_on), 37 | m_os() 38 | { 39 | m_os << other.m_os.str(); 40 | } 41 | 42 | LogMessage::~LogMessage() 43 | { 44 | if(m_on) 45 | { 46 | if(m_level < Info) 47 | std::cerr << m_os.str() << std::endl; 48 | else 49 | std::cout << m_os.str() << std::endl; 50 | } 51 | } 52 | 53 | template 54 | LogMessage& LogMessage::operator << (const T& val) 55 | { 56 | m_os << val; 57 | return *this; 58 | } 59 | 60 | template 61 | LogMessage& LogMessage::operator << (T& val) 62 | { 63 | m_os << val; 64 | return *this; 65 | } 66 | 67 | LogMessage& LogMessage::iff(bool b) 68 | { 69 | m_on = b; 70 | return *this; 71 | } 72 | 73 | } // namespace pdpc 74 | -------------------------------------------------------------------------------- /src/PDPC/Common/Macro.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | // macro delimiters 7 | #define PDPC_MACRO_START do { 8 | #define PDPC_MACRO_END } while(0) 9 | 10 | // Stringification 11 | #define PDPC_XSTR(S) #S 12 | #define PDPC_STR(S) PDPC_XSTR(S) 13 | 14 | #define PDPC_CRASH \ 15 | PDPC_MACRO_START \ 16 | psnip_trap(); \ 17 | PDPC_MACRO_END 18 | 19 | #define PDPC_PRINT_ERROR(MSG) \ 20 | PDPC_MACRO_START \ 21 | fprintf(stderr, \ 22 | "%s:%i: [Error] %s\n", \ 23 | __FILE__,__LINE__,MSG); \ 24 | fflush(stderr); \ 25 | PDPC_MACRO_END 26 | 27 | #define PDPC_PRINT_WARNING(MSG) \ 28 | PDPC_MACRO_START \ 29 | fprintf(stderr, \ 30 | "%s:%i: [Warning] %s\n", \ 31 | __FILE__,__LINE__,MSG); \ 32 | fflush(stderr); \ 33 | PDPC_MACRO_END 34 | 35 | // turnoff warning 36 | #define PDPC_UNUSED(VAR) \ 37 | PDPC_MACRO_START \ 38 | (void)(VAR); \ 39 | PDPC_MACRO_END 40 | 41 | #define PDPC_TODO \ 42 | PDPC_MACRO_START \ 43 | PDPC_PRINT_ERROR("TODO"); \ 44 | PDPC_CRASH; \ 45 | PDPC_MACRO_END 46 | 47 | template struct XXXXXXXXXX_The_unkown_type_is_; 48 | #define WhatIsTheTypeOf(expr) XXXXXXXXXX_The_unkown_type_is_ _XXXXXXXXXX 49 | #define WhatIsThisType(type) XXXXXXXXXX_The_unkown_type_is_ _XXXXXXXXXX 50 | -------------------------------------------------------------------------------- /src/PDPC/Common/Option.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace pdpc { 12 | 13 | using String = std::string; 14 | 15 | class Option 16 | { 17 | protected: 18 | template using Arg = OptionArgumentT; 19 | template using ArgVec = OptionVectorArgumentT; 20 | 21 | public: 22 | Option(int argc, char** argv); 23 | 24 | bool operator !() const; 25 | bool ok() const; 26 | friend std::ostream& operator <<(std::ostream& os, const Option& opt); 27 | 28 | public: 29 | bool has(const std::string& id, const std::string& id2) const; 30 | int index(const std::string& id, const std::string& id2) const; 31 | 32 | const std::string& operator [](int idx) const; 33 | 34 | public: 35 | Arg& get_bool( const String& id, const String& id2 = ""); 36 | Arg& get_int( const String& id, const String& id2 = ""); 37 | Arg& get_float( const String& id, const String& id2 = ""); 38 | Arg& get_string(const String& id, const String& id2 = ""); 39 | 40 | ArgVec& get_strings(const String& id, const String& id2 = ""); 41 | ArgVec& get_ints(const String& id, const String& id2 = ""); 42 | ArgVec& get_floats(const String& id, const String& id2 = ""); 43 | 44 | template 45 | Arg& get(const String& id, const String& id2 = ""); 46 | 47 | template 48 | ArgVec& get_vec(const String& id, const String& id2 = ""); 49 | 50 | template 51 | ArgVec& get_delimited_vec(const String& id, const String& id2 = ""); 52 | 53 | public: 54 | void print_help() const; 55 | 56 | void set_description(const std::string& description); 57 | 58 | protected: 59 | static void cast(const String& str, int& val); 60 | static void cast(const String& str, float& val); 61 | static void cast(const String& str, String& val); 62 | 63 | static bool is_arg(const std::string& str); 64 | static bool is_part_of_number(char c); 65 | 66 | static bool is_begin_delimiter(const std::string& str); 67 | static bool is_end_delimiter(const std::string& str); 68 | 69 | static bool is_begin_delimiter(char c); 70 | static bool is_end_delimiter(char c); 71 | 72 | protected: 73 | std::vector m_input; 74 | std::vector> m_args; 75 | std::string m_description; 76 | }; 77 | 78 | } // namespace pdpc 79 | 80 | #include 81 | -------------------------------------------------------------------------------- /src/PDPC/Common/Progress.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | class Timer; 8 | 9 | class Progress 10 | { 11 | public: 12 | Progress(); 13 | Progress(int step_count); 14 | Progress(int step_count, int percentage_increment); 15 | Progress(int step_count, int percentage_increment, bool enable); 16 | Progress(int step_count, bool enable); 17 | 18 | Progress(const Progress& other); 19 | Progress& operator =(const Progress& other); 20 | 21 | ~Progress(); 22 | 23 | public: 24 | void operator ++(); 25 | void incr(const char* prefix); 26 | 27 | protected: 28 | int m_step; 29 | int m_step_count; 30 | 31 | int m_step_increment; 32 | int m_percentage_increment; 33 | 34 | int m_next_step; 35 | int m_next_percentage; 36 | 37 | std::unique_ptr m_timer; 38 | bool m_enabled; 39 | }; 40 | 41 | } // namespace pdpc 42 | -------------------------------------------------------------------------------- /src/PDPC/Common/String.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | namespace str { 5 | 6 | std::string push_zeros_front(const std::string& s, int n) 7 | { 8 | if(n > 0) 9 | { 10 | return std::string(n, '0').append(s); 11 | } 12 | else 13 | { 14 | return s; 15 | } 16 | } 17 | 18 | std::string to_string(int number, int n) 19 | { 20 | return to_string(std::to_string(number), n); 21 | } 22 | 23 | std::string to_string(const std::string& s, int n) 24 | { 25 | const int diff = n - s.size(); 26 | return push_zeros_front(s, diff); 27 | } 28 | 29 | } // namespace str 30 | } // namespace pdpc 31 | -------------------------------------------------------------------------------- /src/PDPC/Common/String.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | namespace str { 7 | 8 | //! \brief add n '0' in front of s 9 | std::string push_zeros_front(const std::string& s, int n); 10 | 11 | //! \brief int to string using n digits 12 | std::string to_string(int number, int n); 13 | std::string to_string(const std::string& s, int n); 14 | 15 | } // namespace str 16 | } // namespace pdpc 17 | -------------------------------------------------------------------------------- /src/PDPC/Common/Timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace pdpc { 8 | 9 | class Timer 10 | { 11 | public: 12 | // Types ------------------------------------------------------------------- 13 | public: 14 | using Clock = std::chrono::high_resolution_clock; 15 | using TimePoint = std::chrono::high_resolution_clock::time_point; 16 | using Duration = std::chrono::high_resolution_clock::duration; 17 | using SystemClock = std::chrono::system_clock; 18 | using ullint = unsigned long long int; 19 | using ldouble = long double; 20 | using String = std::string; 21 | 22 | // Timer ------------------------------------------------------------------- 23 | public: 24 | Timer(bool start = true); 25 | 26 | // Timing ------------------------------------------------------------------ 27 | public: 28 | inline void start(); 29 | inline void restart(); 30 | 31 | inline ldouble time_sec() const; 32 | inline ullint time_milli_sec() const; 33 | 34 | private: 35 | inline Duration time() const; 36 | 37 | // String ------------------------------------------------------------------ 38 | public: 39 | String smart_str(); 40 | 41 | static String millisec_str(ldouble millisec); 42 | static String sec_str(ldouble sec); 43 | 44 | // Date -------------------------------------------------------------------- 45 | public: 46 | static String date(); 47 | static String date_str(); 48 | 49 | // Data -------------------------------------------------------------------- 50 | private: 51 | TimePoint m_start; 52 | 53 | }; // class Timer 54 | 55 | } // namespace pdpc 56 | 57 | #include 58 | -------------------------------------------------------------------------------- /src/PDPC/Common/Timer.inl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | // Timing ---------------------------------------------------------------------- 6 | 7 | void Timer::start() 8 | { 9 | m_start = Clock::now(); 10 | } 11 | 12 | void Timer::restart() 13 | { 14 | m_start = Clock::now(); 15 | } 16 | 17 | Timer::ldouble Timer::time_sec() const 18 | { 19 | return ldouble(time_milli_sec())*1e-3; 20 | } 21 | 22 | Timer::ullint Timer::time_milli_sec() const 23 | { 24 | return std::chrono::duration_cast(time()).count(); 25 | } 26 | 27 | Timer::Duration Timer::time() const 28 | { 29 | return Clock::now()-m_start; 30 | } 31 | 32 | } // namespace pdpc 33 | -------------------------------------------------------------------------------- /src/PDPC/Common/internal/OptionArgument.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | OptionArgument::OptionArgument(const std::string& id, 6 | const std::string& short_id) : 7 | m_id(id), 8 | m_short_id(short_id), 9 | m_brief(""), 10 | m_default_value(""), 11 | m_required(false), 12 | m_found(false) 13 | { 14 | } 15 | 16 | bool OptionArgument::match(const std::string& arg) const 17 | { 18 | return arg == "-" + m_id || (has_short_id() && arg == "-" + m_short_id); 19 | } 20 | 21 | const std::string& OptionArgument::id() const 22 | { 23 | return m_id; 24 | } 25 | 26 | const std::string& OptionArgument::short_id() const 27 | { 28 | return m_short_id; 29 | } 30 | 31 | const std::string& OptionArgument::brief() const 32 | { 33 | return m_brief; 34 | } 35 | 36 | const std::string& OptionArgument::default_value() 37 | { 38 | return m_default_value; 39 | } 40 | 41 | bool OptionArgument::is_required() const 42 | { 43 | return m_required; 44 | } 45 | 46 | bool OptionArgument::is_found() const 47 | { 48 | return m_found; 49 | } 50 | 51 | bool OptionArgument::has_id() const 52 | { 53 | return !m_id.empty(); 54 | } 55 | 56 | bool OptionArgument::has_short_id() const 57 | { 58 | return !m_short_id.empty(); 59 | } 60 | 61 | bool OptionArgument::has_brief() const 62 | { 63 | return !m_brief.empty(); 64 | } 65 | 66 | bool OptionArgument::has_default_value() 67 | { 68 | return !m_default_value.empty(); 69 | } 70 | 71 | void OptionArgument::set_found() 72 | { 73 | m_found = true; 74 | } 75 | 76 | } // namespace pdpc 77 | -------------------------------------------------------------------------------- /src/PDPC/Common/internal/OptionArgument.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | class Option; 8 | 9 | class OptionArgument 10 | { 11 | friend class Option; 12 | friend std::ostream& operator<<(std::ostream&, const Option&); 13 | 14 | public: 15 | virtual std::string to_string() const = 0; 16 | 17 | protected: 18 | OptionArgument(const std::string& id, 19 | const std::string& short_id = ""); 20 | 21 | public: 22 | virtual ~OptionArgument(){}; 23 | 24 | bool match(const std::string &arg) const; 25 | 26 | protected: 27 | const std::string& id() const; 28 | const std::string& short_id() const; 29 | const std::string& brief() const; 30 | const std::string& default_value(); 31 | bool is_required() const; 32 | bool is_found() const; 33 | 34 | protected: 35 | bool has_id() const; 36 | bool has_short_id() const; 37 | bool has_brief() const; 38 | bool has_default_value(); 39 | 40 | protected: 41 | void set_found(); 42 | 43 | protected: 44 | std::string m_id; 45 | std::string m_short_id; 46 | std::string m_brief; 47 | std::string m_default_value; 48 | bool m_required; 49 | bool m_found; 50 | }; 51 | 52 | } // namespace pdpc 53 | -------------------------------------------------------------------------------- /src/PDPC/Common/internal/OptionArgumentT.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace pdpc { 8 | 9 | template 10 | class OptionArgumentT final : public OptionArgument 11 | { 12 | friend class Option; 13 | 14 | public: 15 | OptionArgumentT& set_required(); 16 | OptionArgumentT& set_brief(const std::string& brief); 17 | OptionArgumentT& set_default(T value); 18 | 19 | operator T() const; 20 | 21 | std::string to_string() const override; 22 | 23 | protected: 24 | OptionArgumentT(const std::string& id, 25 | const std::string& short_id = ""); 26 | 27 | void set_value(const T& value); 28 | void set(const std::string& str); 29 | 30 | template 31 | static std::string to_string(const U& value); 32 | static std::string to_string(const std::string& value); 33 | 34 | protected: 35 | T m_value; 36 | }; 37 | 38 | } // namespace pdpc 39 | 40 | #include 41 | -------------------------------------------------------------------------------- /src/PDPC/Common/internal/OptionArgumentT.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | template 6 | OptionArgumentT& OptionArgumentT::set_required() 7 | { 8 | m_required = true; 9 | return *this; 10 | } 11 | 12 | template 13 | OptionArgumentT& OptionArgumentT::set_brief(const std::string& brief) 14 | { 15 | m_brief = brief; 16 | return *this; 17 | } 18 | 19 | template 20 | OptionArgumentT& OptionArgumentT::set_default(T value) 21 | { 22 | if(!m_found) 23 | { 24 | m_value = value; 25 | } 26 | m_default_value = to_string(value); 27 | return *this; 28 | } 29 | 30 | template 31 | OptionArgumentT::operator T() const 32 | { 33 | return m_value; 34 | } 35 | 36 | template 37 | std::string OptionArgumentT::to_string() const 38 | { 39 | std::stringstream str; 40 | str << m_value; 41 | return str.str(); 42 | } 43 | 44 | template 45 | OptionArgumentT::OptionArgumentT(const std::string& id, 46 | const std::string& short_id) : 47 | OptionArgument(id, short_id), 48 | m_value() 49 | { 50 | } 51 | 52 | template 53 | void OptionArgumentT::set_value(const T& value) 54 | { 55 | m_value = value; 56 | } 57 | 58 | template 59 | void OptionArgumentT::set(const std::string& str) 60 | { 61 | std::stringstream stream(str); 62 | stream >> m_value; 63 | } 64 | 65 | template 66 | template 67 | std::string OptionArgumentT::to_string(const U& value) 68 | { 69 | std::stringstream str; 70 | str << value; 71 | return str.str(); 72 | } 73 | 74 | template 75 | std::string OptionArgumentT::to_string(const std::string& value) 76 | { 77 | return value; 78 | } 79 | 80 | } // namespace pdpc 81 | -------------------------------------------------------------------------------- /src/PDPC/Common/internal/OptionVectorArgumentT.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace pdpc { 9 | 10 | template 11 | class OptionVectorArgumentT final : public OptionArgument 12 | { 13 | friend class Option; 14 | 15 | public: 16 | OptionVectorArgumentT& set_required(); 17 | OptionVectorArgumentT& set_brief(const std::string& brief); 18 | // OptionVectorArgumentT& set_default(T value); 19 | 20 | operator std::vector() const; 21 | 22 | std::string to_string() const override; 23 | 24 | protected: 25 | OptionVectorArgumentT(const std::string& id, 26 | const std::string& short_id = ""); 27 | 28 | // void set_value(const T& value); 29 | void add(const std::string& str); 30 | 31 | // template 32 | // static std::string to_string(const U& value); 33 | // static std::string to_string(const std::string& value); 34 | 35 | protected: 36 | std::vector m_values; 37 | }; 38 | 39 | } // namespace pdpc 40 | 41 | #include 42 | -------------------------------------------------------------------------------- /src/PDPC/Common/internal/OptionVectorArgumentT.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | template 6 | OptionVectorArgumentT& OptionVectorArgumentT::set_required() 7 | { 8 | m_required = true; 9 | return *this; 10 | } 11 | 12 | template 13 | OptionVectorArgumentT& OptionVectorArgumentT::set_brief(const std::string& brief) 14 | { 15 | m_brief = brief; 16 | return *this; 17 | } 18 | 19 | //template 20 | //OptionVectorArgumentT& OptionVectorArgumentT::set_default(T value) 21 | //{ 22 | // if(!m_found) 23 | // { 24 | // m_value = value; 25 | // } 26 | // m_default_value = to_string(value); 27 | // return *this; 28 | //} 29 | 30 | template 31 | OptionVectorArgumentT::operator std::vector() const 32 | { 33 | return m_values; 34 | } 35 | 36 | template 37 | std::string OptionVectorArgumentT::to_string() const 38 | { 39 | std::stringstream str; 40 | for(const auto& val : m_values) 41 | str << val << " "; 42 | return str.str(); 43 | } 44 | 45 | template 46 | OptionVectorArgumentT::OptionVectorArgumentT(const std::string& id, 47 | const std::string& short_id) : 48 | OptionArgument(id, short_id), 49 | m_values() 50 | { 51 | } 52 | 53 | //template 54 | //void OptionVectorArgumentT::set_value(const T& value) 55 | //{ 56 | // m_value = value; 57 | //} 58 | 59 | template 60 | void OptionVectorArgumentT::add(const std::string& str) 61 | { 62 | std::stringstream stream(str); 63 | T val; 64 | stream >> val; 65 | m_values.push_back(val); 66 | } 67 | 68 | //template 69 | //template 70 | //std::string OptionVectorArgumentT::to_string(const U& value) 71 | //{ 72 | // std::stringstream str; 73 | // str << value; 74 | // return str.str(); 75 | //} 76 | 77 | //template 78 | //std::string OptionVectorArgumentT::to_string(const std::string& value) 79 | //{ 80 | // return value; 81 | //} 82 | 83 | } // namespace pdpc 84 | -------------------------------------------------------------------------------- /src/PDPC/Graph/Edge.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | struct Edge 6 | { 7 | int source; 8 | int target; 9 | 10 | inline bool operator == (const Edge& edge) const 11 | { 12 | return source == edge.source && target == edge.target; 13 | } 14 | }; 15 | 16 | } // namespace pdpc 17 | -------------------------------------------------------------------------------- /src/PDPC/Graph/Node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | struct Node 8 | { 9 | std::vector in; 10 | std::vector out; 11 | 12 | inline bool operator == (const Node& node) const 13 | { 14 | return in == node.in && out == node.out; 15 | } 16 | }; 17 | 18 | } // namespace pdpc 19 | -------------------------------------------------------------------------------- /src/PDPC/MultiScaleFeatures/MultiScaleFeatures.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace pdpc { 7 | 8 | class MultiScaleFeatures 9 | { 10 | public: 11 | MultiScaleFeatures(int point_count = 0, int scale_count = 0); 12 | 13 | public: 14 | bool save(const std::string& filename, bool verbose = true) const; 15 | bool load(const std::string& filename, bool verbose = true); 16 | 17 | public: 18 | void clear(); 19 | void resize(int point_count, int scale_count); 20 | 21 | public: 22 | inline const Vector3& normal(int i, int j) const; 23 | inline Vector3& normal(int i, int j); 24 | 25 | inline const Vector2& curvatures(int i, int j) const; 26 | inline Vector2& curvatures(int i, int j); 27 | 28 | inline const Scalar& k1(int i, int j) const; 29 | inline Scalar& k1(int i, int j); 30 | 31 | inline const Scalar& k2(int i, int j) const; 32 | inline Scalar& k2(int i, int j); 33 | 34 | inline Scalar plane_dev(int i, int j) const; 35 | 36 | public: 37 | inline int index(int i, int j) const; 38 | 39 | public: 40 | int m_point_count; 41 | int m_scale_count; 42 | std::vector m_normals; 43 | std::vector m_curvatures; 44 | }; 45 | 46 | } // namespace pdpc 47 | 48 | #include 49 | -------------------------------------------------------------------------------- /src/PDPC/MultiScaleFeatures/MultiScaleFeatures.inl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | const Vector3& MultiScaleFeatures::normal(int i, int j) const 6 | { 7 | return m_normals[index(i,j)]; 8 | } 9 | 10 | Vector3& MultiScaleFeatures::normal(int i, int j) 11 | { 12 | return m_normals[index(i,j)]; 13 | } 14 | 15 | const Vector2& MultiScaleFeatures::curvatures(int i, int j) const 16 | { 17 | return m_curvatures[index(i,j)]; 18 | } 19 | 20 | Vector2& MultiScaleFeatures::curvatures(int i, int j) 21 | { 22 | return m_curvatures[index(i,j)]; 23 | } 24 | 25 | const Scalar& MultiScaleFeatures::k1(int i, int j) const 26 | { 27 | return curvatures(i,j)[0]; 28 | } 29 | 30 | Scalar& MultiScaleFeatures::k1(int i, int j) 31 | { 32 | return curvatures(i,j)[0]; 33 | } 34 | 35 | const Scalar& MultiScaleFeatures::k2(int i, int j) const 36 | { 37 | return curvatures(i,j)[1]; 38 | } 39 | 40 | Scalar& MultiScaleFeatures::k2(int i, int j) 41 | { 42 | return curvatures(i,j)[1]; 43 | } 44 | 45 | int MultiScaleFeatures::index(int i, int j) const 46 | { 47 | PDPC_DEBUG_ASSERT(0 <= i && i < m_point_count); 48 | PDPC_DEBUG_ASSERT(0 <= j && j < m_scale_count); 49 | return j * m_point_count + i; 50 | } 51 | 52 | Scalar MultiScaleFeatures::plane_dev(int i, int j) const 53 | { 54 | return std::sqrt( k1(i,j)*k1(i,j) + k2(i,j)*k2(i,j) ); 55 | } 56 | 57 | } // namespace pdpc 58 | -------------------------------------------------------------------------------- /src/PDPC/Persistence/Component.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace pdpc { 7 | 8 | class Component 9 | { 10 | // Component --------------------------------------------------------------- 11 | public: 12 | Component(); 13 | Component(int index); 14 | Component(int birth_level, int index); 15 | 16 | bool is_valid() const; 17 | 18 | // IO ---------------------------------------------------------------------- 19 | public: 20 | std::ostream& write(std::ostream& os) const; 21 | std::istream& read(std::istream& is); 22 | 23 | // Accessors --------------------------------------------------------------- 24 | public: 25 | int size() const; 26 | bool empty() const; 27 | 28 | int birth_level() const; 29 | int death_level() const; 30 | int persistence() const; 31 | 32 | int index(int level) const; 33 | int operator[] (int level) const; 34 | 35 | int level_at(int i) const; 36 | int index_at(int i) const; 37 | 38 | // Modifiers --------------------------------------------------------------- 39 | public: 40 | void clear(); 41 | 42 | void set_index(int level, int index); 43 | void push_back(int index); 44 | 45 | void initialize(int birth_level, int index); 46 | 47 | void reserve(int cap); 48 | 49 | // Internal ---------------------------------------------------------------- 50 | protected: 51 | int index_at_level(int level) const; 52 | int& index_at_level(int level); 53 | 54 | // Data -------------------------------------------------------------------- 55 | protected: 56 | int m_birth_level; 57 | std::vector m_indices; 58 | 59 | }; // class Component 60 | 61 | } // namespace pdpc 62 | 63 | -------------------------------------------------------------------------------- /src/PDPC/Persistence/ComponentDataSet.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | namespace pdpc { 8 | 9 | ComponentDataSet::ComponentDataSet(const ComponentSet& comp_set, RegionSet&& reg_set) : 10 | m_data(comp_set.size()) 11 | { 12 | for(int i=0; isize(); ++i) 30 | { 31 | const auto& comp = m_data[i]; 32 | 33 | ofs << comp.birth_level() 34 | << " " 35 | << comp.death_level() 36 | << " "; 37 | 38 | for(int idx : comp.indices()) 39 | ofs << idx << " "; 40 | 41 | ofs << "\n"; 42 | } 43 | 44 | return true; 45 | } 46 | 47 | bool ComponentDataSet::load(const std::string& filename) 48 | { 49 | std::ifstream ifs(filename); 50 | if(!ifs.is_open()) 51 | { 52 | warning() << "Failed to open input file " << filename; 53 | return false; 54 | } 55 | 56 | std::string line; 57 | while(std::getline(ifs, line)) 58 | { 59 | m_data.push_back(ComponentData()); 60 | auto& comp = m_data.back(); 61 | 62 | std::stringstream str(line); 63 | 64 | str >> comp.m_birth; 65 | str >> comp.m_death; 66 | 67 | int i; 68 | while(str >> i) comp.indices().push_back(i); 69 | } 70 | 71 | return true; 72 | } 73 | 74 | } // namespace pdpc 75 | -------------------------------------------------------------------------------- /src/PDPC/Persistence/ComponentDataSet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace pdpc { 7 | 8 | class ComponentSet; 9 | class RegionSet; 10 | 11 | class ComponentData 12 | { 13 | public: 14 | inline ComponentData() = default; 15 | inline ComponentData(int birth, int death) : m_birth(birth), m_death(death), m_indices() {} 16 | 17 | inline int birth_level() const {return m_birth;} 18 | inline int death_level() const {return m_death;} 19 | inline int persistence() const {return m_death - m_birth;} 20 | 21 | inline int size() const {return m_indices.size();} 22 | 23 | inline const std::vector& indices() const {return m_indices;} 24 | inline std::vector& indices() {return m_indices;} 25 | 26 | public: 27 | int m_birth; 28 | int m_death; 29 | std::vector m_indices; 30 | }; 31 | 32 | // ============================================================================= 33 | // ============================================================================= 34 | // ============================================================================= 35 | 36 | class ComponentDataSet 37 | { 38 | public: 39 | ComponentDataSet() = default; 40 | ComponentDataSet(const ComponentSet& comp_set, RegionSet&& reg_set); 41 | 42 | bool save(const std::string& filename) const; 43 | bool load(const std::string& filename); 44 | 45 | inline int size() const {return m_data.size();} 46 | 47 | inline const ComponentData& operator[](int i) const {return m_data[i];} 48 | inline ComponentData& operator[](int i) {return m_data[i];} 49 | 50 | public: 51 | std::vector m_data; 52 | }; 53 | 54 | } // namespace pdpc 55 | -------------------------------------------------------------------------------- /src/PDPC/Persistence/ComponentSet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace pdpc { 7 | 8 | class ComponentSet 9 | { 10 | // ComponentSet ------------------------------------------------------------ 11 | public: 12 | ComponentSet(); 13 | ComponentSet(int size); 14 | 15 | bool is_valid() const; 16 | 17 | // IO ---------------------------------------------------------------------- 18 | public: 19 | std::ostream& write(std::ostream& os) const; 20 | std::istream& read(std::istream& is); 21 | 22 | // Accessors --------------------------------------------------------------- 23 | public: 24 | int size() const; 25 | bool empty() const; 26 | 27 | const Component& component(int i) const; 28 | Component& component(int i); 29 | 30 | const Component& operator[](int i) const; 31 | Component& operator[](int i); 32 | 33 | const Component& back() const; 34 | Component& back(); 35 | 36 | const Component& front() const; 37 | Component& front(); 38 | 39 | const std::vector& data() const; 40 | std::vector& data(); 41 | 42 | const property_map& properties() const; 43 | property_map& properties(); 44 | 45 | // Modifiers --------------------------------------------------------------- 46 | public: 47 | void clear(); 48 | void resize(int count); 49 | void push_back(); 50 | 51 | // Data -------------------------------------------------------------------- 52 | protected: 53 | std::vector m_components; 54 | property_map m_properties; 55 | 56 | }; // class ComponentSet 57 | 58 | } // namespace pdpc 59 | -------------------------------------------------------------------------------- /src/PDPC/PointCloud/Loader.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | namespace pdpc { 8 | 9 | bool Loader::Load(const std::string& filename, PointCloud& g, bool verbose) 10 | { 11 | const std::string ext = filename.substr(filename.find_last_of(".") + 1); 12 | if(ext == "obj") 13 | { 14 | return OBJ::load(filename, g, verbose); 15 | } 16 | else if(ext == "ply") 17 | { 18 | return PLY::load(filename, g, verbose); 19 | } 20 | else 21 | { 22 | error() << "Missing or unsupported extension for file " << filename; 23 | return false; 24 | } 25 | } 26 | 27 | bool Loader::Save(const std::string& filename, const PointCloud& g, bool verbose) 28 | { 29 | const std::string ext = filename.substr(filename.find_last_of(".") + 1); 30 | if(ext == "obj") 31 | { 32 | return OBJ::save(filename, g, verbose); 33 | } 34 | else if(ext == "ply") 35 | { 36 | return PLY::save(filename, g, verbose); 37 | } 38 | else 39 | { 40 | return PLY::save(filename + ".ply", g, verbose); 41 | } 42 | } 43 | 44 | } // namespace pdpc 45 | -------------------------------------------------------------------------------- /src/PDPC/PointCloud/Loader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | class PointCloud; 8 | 9 | class Loader 10 | { 11 | public: 12 | static bool Load(const std::string& filename, PointCloud& g, bool verbose = true); 13 | static bool Save(const std::string& filename, const PointCloud& g, bool verbose = true); 14 | 15 | }; 16 | 17 | } // namespace pdpc 18 | -------------------------------------------------------------------------------- /src/PDPC/PointCloud/OBJ.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | class PointCloud; 8 | 9 | class OBJ 10 | { 11 | public: 12 | static bool load(const std::string& filename, PointCloud& g, bool verbose = true); 13 | static bool load(const std::string& filename, PointCloud& g, std::string& texture, bool verbose = true); 14 | static bool load_soup(const std::string& filename, PointCloud& g, bool verbose = true); 15 | static bool load_soup(const std::string& filename, PointCloud& g, std::string& texture, bool verbose = true); 16 | static bool save(const std::string& filename, const PointCloud& g, bool verbose = true); 17 | static bool save(const std::string& filename, const PointCloud& g, const std::string& texture, bool verbose = true); 18 | }; 19 | 20 | } // namespace pdpc 21 | -------------------------------------------------------------------------------- /src/PDPC/PointCloud/PLY.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | class PointCloud; 8 | 9 | class PLY 10 | { 11 | public: 12 | static bool load(const std::string& filename, PointCloud& g, bool verbose = true); 13 | static bool save(const std::string& filename, const PointCloud& g, bool verbose = true, bool binary = true); 14 | }; 15 | 16 | } // namespace pdpc 17 | -------------------------------------------------------------------------------- /src/PDPC/PointCloud/Point.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace pdpc { 5 | 6 | ConstPoint::ConstPoint() : 7 | m_point_cloud(nullptr), 8 | m_index(-1) 9 | { 10 | } 11 | 12 | ConstPoint::ConstPoint(const PointCloud* point_cloud, int index) : 13 | m_point_cloud(point_cloud), 14 | m_index(index) 15 | { 16 | } 17 | 18 | int ConstPoint::index() const 19 | { 20 | return m_index; 21 | } 22 | 23 | int& ConstPoint::index() 24 | { 25 | return m_index; 26 | } 27 | 28 | const Vector3& ConstPoint::pos() const 29 | { 30 | return m_point_cloud->point(m_index); 31 | } 32 | 33 | const Vector3& ConstPoint::point() const 34 | { 35 | return m_point_cloud->point(m_index); 36 | } 37 | 38 | const Vector3& ConstPoint::normal() const 39 | { 40 | return m_point_cloud->normal(m_index); 41 | } 42 | 43 | const Vector4& ConstPoint::color() const 44 | { 45 | return m_point_cloud->color(m_index); 46 | } 47 | 48 | //////////////////////////////////////////////////////////////////////////////// 49 | 50 | Point::Point() : 51 | ConstPoint() 52 | { 53 | } 54 | 55 | Point::Point(PointCloud* point_cloud, int index) : 56 | ConstPoint(point_cloud, index) 57 | { 58 | } 59 | 60 | Vector3& Point::pos() 61 | { 62 | return point_cloud()->point(m_index); 63 | } 64 | 65 | Vector3& Point::point() 66 | { 67 | return point_cloud()->point(m_index); 68 | } 69 | 70 | Vector3& Point::normal() 71 | { 72 | return point_cloud()->normal(m_index); 73 | } 74 | 75 | Vector4& Point::color() 76 | { 77 | return point_cloud()->color(m_index); 78 | } 79 | 80 | const Vector3& Point::pos() const 81 | { 82 | return m_point_cloud->point(m_index); 83 | } 84 | 85 | const Vector3& Point::point() const 86 | { 87 | return m_point_cloud->point(m_index); 88 | } 89 | 90 | const Vector3& Point::normal() const 91 | { 92 | return m_point_cloud->normal(m_index); 93 | } 94 | 95 | const Vector4& Point::color() const 96 | { 97 | return m_point_cloud->color(m_index); 98 | } 99 | 100 | PointCloud* Point::point_cloud() 101 | { 102 | return const_cast(m_point_cloud); 103 | } 104 | 105 | } // namespace pdpc 106 | -------------------------------------------------------------------------------- /src/PDPC/PointCloud/Point.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | class PointCloud; 8 | 9 | class ConstPoint 10 | { 11 | public: 12 | enum{ Dim = 3}; 13 | using Scalar = pdpc::Scalar; 14 | using VectorType = Vector3; 15 | using MatrixType = Matrix3; 16 | 17 | public: 18 | ConstPoint(); 19 | ConstPoint(const PointCloud* point_cloud, int index); 20 | 21 | public: 22 | int index() const; 23 | int& index(); 24 | 25 | public: 26 | const Vector3& pos() const; 27 | const Vector3& point() const; 28 | const Vector3& normal() const; 29 | const Vector4& color() const; 30 | 31 | protected: 32 | const PointCloud* m_point_cloud; 33 | int m_index; 34 | }; 35 | 36 | //////////////////////////////////////////////////////////////////////////////// 37 | 38 | class Point : public ConstPoint 39 | { 40 | public: 41 | Point(); 42 | Point(PointCloud* point_cloud, int index); 43 | 44 | public: 45 | Vector3& pos(); 46 | Vector3& point(); 47 | Vector3& normal(); 48 | Vector4& color(); 49 | 50 | public: 51 | const Vector3& pos() const; 52 | const Vector3& point() const; 53 | const Vector3& normal() const; 54 | const Vector4& color() const; 55 | 56 | protected: 57 | PointCloud* point_cloud(); 58 | }; 59 | 60 | } // namespace pdpc 61 | -------------------------------------------------------------------------------- /src/PDPC/PointCloud/orthonormal_basis.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | //! 8 | //! \brief compute an orthonormal basis {u,v,w} in 3D given w (normalized) 9 | //! 10 | inline void orthonormal_basis(Vector3& u, Vector3& v, const Vector3& w); 11 | inline Matrix3 orthonormal_basis(const Vector3& w); 12 | 13 | //////////////////////////////////////////////////////////////////////////////// 14 | //////////////////////////////////////////////////////////////////////////////// 15 | //////////////////////////////////////////////////////////////////////////////// 16 | 17 | void orthonormal_basis(Vector3& u, Vector3& v, const Vector3& w) 18 | { 19 | // i0: dimension where w extends the least 20 | int i0 = (std::abs(w[0] ) < std::abs(w[1])) ? 0 : 1; 21 | i0 = (std::abs(w[i0]) < std::abs(w[2])) ? i0 : 2; 22 | int i1 = (i0 + 1) % 3; 23 | int i2 = (i0 + 2) % 3; 24 | 25 | // setting the i0-th coordinate of u to zero ensure that u is not null 26 | u[i0] = 0; 27 | u[i1] = w[i2]; 28 | u[i2] = -w[i1]; 29 | 30 | // normalize u 31 | u /= std::sqrt(u[i1] * u[i1] + u[i2] * u[i2]); 32 | 33 | v = w.cross(u); 34 | } 35 | 36 | Matrix3 orthonormal_basis(const Vector3& w) 37 | { 38 | Matrix3 M; 39 | M.col(2) = w; 40 | 41 | // i0: dimension where w extends the least 42 | int i0 = (std::abs(w[0] ) < std::abs(w[1])) ? 0 : 1; 43 | i0 = (std::abs(w[i0]) < std::abs(w[2])) ? i0 : 2; 44 | int i1 = (i0 + 1) % 3; 45 | int i2 = (i0 + 2) % 3; 46 | 47 | // setting the i0-th coordinate of u to zero ensure that u is not null 48 | M.col(0)[i0] = 0; 49 | M.col(0)[i1] = w[i2]; 50 | M.col(0)[i2] = -w[i1]; 51 | 52 | // normalize u 53 | M.col(0) /= std::sqrt(M.col(0)[i1] * M.col(0)[i1] + M.col(0)[i2] * M.col(0)[i2]); 54 | 55 | M.col(1) = w.cross(M.col(0)); 56 | 57 | return M; 58 | } 59 | 60 | } // namespace pdpc 61 | -------------------------------------------------------------------------------- /src/PDPC/PointCloud/triangle_area.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | template 6 | T triangle_area(T x1, T y1, T x2, T y2, T x3, T y3) 7 | { 8 | const T ux = x2 - x1; 9 | const T uy = y2 - y1; 10 | const T vx = x3 - x1; 11 | const T vy = y3 - y1; 12 | 13 | return T(0.5) * (ux*vy - uy*vx); 14 | } 15 | 16 | } // namespace pdpc 17 | -------------------------------------------------------------------------------- /src/PDPC/RIMLS/RIMLSOperator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace pdpc { 11 | 12 | class KdTreeRangePointQuery; 13 | class PointCloud; 14 | 15 | // ============================================================================= 16 | 17 | class RIMLSOperator 18 | { 19 | // Types ------------------------------------------------------------------- 20 | public: 21 | using Point = RIMLSPoint; 22 | using WeightKernel = Ponca::SmoothWeightKernel; 23 | using WeightFunc = RIMLSWeightFunc; 24 | using FitStep = Ponca::Basket; 25 | using FitFinal = Ponca::Basket; 29 | 30 | // MLSOperator ------------------------------------------------------------- 31 | public: 32 | RIMLSOperator(); 33 | RIMLSOperator(const RIMLSOperator& other); 34 | ~RIMLSOperator(); 35 | 36 | void compute(const PointCloud& points, Vector3& point); 37 | 38 | // Parameters -------------------------------------------------------------- 39 | public: 40 | void set_scale(Scalar scale); 41 | void set_step_max(int step_max); 42 | void set_convergence_ratio_min(Scalar convergence_ratio_min); 43 | 44 | void set_reweighting_sigma(Scalar sigma); 45 | void set_reweighting_step(int step); 46 | 47 | // Accessors --------------------------------------------------------------- 48 | public: 49 | bool stable() const; 50 | const FitFinal& fit() const; 51 | FitFinal& fit(); 52 | 53 | // Data -------------------------------------------------------------------- 54 | protected: 55 | Scalar m_scale; 56 | 57 | Scalar m_reweighting_sigma; //TODO this is never used... 58 | int m_reweighting_step; 59 | 60 | int m_step_max; 61 | Scalar m_convergence_ratio_min; 62 | 63 | int m_step; 64 | bool m_stable; 65 | int m_neighbor_count; 66 | 67 | WeightFunc m_weight_func; 68 | FitStep m_fit_step; 69 | FitFinal m_fit_final; 70 | 71 | std::unique_ptr m_query; 72 | }; 73 | 74 | } // namespace pdpc 75 | -------------------------------------------------------------------------------- /src/PDPC/RIMLS/RIMLSPoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | template 6 | class RIMLSPoint 7 | { 8 | public: 9 | enum {Dim = VectorT::RowsAtCompileTime}; 10 | using VectorType = VectorT; 11 | using Scalar = typename VectorT::Scalar; 12 | using MatrixType = Eigen::Matrix; 13 | using HVectorType = Eigen::Matrix; 14 | 15 | public: 16 | inline RIMLSPoint(const VectorType& pos, 17 | const VectorType& normal, 18 | Scalar gradientDiff, 19 | Scalar potentialDiff) : 20 | m_pos(pos.data()), 21 | m_normal(normal.data()), 22 | m_gradientDiff(gradientDiff), 23 | m_potentialDiff(potentialDiff) 24 | { 25 | } 26 | 27 | inline const Eigen::Map& pos() const {return m_pos;} 28 | inline const Eigen::Map& normal() const {return m_normal;} 29 | 30 | inline Scalar gradientDiff() const {return m_gradientDiff;} 31 | inline Scalar potentialDiff() const {return m_potentialDiff;} 32 | 33 | protected: 34 | Eigen::Map m_pos; 35 | Eigen::Map m_normal; 36 | Scalar m_gradientDiff; 37 | Scalar m_potentialDiff; 38 | }; 39 | 40 | } // namespace pdpc 41 | -------------------------------------------------------------------------------- /src/PDPC/RIMLS/RIMLSWeightFunc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | template 8 | class RIMLSWeightFunc 9 | { 10 | public: 11 | using Scalar = typename DataPoint::Scalar; 12 | using VectorType = typename DataPoint::VectorType; 13 | using MatrixType = typename DataPoint::MatrixType; 14 | 15 | public: 16 | inline RIMLSWeightFunc(Scalar t = 1, Scalar sigma = 1); 17 | 18 | public: 19 | inline Scalar w(const VectorType& _q, const DataPoint& attributes) const; 20 | 21 | inline VectorType spacedw(const VectorType& _q, const DataPoint& attributes) const; 22 | inline MatrixType spaced2w(const VectorType& _q, const DataPoint& attributes) const; 23 | 24 | inline Scalar scaledw(const VectorType& _q, const DataPoint& attributes) const; 25 | inline Scalar scaled2w(const VectorType& _q, const DataPoint& attributes) const; 26 | 27 | inline VectorType scaleSpaced2w(const VectorType& _q, const DataPoint& attributes) const; 28 | 29 | inline Scalar evalScale() const; 30 | 31 | private: 32 | inline Scalar reweight(const VectorType& _q, const DataPoint& attributes) const; 33 | 34 | protected: 35 | Ponca::DistWeightFunc m_weightFunc; 36 | Scalar m_invSigma2; 37 | Scalar m_invSigmaScale2; 38 | }; 39 | 40 | } // namespace pdpc 41 | 42 | #include 43 | -------------------------------------------------------------------------------- /src/PDPC/RIMLS/RIMLSWeightFunc.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | template 6 | RIMLSWeightFunc::RIMLSWeightFunc(Scalar t, Scalar sigma) : 7 | m_weightFunc(t), 8 | m_invSigma2(Scalar(1)/(sigma*sigma)), 9 | m_invSigmaScale2(Scalar(1)/(0.5*t * 0.5*t)) 10 | { 11 | } 12 | 13 | template 14 | typename RIMLSWeightFunc::Scalar 15 | RIMLSWeightFunc::w(const VectorType& _q, const P& attributes) const 16 | { 17 | return reweight(_q, attributes) * m_weightFunc.w(_q, attributes); 18 | } 19 | 20 | template 21 | typename RIMLSWeightFunc::VectorType 22 | RIMLSWeightFunc::spacedw(const VectorType& _q, const P& attributes) const 23 | { 24 | return reweight(_q, attributes) * m_weightFunc.spacedw(_q, attributes); 25 | } 26 | 27 | template 28 | typename RIMLSWeightFunc::MatrixType 29 | RIMLSWeightFunc::spaced2w(const VectorType& _q, const P& attributes) const 30 | { 31 | return reweight(_q, attributes) * m_weightFunc.spaced2w(_q, attributes); 32 | } 33 | 34 | template 35 | typename RIMLSWeightFunc::Scalar 36 | RIMLSWeightFunc::scaledw(const VectorType& _q, const P& attributes) const 37 | { 38 | return reweight(_q, attributes) * m_weightFunc.scaledw(_q, attributes); 39 | } 40 | 41 | template 42 | typename RIMLSWeightFunc::Scalar 43 | RIMLSWeightFunc::scaled2w(const VectorType& _q, const P& attributes) const 44 | { 45 | return reweight(_q, attributes) * m_weightFunc.scaled2w(_q, attributes); 46 | } 47 | 48 | template 49 | typename RIMLSWeightFunc::VectorType 50 | RIMLSWeightFunc::scaleSpaced2w(const VectorType& _q, const P& attributes) const 51 | { 52 | return reweight(_q, attributes) * m_weightFunc.scaleSpaced2w(_q, attributes); 53 | } 54 | 55 | template 56 | typename RIMLSWeightFunc::Scalar 57 | RIMLSWeightFunc::evalScale() const 58 | { 59 | return m_weightFunc.evalScale(); 60 | } 61 | 62 | template 63 | typename RIMLSWeightFunc::Scalar 64 | RIMLSWeightFunc::reweight(const VectorType& /*_q*/, const P& attributes) const 65 | { 66 | return exp(-attributes.gradientDiff() * attributes.gradientDiff() * m_invSigma2 67 | -attributes.potentialDiff() * attributes.potentialDiff() * m_invSigmaScale2); 68 | } 69 | 70 | } // namespace pdpc 71 | -------------------------------------------------------------------------------- /src/PDPC/ScaleSpace/ScaleSampling.inl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | // Modifiers ------------------------------------------------------------------- 6 | 7 | void ScaleSampling::clear() 8 | { 9 | m_scales.clear(); 10 | } 11 | 12 | void ScaleSampling::resize(int size) 13 | { 14 | m_scales.resize(size); 15 | } 16 | 17 | void ScaleSampling::multiply(Scalar s) 18 | { 19 | for(Scalar& scale : m_scales) 20 | { 21 | scale *= s; 22 | } 23 | } 24 | 25 | void ScaleSampling::multiply_by(Scalar s) 26 | { 27 | for(Scalar& scale : m_scales) 28 | { 29 | scale *= s; 30 | } 31 | } 32 | 33 | // Accessors ------------------------------------------------------------------- 34 | 35 | int ScaleSampling::size() const 36 | { 37 | return m_scales.size(); 38 | } 39 | 40 | bool ScaleSampling::empty() const 41 | { 42 | return m_scales.empty(); 43 | } 44 | 45 | const Scalar& ScaleSampling::operator [] (int i) const 46 | { 47 | return m_scales[i]; 48 | } 49 | 50 | Scalar& ScaleSampling::operator [] (int i) 51 | { 52 | return m_scales[i]; 53 | } 54 | 55 | const ScaleSampling::ScalarArray& ScaleSampling::scales() const 56 | { 57 | return m_scales; 58 | } 59 | 60 | ScaleSampling::ScalarArray& ScaleSampling::scales() 61 | { 62 | return m_scales; 63 | } 64 | 65 | // Basic info ------------------------------------------------------------------ 66 | 67 | const Scalar& ScaleSampling::min() const 68 | { 69 | return m_scales.front(); 70 | } 71 | 72 | const Scalar& ScaleSampling::max() const 73 | { 74 | return m_scales.back(); 75 | } 76 | 77 | Scalar ScaleSampling::range() const 78 | { 79 | return max()-min(); 80 | } 81 | 82 | } // namespace pdpc 83 | -------------------------------------------------------------------------------- /src/PDPC/Segmentation/MSSegmentation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | namespace pdpc { 7 | 8 | // Modifiers ------------------------------------------------------------------- 9 | 10 | void MSSegmentation::make_continuous() 11 | { 12 | for_each([](auto& seg){seg.make_continuous();}); 13 | } 14 | 15 | void MSSegmentation::make_valid(int l) 16 | { 17 | for_each([l](auto& seg){seg.make_valid(l);}); 18 | } 19 | 20 | bool MSSegmentation::is_valid() const 21 | { 22 | for(const Segmentation& seg : m_data) 23 | { 24 | if(!seg.is_valid()) 25 | return false; 26 | } 27 | return true; 28 | } 29 | 30 | bool MSSegmentation::load(const std::string& filename) 31 | { 32 | std::ifstream ifs(filename); 33 | if(!ifs.is_open()) 34 | { 35 | warning() << "Failed to open output file " << filename; 36 | return false; 37 | } 38 | 39 | int point_count = 0; 40 | int scale_count = 0; 41 | 42 | ifs >> point_count; 43 | ifs >> scale_count; 44 | 45 | PDPC_DEBUG_ASSERT(point_count > 0); 46 | PDPC_DEBUG_ASSERT(scale_count > 0); 47 | 48 | this->resize(scale_count); 49 | 50 | std::vector> labels(scale_count, std::vector(point_count, -1)); 51 | 52 | for(int i=0; i> labels[j][i]; 57 | } 58 | } 59 | for(int j=0; j 4 | #include 5 | 6 | namespace pdpc { 7 | 8 | class MSSegmentation : public ScaleSpaceStack 9 | { 10 | public: 11 | using Base = ScaleSpaceStack; 12 | using Base::Base; 13 | 14 | public: 15 | bool is_valid() const; 16 | 17 | bool load(const std::string& filename); 18 | bool save(const std::string& filename) const; 19 | 20 | // Modifiers --------------------------------------------------------------- 21 | public: 22 | void make_continuous(); 23 | void make_valid(int l = 0); 24 | 25 | }; // class MSSegmentation 26 | 27 | } // namespace pdpc 28 | 29 | -------------------------------------------------------------------------------- /src/PDPC/Segmentation/MSSegmentationGraph.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | class HierarchicalGraph; 6 | class MSSegmentation; 7 | 8 | class MSSegmentationGraph 9 | { 10 | public: 11 | static void create(const MSSegmentation& msSegmentation, HierarchicalGraph& g); 12 | static void reorganize(MSSegmentation& msSegmentation, HierarchicalGraph& g); 13 | 14 | static bool valid(const MSSegmentation& msSegmentation, const HierarchicalGraph& g); 15 | 16 | // Similarities 17 | public: 18 | static float jaccard(const HierarchicalGraph& hgraph, int level_edge, int idx_edge, int prop_size, int prop_weight); 19 | 20 | }; // class MSSegmentationGraph 21 | 22 | } // namespace pdpc 23 | -------------------------------------------------------------------------------- /src/PDPC/Segmentation/RegionSet.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | // RegionSet ------------------------------------------------------------------- 6 | 7 | RegionSet::RegionSet() : 8 | m_regions(), 9 | m_properties() 10 | { 11 | } 12 | 13 | RegionSet::RegionSet(int region_count) : 14 | m_regions(region_count), 15 | m_properties(region_count) 16 | { 17 | } 18 | 19 | // IO -------------------------------------------------------------------------- 20 | 21 | std::ostream& RegionSet::write(std::ostream& os) const 22 | { 23 | int region_count = size(); 24 | IO::write_value(os, region_count); 25 | for(int i=0; i 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace pdpc { 14 | 15 | class SeededKNNGraphRegionGrowing 16 | { 17 | public: 18 | 19 | //! 20 | //! \param comp_f (int l, int i, int j) -> bool return true if region l can grow from element i to j 21 | //! \param priority_f (int i, int j) -> bool return true if element i has priority on element j (for seed selection) 22 | //! \param init_f (int l, int i) -> void called when a new region l is created at element i 23 | //! 24 | template 25 | static void compute(const PointCloud& point_cloud, 26 | Segmentation& segmentation, 27 | CompFuncT&& comp_f, 28 | PriorityCompFunc&& priority_f, 29 | InitFuncT&& init_f, 30 | bool verbose = false); 31 | }; 32 | 33 | } // namespace pdpc 34 | 35 | #include 36 | -------------------------------------------------------------------------------- /src/PDPC/Segmentation/SeededKNNGraphRegionGrowing.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | template 6 | void SeededKNNGraphRegionGrowing::compute(const PointCloud& point_cloud, 7 | Segmentation& segmentation, 8 | CompFuncT&& comp_f, 9 | PriorityCompFunc&& priority_f, 10 | InitFuncT&& init_f, 11 | bool verbose) 12 | { 13 | PDPC_DEBUG_ASSERT(point_cloud.has_knn_graph()); 14 | 15 | // init segmentation 16 | const int size = point_cloud.size(); 17 | segmentation.resize(size); 18 | segmentation.reset(Segmentation::invalid()); 19 | 20 | // init priority queue 21 | std::vector queue(size); 22 | std::iota(queue.begin(), queue.end(), 0); 23 | std::sort(queue.begin(), queue.end(), priority_f); 24 | 25 | // init stack 26 | std::vector stack; 27 | 28 | auto prog = Progress(size, verbose); 29 | 30 | while(!queue.empty()) 31 | { 32 | // get new seed 33 | const int idx_seed = queue.back(); 34 | queue.pop_back(); 35 | 36 | if(segmentation[idx_seed] == Segmentation::invalid()) 37 | { 38 | // init new region 39 | const int new_label = segmentation.new_label(); 40 | segmentation.set_label(idx_seed, new_label); 41 | 42 | init_f(new_label, idx_seed); 43 | stack.push_back(idx_seed); 44 | 45 | // growing 46 | while(!stack.empty()) 47 | { 48 | int idx_point = stack.back(); 49 | stack.pop_back(); 50 | 51 | for(int idx_nei : point_cloud.knn_graph().k_nearest_neighbors(idx_point)) 52 | { 53 | if(segmentation[idx_nei] == Segmentation::invalid()) 54 | { 55 | if(comp_f(new_label, idx_point, idx_nei)) 56 | { 57 | segmentation.set_label(idx_nei, new_label); 58 | stack.push_back(idx_nei); 59 | } 60 | } 61 | } 62 | } 63 | } 64 | ++prog; 65 | } 66 | } 67 | 68 | } // namespace pdpc 69 | -------------------------------------------------------------------------------- /src/PDPC/Segmentation/Segmentation.inl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | // Capacity -------------------------------------------------------------------- 6 | 7 | int Segmentation::size() const 8 | { 9 | return m_labels.size(); 10 | } 11 | 12 | int Segmentation::region_size(int l) const 13 | { 14 | return count(l); 15 | } 16 | 17 | int Segmentation::region_count() const 18 | { 19 | return m_counts.size() - 1; 20 | } 21 | 22 | int Segmentation::label_count() const 23 | { 24 | return m_counts.size() - 1; 25 | } 26 | 27 | int Segmentation::size(int l) const 28 | { 29 | return count(l); 30 | } 31 | 32 | // Accessors ------------------------------------------------------------------- 33 | 34 | int Segmentation::label(int idx) const 35 | { 36 | PDPC_DEBUG_ASSERT(0 <= idx && idx < size()); 37 | return m_labels[idx]; 38 | } 39 | 40 | int Segmentation::operator [](int idx) const 41 | { 42 | PDPC_DEBUG_ASSERT(0 <= idx && idx < size()); 43 | return m_labels[idx]; 44 | } 45 | 46 | bool Segmentation::contains(int l) const 47 | { 48 | return counts_size(l) <= region_count(); 49 | } 50 | 51 | bool Segmentation::is_valid(int idx) const 52 | { 53 | return label(idx) != invalid(); 54 | } 55 | 56 | bool Segmentation::is_invalid(int idx) const 57 | { 58 | return label(idx) == invalid(); 59 | } 60 | 61 | int Segmentation::label_max() const 62 | { 63 | int lmax = label_sup(); 64 | int limit = label_inf(); 65 | while(lmax>=limit && count(lmax)==0) 66 | { 67 | --lmax; 68 | } 69 | return lmax==limit-1 ? invalid()-2 : lmax; 70 | } 71 | 72 | int Segmentation::label_min() const 73 | { 74 | int lmin = label_inf() + 1; 75 | int limit = label_sup(); 76 | while(lmin<=limit && count(lmin)==0) 77 | { 78 | ++lmin; 79 | } 80 | return lmin==limit+1 ? invalid()-1 : lmin; 81 | } 82 | 83 | int Segmentation::label_sup() const 84 | { 85 | return m_counts.size()-2; 86 | } 87 | 88 | int Segmentation::label_inf() const 89 | { 90 | return invalid(); 91 | } 92 | 93 | int Segmentation::invalid_count() const 94 | { 95 | return count(invalid()); 96 | } 97 | 98 | } // namespace pdpc 99 | -------------------------------------------------------------------------------- /src/PDPC/Segmentation/SegmentationIterators.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | class Segmentation; 6 | class RegionIterator; 7 | 8 | class RegionView 9 | { 10 | friend class RegionIterator; 11 | public: 12 | RegionView(const Segmentation& segmentation, int label); 13 | 14 | int label() const; 15 | int size() const; 16 | 17 | protected: 18 | const Segmentation& m_segmentation; 19 | int m_label; 20 | }; 21 | 22 | // ----------------------------------------------------------------------------- 23 | 24 | class RegionIterator 25 | { 26 | public: 27 | RegionIterator(const Segmentation& segmentation, int label); 28 | 29 | RegionIterator operator ++(); 30 | bool operator !=(const RegionIterator& other) const; 31 | const RegionView& operator *() const; 32 | 33 | protected: 34 | RegionView m_region_view; 35 | }; 36 | 37 | // ----------------------------------------------------------------------------- 38 | 39 | class IndexIterator 40 | { 41 | public: 42 | IndexIterator(const Segmentation& segmentation, int label, bool is_begin); 43 | 44 | int label() const; 45 | int index() const; 46 | 47 | IndexIterator operator ++(); 48 | bool operator !=(const IndexIterator& other) const; 49 | int operator *() const; 50 | 51 | protected: 52 | void advance(); 53 | 54 | protected: 55 | const Segmentation& m_segmentation; 56 | int m_label; 57 | int m_index; 58 | }; 59 | 60 | // ----------------------------------------------------------------------------- 61 | 62 | class IndexIteratorView 63 | { 64 | public: 65 | IndexIteratorView(const Segmentation& segmentation, int label); 66 | 67 | IndexIterator begin(); 68 | IndexIterator end(); 69 | 70 | protected: 71 | const Segmentation& m_segmentation; 72 | int m_label; 73 | }; 74 | 75 | } // namespace pdpc 76 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Iterator/KdTreeKNearestIndexIterator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | KdTreeKNearestIndexIterator::KdTreeKNearestIndexIterator() : 6 | m_iterator() 7 | { 8 | } 9 | 10 | KdTreeKNearestIndexIterator::KdTreeKNearestIndexIterator(limited_priority_queue::iterator iterator) : 11 | m_iterator(iterator) 12 | { 13 | } 14 | 15 | bool KdTreeKNearestIndexIterator::operator !=(const KdTreeKNearestIndexIterator& other) const 16 | { 17 | return m_iterator != other.m_iterator; 18 | } 19 | 20 | void KdTreeKNearestIndexIterator::operator ++() 21 | { 22 | ++m_iterator; 23 | } 24 | 25 | int KdTreeKNearestIndexIterator::operator * () const 26 | { 27 | return m_iterator->index; 28 | } 29 | 30 | void KdTreeKNearestIndexIterator::operator +=(int i) 31 | { 32 | m_iterator += i; 33 | } 34 | 35 | } // namespace pdpc 36 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Iterator/KdTreeKNearestIndexIterator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | class KdTreeKNearestIndexIterator 8 | { 9 | public: 10 | KdTreeKNearestIndexIterator(); 11 | KdTreeKNearestIndexIterator(limited_priority_queue::iterator iterator); 12 | 13 | public: 14 | bool operator !=(const KdTreeKNearestIndexIterator& other) const; 15 | void operator ++(); 16 | int operator * () const; 17 | void operator +=(int i); 18 | 19 | protected: 20 | limited_priority_queue::iterator m_iterator; 21 | }; 22 | 23 | } // namespace pdpc 24 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Iterator/KdTreeKNearestPointIterator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | KdTreeKNearestPointIterator::KdTreeKNearestPointIterator() : 6 | m_iterator() 7 | { 8 | } 9 | 10 | KdTreeKNearestPointIterator::KdTreeKNearestPointIterator(limited_priority_queue::iterator iterator) : 11 | m_iterator(iterator) 12 | { 13 | } 14 | 15 | bool KdTreeKNearestPointIterator::operator !=(const KdTreeKNearestPointIterator& other) const 16 | { 17 | return m_iterator != other.m_iterator; 18 | } 19 | 20 | void KdTreeKNearestPointIterator::operator ++() 21 | { 22 | ++m_iterator; 23 | } 24 | 25 | int KdTreeKNearestPointIterator::operator * () const 26 | { 27 | return m_iterator->index; 28 | } 29 | 30 | } // namespace pdpc 31 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Iterator/KdTreeKNearestPointIterator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | class KdTreeKNearestPointIterator 8 | { 9 | public: 10 | KdTreeKNearestPointIterator(); 11 | KdTreeKNearestPointIterator(limited_priority_queue::iterator iterator); 12 | 13 | public: 14 | bool operator !=(const KdTreeKNearestPointIterator& other) const; 15 | void operator ++(); 16 | int operator * () const; 17 | 18 | protected: 19 | limited_priority_queue::iterator m_iterator; 20 | }; 21 | 22 | } // namespace pdpc 23 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Iterator/KdTreeNearestIndexIterator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | KdTreeNearestIndexIterator::KdTreeNearestIndexIterator() : 6 | m_index(-1) 7 | { 8 | } 9 | 10 | KdTreeNearestIndexIterator::KdTreeNearestIndexIterator(int index) : 11 | m_index(index) 12 | { 13 | } 14 | 15 | bool KdTreeNearestIndexIterator::operator !=(const KdTreeNearestIndexIterator& other) const 16 | { 17 | return m_index != other.m_index; 18 | } 19 | 20 | void KdTreeNearestIndexIterator::operator ++() 21 | { 22 | ++m_index; 23 | } 24 | 25 | int KdTreeNearestIndexIterator::operator * () const 26 | { 27 | return m_index; 28 | } 29 | 30 | } // namespace pdpc 31 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Iterator/KdTreeNearestIndexIterator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | class KdTreeNearestIndexIterator 6 | { 7 | public: 8 | KdTreeNearestIndexIterator(); 9 | KdTreeNearestIndexIterator(int index); 10 | 11 | public: 12 | bool operator !=(const KdTreeNearestIndexIterator& other) const; 13 | void operator ++(); 14 | int operator * () const; 15 | 16 | protected: 17 | int m_index; 18 | }; 19 | 20 | } // namespace pdpc 21 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Iterator/KdTreeNearestPointIterator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | KdTreeNearestPointIterator::KdTreeNearestPointIterator() : 6 | m_index(-1) 7 | { 8 | } 9 | 10 | KdTreeNearestPointIterator::KdTreeNearestPointIterator(int index) : 11 | m_index(index) 12 | { 13 | } 14 | 15 | bool KdTreeNearestPointIterator::operator !=(const KdTreeNearestPointIterator& other) const 16 | { 17 | return m_index != other.m_index; 18 | } 19 | 20 | void KdTreeNearestPointIterator::operator ++() 21 | { 22 | ++m_index; 23 | } 24 | 25 | int KdTreeNearestPointIterator::operator * () const 26 | { 27 | return m_index; 28 | } 29 | 30 | } // namespace pdpc 31 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Iterator/KdTreeNearestPointIterator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | class KdTreeNearestPointIterator 6 | { 7 | public: 8 | KdTreeNearestPointIterator(); 9 | KdTreeNearestPointIterator(int index); 10 | 11 | public: 12 | bool operator !=(const KdTreeNearestPointIterator& other) const; 13 | void operator ++(); 14 | int operator * () const; 15 | 16 | protected: 17 | int m_index; 18 | }; 19 | 20 | } // namespace pdpc 21 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Iterator/KdTreeRangeIndexIterator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace pdpc { 5 | 6 | KdTreeRangeIndexIterator::KdTreeRangeIndexIterator() : 7 | m_query(nullptr), 8 | m_index(-1), 9 | m_start(0), 10 | m_end(0) 11 | { 12 | } 13 | 14 | KdTreeRangeIndexIterator::KdTreeRangeIndexIterator(KdTreeRangeIndexQuery* query) : 15 | m_query(query), 16 | m_index(-1), 17 | m_start(0), 18 | m_end(0) 19 | { 20 | } 21 | 22 | KdTreeRangeIndexIterator::KdTreeRangeIndexIterator(KdTreeRangeIndexQuery* query, int index) : 23 | m_query(query), 24 | m_index(index), 25 | m_start(0), 26 | m_end(0) 27 | { 28 | } 29 | 30 | bool KdTreeRangeIndexIterator::operator !=(const KdTreeRangeIndexIterator& other) const 31 | { 32 | return m_index != other.m_index; 33 | } 34 | 35 | void KdTreeRangeIndexIterator::operator ++() 36 | { 37 | m_query->advance(*this); 38 | } 39 | 40 | int KdTreeRangeIndexIterator::operator * () const 41 | { 42 | return m_index; 43 | } 44 | 45 | } // namespace pdpc 46 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Iterator/KdTreeRangeIndexIterator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | class KdTreeRangeIndexQuery; 6 | 7 | class KdTreeRangeIndexIterator 8 | { 9 | protected: 10 | friend class KdTreeRangeIndexQuery; 11 | 12 | public: 13 | KdTreeRangeIndexIterator(); 14 | KdTreeRangeIndexIterator(KdTreeRangeIndexQuery* query); 15 | KdTreeRangeIndexIterator(KdTreeRangeIndexQuery* query, int index); 16 | 17 | public: 18 | bool operator !=(const KdTreeRangeIndexIterator& other) const; 19 | void operator ++(); 20 | int operator * () const; 21 | 22 | protected: 23 | KdTreeRangeIndexQuery* m_query; 24 | int m_index; 25 | int m_start; 26 | int m_end; 27 | }; 28 | 29 | } // namespace pdpc 30 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Iterator/KdTreeRangePointIterator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace pdpc { 5 | 6 | KdTreeRangePointIterator::KdTreeRangePointIterator() : 7 | m_query(nullptr), 8 | m_index(-1), 9 | m_start(0), 10 | m_end(0) 11 | { 12 | } 13 | 14 | KdTreeRangePointIterator::KdTreeRangePointIterator(KdTreeRangePointQuery* query) : 15 | m_query(query), 16 | m_index(-1), 17 | m_start(0), 18 | m_end(0) 19 | { 20 | } 21 | 22 | KdTreeRangePointIterator::KdTreeRangePointIterator(KdTreeRangePointQuery* query, int index) : 23 | m_query(query), 24 | m_index(index), 25 | m_start(0), 26 | m_end(0) 27 | { 28 | } 29 | 30 | bool KdTreeRangePointIterator::operator !=(const KdTreeRangePointIterator& other) const 31 | { 32 | return m_index != other.m_index; 33 | } 34 | 35 | void KdTreeRangePointIterator::operator ++() 36 | { 37 | m_query->advance(*this); 38 | } 39 | 40 | int KdTreeRangePointIterator::operator * () const 41 | { 42 | return m_index; 43 | } 44 | 45 | } // namespace pdpc 46 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Iterator/KdTreeRangePointIterator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | class KdTreeRangePointQuery; 6 | 7 | class KdTreeRangePointIterator 8 | { 9 | protected: 10 | friend class KdTreeRangePointQuery; 11 | 12 | public: 13 | KdTreeRangePointIterator(); 14 | KdTreeRangePointIterator(KdTreeRangePointQuery* query); 15 | KdTreeRangePointIterator(KdTreeRangePointQuery* query, int index); 16 | 17 | public: 18 | bool operator !=(const KdTreeRangePointIterator& other) const; 19 | void operator ++(); 20 | int operator * () const; 21 | 22 | protected: 23 | KdTreeRangePointQuery* m_query; 24 | int m_index; 25 | int m_start; 26 | int m_end; 27 | }; 28 | 29 | } // namespace pdpc 30 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/KdTreeNode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | struct KdTreeNode 6 | { 7 | union { 8 | struct { 9 | float splitValue; 10 | unsigned int firstChildId:24; 11 | unsigned int dim:2; 12 | unsigned int leaf:1; 13 | }; 14 | struct { 15 | unsigned int start; 16 | unsigned short size; 17 | }; 18 | }; 19 | }; 20 | 21 | } // namespace pdpc 22 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Query/KdTreeKNearestIndexQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace pdpc { 8 | 9 | class KdTreeKNearestIndexQuery : public KdTreeQuery, 10 | public KNearestIndexQuery 11 | { 12 | public: 13 | KdTreeKNearestIndexQuery(); 14 | KdTreeKNearestIndexQuery(const KdTree* kdtree, int k); 15 | KdTreeKNearestIndexQuery(const KdTree* kdtree, int k, int index); 16 | 17 | public: 18 | KdTreeKNearestIndexIterator begin(); 19 | KdTreeKNearestIndexIterator end(); 20 | 21 | public: 22 | const limited_priority_queue& search(); 23 | }; 24 | 25 | } // namespace pdpc 26 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Query/KdTreeKNearestPointQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace pdpc { 8 | 9 | class KdTreeKNearestPointQuery : public KdTreeQuery, 10 | public KNearestPointQuery 11 | { 12 | public: 13 | KdTreeKNearestPointQuery(); 14 | KdTreeKNearestPointQuery(const KdTree* kdtree, int k); 15 | KdTreeKNearestPointQuery(const KdTree* kdtree, int k, const Vector3& point); 16 | 17 | public: 18 | KdTreeKNearestPointIterator begin(); 19 | KdTreeKNearestPointIterator end(); 20 | 21 | public: 22 | const limited_priority_queue& search(); 23 | }; 24 | 25 | } // namespace pdpc 26 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Query/KdTreeNearestIndexQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace pdpc { 8 | 9 | class KdTreeNearestIndexQuery : public KdTreeQuery, 10 | public NearestIndexQuery 11 | { 12 | public: 13 | KdTreeNearestIndexQuery(); 14 | KdTreeNearestIndexQuery(const KdTree* kdtree); 15 | KdTreeNearestIndexQuery(const KdTree* kdtree, int index); 16 | 17 | public: 18 | KdTreeNearestIndexIterator begin(); 19 | KdTreeNearestIndexIterator end(); 20 | 21 | public: 22 | const NearestIndexQuery& search(); 23 | }; 24 | 25 | } // namespace pdpc 26 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Query/KdTreeNearestPointQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace pdpc { 8 | 9 | class KdTreeNearestPointQuery : public KdTreeQuery, 10 | public NearestPointQuery 11 | { 12 | public: 13 | KdTreeNearestPointQuery(); 14 | KdTreeNearestPointQuery(const KdTree* kdtree); 15 | KdTreeNearestPointQuery(const KdTree* kdtree, const Vector3& point); 16 | 17 | public: 18 | KdTreeNearestPointIterator begin(); 19 | KdTreeNearestPointIterator end(); 20 | 21 | protected: 22 | void search(); 23 | }; 24 | 25 | } // namespace pdpc 26 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Query/KdTreeQuery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | KdTreeQuery::KdTreeQuery() : 6 | m_kdtree(nullptr) 7 | { 8 | } 9 | 10 | KdTreeQuery::KdTreeQuery(const KdTree* kdtree) : 11 | m_kdtree(kdtree) 12 | { 13 | } 14 | 15 | } // namespace pdpc 16 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Query/KdTreeQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #define PDPC_KDTREE_MAX_DEPTH 32 7 | 8 | namespace pdpc { 9 | 10 | class KdTree; 11 | 12 | class KdTreeQuery 13 | { 14 | public: 15 | KdTreeQuery(); 16 | KdTreeQuery(const KdTree* kdtree); 17 | 18 | protected: 19 | const KdTree* m_kdtree; 20 | static_stack m_stack; 21 | }; 22 | 23 | } // namespace pdpc 24 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Query/KdTreeRangeIndexQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace pdpc { 8 | 9 | class KdTreeRangeIndexQuery : public KdTreeQuery, 10 | public RangeIndexQuery 11 | { 12 | protected: 13 | friend class KdTreeRangeIndexIterator; 14 | 15 | public: 16 | KdTreeRangeIndexQuery(); 17 | KdTreeRangeIndexQuery(const KdTree* kdtree); 18 | KdTreeRangeIndexQuery(const KdTree* kdtree, Scalar radius); 19 | KdTreeRangeIndexQuery(const KdTree* kdtree, Scalar radius, int index); 20 | 21 | public: 22 | KdTreeRangeIndexIterator begin(); 23 | KdTreeRangeIndexIterator end(); 24 | 25 | protected: 26 | void initialize(KdTreeRangeIndexIterator& iterator); 27 | void advance(KdTreeRangeIndexIterator& iterator); 28 | }; 29 | 30 | } // namespace pdpc 31 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KdTree/Query/KdTreeRangePointQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace pdpc { 8 | 9 | class KdTreeRangePointQuery : public KdTreeQuery, 10 | public RangePointQuery 11 | { 12 | protected: 13 | friend class KdTreeRangePointIterator; 14 | 15 | public: 16 | KdTreeRangePointQuery(); 17 | KdTreeRangePointQuery(const KdTree* kdtree); 18 | KdTreeRangePointQuery(const KdTree* kdtree, Scalar radius); 19 | KdTreeRangePointQuery(const KdTree* kdtree, Scalar radius, const Vector3& point); 20 | 21 | public: 22 | KdTreeRangePointIterator begin(); 23 | KdTreeRangePointIterator end(); 24 | 25 | protected: 26 | void initialize(KdTreeRangePointIterator& iterator); 27 | void advance(KdTreeRangePointIterator& iterator); 28 | }; 29 | 30 | } // namespace pdpc 31 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KnnGraph.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace pdpc { 9 | 10 | class KdTree; 11 | 12 | class KnnGraph 13 | { 14 | // Types ------------------------------------------------------------------- 15 | public: 16 | using KNearestIndexQuery = KnnGraphQuery; 17 | using RangeIndexQuery = KnnGraphRangeQuery; 18 | 19 | // KnnGraph ---------------------------------------------------------------- 20 | public: 21 | KnnGraph(); 22 | KnnGraph(int k); 23 | 24 | void clear(); 25 | void build(const KdTree& kdtree, bool verbose = false); 26 | void build(const KdTree& kdtree, int k, bool verbose = false); 27 | void build(const KdTree& kdtree, const std::vector& indices, bool verbose = false); 28 | void build(const KdTree& kdtree, int k, const std::vector& indices, bool verbose = false); 29 | 30 | 31 | // Query ------------------------------------------------------------------- 32 | public: 33 | KNearestIndexQuery k_nearest_neighbors(int index) const; 34 | RangeIndexQuery range_neighbors(int index, Scalar r) const; 35 | 36 | int k_neighbor(int index, int i) const; 37 | 38 | // Empty Query ------------------------------------------------------------- 39 | public: 40 | RangeIndexQuery range_query(Scalar r = 0) const; 41 | 42 | // Accessors --------------------------------------------------------------- 43 | public: 44 | int k() const; 45 | int size() const; 46 | 47 | const Vector3Array& point_data() const; 48 | Vector3Array& point_data(); 49 | 50 | const std::vector& index_data() const; 51 | std::vector& index_data(); 52 | 53 | // Data -------------------------------------------------------------------- 54 | protected: 55 | int m_k; 56 | std::shared_ptr m_points; 57 | std::shared_ptr> m_indices; 58 | }; 59 | 60 | } // namespace pdpc 61 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KnnGraph/Iterator/KnnGraphRangeIterator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace pdpc { 5 | 6 | KnnGraphRangeIterator::KnnGraphRangeIterator() : 7 | m_query(nullptr), 8 | m_index(-1) 9 | { 10 | } 11 | 12 | KnnGraphRangeIterator::KnnGraphRangeIterator(KnnGraphRangeQuery* query) : 13 | m_query(query), 14 | m_index(-1) 15 | { 16 | } 17 | 18 | KnnGraphRangeIterator::KnnGraphRangeIterator(KnnGraphRangeQuery* query, int index) : 19 | m_query(query), 20 | m_index(index) 21 | { 22 | } 23 | 24 | bool KnnGraphRangeIterator::operator != (const KnnGraphRangeIterator& other) const 25 | { 26 | return m_index != other.m_index; 27 | } 28 | 29 | void KnnGraphRangeIterator::operator ++ () 30 | { 31 | m_query->advance(*this); 32 | } 33 | 34 | int KnnGraphRangeIterator::operator * () const 35 | { 36 | return m_index; 37 | } 38 | 39 | 40 | } // namespace pdpc 41 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KnnGraph/Iterator/KnnGraphRangeIterator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | class KnnGraphRangeQuery; 6 | 7 | class KnnGraphRangeIterator 8 | { 9 | protected: 10 | friend class KnnGraphRangeQuery; 11 | 12 | public: 13 | KnnGraphRangeIterator(); 14 | KnnGraphRangeIterator(KnnGraphRangeQuery* query); 15 | KnnGraphRangeIterator(KnnGraphRangeQuery* query, int index); 16 | 17 | public: 18 | bool operator != (const KnnGraphRangeIterator& other) const; 19 | void operator ++ (); 20 | int operator * () const; 21 | 22 | protected: 23 | KnnGraphRangeQuery* m_query; 24 | int m_index; 25 | }; 26 | 27 | } // namespace pdpc 28 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KnnGraph/Query/KnnGraphQuery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace pdpc { 5 | 6 | KnnGraphQuery::KnnGraphQuery() : 7 | m_graph(nullptr), 8 | m_index(-1) 9 | { 10 | } 11 | 12 | KnnGraphQuery::KnnGraphQuery(const KnnGraph* graph, int index) : 13 | m_graph(graph), 14 | m_index(index) 15 | { 16 | } 17 | 18 | KnnGraphQuery::iterator KnnGraphQuery::begin() const 19 | { 20 | return m_graph->index_data().begin() + m_index * m_graph->k(); 21 | } 22 | 23 | KnnGraphQuery::iterator KnnGraphQuery::end() const 24 | { 25 | return m_graph->index_data().begin() + (m_index+1) * m_graph->k(); 26 | } 27 | 28 | } // namespace pdpc 29 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KnnGraph/Query/KnnGraphQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | class KnnGraph; 8 | 9 | class KnnGraphQuery 10 | { 11 | public: 12 | using iterator = std::vector::const_iterator; 13 | 14 | public: 15 | KnnGraphQuery(); 16 | KnnGraphQuery(const KnnGraph* graph, int index); 17 | 18 | iterator begin() const; 19 | iterator end() const; 20 | 21 | protected: 22 | const KnnGraph* m_graph; 23 | int m_index; 24 | }; 25 | 26 | } // namespace pdpc 27 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KnnGraph/Query/KnnGraphRangeQuery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | KnnGraphRangeQuery::KnnGraphRangeQuery() : 8 | RangeIndexQuery(), 9 | m_graph(nullptr), 10 | m_flag(), 11 | m_stack() 12 | { 13 | } 14 | 15 | KnnGraphRangeQuery::KnnGraphRangeQuery(const KnnGraph* graph) : 16 | RangeIndexQuery(), 17 | m_graph(graph), 18 | m_flag(graph->size()), 19 | m_stack() 20 | { 21 | } 22 | 23 | KnnGraphRangeQuery::KnnGraphRangeQuery(const KnnGraph* graph, Scalar radius) : 24 | RangeIndexQuery(radius), 25 | m_graph(graph), 26 | m_flag(graph->size()), 27 | m_stack() 28 | { 29 | } 30 | 31 | KnnGraphRangeQuery::KnnGraphRangeQuery(const KnnGraph* graph, Scalar radius, int index) : 32 | RangeIndexQuery(radius, index), 33 | m_graph(graph), 34 | m_flag(graph->size()), 35 | m_stack() 36 | { 37 | } 38 | 39 | KnnGraphRangeIterator KnnGraphRangeQuery::begin() 40 | { 41 | KnnGraphRangeIterator it(this); 42 | this->initialize(it); 43 | this->advance(it); 44 | return it; 45 | } 46 | 47 | KnnGraphRangeIterator KnnGraphRangeQuery::end() 48 | { 49 | return KnnGraphRangeIterator(this, m_graph->size()); 50 | } 51 | 52 | void KnnGraphRangeQuery::initialize(KnnGraphRangeIterator& iterator) 53 | { 54 | m_flag.resize(m_graph->size()); 55 | std::fill(m_flag.begin(), m_flag.end(), false); 56 | 57 | PDPC_DEBUG_ASSERT(m_stack.empty()); 58 | m_stack.push(m_index); 59 | m_flag[m_index] = true; 60 | 61 | iterator.m_index = -1; 62 | } 63 | 64 | void KnnGraphRangeQuery::advance(KnnGraphRangeIterator& iterator) 65 | { 66 | const auto& points = m_graph->point_data(); 67 | const auto& point = points[m_index]; 68 | 69 | if(m_stack.empty()) 70 | { 71 | iterator.m_index = m_graph->size(); 72 | } 73 | else 74 | { 75 | int idx_current = m_stack.top(); 76 | m_stack.pop(); 77 | 78 | PDPC_DEBUG_ASSERT((point - points[idx_current]).squaredNorm() < m_squared_radius); 79 | 80 | iterator.m_index = idx_current; 81 | 82 | for(int idx_nei : m_graph->k_nearest_neighbors(idx_current)) 83 | { 84 | if(!m_flag[idx_nei] && (point - points[idx_nei]).squaredNorm() < m_squared_radius) 85 | { 86 | m_flag[idx_nei] = true; 87 | m_stack.push(idx_nei); 88 | } 89 | } 90 | } 91 | } 92 | 93 | } // namespace pdpc 94 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/KnnGraph/Query/KnnGraphRangeQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace pdpc { 10 | 11 | class KnnGraph; 12 | 13 | class KnnGraphRangeQuery : public RangeIndexQuery 14 | { 15 | protected: 16 | friend class KnnGraphRangeIterator; 17 | 18 | public: 19 | KnnGraphRangeQuery(); 20 | KnnGraphRangeQuery(const KnnGraph* graph); 21 | KnnGraphRangeQuery(const KnnGraph* graph, Scalar radius); 22 | KnnGraphRangeQuery(const KnnGraph* graph, Scalar radius, int index); 23 | 24 | public: 25 | KnnGraphRangeIterator begin(); 26 | KnnGraphRangeIterator end(); 27 | 28 | protected: 29 | void initialize(KnnGraphRangeIterator& iterator); 30 | void advance(KnnGraphRangeIterator& iterator); 31 | 32 | protected: 33 | const KnnGraph* m_graph; 34 | std::vector m_flag; 35 | std::stack m_stack; 36 | }; 37 | 38 | } // namespace pdpc 39 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/IndexQuery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | IndexQuery::IndexQuery() : 6 | m_index(-1) 7 | { 8 | } 9 | 10 | IndexQuery::IndexQuery(int index) : 11 | m_index(index) 12 | { 13 | } 14 | 15 | int IndexQuery::index() const 16 | { 17 | return m_index; 18 | } 19 | 20 | void IndexQuery::set_index(int index) 21 | { 22 | m_index = index; 23 | } 24 | 25 | } // namespace pdpc 26 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/IndexQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | class IndexQuery 6 | { 7 | public: 8 | IndexQuery(); 9 | IndexQuery(int index); 10 | 11 | int index() const; 12 | void set_index(int index); 13 | 14 | protected: 15 | int m_index; 16 | }; 17 | 18 | } // namespace pdpc 19 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/KNearestIndexQuery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | KNearestIndexQuery::KNearestIndexQuery() : 6 | IndexQuery(), 7 | KNearestQuery() 8 | { 9 | } 10 | 11 | KNearestIndexQuery::KNearestIndexQuery(int k) : 12 | IndexQuery(), 13 | KNearestQuery(k) 14 | { 15 | } 16 | 17 | KNearestIndexQuery::KNearestIndexQuery(int k, int index) : 18 | IndexQuery(index), 19 | KNearestQuery(k) 20 | { 21 | } 22 | 23 | } // namespace pdpc 24 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/KNearestIndexQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace pdpc { 7 | 8 | class KNearestIndexQuery : public IndexQuery, 9 | public KNearestQuery 10 | { 11 | public: 12 | KNearestIndexQuery(); 13 | KNearestIndexQuery(int k); 14 | KNearestIndexQuery(int k, int index); 15 | }; 16 | 17 | } // namespace pdpc 18 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/KNearestPointQuery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | KNearestPointQuery::KNearestPointQuery() : 6 | PointQuery(), 7 | KNearestQuery() 8 | { 9 | } 10 | 11 | KNearestPointQuery::KNearestPointQuery(const Vector3& point) : 12 | PointQuery(point), 13 | KNearestQuery() 14 | { 15 | } 16 | 17 | KNearestPointQuery::KNearestPointQuery(int k) : 18 | PointQuery(), 19 | KNearestQuery(k) 20 | { 21 | } 22 | 23 | KNearestPointQuery::KNearestPointQuery(int k, const Vector3& point) : 24 | PointQuery(point), 25 | KNearestQuery(k) 26 | { 27 | } 28 | 29 | } // namespace pdpc 30 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/KNearestPointQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace pdpc { 7 | 8 | class KNearestPointQuery : public PointQuery, 9 | public KNearestQuery 10 | { 11 | public: 12 | KNearestPointQuery(); 13 | KNearestPointQuery(const Vector3& point); 14 | KNearestPointQuery(int k); 15 | KNearestPointQuery(int k, const Vector3& point); 16 | }; 17 | 18 | } // namespace pdpc 19 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/KNearestQuery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | KNearestQuery::KNearestQuery() : 6 | m_queue() 7 | { 8 | } 9 | 10 | KNearestQuery::KNearestQuery(int k) : 11 | m_queue(k) 12 | { 13 | } 14 | 15 | int KNearestQuery::k() const 16 | { 17 | return m_queue.capacity(); 18 | } 19 | 20 | void KNearestQuery::set_k(int k) 21 | { 22 | m_queue.reserve(k); 23 | } 24 | 25 | limited_priority_queue& KNearestQuery::queue() 26 | { 27 | return m_queue; 28 | } 29 | 30 | 31 | } // namespace pdpc 32 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/KNearestQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace pdpc { 8 | 9 | class KNearestQuery 10 | { 11 | public: 12 | KNearestQuery(); 13 | KNearestQuery(int k); 14 | 15 | public: 16 | int k() const; 17 | void set_k(int k); 18 | 19 | public: 20 | limited_priority_queue& queue(); 21 | 22 | protected: 23 | limited_priority_queue m_queue; 24 | }; 25 | 26 | } // namespace pdpc 27 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/NearestIndexQuery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | NearestIndexQuery::NearestIndexQuery() : 6 | IndexQuery(), 7 | NearestQuery() 8 | { 9 | } 10 | 11 | NearestIndexQuery::NearestIndexQuery(int index) : 12 | IndexQuery(index), 13 | NearestQuery() 14 | { 15 | } 16 | 17 | } // namespace pdpc 18 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/NearestIndexQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace pdpc { 7 | 8 | class NearestIndexQuery : public IndexQuery, 9 | public NearestQuery 10 | { 11 | public: 12 | NearestIndexQuery(); 13 | NearestIndexQuery(int index); 14 | }; 15 | 16 | } // namespace pdpc 17 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/NearestPointQuery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | NearestPointQuery::NearestPointQuery() : 6 | PointQuery(), 7 | NearestQuery() 8 | { 9 | } 10 | 11 | NearestPointQuery::NearestPointQuery(const Vector3& point) : 12 | PointQuery(point), 13 | NearestQuery() 14 | { 15 | } 16 | 17 | } // namespace pdpc 18 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/NearestPointQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace pdpc { 7 | 8 | class NearestPointQuery : public PointQuery, 9 | public NearestQuery 10 | { 11 | public: 12 | NearestPointQuery(); 13 | NearestPointQuery(const Vector3& point); 14 | }; 15 | 16 | } // namespace pdpc 17 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/NearestQuery.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STORM-IRIT/Plane-Detection-Point-Cloud/7d0b489502d2bf3c3e7b21ab956ec48cb63c5022/src/PDPC/SpacePartitioning/Query/NearestQuery.cpp -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/NearestQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace pdpc { 8 | 9 | class NearestQuery 10 | { 11 | public: 12 | NearestQuery(){} 13 | 14 | int get() const{return m_nearest;} 15 | Scalar distance() const {return std::sqrt(m_squared_distance);} 16 | 17 | protected: 18 | int m_nearest; 19 | Scalar m_squared_distance; 20 | }; 21 | 22 | } // namespace pdpc 23 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/PointQuery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | PointQuery::PointQuery() : 6 | m_point(Vector3::Zero()) 7 | { 8 | } 9 | 10 | PointQuery::PointQuery(const Vector3& point) : 11 | m_point(point) 12 | { 13 | } 14 | 15 | const Vector3& PointQuery::point() const 16 | { 17 | return m_point; 18 | } 19 | 20 | void PointQuery::set_point(const Vector3& point) 21 | { 22 | m_point = point; 23 | } 24 | 25 | } // namespace pdpc 26 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/PointQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | class PointQuery 8 | { 9 | public: 10 | PointQuery(); 11 | PointQuery(const Vector3& point); 12 | 13 | const Vector3& point() const; 14 | void set_point(const Vector3& point); 15 | 16 | protected: 17 | Vector3 m_point; 18 | }; 19 | 20 | } // namespace pdpc 21 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/RangeIndexQuery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | RangeIndexQuery::RangeIndexQuery() : 6 | IndexQuery(), 7 | RangeQuery() 8 | { 9 | } 10 | 11 | RangeIndexQuery::RangeIndexQuery(Scalar radius) : 12 | IndexQuery(), 13 | RangeQuery(radius) 14 | { 15 | } 16 | 17 | RangeIndexQuery::RangeIndexQuery(Scalar radius, int index) : 18 | IndexQuery(index), 19 | RangeQuery(radius) 20 | { 21 | } 22 | 23 | } // namespace pdpc 24 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/RangeIndexQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace pdpc { 7 | 8 | class RangeIndexQuery : public IndexQuery, 9 | public RangeQuery 10 | { 11 | public: 12 | RangeIndexQuery(); 13 | RangeIndexQuery(Scalar radius); 14 | RangeIndexQuery(Scalar radius, int index); 15 | }; 16 | 17 | } // namespace pdpc 18 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/RangePointQuery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | RangePointQuery::RangePointQuery() : 6 | PointQuery(), 7 | RangeQuery() 8 | { 9 | } 10 | 11 | RangePointQuery::RangePointQuery(Scalar radius) : 12 | PointQuery(), 13 | RangeQuery(radius) 14 | { 15 | } 16 | 17 | RangePointQuery::RangePointQuery(Scalar radius, const Vector3& point) : 18 | PointQuery(point), 19 | RangeQuery(radius) 20 | { 21 | } 22 | 23 | } // namespace pdpc 24 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/RangePointQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace pdpc { 7 | 8 | class RangePointQuery : public PointQuery, 9 | public RangeQuery 10 | { 11 | public: 12 | RangePointQuery(); 13 | RangePointQuery(Scalar radius); 14 | RangePointQuery(Scalar radius, const Vector3& point); 15 | }; 16 | 17 | } // namespace pdpc 18 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/RangeQuery.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | RangeQuery::RangeQuery() : 8 | m_squared_radius(0) 9 | { 10 | } 11 | 12 | RangeQuery::RangeQuery(Scalar radius) : 13 | m_squared_radius(radius * radius) 14 | { 15 | } 16 | 17 | Scalar RangeQuery::radius() const 18 | { 19 | return std::sqrt(m_squared_radius); 20 | } 21 | 22 | Scalar RangeQuery::squared_radius() const 23 | { 24 | return m_squared_radius; 25 | } 26 | 27 | void RangeQuery::set_radius(Scalar radius) 28 | { 29 | m_squared_radius = radius * radius; 30 | } 31 | 32 | } // namespace pdpc 33 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/Query/RangeQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pdpc { 6 | 7 | class RangeQuery 8 | { 9 | public: 10 | RangeQuery(); 11 | RangeQuery(Scalar radius); 12 | 13 | public: 14 | Scalar radius() const; 15 | Scalar squared_radius() const; 16 | void set_radius(Scalar radius); 17 | 18 | protected: 19 | Scalar m_squared_radius; 20 | }; 21 | 22 | } // namespace pdpc 23 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/internal/IndexSquaredDistance.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace pdpc { 4 | 5 | bool IndexSquaredDistance::operator < (const IndexSquaredDistance& other) const 6 | { 7 | return squared_distance < other.squared_distance; 8 | } 9 | 10 | } // namespace pdpc 11 | -------------------------------------------------------------------------------- /src/PDPC/SpacePartitioning/internal/IndexSquaredDistance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pdpc { 4 | 5 | struct IndexSquaredDistance 6 | { 7 | int index; 8 | float squared_distance; 9 | 10 | bool operator < (const IndexSquaredDistance& other) const; 11 | }; 12 | 13 | } // namespace pdpc 14 | -------------------------------------------------------------------------------- /src/Ponca/Core/algebraicEllipsoid.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | This Source Code Form is subject to the terms of the Mozilla Public 3 | License, v. 2.0. If a copy of the MPL was not distributed with this 4 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 | */ 6 | 7 | 8 | /*! 9 | Use gradient descent 10 | */ 11 | template < class DataPoint, class _WFunctor, typename T> 12 | typename DataPoint::VectorType 13 | AlgebraicEllipsoid::project( const VectorType& _q ) const 14 | { 15 | PONCA_MULTIARCH_STD_MATH(min) 16 | 17 | // turn to centered basis 18 | const VectorType lq = _q-m_p; 19 | 20 | //if(_isPlane) 21 | //{ 22 | VectorType grad; 23 | VectorType dir = m_ul+Scalar(2.)*m_uq*lq; 24 | Scalar ilg = Scalar(1.)/dir.norm(); 25 | dir = dir*ilg; 26 | Scalar ad = m_uc + m_ul.dot(lq) + lq.transpose() * m_uq * lq; 27 | Scalar delta = -ad*min(ilg,Scalar(1.)); 28 | VectorType proj = lq + dir*delta; 29 | 30 | for (int i=0; i<16; ++i) 31 | { 32 | grad = m_ul+Scalar(2.)*m_uq*proj; 33 | ilg = Scalar(1.)/grad.norm(); 34 | delta = -(m_uc + proj.dot(m_ul) + proj.transpose() * m_uq * proj)*min(ilg,Scalar(1.)); 35 | proj += dir*delta; 36 | } 37 | return proj + m_p; 38 | //} 39 | //return other - _ul * dot(other,_ul) + _uc; 40 | //return normalize(other-_center) * _r + _center; 41 | } 42 | 43 | template < class DataPoint, class _WFunctor, typename T> 44 | typename DataPoint::Scalar 45 | AlgebraicEllipsoid::potential( const VectorType &_q ) const 46 | { 47 | // turn to centered basis 48 | const VectorType lq = _q-m_p; 49 | 50 | return m_uc + lq.dot(m_ul) + lq.transpose * m_uq * lq ; 51 | } 52 | 53 | 54 | template < class DataPoint, class _WFunctor, typename T> 55 | typename DataPoint::VectorType 56 | AlgebraicEllipsoid::primitiveGradient( const VectorType &_q ) const 57 | { 58 | // turn to centered basis 59 | const VectorType lq = _q-m_p; 60 | return (m_ul + Scalar(2.f) * m_uq * lq); 61 | } 62 | 63 | -------------------------------------------------------------------------------- /src/Ponca/Core/algebraicSphere.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | This Source Code Form is subject to the terms of the Mozilla Public 3 | License, v. 2.0. If a copy of the MPL was not distributed with this 4 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 | */ 6 | 7 | 8 | /*! 9 | Use gradient descent 10 | */ 11 | template < class DataPoint, class _WFunctor, typename T> 12 | typename DataPoint::VectorType 13 | AlgebraicSphere::project( const VectorType& _q ) const 14 | { 15 | PONCA_MULTIARCH_STD_MATH(min) 16 | 17 | // turn to centered basis 18 | const VectorType lq = _q-m_p; 19 | 20 | //if(_isPlane) 21 | //{ 22 | VectorType grad; 23 | VectorType dir = m_ul+Scalar(2.)*m_uq*lq; 24 | Scalar ilg = Scalar(1.)/dir.norm(); 25 | dir = dir*ilg; 26 | Scalar ad = m_uc + m_ul.dot(lq) + m_uq * lq.squaredNorm(); 27 | Scalar delta = -ad*min(ilg,Scalar(1.)); 28 | VectorType proj = lq + dir*delta; 29 | 30 | for (int i=0; i<16; ++i) 31 | { 32 | grad = m_ul+Scalar(2.)*m_uq*proj; 33 | ilg = Scalar(1.)/grad.norm(); 34 | delta = -(m_uc + proj.dot(m_ul) + m_uq * proj.squaredNorm())*min(ilg,Scalar(1.)); 35 | proj += dir*delta; 36 | } 37 | return proj + m_p; 38 | //} 39 | //return other - _ul * dot(other,_ul) + _uc; 40 | //return normalize(other-_center) * _r + _center; 41 | } 42 | 43 | template < class DataPoint, class _WFunctor, typename T> 44 | typename DataPoint::Scalar 45 | AlgebraicSphere::potential( const VectorType &_q ) const 46 | { 47 | // turn to centered basis 48 | const VectorType lq = _q-m_p; 49 | 50 | return m_uc + lq.dot(m_ul) + m_uq * lq.squaredNorm(); 51 | } 52 | 53 | 54 | template < class DataPoint, class _WFunctor, typename T> 55 | typename DataPoint::VectorType 56 | AlgebraicSphere::primitiveGradient( const VectorType &_q ) const 57 | { 58 | // turn to centered basis 59 | const VectorType lq = _q-m_p; 60 | return (m_ul + Scalar(2.f) * m_uq * lq); 61 | } 62 | 63 | -------------------------------------------------------------------------------- /src/Ponca/Core/defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | This Source Code Form is subject to the terms of the Mozilla Public 3 | License, v. 2.0. If a copy of the MPL was not distributed with this 4 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 | */ 6 | 7 | 8 | #pragma once 9 | 10 | //////////////////////////////////////////////////////////////////////////////// 11 | // Compatibility types, macros, functions 12 | // 13 | #ifdef __CUDACC__ 14 | # include 15 | # define PONCA_MULTIARCH __host__ __device__ 16 | #else 17 | # define PONCA_MULTIARCH 18 | 19 | // GCC: compile with -std=c++0x 20 | # if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || (__GNUC__ >= 5)) 21 | # if defined(nullptr_t) || (__cplusplus > 199711L) || defined(HACK_GCC_ITS_CPP0X) 22 | # define __CPP0X__ 23 | # endif 24 | # endif 25 | 26 | #endif // ifdef __CUDACC__ 27 | 28 | #ifdef __CUDA_ARCH__ 29 | #define PONCA_MULTIARCH_INCLUDE_STD(FILENAME) "defines.h" 30 | #define PONCA_MULTIARCH_STD_MATH(FUNC) 31 | #define PONCA_CUDA_ARCH 32 | #else 33 | #define PONCA_MULTIARCH_INCLUDE_STD(FILENAME) 34 | #define PONCA_MULTIARCH_STD_MATH(FUNC) using std::FUNC; 35 | #define PONCA_CPU_ARCH 36 | #endif 37 | -------------------------------------------------------------------------------- /src/Ponca/Core/enums.h: -------------------------------------------------------------------------------- 1 | /* 2 | This Source Code Form is subject to the terms of the Mozilla Public 3 | License, v. 2.0. If a copy of the MPL was not distributed with this 4 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 | */ 6 | 7 | #pragma once 8 | 9 | namespace Ponca 10 | { 11 | /*! Enum corresponding to the state of a fitting method (and what the finalize function can return) */ 12 | enum FIT_RESULT 13 | { 14 | /*! \brief The fitting is stable an ready to use (and having more than 6 15 | neighbours)*/ 16 | STABLE = 0, 17 | /*! \brief The fitting is ready to use but it can be unstable (and 18 | having between 3 and 6 neighbors)*/ 19 | UNSTABLE = 1, 20 | /*! \brief The fitting is undefined, you can't use it for valid results 21 | (and having less than 3 neighbors)*/ 22 | UNDEFINED = 2, 23 | /*! \brief The fitting procedure needs to analyse the neighborhood 24 | another time*/ 25 | NEED_OTHER_PASS = 3, 26 | NBMAX /*!< \brief Nb enums */ 27 | }; 28 | 29 | namespace internal 30 | { 31 | enum 32 | { 33 | FitScaleDer = 0x01, /*!< \brief Flag indicating a scale differentiation. */ 34 | FitSpaceDer = 0x02 /*!< \brief Flag indicating a space differentiation. */ 35 | }; 36 | } // end namespace internal 37 | 38 | } //namespace Ponca 39 | -------------------------------------------------------------------------------- /src/Ponca/Core/meanPlaneFit.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018 Nicolas Mellado 3 | 4 | This Source Code Form is subject to the terms of the Mozilla Public 5 | License, v. 2.0. If a copy of the MPL was not distributed with this 6 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | 10 | template < class DataPoint, class _WFunctor, typename T> 11 | void 12 | MeanPlaneFit::init(const VectorType& _evalPos) 13 | { 14 | // Setup primitive 15 | Base::resetPrimitive(); 16 | Base::basisCenter() = _evalPos; 17 | 18 | // Setup fitting internal values 19 | m_sumP = VectorType::Zero(); 20 | m_sumN = VectorType::Zero(); 21 | m_sumW = Scalar(0.0); 22 | } 23 | 24 | template < class DataPoint, class _WFunctor, typename T> 25 | bool 26 | MeanPlaneFit::addNeighbor(const DataPoint& _nei) 27 | { 28 | VectorType q = _nei.pos() - Base::basisCenter(); 29 | // compute weight 30 | Scalar w = m_w.w(q, _nei); 31 | 32 | if (w > Scalar(0.)) 33 | { 34 | m_sumP += q * w; 35 | m_sumN += _nei.normal() * w; 36 | m_sumW += w; 37 | 38 | ++(Base::m_nbNeighbors); 39 | return true; 40 | } 41 | return false; 42 | } 43 | 44 | 45 | template < class DataPoint, class _WFunctor, typename T> 46 | FIT_RESULT 47 | MeanPlaneFit::finalize () 48 | { 49 | // handle specific configurations 50 | // With less than 3 neighbors the fitting is undefined 51 | if(m_sumW == Scalar(0.) || Base::m_nbNeighbors == 0) 52 | { 53 | Base::resetPrimitive(); 54 | Base::m_eCurrentState = UNDEFINED; 55 | return Base::m_eCurrentState; 56 | } 57 | 58 | Base::setPlane(m_sumN / m_sumW, m_sumP / m_sumW); 59 | 60 | return Base::m_eCurrentState = STABLE; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /src/Ponca/Core/primitive.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2014 Nicolas Mellado 3 | 4 | This Source Code Form is subject to the terms of the Mozilla Public 5 | License, v. 2.0. If a copy of the MPL was not distributed with this 6 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "defines.h" 12 | #include "enums.h" 13 | 14 | namespace Ponca 15 | { 16 | 17 | /*! 18 | \brief Primitive base class. 19 | 20 | This class stores and provides public access to the fitting state, and must 21 | be inherited by classes implementing new primitives. 22 | 23 | Protected fields #m_eCurrentState and #m_nbNeighbors should be updated 24 | during the fitting process by the inheriting class. 25 | */ 26 | template < class DataPoint, class _WFunctor, typename T = void > 27 | class PrimitiveBase 28 | { 29 | 30 | protected: 31 | 32 | //! \brief Represent the current state of the fit (finalize function 33 | //! update the state) 34 | FIT_RESULT m_eCurrentState; 35 | 36 | //! \brief Give the number of neighbors 37 | int m_nbNeighbors; 38 | 39 | public: 40 | 41 | /*! \brief Default constructor */ 42 | PONCA_MULTIARCH inline PrimitiveBase() { } 43 | 44 | /*! \brief Reset fitting state 45 | status */ 46 | PONCA_MULTIARCH inline void resetPrimitive() 47 | { 48 | m_eCurrentState = UNDEFINED; 49 | m_nbNeighbors = 0; 50 | } 51 | 52 | /*! \brief Is the primitive well fitted an ready to use (finalize has been 53 | called) 54 | \warning The fit can be unstable (having neighbors between 3 and 6) */ 55 | PONCA_MULTIARCH inline bool isReady() const 56 | { 57 | return (m_eCurrentState == STABLE) || (m_eCurrentState == UNSTABLE); 58 | } 59 | 60 | /*! \brief Is the plane fitted an ready to use (finalize has been called 61 | and the result is stable, eq. having more than 6 neighbors) */ 62 | PONCA_MULTIARCH inline bool isStable() const { return m_eCurrentState == STABLE; } 63 | 64 | /*! \return the current test of the fit */ 65 | PONCA_MULTIARCH inline FIT_RESULT getCurrentState() const 66 | { 67 | return m_eCurrentState; 68 | } 69 | 70 | }; //class Plane 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/Ponca/Core/weightKernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | This Source Code Form is subject to the terms of the Mozilla Public 3 | License, v. 2.0. If a copy of the MPL was not distributed with this 4 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 | */ 6 | 7 | #pragma once 8 | 9 | /*! 10 | \file weightKernel.h Define 1D weight kernel functors 11 | */ 12 | 13 | 14 | namespace Ponca 15 | { 16 | /*! 17 | \brief Concept::WeightKernelConcept returning a constant value 18 | 19 | \inherit Concept::WeightKernelConcept 20 | */ 21 | template 22 | class ConstantWeightKernel 23 | { 24 | public: 25 | /*! \brief Scalar type defined outside the class */ 26 | typedef _Scalar Scalar; 27 | 28 | // Init 29 | //! \brief Default constructor that could be used to set the returned value 30 | PONCA_MULTIARCH inline ConstantWeightKernel(const Scalar& _value = Scalar(1.)) : m_y(_value){} 31 | //! \brief Set the returned value 32 | PONCA_MULTIARCH inline void setValue(const Scalar& _value){ m_y = _value; } 33 | 34 | // Functor 35 | //! \brief Return the constant value 36 | PONCA_MULTIARCH inline Scalar f (const Scalar&) const { return m_y; } 37 | //! \brief Return \f$ 0 \f$ 38 | PONCA_MULTIARCH inline Scalar df (const Scalar&) const { return Scalar(0.); } 39 | //! \brief Return \f$ 0 \f$ 40 | PONCA_MULTIARCH inline Scalar ddf(const Scalar&) const { return Scalar(0.); } 41 | 42 | private: 43 | Scalar m_y; /*!< \brief Constant value returned by the kernel */ 44 | };// class ConstantWeightKernel 45 | 46 | 47 | /*! 48 | \brief Smooth WeightKernel defined in \f$\left[0 : 1\right]\f$ 49 | \todo Add a degree value as template parameter (in this class or another one), with specialized functions for 2 50 | 51 | \inherit Concept::WeightKernelConcept 52 | */ 53 | template 54 | class SmoothWeightKernel 55 | { 56 | public: 57 | /*! \brief Scalar type defined outside the class*/ 58 | typedef _Scalar Scalar; 59 | 60 | // Functor 61 | /*! \brief Defines the smooth weighting function \f$ w(x) = (x^2-1)^2 \f$ */ 62 | PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const { Scalar v = _x*_x - Scalar(1.); return v*v; } 63 | /*! \brief Defines the smooth first order weighting function \f$ \nabla w(x) = 4x(x^2-1) \f$ */ 64 | PONCA_MULTIARCH inline Scalar df (const Scalar& _x) const { return Scalar(4.)*_x*(_x*_x-Scalar(1.)); } 65 | /*! \brief Defines the smooth second order weighting function \f$ \nabla^2 w(x) = 12x^2-4 \f$ */ 66 | PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const { return Scalar(12.)*_x*_x - Scalar(4.); } 67 | };//class SmoothWeightKernel 68 | 69 | }// namespace Ponca 70 | -------------------------------------------------------------------------------- /src/Ponca/core.h: -------------------------------------------------------------------------------- 1 | /* 2 | This Source Code Form is subject to the terms of the Mozilla Public 3 | License, v. 2.0. If a copy of the MPL was not distributed with this 4 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 | */ 6 | 7 | #pragma once 8 | 9 | // Include Ponca Core components 10 | #include "Ponca/Core/defines.h" 11 | #include "Ponca/Core/enums.h" 12 | #include "Ponca/Core/basket.h" 13 | 14 | #include "Ponca/Core/weightKernel.h" 15 | #include "Ponca/Core/weightFunc.h" 16 | 17 | #include "Ponca/Core/plane.h" 18 | #include "Ponca/Core/meanPlaneFit.h" 19 | #include "Ponca/Core/covariancePlaneFit.h" 20 | #include "Ponca/Core/mongePatch.h" 21 | 22 | #include "Ponca/Core/sphereFit.h" 23 | #include "Ponca/Core/orientedSphereFit.h" 24 | #include "Ponca/Core/orientedEllipsoidFit.h" 25 | #include "Ponca/Core/mlsSphereFitDer.h" 26 | #include "Ponca/Core/curvature.h" 27 | #include "Ponca/Core/gls.h" 28 | 29 | #include "Ponca/Core/curvatureEstimation.h" 30 | 31 | // not supported on cuda 32 | #ifndef __CUDACC__ 33 | # include "Ponca/Core/unorientedSphereFit.h" 34 | #endif 35 | --------------------------------------------------------------------------------