From fb4aca4db5b5a469d578ace388eeb004a0671aa1 Mon Sep 17 00:00:00 2001 From: mkazhdan Date: Sat, 8 Dec 2018 22:56:40 -0500 Subject: [PATCH] Added support for the --inCore flag. --- Src/Geometry.h | 1 + Src/PoissonRecon.cpp | 42 +++++++++++++++++++++++++++++++++--------- Src/SSDRecon.cpp | 42 +++++++++++++++++++++++++++++++++--------- 3 files changed, 67 insertions(+), 18 deletions(-) diff --git a/Src/Geometry.h b/Src/Geometry.h index 7e52c76..7faf508 100644 --- a/Src/Geometry.h +++ b/Src/Geometry.h @@ -440,6 +440,7 @@ template< class Vertex > class CoredMeshData { public: + virtual ~CoredMeshData( void ){} std::vector< Vertex > inCorePoints; virtual void resetIterator( void ) = 0; diff --git a/Src/PoissonRecon.cpp b/Src/PoissonRecon.cpp index c9c1680..2276188 100644 --- a/Src/PoissonRecon.cpp +++ b/Src/PoissonRecon.cpp @@ -74,6 +74,7 @@ cmdLineReadable ExactInterpolation( "exact" ) , Normals( "normals" ) , Colors( "colors" ) , + InCore( "inCore" ) , Verbose( "verbose" ); cmdLineParameter< int > @@ -128,6 +129,7 @@ cmdLineReadable* params[] = &ExactInterpolation , &Performance , &MaxMemoryGB , + &InCore , NULL }; @@ -172,6 +174,7 @@ void ShowUsage(char* ex) printf( "\t[--%s]\n" , ASCII.name ); printf( "\t[--%s]\n" , NoComments.name ); printf( "\t[--%s]\n" , TempDir.name ); + printf( "\t[--%s]\n" , InCore.name ); printf( "\t[--%s]\n" , Verbose.name ); } @@ -313,7 +316,9 @@ void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTr if( tempPath[ strlen( tempPath )-1 ]==FileSeparator ) sprintf( tempHeader , "%sPR_" , tempPath ); else sprintf( tempHeader , "%s%cPR_" , tempPath , FileSeparator ); } - CoredFileMeshData< Vertex > mesh( tempHeader ); + CoredMeshData< Vertex > *mesh; + if( InCore.set ) mesh = new CoredVectorMeshData< Vertex >(); + else mesh = new CoredFileMeshData< Vertex >( tempHeader ); profiler.start(); typename IsoSurfaceExtractor< Dim , Real , Vertex >::IsoStats isoStats; @@ -325,22 +330,24 @@ void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTr ProjectiveData< TotalPointSampleData , Real >* clr = _sampleData( n ); if( clr ) (*clr) *= (Real)pow( DataX.value , tree.depth( n ) ); } - isoStats = IsoSurfaceExtractor< Dim , Real , Vertex >::template Extract< TotalPointSampleData >( Sigs() , UIntPack< WEIGHT_DEGREE >() , UIntPack< DataSig >() , tree , density , &_sampleData , solution , isoValue , mesh , SetVertex , !LinearFit.set , !NonManifold.set , PolygonMesh.set , false ); + isoStats = IsoSurfaceExtractor< Dim , Real , Vertex >::template Extract< TotalPointSampleData >( Sigs() , UIntPack< WEIGHT_DEGREE >() , UIntPack< DataSig >() , tree , density , &_sampleData , solution , isoValue , *mesh , SetVertex , !LinearFit.set , !NonManifold.set , PolygonMesh.set , false ); } #if defined( __GNUC__ ) && __GNUC__ < 5 #warning "you've got me gcc version<5" - else isoStats = IsoSurfaceExtractor< Dim , Real , Vertex >::template Extract< TotalPointSampleData >( Sigs() , UIntPack< WEIGHT_DEGREE >() , UIntPack< DataSig >() , tree , density , (SparseNodeData< ProjectiveData< TotalPointSampleData , Real > , IsotropicUIntPack< Dim , DataSig > > *)NULL , solution , isoValue , mesh , SetVertex , !LinearFit.set , !NonManifold.set , PolygonMesh.set , false ); + else isoStats = IsoSurfaceExtractor< Dim , Real , Vertex >::template Extract< TotalPointSampleData >( Sigs() , UIntPack< WEIGHT_DEGREE >() , UIntPack< DataSig >() , tree , density , (SparseNodeData< ProjectiveData< TotalPointSampleData , Real > , IsotropicUIntPack< Dim , DataSig > > *)NULL , solution , isoValue , *mesh , SetVertex , !LinearFit.set , !NonManifold.set , PolygonMesh.set , false ); #else // !__GNUC__ || __GNUC__ >=5 - else isoStats = IsoSurfaceExtractor< Dim , Real , Vertex >::template Extract< TotalPointSampleData >( Sigs() , UIntPack< WEIGHT_DEGREE >() , UIntPack< DataSig >() , tree , density , NULL , solution , isoValue , mesh , SetVertex , !LinearFit.set , !NonManifold.set , PolygonMesh.set , false ); + else isoStats = IsoSurfaceExtractor< Dim , Real , Vertex >::template Extract< TotalPointSampleData >( Sigs() , UIntPack< WEIGHT_DEGREE >() , UIntPack< DataSig >() , tree , density , NULL , solution , isoValue , *mesh , SetVertex , !LinearFit.set , !NonManifold.set , PolygonMesh.set , false ); #endif // __GNUC__ || __GNUC__ < 4 - messageWriter( "Vertices / Polygons: %d / %d\n" , mesh.outOfCorePointCount()+mesh.inCorePoints.size() , mesh.polygonCount() ); + messageWriter( "Vertices / Polygons: %d / %d\n" , mesh->outOfCorePointCount()+mesh->inCorePoints.size() , mesh->polygonCount() ); messageWriter( "Corners / Vertices / Edges / Surface / Set Table / Copy Finer: %.1f / %.1f / %.1f / %.1f / %.1f / %.1f (s)\n" , isoStats.cornersTime , isoStats.verticesTime , isoStats.edgesTime , isoStats.surfaceTime , isoStats.setTableTime , isoStats.copyFinerTime ); if( PolygonMesh.set ) profiler.dumpOutput2( comments , "# Got polygons:" ); else profiler.dumpOutput2( comments , "# Got triangles:" ); std::vector< std::string > noComments; - if( !PlyWritePolygons< Vertex , Real , Dim >( Out.value , &mesh , ASCII.set ? PLY_ASCII : PLY_BINARY_NATIVE , NoComments.set ? noComments : comments , iXForm ) ) + if( !PlyWritePolygons< Vertex , Real , Dim >( Out.value , mesh , ASCII.set ? PLY_ASCII : PLY_BINARY_NATIVE , NoComments.set ? noComments : comments , iXForm ) ) ERROR_OUT( "Could not write mesh to: %s" , Out.value ); + + delete mesh; } template< class Real , typename ... SampleData , unsigned int ... FEMSigs > @@ -423,9 +430,26 @@ void Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > ) InputPointStream* pointStream; char* ext = GetFileExtension( In.value ); sampleData = new std::vector< TotalPointSampleData >(); - if ( !strcasecmp( ext , "bnpts" ) ) pointStream = new BinaryInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::ReadBinary ); - else if( !strcasecmp( ext , "ply" ) ) pointStream = new PLYInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::PlyReadProperties() , TotalPointSampleData::PlyReadNum , TotalPointSampleData::ValidPlyReadProperties ); - else pointStream = new ASCIIInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::ReadASCII ); + std::vector< std::pair< Point< Real , Dim > , TotalPointSampleData > > inCorePoints; + if( InCore.set ) + { + InputPointStream *_pointStream; + if ( !strcasecmp( ext , "bnpts" ) ) _pointStream = new BinaryInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::ReadBinary ); + else if( !strcasecmp( ext , "ply" ) ) _pointStream = new PLYInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::PlyReadProperties() , TotalPointSampleData::PlyReadNum , TotalPointSampleData::ValidPlyReadProperties ); + else _pointStream = new ASCIIInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::ReadASCII ); + Point< Real , Dim > p; + TotalPointSampleData d; + while( _pointStream->nextPoint( p , d ) ) inCorePoints.push_back( std::pair< Point< Real , Dim > , TotalPointSampleData >( p , d ) ); + delete _pointStream; + + pointStream = new MemoryInputPointStreamWithData< Real , Dim , TotalPointSampleData >( inCorePoints.size() , &inCorePoints[0] ); + } + else + { + if ( !strcasecmp( ext , "bnpts" ) ) pointStream = new BinaryInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::ReadBinary ); + else if( !strcasecmp( ext , "ply" ) ) pointStream = new PLYInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::PlyReadProperties() , TotalPointSampleData::PlyReadNum , TotalPointSampleData::ValidPlyReadProperties ); + else pointStream = new ASCIIInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::ReadASCII ); + } delete[] ext; typename TotalPointSampleData::Transform _xForm( xForm ); XInputPointStream _pointStream( [&]( Point< Real , Dim >& p , TotalPointSampleData& d ){ p = xForm*p , d = _xForm(d); } , *pointStream ); diff --git a/Src/SSDRecon.cpp b/Src/SSDRecon.cpp index f873cec..22817dc 100644 --- a/Src/SSDRecon.cpp +++ b/Src/SSDRecon.cpp @@ -74,6 +74,7 @@ cmdLineReadable ExactInterpolation( "exact" ) , Normals( "normals" ) , Colors( "colors" ) , + InCore( "inCore" ) , Verbose( "verbose" ); cmdLineParameter< int > @@ -131,6 +132,7 @@ cmdLineReadable* params[] = &ExactInterpolation , &Performance , &MaxMemoryGB , + &InCore , NULL }; @@ -177,6 +179,7 @@ void ShowUsage(char* ex) printf( "\t[--%s]\n" , ASCII.name ); printf( "\t[--%s]\n" , NoComments.name ); printf( "\t[--%s]\n" , TempDir.name ); + printf( "\t[--%s]\n" , InCore.name ); printf( "\t[--%s]\n" , Verbose.name ); } @@ -334,7 +337,10 @@ void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTr if( tempPath[ strlen( tempPath )-1 ]==FileSeparator ) sprintf( tempHeader , "%sPR_" , tempPath ); else sprintf( tempHeader , "%s%cPR_" , tempPath , FileSeparator ); } - CoredFileMeshData< Vertex > mesh( tempHeader ); + + CoredMeshData< Vertex > *mesh; + if( InCore.set ) mesh = new CoredVectorMeshData< Vertex >(); + else mesh = new CoredFileMeshData< Vertex >( tempHeader ); profiler.start(); typename IsoSurfaceExtractor< Dim , Real , Vertex >::IsoStats isoStats; if( sampleData ) @@ -345,22 +351,23 @@ void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTr ProjectiveData< TotalPointSampleData , Real >* clr = _sampleData( n ); if( clr ) (*clr) *= (Real)pow( DataX.value , tree.depth( n ) ); } - isoStats = IsoSurfaceExtractor< Dim , Real , Vertex >::template Extract< TotalPointSampleData >( Sigs() , UIntPack< WEIGHT_DEGREE >() , UIntPack< DataSig >() , tree , density , &_sampleData , solution , isoValue , mesh , SetVertex , NonLinearFit.set , !NonManifold.set , PolygonMesh.set , false ); + isoStats = IsoSurfaceExtractor< Dim , Real , Vertex >::template Extract< TotalPointSampleData >( Sigs() , UIntPack< WEIGHT_DEGREE >() , UIntPack< DataSig >() , tree , density , &_sampleData , solution , isoValue , *mesh , SetVertex , NonLinearFit.set , !NonManifold.set , PolygonMesh.set , false ); } #if defined( __GNUC__ ) && __GNUC__ < 5 #warning "you've got me gcc version<5" - else isoStats = IsoSurfaceExtractor< Dim , Real , Vertex >::template Extract< TotalPointSampleData >( Sigs() , UIntPack< WEIGHT_DEGREE >() , UIntPack< DataSig >() , tree , density , (SparseNodeData< ProjectiveData< TotalPointSampleData , Real > , IsotropicUIntPack< Dim , DataSig > > *)NULL , solution , isoValue , mesh , SetVertex , NonLinearFit.set , !NonManifold.set , PolygonMesh.set , false ); + else isoStats = IsoSurfaceExtractor< Dim , Real , Vertex >::template Extract< TotalPointSampleData >( Sigs() , UIntPack< WEIGHT_DEGREE >() , UIntPack< DataSig >() , tree , density , (SparseNodeData< ProjectiveData< TotalPointSampleData , Real > , IsotropicUIntPack< Dim , DataSig > > *)NULL , solution , isoValue , *mesh , SetVertex , NonLinearFit.set , !NonManifold.set , PolygonMesh.set , false ); #else // !__GNUC__ || __GNUC__ >=5 - else isoStats = IsoSurfaceExtractor< Dim , Real , Vertex >::template Extract< TotalPointSampleData >( Sigs() , UIntPack< WEIGHT_DEGREE >() , UIntPack< DataSig >() , tree , density , NULL , solution , isoValue , mesh , SetVertex , NonLinearFit.set , !NonManifold.set , PolygonMesh.set , false ); + else isoStats = IsoSurfaceExtractor< Dim , Real , Vertex >::template Extract< TotalPointSampleData >( Sigs() , UIntPack< WEIGHT_DEGREE >() , UIntPack< DataSig >() , tree , density , NULL , solution , isoValue , *mesh , SetVertex , NonLinearFit.set , !NonManifold.set , PolygonMesh.set , false ); #endif // __GNUC__ || __GNUC__ < 4 - messageWriter( "Vertices / Polygons: %d / %d\n" , mesh.outOfCorePointCount()+mesh.inCorePoints.size() , mesh.polygonCount() ); + messageWriter( "Vertices / Polygons: %d / %d\n" , mesh->outOfCorePointCount()+mesh->inCorePoints.size() , mesh->polygonCount() ); messageWriter( "Corners / Vertices / Edges / Surface / Set Table / Copy Finer: %.1f / %.1f / %.1f / %.1f / %.1f / %.1f (s)\n" , isoStats.cornersTime , isoStats.verticesTime , isoStats.edgesTime , isoStats.surfaceTime , isoStats.setTableTime , isoStats.copyFinerTime ); if( PolygonMesh.set ) profiler.dumpOutput2( comments , "# Got polygons:" ); else profiler.dumpOutput2( comments , "# Got triangles:" ); std::vector< std::string > noComments; - if( !PlyWritePolygons< Vertex , Real , Dim >( Out.value , &mesh , ASCII.set ? PLY_ASCII : PLY_BINARY_NATIVE , NoComments.set ? noComments : comments , iXForm ) ) + if( !PlyWritePolygons< Vertex , Real , Dim >( Out.value , mesh , ASCII.set ? PLY_ASCII : PLY_BINARY_NATIVE , NoComments.set ? noComments : comments , iXForm ) ) ERROR_OUT( "Could not write mesh to: %s" , Out.value ); + delete mesh; } template< class Real , typename ... SampleData , unsigned int ... FEMSigs > @@ -443,9 +450,26 @@ void Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > ) InputPointStream* pointStream; char* ext = GetFileExtension( In.value ); sampleData = new std::vector< TotalPointSampleData >(); - if ( !strcasecmp( ext , "bnpts" ) ) pointStream = new BinaryInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::ReadBinary ); - else if( !strcasecmp( ext , "ply" ) ) pointStream = new PLYInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::PlyReadProperties() , TotalPointSampleData::PlyReadNum , TotalPointSampleData::ValidPlyReadProperties ); - else pointStream = new ASCIIInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::ReadASCII ); + std::vector< std::pair< Point< Real , Dim > , TotalPointSampleData > > inCorePoints; + if( InCore.set ) + { + InputPointStream *_pointStream; + if ( !strcasecmp( ext , "bnpts" ) ) _pointStream = new BinaryInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::ReadBinary ); + else if( !strcasecmp( ext , "ply" ) ) _pointStream = new PLYInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::PlyReadProperties() , TotalPointSampleData::PlyReadNum , TotalPointSampleData::ValidPlyReadProperties ); + else _pointStream = new ASCIIInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::ReadASCII ); + Point< Real , Dim > p; + TotalPointSampleData d; + while( _pointStream->nextPoint( p , d ) ) inCorePoints.push_back( std::pair< Point< Real , Dim > , TotalPointSampleData >( p , d ) ); + delete _pointStream; + + pointStream = new MemoryInputPointStreamWithData< Real , Dim , TotalPointSampleData >( inCorePoints.size() , &inCorePoints[0] ); + } + else + { + if ( !strcasecmp( ext , "bnpts" ) ) pointStream = new BinaryInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::ReadBinary ); + else if( !strcasecmp( ext , "ply" ) ) pointStream = new PLYInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::PlyReadProperties() , TotalPointSampleData::PlyReadNum , TotalPointSampleData::ValidPlyReadProperties ); + else pointStream = new ASCIIInputPointStreamWithData< Real , Dim , TotalPointSampleData >( In.value , TotalPointSampleData::ReadASCII ); + } delete[] ext; typename TotalPointSampleData::Transform _xForm( xForm ); XInputPointStream _pointStream( [&]( Point< Real , Dim >& p , TotalPointSampleData& d ){ p = xForm*p , d = _xForm(d); } , *pointStream );