diff --git a/CMakeLists.txt b/CMakeLists.txt index d1a914e..94d3c92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.0) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) @@ -19,6 +19,8 @@ file( GLOB source_list Src_CC_wrap/*.cpp ) add_library( ${PROJECT_NAME} STATIC ${header_list} ${source_list} ) +target_include_directories( ${PROJECT_NAME} PRIVATE Src ) + # Add preprocessor definitions target_compile_definitions( ${PROJECT_NAME} PRIVATE _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS NOMINMAX ) diff --git a/Src_CC_wrap/PointData.cpp b/Src_CC_wrap/PointData.cpp new file mode 100644 index 0000000..b18538a --- /dev/null +++ b/Src_CC_wrap/PointData.cpp @@ -0,0 +1,21 @@ +//########################################################################## +//# # +//# CLOUDCOMPARE WRAPPER: PoissonReconLib # +//# # +//# This program is free software; you can redistribute it and/or modify # +//# it under the terms of the GNU General Public License as published by # +//# the Free Software Foundation; version 2 or later of the License. # +//# # +//# This program is distributed in the hope that it will be useful, # +//# but WITHOUT ANY WARRANTY; without even the implied warranty of # +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +//# GNU General Public License for more details. # +//# # +//# COPYRIGHT: CloudCompare Project # +//# # +//########################################################################## + +#include "PointData.h" + +template class PointData; +template class PointData; diff --git a/Src_CC_wrap/PointData.h b/Src_CC_wrap/PointData.h new file mode 100644 index 0000000..d676385 --- /dev/null +++ b/Src_CC_wrap/PointData.h @@ -0,0 +1,74 @@ +//########################################################################## +//# # +//# CLOUDCOMPARE WRAPPER: PoissonReconLib # +//# # +//# This program is free software; you can redistribute it and/or modify # +//# it under the terms of the GNU General Public License as published by # +//# the Free Software Foundation; version 2 or later of the License. # +//# # +//# This program is distributed in the hope that it will be useful, # +//# but WITHOUT ANY WARRANTY; without even the implied warranty of # +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +//# GNU General Public License for more details. # +//# # +//# COPYRIGHT: Daniel Girardeau-Montaut # +//# # +//########################################################################## + +#ifndef POINTDATA_H +#define POINTDATA_H + +template +class PointData { +public: + PointData() : normal{ 0, 0, 0 }, color{ 0, 0, 0 } {} + PointData(const Real _normal[3], const Real _color[3], Real scale = 1.0) + { + normal[0] = scale * _normal[0]; + normal[1] = scale * _normal[1]; + normal[2] = scale * _normal[2]; + color[0] = scale * _color[0]; + color[1] = scale * _color[1]; + color[2] = scale * _color[2]; + } + + PointData operator * (Real s) const + { + return PointData(normal, color, s); + } + + PointData operator / (Real s) const + { + return PointData(normal, color, 1 / s); + } + + PointData& operator += (const PointData& d) + { + normal[0] += d.normal[0]; + normal[1] += d.normal[1]; + normal[2] += d.normal[2]; + color[0] += d.color[0]; + color[1] += d.color[1]; + color[2] += d.color[2]; + return *this; + } + PointData& operator *= (Real s) + { + normal[0] *= s; + normal[1] *= s; + normal[2] *= s; + color[0] *= s; + color[1] *= s; + color[2] *= s; + return *this; + } + +public: + Real normal[3]; + Real color[3]; +}; + +extern template class PointData; +extern template class PointData; + +#endif // POINTDATA_H diff --git a/Src_CC_wrap/PoissonReconLib.cpp b/Src_CC_wrap/PoissonReconLib.cpp index 875c376..36e085f 100644 --- a/Src_CC_wrap/PoissonReconLib.cpp +++ b/Src_CC_wrap/PoissonReconLib.cpp @@ -20,18 +20,32 @@ //PoissonRecon #include "../Src/FEMTree.h" -#include +#include "PointData.h" -// The order of the B-Spline used to splat in data for color interpolation -static const int DATA_DEGREE = 0; -// The order of the B-Spline used to splat in the weights for density estimation -static const int WEIGHT_DEGREE = 2; -// The order of the B-Spline used to splat in the normals for constructing the Laplacian constraints -static const int NORMAL_DEGREE = 2; -// The default finite-element degree -static const int DEFAULT_FEM_DEGREE = 1; -// The dimension of the system -static const int DIMENSION = 3; +#include + +namespace { + // The order of the B-Spline used to splat in data for color interpolation + constexpr int DATA_DEGREE = 0; + // The order of the B-Spline used to splat in the weights for density estimation + constexpr int WEIGHT_DEGREE = 2; + // The order of the B-Spline used to splat in the normals for constructing the Laplacian constraints + constexpr int NORMAL_DEGREE = 2; + // The default finite-element degree + constexpr int DEFAULT_FEM_DEGREE = 1; + // The dimension of the system + constexpr int DIMENSION = 3; + + inline float ComputeNorm(const float vec[3]) + { + return sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]); + } + + inline double ComputeNorm(const double vec[3]) + { + return sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]); + } +} PoissonReconLib::Parameters::Parameters() { @@ -40,56 +54,6 @@ PoissonReconLib::Parameters::Parameters() #endif } -template -class PointData { -public: - PointData() : normal{ 0, 0, 0 }, color{ 0, 0, 0 } {} - PointData(const Real _normal[3], const Real _color[3], Real scale = 1.0) - { - normal[0] = scale * _normal[0]; - normal[1] = scale * _normal[1]; - normal[2] = scale * _normal[2]; - color[0] = scale * _color[0]; - color[1] = scale * _color[1]; - color[2] = scale * _color[2]; - } - - PointData operator * (Real s) const - { - return PointData(normal, color, s); - } - - PointData operator / (Real s) const - { - return PointData(normal, color, 1 / s); - } - - PointData& operator += (const PointData& d) - { - normal[0] += d.normal[0]; - normal[1] += d.normal[1]; - normal[2] += d.normal[2]; - color[0] += d.color[0]; - color[1] += d.color[1]; - color[2] += d.color[2]; - return *this; - } - PointData& operator *= (Real s) - { - normal[0] *= s; - normal[1] *= s; - normal[2] *= s; - color[0] *= s; - color[1] *= s; - color[2] *= s; - return *this; - } - -public: - Real normal[3]; - Real color[3]; -}; - template class Vertex : public PointData<_Real> { @@ -428,12 +392,6 @@ void ExtractMesh( const PoissonReconLib::Parameters& params, } } -template -static Real ComputeNorm(const Real vec[3]) -{ - return sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]); -} - template static bool Execute(PointStream& pointStream, PoissonReconLib::IMesh& out_mesh, @@ -491,7 +449,7 @@ static bool Execute(PointStream& pointStream, { auto ProcessDataWithConfidence = [&](const Point& p, PointData& d) { - Real l = ComputeNorm(d.normal); + Real l = ComputeNorm(d.normal); if (std::isnan(l) || l == 0) return static_cast(-1.0); @@ -504,7 +462,7 @@ static bool Execute(PointStream& pointStream, { auto ProcessData = [](const Point& p, PointData& d) { - Real l = ComputeNorm(d.normal); + Real l = ComputeNorm(d.normal); if (std::isnan(l) || l == 0) return static_cast(-1.0);