From 4cbbb6e1cf0f1341a6c1b5e186f710b0528cc229 Mon Sep 17 00:00:00 2001 From: mkazhdan Date: Mon, 8 Oct 2018 10:27:59 -0400 Subject: [PATCH] no message --- .gitignore | 1 + AdaptiveSolvers.sln | 6 ++++++ Makefile | 2 +- README.md | 26 ++++++++++++++++--------- Src/EDTInHeat.cpp | 7 +++++++ Src/FEMTree.System.inl | 2 +- Src/FEMTree.h | 4 ++-- Src/Geometry.h | 2 +- Src/Image.h | 1 + Src/ImageStitching.cpp | 7 ++++++- Src/PNG.inl | 1 + Src/Ply.h | 44 +++++++++++++++++++++++++++++++++++++++++- Src/PointStream.inl | 36 ++++++++++++++++++++++++++++++++++ Src/PoissonRecon.cpp | 4 +++- Src/RegularTree.h | 3 +++ Src/RegularTree.inl | 9 +++++++++ Src/SSDRecon.cpp | 4 +++- Src/SurfaceTrimmer.cpp | 3 +++ 18 files changed, 144 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index a0e2570..73ae173 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ /Bin/ *.opensdf *.bat +*.zip .vs/* \ No newline at end of file diff --git a/AdaptiveSolvers.sln b/AdaptiveSolvers.sln index 6b4486e..3d77c31 100644 --- a/AdaptiveSolvers.sln +++ b/AdaptiveSolvers.sln @@ -37,11 +37,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Header Files", "Header File Src\FEMTree.h = Src\FEMTree.h Src\FunctionData.h = Src\FunctionData.h Src\Geometry.h = Src\Geometry.h + Src\Image.h = Src\Image.h + Src\JPEG.h = Src\JPEG.h Src\MarchingCubes.h = Src\MarchingCubes.h Src\MAT.h = Src\MAT.h Src\MyMiscellany.h = Src\MyMiscellany.h Src\Ply.h = Src\Ply.h Src\PlyFile.h = Src\PlyFile.h + Src\PNG.h = Src\PNG.h Src\PointStream.h = Src\PointStream.h Src\PointStreamData.h = Src\PointStreamData.h Src\Polynomial.h = Src\Polynomial.h @@ -55,6 +58,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Inline Files", "Inline Files", "{ACD217C3-BE24-4438-A4E6-C713312FEA34}" ProjectSection(SolutionItems) = preProject Src\Array.inl = Src\Array.inl + Src\BMPStream.inl = Src\BMPStream.inl Src\BSplineData.inl = Src\BSplineData.inl Src\CmdLineParser.inl = Src\CmdLineParser.inl Src\FEMTree.Evaluation.inl = Src\FEMTree.Evaluation.inl @@ -66,7 +70,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Inline Files", "Inline File Src\FEMTree.WeightedSamples.inl = Src\FEMTree.WeightedSamples.inl Src\FunctionData.inl = Src\FunctionData.inl Src\Geometry.inl = Src\Geometry.inl + Src\JPEG.inl = Src\JPEG.inl Src\MAT.inl = Src\MAT.inl + Src\PNG.inl = Src\PNG.inl Src\PointStream.inl = Src\PointStream.inl Src\Polynomial.inl = Src\Polynomial.inl Src\PPolynomial.inl = Src\PPolynomial.inl diff --git a/Makefile b/Makefile index bee5ee4..1b00f2a 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ COMPILER = gcc #COMPILER = clang ifeq ($(COMPILER),gcc) - CFLAGS += -fopenmp -Wno-deprecated -Wno-write-strings -std=c++11 + CFLAGS += -fopenmp -Wno-deprecated -Wno-write-strings -std=c++11 -Wno-invalid-offsetof LFLAGS += -lgomp -lstdc++ else # CFLAGS += -fopenmp=libiomp5 -Wno-deprecated -Wno-write-strings -std=c++11 -Wno-invalid-offsetof diff --git a/README.md b/README.md index 04e2983..2baf6b9 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -

Adaptive Multigrid Solvers (Version 10.02)

+

Adaptive Multigrid Solvers (Version 10.03)

-links -executables -usage -changes +links +executables +usage +changes

@@ -27,10 +27,11 @@ This code-base was born from the Poisson Surface Reconstruction code. It has evo [Kazhdan and Hoppe, 2013]
Executables: -Win64
+Win64
Source Code: -ZIP GitHub
+ZIP GitHub
Older Versions: +V10.02, V10.01, V10.00, V9.011, @@ -773,8 +774,15 @@ Similarly, to reduce compilation times, support for specific degrees can be remo Version 10.02:
    -
  1. Set the default FEM degree for PoissonRecon to 1 and set the default data dgree for PoissonRecon and SSDRecon to 0.
  2. +
  3. Set the default value for --degree in PoissonRecon to 1 and change the definitiion of DATA_DEGREE to 0 for sharper color interpolation.
+ + +Version 10.03: +
    +
  1. Cleaned up memory leaks. +
+ diff --git a/Src/EDTInHeat.cpp b/Src/EDTInHeat.cpp index 42f5b0f..762dbcb 100644 --- a/Src/EDTInHeat.cpp +++ b/Src/EDTInHeat.cpp @@ -318,6 +318,7 @@ int _Execute( int argc , char* argv[] ) for( int i=0 ; i( nodes , (int)geometrySamples.size() ); profiler.dumpOutput2( comments , "# Thickened tree:" ); + delete[] nodes; } // Finalize the topology of the tree @@ -529,6 +530,8 @@ int _Execute( int argc , char* argv[] ) } } + for( int i=0 ; iFullDepth.value ) { if( BaseDepth.set ) fprintf( stderr , "[WARNING] Base depth must be smaller than full depth: %d <= %d\n" , BaseDepth.value , FullDepth.value ); diff --git a/Src/FEMTree.System.inl b/Src/FEMTree.System.inl index e7c3dfc..8018ed4 100644 --- a/Src/FEMTree.System.inl +++ b/Src/FEMTree.System.inl @@ -1872,7 +1872,7 @@ DenseNodeData< Real , UIntPack< FEMSigs ... > > FEMTree< Dim , Real >::supportWe for( int d=0 ; d<=_maxDepth ; d++ ) { for( size_t i=0 ; i( stencil ); #pragma omp parallel for for( int i=_sNodesBegin(d) ; i<_sNodesEnd(d) ; i++ ) if( _isValidFEM1Node( _sNodes.treeNodes[i] ) ) diff --git a/Src/FEMTree.h b/Src/FEMTree.h index 7c11eaa..3d1c421 100644 --- a/Src/FEMTree.h +++ b/Src/FEMTree.h @@ -42,7 +42,7 @@ DAMAGE. #ifndef FEM_TREE_INCLUDED #define FEM_TREE_INCLUDED -#define VERSION "10.02" +#define VERSION "10.03" #define MEMORY_ALLOCATOR_BLOCK_SIZE 1<<12 #define NEW_CODE @@ -865,7 +865,7 @@ public: { typedef Constraint< UIntPack< TDegrees ... > , UIntPack< TDegrees ... > , 1 > Base; SystemConstraint( System< UIntPack< TDegrees ... > >& sys ) : _sys( sys ){;} - void init( void ){ _sys.init( Base::highDepth() ) ; _sys.init(); } + void init( void ){ _sys.init( Base::highDepth() ) ; _sys.init(); } Point< double , 1 > ccIntegrate( const int off1[] , const int off2[] ) const{ return Point< double , 1 >( _sys.ccIntegrate( off1 , off2 ) ); } Point< double , 1 > pcIntegrate( const int off1[] , const int off2[] ) const{ return Point< double , 1 >( _sys.pcIntegrate( off1 , off2 ) ); } Point< double , 1 > cpIntegrate( const int off1[] , const int off2[] ) const{ return Point< double , 1 >( _sys.pcIntegrate( off2 , off1 ) ); } diff --git a/Src/Geometry.h b/Src/Geometry.h index a7b56c9..8071039 100644 --- a/Src/Geometry.h +++ b/Src/Geometry.h @@ -539,7 +539,7 @@ public: bool write( const void* data , size_t size ) { if( !size ) return true; - char* _data = (char*) data; + const char* _data = (char*) data; size_t sz = _bufferSize - _bufferIndex; while( sz<=size ) { diff --git a/Src/Image.h b/Src/Image.h index 8c1cda6..b2bf7b7 100644 --- a/Src/Image.h +++ b/Src/Image.h @@ -194,6 +194,7 @@ inline void ImageReader::GetInfo( const char* fileName , unsigned int& width , u else if( !strcasecmp( ext , "png" ) ) PNGReader::GetInfo( fileName , width , height , channels ); else if( !strcasecmp( ext , "iGrid" ) ) TiledImageReader::GetInfo( fileName , width , height , channels ); #endif // WIN32 + delete[] ext; } inline ImageWriter* ImageWriter::Get( const char* fileName , unsigned int width , unsigned int height , unsigned int channels , ImageWriterParams params ) { diff --git a/Src/ImageStitching.cpp b/Src/ImageStitching.cpp index 4d2843c..065f815 100644 --- a/Src/ImageStitching.cpp +++ b/Src/ImageStitching.cpp @@ -459,7 +459,7 @@ void _Execute( void ) c += outBlock[ii] - average; _outRows[ii] = RGBPixel( c[0] , c[1] , c[2] ); } - FreePointer( outBlock ); + DeletePointer( outBlock ); } } } @@ -475,6 +475,9 @@ void _Execute( void ) delete out; } } + +#ifdef FAST_COMPILE +#else // !FAST_COMPILE template< typename Real > void _Execute( void ) { @@ -487,6 +490,8 @@ void _Execute( void ) default: fprintf( stderr , "[ERROR] Only B-Splines of degree 1 - 2 are supported" ) ; exit( 0 ); } } +#endif // FAST_COMPILE + int main( int argc , char* argv[] ) { Timer timer; diff --git a/Src/PNG.inl b/Src/PNG.inl index fb05ec2..6565c10 100644 --- a/Src/PNG.inl +++ b/Src/PNG.inl @@ -67,6 +67,7 @@ PNGReader::~PNGReader( void ) { if( _scratchRow ) delete[] _scratchRow; _scratchRow = NULL; + png_destroy_read_struct( &_png_ptr , &_info_ptr , &_end_info ); } inline bool PNGReader::GetInfo( const char* fileName , unsigned int& width , unsigned int& height , unsigned int& channels ) diff --git a/Src/Ply.h b/Src/Ply.h index cf3c8da..58a82b5 100644 --- a/Src/Ply.h +++ b/Src/Ply.h @@ -421,6 +421,27 @@ int PlyWritePolygons( const char* fileName, } delete[] ply_face.vertices; + if( ply->nelems ) + { + for( int i=0 ; inelems ; i++ ) + { + free( ply->elems[i]->name ); + if( ply->elems[i]->store_prop ) free( ply->elems[i]->store_prop ); + for( int j=0 ; jelems[i]->nprops ; j++ ) + { + free( ply->elems[i]->props[j]->name ); + free( ply->elems[i]->props[j] ); + } + free( ply->elems[i]->props ); + free( ply->elems[i] ); + } + free( ply->elems ); + } + if( ply->num_comments ) + { + for( int i=0 ; inum_comments ; i++ ) free( ply->comments[i] ); + free( ply->comments ); + } ply_close(ply); return 1; } @@ -498,7 +519,7 @@ int PlyReadPolygons( const char* fileName, ply_get_element (ply, (void *) &ply_face); polygons[j].resize(ply_face.nr_vertices); for(k=0;k* mesh , int delete[] ply_face.vertices; } // for, write faces + if( ply->nelems ) + { + for( int i=0 ; inelems ; i++ ) + { + free( ply->elems[i]->name ); + if( ply->elems[i]->store_prop ) free( ply->elems[i]->store_prop ); + for( int j=0 ; jelems[i]->nprops ; j++ ) + { + free( ply->elems[i]->props[j]->name ); + free( ply->elems[i]->props[j] ); + } + free( ply->elems[i]->props ); + free( ply->elems[i] ); + } + free( ply->elems ); + } + if( ply->num_comments ) + { + for( int i=0 ; inum_comments ; i++ ) free( ply->comments[i] ); + free( ply->comments ); + } ply_close( ply ); return 1; } diff --git a/Src/PointStream.inl b/Src/PointStream.inl index 8bc144a..93bd511 100644 --- a/Src/PointStream.inl +++ b/Src/PointStream.inl @@ -182,6 +182,16 @@ void PLYInputPointStream< Real , Dim >::reset( void ) template< class Real , int Dim > void PLYInputPointStream< Real , Dim >::_free( void ) { + if( _ply->comments ) + { + for( int i=0 ; i<_ply->num_comments ; i++ ) free( _ply->comments[i] ); + free( _ply->comments ); + } + if( _ply->obj_info ) + { + for( int i=0 ; i<_ply->num_obj_info ; i++ ) free( _ply->obj_info[i] ); + free( _ply->obj_info ); + } if( _ply ) ply_close( _ply ) , _ply = NULL; if( _elist ) { @@ -391,6 +401,32 @@ void PLYInputPointStreamWithData< Real , Dim , Data >::reset( void ) template< class Real , int Dim , class Data > void PLYInputPointStreamWithData< Real , Dim , Data >::_free( void ) { + if( _ply->comments ) + { + for( int i=0 ; i<_ply->num_comments ; i++ ) free( _ply->comments[i] ); + free( _ply->comments ); + } + if( _ply->obj_info ) + { + for( int i=0 ; i<_ply->num_obj_info ; i++ ) free( _ply->obj_info[i] ); + free( _ply->obj_info ); + } + if( _ply->elems ) + { + for( int i=0 ; i<_ply->nelems ; i++ ) + { + free( _ply->elems[i]->name ); + if( _ply->elems[i]->store_prop ) free( _ply->elems[i]->store_prop ); + for( int j=0 ; j<_ply->elems[i]->nprops ; j++ ) + { + free( _ply->elems[i]->props[j]->name ); + free( _ply->elems[i]->props[j] ); + } + free( _ply->elems[i]->props ); + free( _ply->elems[i] ); + } + free( _ply->elems ); + } if( _ply ) ply_close( _ply ) , _ply = NULL; if( _elist ) { diff --git a/Src/PoissonRecon.cpp b/Src/PoissonRecon.cpp index 2329f83..d5489f3 100644 --- a/Src/PoissonRecon.cpp +++ b/Src/PoissonRecon.cpp @@ -291,7 +291,7 @@ struct SystemDual< Dim , double > }; template< typename Vertex , typename Real , unsigned int ... FEMSigs , typename ... SampleData > -void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTree< sizeof ... ( FEMSigs ) , Real >& tree , const DenseNodeData< Real , UIntPack< FEMSigs ... > >& solution , Real isoValue , const std::vector< typename FEMTree< sizeof ... ( FEMSigs ) , Real >::PointSample >* samples , std::vector< MultiPointStreamData< Real , PointStreamNormal< Real , DIMENSION > , MultiPointStreamData< Real , SampleData ... > > >* sampleData , const typename FEMTree< sizeof ... ( FEMSigs ) , Real >::template DensityEstimator< WEIGHT_DEGREE >* density , std::function< void ( Vertex& , Point< Real , DIMENSION > , Real , MultiPointStreamData< Real , PointStreamNormal< Real , DIMENSION > , MultiPointStreamData< Real , SampleData ... > > ) > SetVertex , std::vector< char* > comments , XForm< Real , sizeof...(FEMSigs)+1 > iXForm ) +void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTree< sizeof ... ( FEMSigs ) , Real >& tree , const DenseNodeData< Real , UIntPack< FEMSigs ... > >& solution , Real isoValue , const std::vector< typename FEMTree< sizeof ... ( FEMSigs ) , Real >::PointSample >* samples , std::vector< MultiPointStreamData< Real , PointStreamNormal< Real , DIMENSION > , MultiPointStreamData< Real , SampleData ... > > >* sampleData , const typename FEMTree< sizeof ... ( FEMSigs ) , Real >::template DensityEstimator< WEIGHT_DEGREE >* density , std::function< void ( Vertex& , Point< Real , DIMENSION > , Real , MultiPointStreamData< Real , PointStreamNormal< Real , DIMENSION > , MultiPointStreamData< Real , SampleData ... > > ) > SetVertex , std::vector< char* >& comments , XForm< Real , sizeof...(FEMSigs)+1 > iXForm ) { static const int Dim = sizeof ... ( FEMSigs ); typedef UIntPack< FEMSigs ... > Sigs; @@ -632,6 +632,8 @@ int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > ) if( density ) delete density , density = NULL; messageWriter( comments , "# Total Solve: %9.1f (s), %9.1f (MB)\n" , Time()-startTime , FEMTree< Dim , Real >::MaxMemoryUsage() ); + for( int i=0 ; i::ConstNeighborKey< UIntPa if( neighbors ) delete[] neighbors; neighbors=NULL; } +#if 1 +template< unsigned int Dim , class NodeData , class DepthAndOffsetType > +template< unsigned int ... LeftRadii , unsigned int ... RightRadii > +RegularTreeNode< Dim , NodeData , DepthAndOffsetType >::ConstNeighborKey< UIntPack< LeftRadii ... > , UIntPack< RightRadii ... > >& RegularTreeNode< Dim , NodeData , DepthAndOffsetType >::ConstNeighborKey< UIntPack< LeftRadii ... > , UIntPack< RightRadii ... > >::operator = ( const ConstNeighborKey& key ) +{ + set( key._depth ); + for( int d=0 ; d<=_depth ; d++ ) memcpy( &neighbors[d] , &key.neighbors[d] , sizeof( ConstNeighbors< UIntPack< ( LeftRadii + RightRadii + 1 ) ... > > ) ); +} +#endif template< unsigned int Dim , class NodeData , class DepthAndOffsetType > template< unsigned int ... LeftRadii , unsigned int ... RightRadii > void RegularTreeNode< Dim , NodeData , DepthAndOffsetType >::ConstNeighborKey< UIntPack< LeftRadii ... > , UIntPack< RightRadii ... > >::set( int d ) diff --git a/Src/SSDRecon.cpp b/Src/SSDRecon.cpp index fe25aa5..db2f744 100644 --- a/Src/SSDRecon.cpp +++ b/Src/SSDRecon.cpp @@ -312,7 +312,7 @@ struct SystemDual< Dim , double , TotalPointSampleData > }; template< typename Vertex , typename Real , unsigned int ... FEMSigs , typename ... SampleData > -void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTree< sizeof ... ( FEMSigs ) , Real >& tree , const DenseNodeData< Real , UIntPack< FEMSigs ... > >& solution , Real isoValue , const std::vector< typename FEMTree< sizeof ... ( FEMSigs ) , Real >::PointSample >* samples , std::vector< MultiPointStreamData< Real , PointStreamNormal< Real , DIMENSION > , MultiPointStreamData< Real , SampleData ... > > >* sampleData , const typename FEMTree< sizeof ... ( FEMSigs ) , Real >::template DensityEstimator< WEIGHT_DEGREE >* density , std::function< void ( Vertex& , Point< Real , DIMENSION > , Real , MultiPointStreamData< Real , PointStreamNormal< Real , DIMENSION > , MultiPointStreamData< Real , SampleData ... > > ) > SetVertex , std::vector< char* > comments , XForm< Real , sizeof...(FEMSigs)+1 > iXForm ) +void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTree< sizeof ... ( FEMSigs ) , Real >& tree , const DenseNodeData< Real , UIntPack< FEMSigs ... > >& solution , Real isoValue , const std::vector< typename FEMTree< sizeof ... ( FEMSigs ) , Real >::PointSample >* samples , std::vector< MultiPointStreamData< Real , PointStreamNormal< Real , DIMENSION > , MultiPointStreamData< Real , SampleData ... > > >* sampleData , const typename FEMTree< sizeof ... ( FEMSigs ) , Real >::template DensityEstimator< WEIGHT_DEGREE >* density , std::function< void ( Vertex& , Point< Real , DIMENSION > , Real , MultiPointStreamData< Real , PointStreamNormal< Real , DIMENSION > , MultiPointStreamData< Real , SampleData ... > > ) > SetVertex , std::vector< char* >& comments , XForm< Real , sizeof...(FEMSigs)+1 > iXForm ) { static const int Dim = sizeof ... ( FEMSigs ); typedef UIntPack< FEMSigs ... > Sigs; @@ -633,6 +633,8 @@ int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > ) if( density ) delete density , density = NULL; messageWriter( comments , "# Total Solve: %9.1f (s), %9.1f (MB)\n" , Time()-startTime , FEMTree< Dim , Real >::MaxMemoryUsage() ); + for( int i=0 ; i( Out.value , vertices , gtPolygons , Vertex::PlyWriteProperties() , Vertex::PlyWriteNum , ft , &comments[0] , (int)comments.size() ); + for( int i=0 ; i