PoissonReconWrapper updated to compile with PoissonRecon V8

+ B-spline degree defaulted to 2 for now
+ compilation with VS2012 and older
This commit is contained in:
Daniel Girardeau-Montaut
2015-11-12 10:20:47 +01:00
parent cdfb894961
commit 14e696f9e3
4 changed files with 109 additions and 49 deletions
+2 -2
View File
@@ -13,8 +13,8 @@ set( SAMPLE_PROJECT_VERSION_MAJOR 6 )
set( SAMPLE_PROJECT_VERSION_MINOR 13a )
file( GLOB header_list Src_CC_wrap/*.h )
list (APPEND header_list Src/Allocator.h Src/Array.h Src/BinaryNode.h Src/BSplineData.h Src/CmdLineParser.h Src/Factor.h Src/FunctionData.h Src/Geometry.h Src/Hash.h Src/MarchingCubes.h Src/MAT.h Src/MemoryUsage.h Src/MultiGridOctreeData.h Src/Octree.h Src/Ply.h Src/PointStream.h Src/Polynomial.h Src/PPolynomial.h Src/SparseMatrix.h Src/Vector.h )
list (APPEND header_list Src/Array.inl Src/BSplineData.inl Src/CmdLineParser.inl Src/FunctionData.inl Src/Geometry.inl Src/MAT.inl Src/MultiGridOctreeData.inl Src/MultiGridOctreeData.IsoSurface.inl Src/MultiGridOctreeData.SortedTreeNodes.inl Src/Octree.inl Src/PointStream.inl Src/Polynomial.inl Src/PPolynomial.inl Src/SparseMatrix.inl Src/Vector.inl )
list (APPEND header_list Src/Allocator.h Src/Array.h Src/BinaryNode.h Src/BSplineData.h Src/CmdLineParser.h Src/Factor.h Src/FunctionData.h Src/Geometry.h Src/Hash.h Src/MarchingCubes.h Src/MAT.h Src/MemoryUsage.h Src/MultiGridOctreeData.h Src/Octree.h Src/Ply.h Src/PointStream.h Src/Polynomial.h Src/PPolynomial.h Src/SparseMatrix.h )
list (APPEND header_list Src/Array.inl Src/BSplineData.inl Src/CmdLineParser.inl Src/FunctionData.inl Src/Geometry.inl Src/MAT.inl Src/MultiGridOctreeData.inl Src/MultiGridOctreeData.IsoSurface.inl Src/MultiGridOctreeData.SortedTreeNodes.inl Src/Octree.inl Src/PointStream.inl Src/Polynomial.inl Src/PPolynomial.inl Src/SparseMatrix.inl )
file( GLOB source_list Src_CC_wrap/*.cpp )
list (APPEND source_list Src/CmdLineParser.cpp Src/Factor.cpp Src/Geometry.cpp Src/MarchingCubes.cpp Src/PlyFile.cpp )
+14 -1
View File
@@ -36,6 +36,19 @@ const double MATRIX_ENTRY_EPSILON = 0;
const double EPSILON = 1e-6;
const double ROUND_EPS = 1e-5;
//Visual 2012 and previous versions don't know isnan or isfinite
#if defined(_MSC_VER) && (_MSC_VER <= 1700)
#define ISNAN _isnan
#define ISFINITE !_finite
#else
#include <cmath>
#define ISNAN isnan
#define ISFINITE std::isfinite
#endif
//////////////////
@@ -224,7 +237,7 @@ int Octree< Real >::SetTree( OrientedPointStream< PointReal >* pointStream , int
n *= Real(-1.);
if( !_InBounds(p) ) continue;
Real normalLength = Real( Length( n ) );
if( isnan( normalLength ) || !isfinite( normalLength ) || normalLength<=EPSILON ) continue;
if( ISNAN( normalLength ) || !ISFINITE( normalLength ) || normalLength<=EPSILON ) continue;
if( !useConfidence ) n /= normalLength;
Real pointWeight = Real(1.f);
+92 -45
View File
@@ -35,6 +35,8 @@
#define DumpOutput(...) ((void)0)
#include "../Src/MultiGridOctreeData.h" //only after DumpOutput has been defined!
#define BSPLINE_DEGREE 2
PoissonReconLib::Parameters::Parameters()
: depth(8) //8
, cgDepth(0) //0
@@ -44,7 +46,7 @@ PoissonReconLib::Parameters::Parameters()
, fullDepth(5) //5
, minDepth(0) //0
, maxSolveDepth(0) //?
, boundary(1) //1
, dirichlet(true) //true
, threads(1) //ideally omp_get_num_procs()
, samplesPerNode(1.0f) //1.0f
, scale(1.1f) //1.1f
@@ -63,7 +65,7 @@ PoissonReconLib::Parameters::Parameters()
#endif
}
template< class PointCoordinateType, class Real, class Vertex >
template< class PointCoordinateType, class Real, int Degree, class Vertex >
bool Execute(PoissonReconLib::Parameters params, OrientedPointStream< PointCoordinateType >* pointStream, CoredVectorMeshData< Vertex >& mesh)
{
XForm4x4< Real > xForm = XForm4x4< Real >::Identity();
@@ -88,13 +90,14 @@ bool Execute(PoissonReconLib::Parameters params, OrientedPointStream< PointCoord
params.fullDepth = std::min(params.fullDepth, params.depth);
tree.maxMemoryUsage = 0;
typename Octree< Real >::template SparseNodeData< typename Octree< Real >::PointData >* pointInfo = new typename Octree< Real >::template SparseNodeData< typename Octree< Real >::PointData >();
typename Octree< Real >::template SparseNodeData< Point3D< Real > >* normalInfo = new typename Octree< Real >::template SparseNodeData< Point3D< Real > >();
std::vector< Real >* kernelDensityWeights = new std::vector< Real >();
std::vector< Real >* centerWeights = new std::vector< Real >();
SparseNodeData< PointData< Real > , 0 >* pointInfo = new SparseNodeData< PointData < Real > , 0 >();
SparseNodeData< Point3D< Real > , NORMAL_DEGREE >* normalInfo = new SparseNodeData< Point3D< Real > , NORMAL_DEGREE >();
SparseNodeData< Real , WEIGHT_DEGREE >* densityWeights = new SparseNodeData< Real , WEIGHT_DEGREE >();
SparseNodeData< Real , NORMAL_DEGREE >* nodeWeights = new SparseNodeData< Real , NORMAL_DEGREE >();
typedef typename Octree< Real >::template ProjectiveData< Point3D< Real > > ProjectiveColor;
SparseNodeData< ProjectiveColor , DATA_DEGREE >* colorData = 0;
int pointCount = tree.template SetTree< PointCoordinateType >(
int pointCount = tree.template SetTree< PointCoordinateType, NORMAL_DEGREE , WEIGHT_DEGREE , DATA_DEGREE , Point3D< unsigned char > >(
pointStream,
params.minDepth,
params.depth,
@@ -106,18 +109,36 @@ bool Execute(PoissonReconLib::Parameters params, OrientedPointStream< PointCoord
params.normalWeights,
params.pointWeight,
params.adaptiveExp,
*kernelDensityWeights,
*densityWeights,
*pointInfo,
*normalInfo,
*centerWeights,
*nodeWeights,
colorData,
xForm,
params.boundary,
params.dirichlet,
params.complete );
if( !params.density )
{
delete kernelDensityWeights;
kernelDensityWeights = NULL;
delete densityWeights;
densityWeights = NULL;
}
//reamp indexes
{
std::vector< int > indexMap;
if( NORMAL_DEGREE > Degree )
tree.template EnableMultigrid< NORMAL_DEGREE >( &indexMap );
else
tree.template EnableMultigrid< Degree >( &indexMap );
if (pointInfo)
pointInfo->remapIndices( indexMap );
if (normalInfo)
normalInfo->remapIndices( indexMap );
if (densityWeights)
densityWeights->remapIndices( indexMap );
if (nodeWeights)
nodeWeights->remapIndices( indexMap );
}
//DumpOutput( "Input Points: %d\n" , pointCount );
@@ -126,32 +147,33 @@ bool Execute(PoissonReconLib::Parameters params, OrientedPointStream< PointCoord
double maxMemoryUsage = tree.maxMemoryUsage;
tree.maxMemoryUsage = 0;
Pointer( Real ) constraints = tree.SetLaplacianConstraints( *normalInfo );
DenseNodeData< Real , Degree > constraints = tree.template SetLaplacianConstraints< Degree >( *normalInfo );
delete normalInfo;
normalInfo = 0;
maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );
tree.maxMemoryUsage = 0;
Pointer( Real ) solution = tree.SolveSystem( *pointInfo , constraints , params.showResidual , params.iters, params.maxSolveDepth, params.cgDepth, params.cgAccuracy );
DenseNodeData< Real , Degree > solution = tree.SolveSystem( *pointInfo , constraints , params.showResidual , params.iters, params.maxSolveDepth, params.cgDepth, params.cgAccuracy );
delete pointInfo;
pointInfo = 0;
FreePointer( constraints );
constraints.resize(0);
maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );
Real isoValue = tree.GetIsoValue( solution , *centerWeights );
delete centerWeights;
centerWeights = 0;
Real isoValue = tree.GetIsoValue( solution , *nodeWeights );
delete nodeWeights;
nodeWeights = 0;
//DumpOutput( "Iso-Value: %e\n" , isoValue );
//output
tree.maxMemoryUsage = 0;
tree.GetMCIsoSurface( kernelDensityWeights ? GetPointer( *kernelDensityWeights ) : NullPointer( Real ),
NULL,
tree.template GetMCIsoSurface< Degree , WEIGHT_DEGREE , DATA_DEGREE >(
densityWeights ? GetPointer( *densityWeights ) : NullPointer( Real ),
0,
solution,
isoValue,
mesh,
@@ -163,12 +185,12 @@ bool Execute(PoissonReconLib::Parameters params, OrientedPointStream< PointCoord
//DumpOutput( "Vertices / Polygons: %d / %d\n" , mesh.outOfCorePointCount()+mesh.inCorePoints.size() , mesh.polygonCount() );
FreePointer( solution );
solution.resize(0);
return true;
}
template< class PointCoordinateType, class Real, class Vertex >
template< class PointCoordinateType, class Real, int Degree, class Vertex >
bool Execute(PoissonReconLib::Parameters params, OrientedPointStreamWithData< PointCoordinateType , Point3D< unsigned char > >* pointStream, CoredVectorMeshData< Vertex >& mesh)
{
XForm4x4< Real > xForm = XForm4x4< Real >::Identity();
@@ -193,14 +215,16 @@ bool Execute(PoissonReconLib::Parameters params, OrientedPointStreamWithData< Po
params.fullDepth = std::min(params.fullDepth, params.depth);
tree.maxMemoryUsage = 0;
typename Octree< Real >::template SparseNodeData< typename Octree< Real >::PointData >* pointInfo = new typename Octree< Real >::template SparseNodeData< typename Octree< Real >::PointData >();
typename Octree< Real >::template SparseNodeData< Point3D< Real > >* normalInfo = new typename Octree< Real >::template SparseNodeData< Point3D< Real > >();
std::vector< Real >* kernelDensityWeights = new std::vector< Real >();
std::vector< Real >* centerWeights = new std::vector< Real >();
SparseNodeData< PointData< Real > , 0 >* pointInfo = new SparseNodeData< PointData < Real > , 0 >();
SparseNodeData< Point3D< Real > , NORMAL_DEGREE >* normalInfo = new SparseNodeData< Point3D< Real > , NORMAL_DEGREE >();
SparseNodeData< Real , WEIGHT_DEGREE >* densityWeights = new SparseNodeData< Real , WEIGHT_DEGREE >();
SparseNodeData< Real , NORMAL_DEGREE >* nodeWeights = new SparseNodeData< Real , NORMAL_DEGREE >();
typedef typename Octree< Real >::template ProjectiveData< Point3D< Real > > ProjectiveColor;
typename Octree< Real >::template SparseNodeData< ProjectiveColor > colorData;
SparseNodeData< ProjectiveColor , DATA_DEGREE > colorData;
int pointCount = tree.template SetTree< PointCoordinateType >(
int pointCount = tree.template SetTree< PointCoordinateType, NORMAL_DEGREE , WEIGHT_DEGREE , DATA_DEGREE , Point3D< unsigned char > >
(
pointStream,
params.minDepth,
params.depth,
@@ -212,16 +236,16 @@ bool Execute(PoissonReconLib::Parameters params, OrientedPointStreamWithData< Po
params.normalWeights,
params.pointWeight,
params.adaptiveExp,
*kernelDensityWeights,
*densityWeights,
*pointInfo,
*normalInfo,
*centerWeights,
colorData,
*nodeWeights,
&colorData,
xForm,
params.boundary,
params.dirichlet,
params.complete );
for (const OctNode< TreeNodeData >* n = tree.tree.nextNode(); n != NULL; n = tree.tree.nextNode(n))
for (const OctNode< TreeNodeData >* n = tree.tree().nextNode(); n != NULL; n = tree.tree().nextNode( n ) )
{
int idx = colorData.index(n);
if (idx >= 0)
@@ -230,8 +254,26 @@ bool Execute(PoissonReconLib::Parameters params, OrientedPointStreamWithData< Po
if( !params.density )
{
delete kernelDensityWeights;
kernelDensityWeights = NULL;
delete densityWeights;
densityWeights = NULL;
}
//reamp indexes
{
std::vector< int > indexMap;
if( NORMAL_DEGREE > Degree )
tree.template EnableMultigrid< NORMAL_DEGREE >( &indexMap );
else
tree.template EnableMultigrid< Degree >( &indexMap );
if (pointInfo)
pointInfo->remapIndices( indexMap );
if (normalInfo)
normalInfo->remapIndices( indexMap );
if (densityWeights)
densityWeights->remapIndices( indexMap );
if (nodeWeights)
nodeWeights->remapIndices( indexMap );
colorData.remapIndices( indexMap );
}
//DumpOutput( "Input Points: %d\n" , pointCount );
@@ -240,31 +282,32 @@ bool Execute(PoissonReconLib::Parameters params, OrientedPointStreamWithData< Po
double maxMemoryUsage = tree.maxMemoryUsage;
tree.maxMemoryUsage = 0;
Pointer( Real ) constraints = tree.SetLaplacianConstraints( *normalInfo );
DenseNodeData< Real , Degree > constraints = tree.template SetLaplacianConstraints< Degree >( *normalInfo );
delete normalInfo;
normalInfo = 0;
maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );
tree.maxMemoryUsage = 0;
Pointer( Real ) solution = tree.SolveSystem( *pointInfo , constraints , params.showResidual , params.iters, params.maxSolveDepth, params.cgDepth, params.cgAccuracy );
DenseNodeData< Real , Degree > solution = tree.SolveSystem( *pointInfo , constraints , params.showResidual , params.iters, params.maxSolveDepth, params.cgDepth, params.cgAccuracy );
delete pointInfo;
pointInfo = 0;
FreePointer( constraints );
constraints.resize(0);
maxMemoryUsage = std::max< double >( maxMemoryUsage , tree.maxMemoryUsage );
Real isoValue = tree.GetIsoValue( solution , *centerWeights );
delete centerWeights;
centerWeights = 0;
Real isoValue = tree.GetIsoValue( solution , *nodeWeights );
delete nodeWeights;
nodeWeights = 0;
//DumpOutput( "Iso-Value: %e\n" , isoValue );
//output
tree.maxMemoryUsage = 0;
tree.GetMCIsoSurface( kernelDensityWeights ? GetPointer( *kernelDensityWeights ) : NullPointer( Real ),
tree.template GetMCIsoSurface< Degree , WEIGHT_DEGREE , DATA_DEGREE >(
densityWeights ? GetPointer( *densityWeights ) : NullPointer( Real ),
&colorData,
solution,
isoValue,
@@ -277,7 +320,7 @@ bool Execute(PoissonReconLib::Parameters params, OrientedPointStreamWithData< Po
//DumpOutput( "Vertices / Polygons: %d / %d\n" , mesh.outOfCorePointCount()+mesh.inCorePoints.size() , mesh.polygonCount() );
FreePointer( solution );
solution.resize(0);
return true;
}
@@ -286,13 +329,15 @@ bool PoissonReconLib::Reconstruct(Parameters params, OrientedPointStreamWithData
{
return Execute< float,
float,
PlyColorAndValueVertex< float > > (params, pointStream, mesh);
BSPLINE_DEGREE,
PlyColorAndValueVertex< float > > (params, pointStream, mesh);
}
bool PoissonReconLib::Reconstruct(Parameters params, OrientedPointStream< float >* pointStream, CoredVectorMeshData< PlyValueVertex< float > >& mesh)
{
return Execute< float,
float,
BSPLINE_DEGREE,
PlyValueVertex< float > > (params, pointStream, mesh);
}
@@ -300,12 +345,14 @@ bool PoissonReconLib::Reconstruct(Parameters params, OrientedPointStreamWithData
{
return Execute< double,
double,
PlyColorAndValueVertex< double > > (params, pointStream, mesh);
BSPLINE_DEGREE,
PlyColorAndValueVertex< double > > (params, pointStream, mesh);
}
bool PoissonReconLib::Reconstruct(Parameters params, OrientedPointStream< double >* pointStream, CoredVectorMeshData< PlyValueVertex< double > >& mesh)
{
return Execute< double,
double,
BSPLINE_DEGREE,
PlyValueVertex< double > > (params, pointStream, mesh);
}
+1 -1
View File
@@ -89,7 +89,7 @@ public:
bool showResidual;
int kernelDepth;
int maxSolveDepth;
int boundary;
bool dirichlet;
//DGM: the above parameters are hidden in PoissonRecon