diff --git a/README.md b/README.md index e50913a..b73caf5 100644 --- a/README.md +++ b/README.md @@ -91,10 +91,10 @@ The file is written in
[--tree <output octree and coefficients>]
This string is the name of the file to which the the octree and solution coefficients are to be written. -
[--voxel <output voxel grid>] +
[--grid <output grid>]
This string is the name of the file to which the sampled implicit function will be written. The file is wrtten out in binary, with the first 4 bytes corresponding to the (integer) sampling resolution, 2^d, -and the next 4 x 2^d x 2^d x 2^d bytes corresponding to the (single precision) floating point values +and the next 4 x 2^d x 2^d x ... bytes corresponding to the (single precision) floating point values of the implicit function.
[--degree <B-spline degree>] @@ -238,8 +238,8 @@ The default value for this parameter is 2.
[--depth <reconstruction depth>]
This integer is the maximum depth of the tree that will be used for surface reconstruction. -Running at depth d corresponds to solving on a voxel grid whose resolution is no larger than -2^d x 2^d x 2^d. Note that since the reconstructor adapts the octree to the +Running at depth d corresponds to solving on a grid whose resolution is no larger than +2^d x 2^d x ... Note that since the reconstructor adapts the octree to the sampling density, the specified reconstruction depth is only an upper bound.
The default value for this parameter is 8. @@ -300,8 +300,8 @@ The default value for this parameter is 0.
This floating point value specifies the exponent to be applied to a point's confidence to bias the resolution at which the sample contributes to the linear system. (Points with lower confidence are biased to contribute at coarser resolutions.)
The default value for this parameter is 0. -
[--primalVoxel] -
Enabling this flag when outputing to a voxel file has the reconstructor sample the implicit function at the corners of the grid, rather than the centers of the cells. +
[--primalGrid] +
Enabling this flag when outputing to a grid file has the reconstructor sample the implicit function at the corners of the grid, rather than the centers of the cells.
[--nonLinearFit]
Enabling this flag has the reconstructor use quadratic interpolation to estimate the positions of iso-vertices. @@ -444,8 +444,8 @@ The default value for this parameter is 1.
[--depth <edt depth>]
This integer is the maximum depth of the tree that will be used for computing the Euclidean Distance Transform. -Running at depth d corresponds to solving on a voxel grid whose resolution is no larger than -2^d x 2^d x 2^d.
+Running at depth d corresponds to solving on a grid whose resolution is no larger than +2^d x 2^d x ...
The default value for this parameter is 8.
[--scale <scale factor>] @@ -503,7 +503,7 @@ Extracts iso-surfaces and a sampling on a regular grid from an implicit function
This string is the name of the file from which the tree and implicit functions coefficients are to be read.
[--grid <output value grid>] -
This string is the name of the file to which the sampling of the implicit along a regular voxel grid will be written.
+
This string is the name of the file to which the sampling of the implicit along a regular grid will be written.
The file is written out in binary, with the first 4 bytes corresponding to the (integer) sampling resolution, R, and the next 4 x R^D bytes corresponding to the (single precision) floating point values of the implicit function. (Here, D is the dimension.) @@ -742,8 +742,8 @@ To obtain a sampling of the implicit function over a regular grid: (Note that as the B-spline degree is a template parameter, only degree 1 through 4 are supported. If higher order degrees are desired, additional template parameters can be easily added in the body of the Execute function inside of PoissonRecon.cpp. Similarly, to reduce compilation times, support for specific degrees can be removed.) -
  • Added the --primalVoxel flag to support to extraction of a voxel grid using primal sampling. -
  • Changed the implementation of the voxel sampling so that computation is now linear, rather than log-linear, in the number of samples. +
  • Added the --primalGrid flag to support to extraction of a grid using primal sampling. +
  • Changed the implementation of the grid sampling so that computation is now linear, rather than log-linear, in the number of samples.
  • Version 9.0: diff --git a/Src/AdaptiveTreeVisualization.cpp b/Src/AdaptiveTreeVisualization.cpp index ddf70d0..9f2e7b5 100644 --- a/Src/AdaptiveTreeVisualization.cpp +++ b/Src/AdaptiveTreeVisualization.cpp @@ -118,7 +118,9 @@ bool WriteImage( const Real *values , int res , const char *fileName , bool verb unsigned char color = (unsigned char )std::min< Real >( (Real)255. , std::max< Real >( (Real)0. , v ) ); for( int c=0 ; c<3 ; c++ ) pixels[i*3+c ] = color; } - bool success = ImageWriter::Write( fileName , pixels , res , res , 3 ); + bool success = true; + try{ ImageWriter::Write( fileName , pixels , res , res , 3 ); } + catch( MKExceptions::Exception & ){ success = false; } delete[] pixels; return success; } @@ -129,9 +131,8 @@ void WriteGrid( const Real *values , int res , const char *fileName ) int resolution = 1; for( int d=0 ; d diff --git a/Src/Image.h b/Src/Image.h index 78c2874..315ba51 100644 --- a/Src/Image.h +++ b/Src/Image.h @@ -64,13 +64,11 @@ struct ImageWriter { virtual unsigned int nextRow( const unsigned char* row ) = 0; virtual unsigned int nextRows( const unsigned char* rows , unsigned int rowNum ){ unsigned int row ; for( unsigned int r=0 ; rnextRow( pixels + j*width*channels ); delete writer; - return true; } static ImageWriter* Get( const char* fileName , unsigned int width , unsigned int height , unsigned int channels , ImageWriterParams params=ImageWriterParams() ); virtual ~ImageWriter( void ){ } @@ -176,6 +174,11 @@ inline ImageReader* ImageReader::Get( const char* fileName ) else if( !strcasecmp( ext , "png" ) ) reader = new PNGReader( fileName , width , height , channels ); else if( !strcasecmp( ext , "iGrid" ) ) reader = new TiledImageReader( fileName , width , height , channels ); #endif // WIN32 + else + { + delete[] ext; + THROW( "failed to get image reader for: %s" , fileName ); + } reader->_width = width; reader->_height = height; reader->_channels = channels; @@ -214,7 +217,11 @@ inline ImageWriter* ImageWriter::Get( const char* fileName , unsigned int width else if( !strcasecmp( ext , "iGrid" ) ) writer = new TiledImageWriter( fileName , width , height , channels , params ); #endif // SUPPORT_TILES #endif // WIN32 - else ERROR_OUT( "Unrecognized file extension: %s" , ext ); + else + { + delete[] ext; + THROW( "failed to get image writer for: %s" , fileName ); + } writer->_width = width; writer->_height = height; writer->_channels = channels; diff --git a/Src/ImageStitching.cpp b/Src/ImageStitching.cpp index fa90c36..c7eca96 100644 --- a/Src/ImageStitching.cpp +++ b/Src/ImageStitching.cpp @@ -139,7 +139,7 @@ struct RGBPixel void WriteImage( char* fileName , RGBPixel* pixels , int w , int h ) { unsigned int _w = w , _h = h , _c = 3; - if( !ImageWriter::Write( fileName , (const unsigned char*)pixels , _w , _h , _c ) ) ERROR_OUT( "Could not write image to: %s" , fileName ); + ImageWriter::Write( fileName , (const unsigned char*)pixels , _w , _h , _c ); } struct Profiler diff --git a/Src/PoissonRecon.cpp b/Src/PoissonRecon.cpp index f0d4146..bdaafb7 100644 --- a/Src/PoissonRecon.cpp +++ b/Src/PoissonRecon.cpp @@ -58,7 +58,7 @@ cmdLineParameter< char* > In( "in" ) , Out( "out" ) , TempDir( "tempDir" ) , - VoxelGrid( "voxel" ) , + Grid( "grid" ) , Tree( "tree" ) , Transform( "xForm" ); @@ -71,7 +71,7 @@ cmdLineReadable ASCII( "ascii" ) , Density( "density" ) , LinearFit( "linearFit" ) , - PrimalVoxel( "primalVoxel" ) , + PrimalGrid( "primalGrid" ) , ExactInterpolation( "exact" ) , Normals( "normals" ) , Colors( "colors" ) , @@ -116,7 +116,7 @@ cmdLineReadable* params[] = &ConfidenceBias , &BaseDepth , &BaseVCycles , &PointWeight , - &VoxelGrid , &Threads , + &Grid , &Threads , &Tree , &Density , &FullDepth , @@ -125,7 +125,7 @@ cmdLineReadable* params[] = &Colors , &Normals , &LinearFit , - &PrimalVoxel , + &PrimalGrid , &TempDir , &ExactInterpolation , &Performance , @@ -139,7 +139,7 @@ void ShowUsage(char* ex) printf( "Usage: %s\n" , ex ); printf( "\t --%s \n" , In.name ); printf( "\t[--%s ]\n" , Out.name ); - printf( "\t[--%s ]\n" , VoxelGrid.name ); + printf( "\t[--%s ]\n" , Grid.name ); printf( "\t[--%s ]\n" , Tree.name ); #ifndef FAST_COMPILE printf( "\t[--%s =%d]\n" , Degree.name , Degree.value ); @@ -147,7 +147,7 @@ void ShowUsage(char* ex) for( int i=0 ; i=%d]\n" , Depth.name , Depth.value ); - printf( "\t[--%s ]\n" , Width.name ); + printf( "\t[--%s ]\n" , Width.name ); printf( "\t[--%s =%d]\n" , FullDepth.name , FullDepth.value ); printf( "\t[--%s =%d]\n" , BaseDepth.name , BaseDepth.value ); printf( "\t[--%s =%d]\n" , BaseVCycles.name , BaseVCycles.value ); @@ -171,7 +171,7 @@ void ShowUsage(char* ex) printf( "\t[--%s]\n" , Performance.name ); printf( "\t[--%s]\n" , Density.name ); printf( "\t[--%s]\n" , LinearFit.name ); - printf( "\t[--%s]\n" , PrimalVoxel.name ); + printf( "\t[--%s]\n" , PrimalGrid.name ); printf( "\t[--%s]\n" , ASCII.name ); printf( "\t[--%s]\n" , NoComments.name ); printf( "\t[--%s]\n" , TempDir.name ); @@ -380,7 +380,9 @@ bool WriteImage( const Real *values , int res , const char *fileName , bool verb unsigned char color = (unsigned char )std::min< Real >( (Real)255. , std::max< Real >( (Real)0. , v ) ); for( int c=0 ; c<3 ; c++ ) pixels[i*3+c ] = color; } - bool success = ImageWriter::Write( fileName , pixels , res , res , 3 ); + bool success = true; + try{ ImageWriter::Write( fileName , pixels , res , res , 3 ); } + catch( MKExceptions::Exception & ){ success = false; } delete[] pixels; return success; } @@ -391,9 +393,8 @@ void WriteGrid( const Real *values , int res , const char *fileName ) int resolution = 1; for( int d=0 ; d @@ -660,18 +659,28 @@ void Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > ) fclose( fp ); } - if( VoxelGrid.set ) + if( Grid.set ) { int res = 0; profiler.start(); - Pointer( Real ) values = tree.template regularGridEvaluate< true >( solution , res , -1 , PrimalVoxel.set ); + Pointer( Real ) values = tree.template regularGridEvaluate< true >( solution , res , -1 , PrimalGrid.set ); int resolution = 1; for( int d=0 ; d( values , res , VoxelGrid.value , Verbose.set ) ) WriteGrid< Real , DIMENSION >( values , res , VoxelGrid.value ); + profiler.dumpOutput( "Got grid:" ); + if( !WriteImage< Real , DIMENSION >( values , res , Grid.value , Verbose.set ) ) WriteGrid< Real , DIMENSION >( values , res , Grid.value ); DeletePointer( values ); + if( Verbose.set ) + { + printf( "Transform:\n" ); + for( int i=0 ; i In( "in" ) , Out( "out" ) , TempDir( "tempDir" ) , - VoxelGrid( "voxel" ) , + Grid( "grid" ) , Tree( "tree" ) , Transform( "xForm" ); @@ -71,7 +71,7 @@ cmdLineReadable ASCII( "ascii" ) , Density( "density" ) , NonLinearFit( "nonLinearFit" ) , - PrimalVoxel( "primalVoxel" ) , + PrimalGrid( "primalGrid" ) , ExactInterpolation( "exact" ) , Normals( "normals" ) , Colors( "colors" ) , @@ -118,7 +118,7 @@ cmdLineReadable* params[] = &KernelDepth , &SamplesPerNode , &Confidence , &NonManifold , &PolygonMesh , &ASCII , &ShowResidual , &ConfidenceBias , &ValueWeight , &GradientWeight , &BiLapWeight , - &VoxelGrid , &Threads , + &Grid , &Threads , &Tree , &Density , &FullDepth , @@ -128,7 +128,7 @@ cmdLineReadable* params[] = &Colors , &Normals , &NonLinearFit , - &PrimalVoxel , + &PrimalGrid , &TempDir , &ExactInterpolation , &Performance , @@ -142,7 +142,7 @@ void ShowUsage(char* ex) printf( "Usage: %s\n" , ex ); printf( "\t --%s \n" , In.name ); printf( "\t[--%s ]\n" , Out.name ); - printf( "\t[--%s ]\n" , VoxelGrid.name ); + printf( "\t[--%s ]\n" , Grid.name ); printf( "\t[--%s ]\n" , Tree.name ); #ifndef FAST_COMPILE printf( "\t[--%s =%d]\n" , Degree.name , Degree.value ); @@ -150,7 +150,7 @@ void ShowUsage(char* ex) for( int i=0 ; i=%d]\n" , Depth.name , Depth.value ); - printf( "\t[--%s ]\n" , Width.name ); + printf( "\t[--%s ]\n" , Width.name ); printf( "\t[--%s =%d]\n" , FullDepth.name , FullDepth.value ); printf( "\t[--%s =%d]\n" , BaseDepth.name , BaseDepth.value ); printf( "\t[--%s =%d]\n" , BaseVCycles.name , BaseVCycles.value ); @@ -176,7 +176,7 @@ void ShowUsage(char* ex) printf( "\t[--%s]\n" , Performance.name ); printf( "\t[--%s]\n" , Density.name ); printf( "\t[--%s]\n" , NonLinearFit.name ); - printf( "\t[--%s]\n" , PrimalVoxel.name ); + printf( "\t[--%s]\n" , PrimalGrid.name ); printf( "\t[--%s]\n" , ASCII.name ); printf( "\t[--%s]\n" , NoComments.name ); printf( "\t[--%s]\n" , TempDir.name ); @@ -404,7 +404,9 @@ bool WriteImage( const Real *values , int res , const char *fileName , bool verb unsigned char color = (unsigned char )std::min< Real >( (Real)255. , std::max< Real >( (Real)0. , v ) ); for( int c=0 ; c<3 ; c++ ) pixels[i*3+c ] = color; } - bool success = ImageWriter::Write( fileName , pixels , res , res , 3 ); + bool success = true; + try{ ImageWriter::Write( fileName , pixels , res , res , 3 ); } + catch( MKExceptions::Exception & ){ success = false; } delete[] pixels; return success; } @@ -415,9 +417,8 @@ void WriteGrid( const Real *values , int res , const char *fileName ) int resolution = 1; for( int d=0 ; d @@ -665,18 +664,28 @@ void Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > ) fclose( fp ); } - if( VoxelGrid.set ) + if( Grid.set ) { int res = 0; profiler.start(); - Pointer( Real ) values = tree.template regularGridEvaluate< true >( solution , res , -1 , PrimalVoxel.set ); + Pointer( Real ) values = tree.template regularGridEvaluate< true >( solution , res , -1 , PrimalGrid.set ); int resolution = 1; for( int d=0 ; d( values , res , VoxelGrid.value , Verbose.set ) ) WriteGrid< Real , DIMENSION >( values , res , VoxelGrid.value ); + profiler.dumpOutput( "Got grid:" ); + if( !WriteImage< Real , DIMENSION >( values , res , Grid.value , Verbose.set ) ) WriteGrid< Real , DIMENSION >( values , res , Grid.value ); DeletePointer( values ); + if( Verbose.set ) + { + printf( "Transform:\n" ); + for( int i=0 ; i