diff --git a/JPEG.vcxproj b/JPEG.vcxproj
index dc07048..3cc7856 100644
--- a/JPEG.vcxproj
+++ b/JPEG.vcxproj
@@ -179,7 +179,7 @@
- Level3
+ TurnOffAllWarnings
MaxSpeed
diff --git a/PNG.vcxproj b/PNG.vcxproj
index 1215cf4..590e080 100644
--- a/PNG.vcxproj
+++ b/PNG.vcxproj
@@ -164,7 +164,7 @@
MultiThreadedDLL
- Level3
+ TurnOffAllWarnings
ProgramDatabase
diff --git a/Src/AdaptiveTreeVisualization.cpp b/Src/AdaptiveTreeVisualization.cpp
index 6b170e9..98d4ed8 100644
--- a/Src/AdaptiveTreeVisualization.cpp
+++ b/Src/AdaptiveTreeVisualization.cpp
@@ -101,7 +101,7 @@ void _Execute( const FEMTree< Dim , Real >* tree , FILE* fp )
if( OutGrid.set )
{
FILE* _fp = fopen( OutGrid.value , "wb" );
- if( !_fp ) fprintf( stderr , "Failed to open grid file for writing: %s\n" , OutGrid.value );
+ if( !_fp ) WARN( "Failed to open grid file for writing: %s" , OutGrid.value );
else
{
int res = 0;
@@ -155,13 +155,13 @@ void _Execute( const FEMTree< Dim , Real >* tree , FILE* fp )
std::vector< std::string > comments;
if( !PlyWritePolygons< Vertex , Real , Dim >( OutMesh.value , &mesh , ASCII.set ? PLY_ASCII : PLY_BINARY_NATIVE , comments , XForm< Real , Dim+1 >::Identity() ) )
- fprintf( stderr , "[ERROR] Could not write mesh to: %s\n" , OutMesh.value ) , exit( 0 );
+ ERROR_OUT( "Could not write mesh to: %s" , OutMesh.value );
}
}
template< unsigned int Dim , class Real >
-int Execute( FILE* fp , int degree , BoundaryType bType )
+void Execute( FILE* fp , int degree , BoundaryType bType )
{
FEMTree< Dim , Real > tree( fp , MEMORY_ALLOCATOR_BLOCK_SIZE );
@@ -177,7 +177,7 @@ int Execute( FILE* fp , int degree , BoundaryType bType )
case 2: _Execute< Dim , Real , FEMDegreeAndBType< 2 , BOUNDARY_FREE >::Signature >( &tree , fp ) ; break;
case 3: _Execute< Dim , Real , FEMDegreeAndBType< 3 , BOUNDARY_FREE >::Signature >( &tree , fp ) ; break;
case 4: _Execute< Dim , Real , FEMDegreeAndBType< 4 , BOUNDARY_FREE >::Signature >( &tree , fp ) ; break;
- default: fprintf( stderr , "[ERROR] Only B-Splines of degree 1 - 4 are supported" ) , exit( 0 );
+ default: ERROR_OUT( "Only B-Splines of degree 1 - 4 are supported" );
}
}
break;
@@ -189,7 +189,7 @@ int Execute( FILE* fp , int degree , BoundaryType bType )
case 2: _Execute< Dim , Real , FEMDegreeAndBType< 2 , BOUNDARY_NEUMANN >::Signature >( &tree , fp ) ; break;
case 3: _Execute< Dim , Real , FEMDegreeAndBType< 3 , BOUNDARY_NEUMANN >::Signature >( &tree , fp ) ; break;
case 4: _Execute< Dim , Real , FEMDegreeAndBType< 4 , BOUNDARY_NEUMANN >::Signature >( &tree , fp ) ; break;
- default: fprintf( stderr , "[ERROR] Only B-Splines of degree 1 - 4 are supported" ) , exit( 0 );
+ default: ERROR_OUT( "Only B-Splines of degree 1 - 4 are supported" );
}
}
break;
@@ -201,19 +201,18 @@ int Execute( FILE* fp , int degree , BoundaryType bType )
case 2: _Execute< Dim , Real , FEMDegreeAndBType< 2 , BOUNDARY_DIRICHLET >::Signature >( &tree , fp ) ; break;
case 3: _Execute< Dim , Real , FEMDegreeAndBType< 3 , BOUNDARY_DIRICHLET >::Signature >( &tree , fp ) ; break;
case 4: _Execute< Dim , Real , FEMDegreeAndBType< 4 , BOUNDARY_DIRICHLET >::Signature >( &tree , fp ) ; break;
- default: fprintf( stderr , "[ERROR] Only B-Splines of degree 1 - 4 are supported" ) , exit( 0 );
+ default: ERROR_OUT( "Only B-Splines of degree 1 - 4 are supported" );
}
}
break;
- default: fprintf( stderr , "[ERROR] Not a valid boundary type: %d\n" , bType ) , exit( 0 );
+ default: ERROR_OUT( "Not a valid boundary type: %d" , bType );
}
- return EXIT_SUCCESS;
}
int main( int argc , char* argv[] )
{
#ifdef ARRAY_DEBUG
- fprintf( stderr , "[WARNING] Array debugging enabled\n" );
+ WARN( "Array debugging enabled" );
#endif // ARRAY_DEBUG
cmdLineParse( argc-1 , &argv[1] , params );
omp_set_num_threads( Threads.value > 1 ? Threads.value : 1 );
@@ -232,20 +231,15 @@ int main( int argc , char* argv[] )
return EXIT_FAILURE;
}
FILE* fp = fopen( In.value , "rb" );
- if( !fp ) fprintf( stderr , "[ERROR] Failed to open file for reading: %s\n" , In.value ) , exit( 0 );
+ if( !fp ) ERROR_OUT( "Failed to open file for reading: %s" , In.value );
FEMTreeRealType realType ; int degree ; BoundaryType bType;
int dimension;
ReadFEMTreeParameter( fp , realType , dimension );
{
unsigned int dim = dimension;
unsigned int* sigs = ReadDenseNodeDataSignatures( fp , dim );
- if( dimension!=dim ) fprintf( stderr , "[ERROR] Octree and node data dimensions don't math: %d != %d\n" , dimension , dim ) , exit( 0 );
- for( unsigned int d=1 ; d( fp , degree , bType ) ; break;
case FEM_TREE_REAL_DOUBLE: Execute< 2 , double >( fp , degree , bType ) ; break;
- default: fprintf( stderr , "[ERROR] Unrecognized real type: %d\n" , realType ) , exit( 0 );
+ default: ERROR_OUT( "Unrecognized real type: %d" , realType );
}
break;
case 3:
@@ -267,10 +261,10 @@ int main( int argc , char* argv[] )
{
case FEM_TREE_REAL_FLOAT: Execute< 3 , float >( fp , degree , bType ) ; break;
case FEM_TREE_REAL_DOUBLE: Execute< 3 , double >( fp , degree , bType ) ; break;
- default: fprintf( stderr , "[ERROR] Unrecognized real type: %d\n" , realType ) , exit( 0 );
+ default: ERROR_OUT( "Unrecognized real type: %d" , realType );
}
break;
- default: fprintf( stderr , "[ERROR] Only dimensions 1-4 supported\n" ) , exit( 0 );
+ default: ERROR_OUT( "Only dimensions 1-4 supported" );
}
fclose( fp );
diff --git a/Src/Allocator.h b/Src/Allocator.h
index 407087b..61a350d 100644
--- a/Src/Allocator.h
+++ b/Src/Allocator.h
@@ -140,13 +140,13 @@ public:
{
T* mem;
if( !elements ) return NULL;
- if( elements>blockSize ) fprintf( stderr , "[ERROR] Allocator: elements bigger than block-size: %d>%d\n" , elements , blockSize ) , exit( 0 );
+ if( elements>blockSize ) ERROR_OUT( "elements bigger than block-size: %d>%d" , elements , blockSize );
if( remains friend class Array;
void _assertBounds( long long idx ) const
{
- if( idx=max )
- {
- fprintf( stderr , "Array index out-of-bounds: %lld <= %lld < %lld\n" , min , idx , max );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( idx=max ) ERROR_OUT( "Array index out-of-bounds: %lld <= %lld < %lld" , min , idx , max );
}
protected:
C *data , *_data;
@@ -94,11 +89,7 @@ protected:
{
size_t idx;
for( idx=0 ; idx [ %lld , %lld ] * %lld\n" , a.minimum() , a.maximum() , szD , min , max , szC );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( min*szC!=a.minimum()*szD || max*szC!=a.maximum()*szD ) ERROR_OUT( "Could not convert array [ %lld , %lld ] * %lld => [ %lld , %lld ] * %lld" , a.minimum() , a.maximum() , szD , min , max , szC );
}
}
static Array FromPointer( C* data , long long max )
@@ -363,12 +349,7 @@ class ConstArray
template< class D > friend class ConstArray;
void _assertBounds( long long idx ) const
{
- if( idx=max )
- {
- fprintf( stderr , "ConstArray index out-of-bounds: %lld <= %lld < %lld\n" , min , idx , max );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( idx=max ) ERROR_OUT( "ConstArray index out-of-bounds: %lld <= %lld < %lld" , min , idx , max );
}
protected:
const C *data;
@@ -398,13 +379,7 @@ public:
data = ( const C* )a.pointer( );
min = ( a.minimum() * szD ) / szC;
max = ( a.maximum() * szD ) / szC;
- if( min*szC!=a.minimum()*szD || max*szC!=a.maximum()*szD )
- {
-// fprintf( stderr , "Could not convert const array [ %lld , %lld ] * %lld => [ %lld , %lld ] * %lld\n" , a.minimum() , a.maximum() , szD , min , max , szC );
- fprintf( stderr , "Could not convert const array [ %lld , %lld ] * %lld => [ %lld , %lld ] * %lld\n %lld %lld %lld\n" , a.minimum() , a.maximum() , szD , min , max , szC , a.minimum() , a.minimum()*szD , (a.minimum()*szD)/szC );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( min*szC!=a.minimum()*szD || max*szC!=a.maximum()*szD ) ERROR_OUT( "Could not convert const array [ %lld , %lld ] * %lld => [ %lld , %lld ] * %lld\n %lld %lld %lld" , a.minimum() , a.maximum() , szD , min , max , szC , a.minimum() , a.minimum()*szD , (a.minimum()*szD)/szC );
}
template< class D >
inline ConstArray( const ConstArray< D >& a )
@@ -415,12 +390,7 @@ public:
data = ( const C*)a.pointer( );
min = ( a.minimum() * szD ) / szC;
max = ( a.maximum() * szD ) / szC;
- if( min*szC!=a.minimum()*szD || max*szC!=a.maximum()*szD )
- {
- fprintf( stderr , "Could not convert array [ %lld , %lld ] * %lld => [ %lld , %lld ] * %lld\n" , a.minimum() , a.maximum() , szD , min , max , szC );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( min*szC!=a.minimum()*szD || max*szC!=a.maximum()*szD ) ERROR_OUT( "Could not convert array [ %lld , %lld ] * %lld => [ %lld , %lld ] * %lld" , a.minimum() , a.maximum() , szD , min , max , szC );
}
static ConstArray FromPointer( const C* data , long long max )
{
@@ -539,84 +509,44 @@ inline void PrintMemoryInfo( void ){ for( size_t i=0 ; i
Array< C > memcpy( Array< C > destination , const void* source , size_t size )
{
- if( size>destination.maximum()*sizeof(C) )
- {
- fprintf( stderr , "Size of copy exceeds destination maximum: %lld > %lld\n" , ( long long )( size ) , ( long long )( destination.maximum()*sizeof( C ) ) );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( size>destination.maximum()*sizeof(C) ) ERROR_OUT( "Size of copy exceeds destination maximum: %lld > %lld" , ( long long )( size ) , ( long long )( destination.maximum()*sizeof( C ) ) );
if( size ) memcpy( &destination[0] , source , size );
return destination;
}
template< class C , class D >
Array< C > memcpy( Array< C > destination , Array< D > source , size_t size )
{
- if( size>destination.maximum()*sizeof( C ) )
- {
- fprintf( stderr , "Size of copy exceeds destination maximum: %lld > %lld\n" , ( long long )( size ) , ( long long )( destination.maximum()*sizeof( C ) ) );
- ASSERT( 0 );
- exit( 0 );
- }
- if( size>source.maximum()*sizeof( D ) )
- {
- fprintf( stderr , "Size of copy exceeds source maximum: %lld > %lld\n" , ( long long )( size ) , ( long long )( source.maximum()*sizeof( D ) ) );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( size>destination.maximum()*sizeof( C ) ) ERROR_OUT( "Size of copy exceeds destination maximum: %lld > %lld" , ( long long )( size ) , ( long long )( destination.maximum()*sizeof( C ) ) );
+ if( size>source.maximum()*sizeof( D ) ) ERROR_OUT( "Size of copy exceeds source maximum: %lld > %lld" , ( long long )( size ) , ( long long )( source.maximum()*sizeof( D ) ) );
if( size ) memcpy( &destination[0] , &source[0] , size );
return destination;
}
template< class C , class D >
Array< C > memcpy( Array< C > destination , ConstArray< D > source , size_t size )
{
- if( size>destination.maximum()*sizeof( C ) )
- {
- fprintf( stderr , "Size of copy exceeds destination maximum: %lld > %lld\n" , ( long long )( size ) , ( long long )( destination.maximum()*sizeof( C ) ) );
- ASSERT( 0 );
- exit( 0 );
- }
- if( size>source.maximum()*sizeof( D ) )
- {
- fprintf( stderr , "Size of copy exceeds source maximum: %lld > %lld\n" , ( long long )( size ) , ( long long )( source.maximum()*sizeof( D ) ) );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( size>destination.maximum()*sizeof( C ) ) ERROR_OUT( "Size of copy exceeds destination maximum: %lld > %lld" , ( long long )( size ) , ( long long )( destination.maximum()*sizeof( C ) ) );
+ if( size>source.maximum()*sizeof( D ) ) ERROR_OUT( "Size of copy exceeds source maximum: %lld > %lld" , ( long long )( size ) , ( long long )( source.maximum()*sizeof( D ) ) );
if( size ) memcpy( &destination[0] , &source[0] , size );
return destination;
}
template< class D >
void* memcpy( void* destination , Array< D > source , size_t size )
{
- if( size>source.maximum()*sizeof( D ) )
- {
- fprintf( stderr , "Size of copy exceeds source maximum: %lld > %lld\n" , ( long long )( size ) , ( long long )( source.maximum()*sizeof( D ) ) );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( size>source.maximum()*sizeof( D ) ) ERROR_OUT( "Size of copy exceeds source maximum: %lld > %lld" , ( long long )( size ) , ( long long )( source.maximum()*sizeof( D ) ) );
if( size ) memcpy( destination , &source[0] , size );
return destination;
}
template< class D >
void* memcpy( void* destination , ConstArray< D > source , size_t size )
{
- if( size>source.maximum()*sizeof( D ) )
- {
- fprintf( stderr , "Size of copy exceeds source maximum: %lld > %lld\n" , ( long long )( size ) , ( long long )( source.maximum()*sizeof( D ) ) );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( size>source.maximum()*sizeof( D ) ) ERROR_OUT( "Size of copy exceeds source maximum: %lld > %lld" , ( long long )( size ) , ( long long )( source.maximum()*sizeof( D ) ) );
if( size ) memcpy( destination , &source[0] , size );
return destination;
}
template< class C >
Array< C > memset( Array< C > destination , int value , size_t size )
{
- if( size>destination.maximum()*sizeof( C ) )
- {
- fprintf( stderr , "Size of set exceeds destination maximum: %lld > %lld\n" , ( long long )( size ) , ( long long )( destination.maximum()*sizeof( C ) ) );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( size>destination.maximum()*sizeof( C ) ) ERROR_OUT( "Size of set exceeds destination maximum: %lld > %lld" , ( long long )( size ) , ( long long )( destination.maximum()*sizeof( C ) ) );
if( size ) memset( &destination[0] , value , size );
return destination;
}
@@ -624,50 +554,25 @@ Array< C > memset( Array< C > destination , int value , size_t size )
template< class C >
size_t fread( Array< C > destination , size_t eSize , size_t count , FILE* fp )
{
- if( count*eSize>destination.maximum()*sizeof( C ) )
- {
- fprintf( stderr , "Size of read exceeds source maximum: %lld > %lld\n" , ( long long )( count*eSize ) , ( long long )( destination.maximum()*sizeof( C ) ) );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( count*eSize>destination.maximum()*sizeof( C ) ) ERROR_OUT( "Size of read exceeds source maximum: %lld > %lld" , ( long long )( count*eSize ) , ( long long )( destination.maximum()*sizeof( C ) ) );
return fread( &destination[0] , eSize , count , fp );
}
template< class C >
size_t fwrite( Array< C > source , size_t eSize , size_t count , FILE* fp )
{
- if( count*eSize>source.maximum()*sizeof( C ) )
- {
- fprintf( stderr , "Size of write exceeds source maximum: %lld > %lld\n" , ( long long )( count*eSize ) , ( long long )( source.maximum()*sizeof( C ) ) );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( count*eSize>source.maximum()*sizeof( C ) ) ERROR_OUT( "Size of write exceeds source maximum: %lld > %lld" , ( long long )( count*eSize ) , ( long long )( source.maximum()*sizeof( C ) ) );
return fwrite( &source[0] , eSize , count , fp );
}
template< class C >
size_t fwrite( ConstArray< C > source , size_t eSize , size_t count , FILE* fp )
{
- if( count*eSize>source.maximum()*sizeof( C ) )
- {
- fprintf( stderr , "Size of write exceeds source maximum: %lld > %lld\n" , ( long long )( count*eSize ) , ( long long )( source.maximum()*sizeof( C ) ) );
- ASSERT( 0 );
- exit( 0 );
- }
+ if( count*eSize>source.maximum()*sizeof( C ) ) ERROR_OUT( "Size of write exceeds source maximum: %lld > %lld" , ( long long )( count*eSize ) , ( long long )( source.maximum()*sizeof( C ) ) );
return fwrite( &source[0] , eSize , count , fp );
}
template< class C >
void qsort( Array< C > base , size_t numElements , size_t elementSize , int (*compareFunction)( const void* , const void* ) )
{
- if( sizeof(C)!=elementSize )
- {
- fprintf( stderr , "Element sizes differ: %lld != %lld\n" , ( long long )( sizeof(C) ) , ( long long )( elementSize ) );
- ASSERT( 0 );
- exit( 0 );
- }
- if( base.minimum()>0 || base.maximum()0 || base.maximum()fp = fopen( fileName , "rb" );
- if( !info->fp ) fprintf( stderr , "[ERROR] BMPInitRead: Failed to open: %s\n" , fileName ) , exit(0);
+ if( !info->fp ) ERROR_OUT( "Failed to open: %s" , fileName );
fread( &bmfh , sizeof( BITMAPFILEHEADER ) , 1 , info->fp );
fread( &bmih , sizeof( BITMAPINFOHEADER ) , 1 , info->fp );
- if( bmfh.bfType!=BMP_BF_TYPE || bmfh.bfOffBits!=BMP_BF_OFF_BITS ) fprintf( stderr , "[ERROR] BMPInitReadColor: Bad bitmap file header\n" ) , exit( 0 );
- if( bmih.biSize!=BMP_BI_SIZE || bmih.biWidth<=0 || bmih.biHeight<=0 || bmih.biPlanes!=1 || bmih.biBitCount!=24 || bmih.biCompression!=BI_RGB ) fprintf( stderr , "[ERROR] BMPInitReadColor: Bad bitmap file info\n" ) , exit( 0 );
+ if( bmfh.bfType!=BMP_BF_TYPE || bmfh.bfOffBits!=BMP_BF_OFF_BITS ) ERROR_OUT( "Bad bitmap file header" );
+ if( bmih.biSize!=BMP_BI_SIZE || bmih.biWidth<=0 || bmih.biHeight<=0 || bmih.biPlanes!=1 || bmih.biBitCount!=24 || bmih.biCompression!=BI_RGB ) ERROR_OUT( "Bad bitmap file info" );
info->width = width = bmih.biWidth;
height = bmih.biHeight;
info->lineLength = width * 3;
if( info->lineLength % 4 ) info->lineLength = (info->lineLength / 4 + 1) * 4;
- if( bmih.biSizeImage!=info->lineLength*height ) fprintf( stderr , "[ERROR] BMPInitRead: Bad bitmap image size\n" ) , exit( 0 );
+ if( bmih.biSizeImage!=info->lineLength*height ) ERROR_OUT( "Bad bitmap image size" );
info->data = AllocPointer< unsigned char >( info->lineLength );
- if( !info->data ) fprintf( stderr , "[ERROR] BMPInitRead: Could not allocate memory for bitmap data\n" ) , exit( 0 );
+ if( !info->data ) ERROR_OUT( "Could not allocate memory for bitmap data" );
fseek( info->fp , (long) bmfh.bfOffBits , SEEK_SET );
fseek( info->fp , (long) info->lineLength * height , SEEK_CUR );
@@ -133,19 +133,19 @@ inline void* BMPInitRead( char* fileName , int& width , int& height )
template< int Channels , bool HDR >
inline void* BMPInitWrite( char* fileName , int width , int height , int quality )
{
- if( HDR ) fprintf( stderr , "[WARNING] No HDR support for JPEG\n" );
+ if( HDR ) WARN( "No HDR support for JPEG" );
BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER bmih;
BMPInfo* info = (BMPInfo*)malloc( sizeof( BMPInfo ) );
info->fp = fopen( fileName , "wb" );
- if( !info->fp ) fprintf( stderr , "BMPInitWrite: Failed to open: %s\n" , fileName ) , exit(0);
+ if( !info->fp ) ERROR_OUT( "Failed to open: %s" , fileName );
info->width = width;
info->lineLength = width * 3; /* RGB */
if( info->lineLength % 4 ) info->lineLength = (info->lineLength / 4 + 1) * 4;
info->data = AllocPointer< unsigned char >( info->lineLength );
- if( !info->data ) fprintf( stderr , "[ERROR] BMPInitWrite: Could not allocate memory for bitmap data\n" ) , exit( 0 );
+ if( !info->data ) ERROR_OUT( "Could not allocate memory for bitmap data" );
/* Write file header */
bmfh.bfType = BMP_BF_TYPE;
@@ -190,7 +190,7 @@ void BMPReadRow( Pointer( ChannelType ) pixels , void* v , int j )
fseek( info->fp , -info->lineLength , SEEK_CUR );
fread( info->data , 1 , info->lineLength , info->fp );
fseek( info->fp , -info->lineLength , SEEK_CUR );
- if( ferror(info->fp) ) fprintf( stderr , "[ERROR] BMPReadRow: Error reading bitmap row\n" ) , exit( 0 );
+ if( ferror(info->fp) ) ERROR_OUT( "Error reading bitmap row" );
for( int i=0 ; iwidth ; i++ ) { unsigned char temp = info->data[i*3] ; info->data[i*3] = info->data[i*3+2] ; info->data[i*3+2] = temp; }
ConvertRow< unsigned char , ChannelType >( ( ConstPointer( unsigned char ) )info->data , pixels , info->width , 3 , Channels );
}
diff --git a/Src/BSplineData.inl b/Src/BSplineData.inl
index ca6d204..5954e73 100644
--- a/Src/BSplineData.inl
+++ b/Src/BSplineData.inl
@@ -242,8 +242,8 @@ template< unsigned int FEMSig1 , unsigned int FEMSig2 >
template< unsigned int D1 , unsigned int D2 >
double BSplineIntegrationData< FEMSig1 , FEMSig2 >::Dot( int depth1 , int off1 , int depth2 , int off2 )
{
- if( D1>Degree1 ) fprintf( stderr , "[ERROR] BSplineIntegrationData::Dot: taking more derivatives than the degree: %d > %d\n" , D1 , Degree1 ) , exit( 0 );
- if( D2>Degree2 ) fprintf( stderr , "[ERROR] BSplineIntegrationData::Dot: taking more derivatives than the degree: %d > %d\n" , D2 , Degree2 ) , exit( 0 );
+ if( D1>Degree1 ) ERROR_OUT( "Taking more derivatives than the degree: %d > %d" , D1 , Degree1 );
+ if( D2>Degree2 ) ERROR_OUT( "Taking more derivatives than the degree: %d > %d" , D2 , Degree2 );
const int _Degree1 = ( Degree1>=D1 ) ? Degree1 - D1 : 0 , _Degree2 = ( Degree2>=D2 ) ? Degree2 - D2 : 0;
int sums[ Degree1+1 ][ Degree2+1 ];
diff --git a/Src/CmdLineParser.inl b/Src/CmdLineParser.inl
index 48b5b1c..135668c 100644
--- a/Src/CmdLineParser.inl
+++ b/Src/CmdLineParser.inl
@@ -252,11 +252,11 @@ inline void cmdLineParse( int argc , char **argv , cmdLineReadable** params )
}
else
{
- fprintf( stderr , "[WARNING] Invalid option: %s\n" , argv[0] );
- for( int i=0 ; params[i]!=NULL ; i++ ) printf( "\t--%s\n" , params[i]->name );
+ WARN( "Invalid option: %s" , argv[0] );
+ for( int i=0 ; params[i]!=NULL ; i++ ) fprintf( stderr , "\t--%s\n" , params[i]->name );
}
}
- else fprintf( stderr , "[WARNING] Parameter name should be of the form --: %s\n" , argv[0] );
+ else WARN( "Parameter name should be of the form --: %s" , argv[0] );
++argv , --argc;
}
}
diff --git a/Src/EDTInHeat.cpp b/Src/EDTInHeat.cpp
index 2cf8f21..79f0c0b 100644
--- a/Src/EDTInHeat.cpp
+++ b/Src/EDTInHeat.cpp
@@ -203,7 +203,7 @@ struct SystemDual< Dim , double >
};
template< unsigned int Dim , class Real , unsigned int FEMSig >
-int _Execute( int argc , char* argv[] )
+void _Execute( int argc , char* argv[] )
{
static const unsigned int Degree = FEMSignature< FEMSig >::Degree;
typedef typename FEMTree< Dim , Real >::template InterpolationInfo< Real , 0 > InterpolationInfo;
@@ -221,7 +221,7 @@ int _Execute( int argc , char* argv[] )
FILE* fp = fopen( InXForm.value , "r" );
if( !fp )
{
- fprintf( stderr , "[WARNING] Could not open file for reading x-form: %s\n" , InXForm.value );
+ WARN( "Could not open file for reading x-form: %s" , InXForm.value );
xForm = XForm< Real , Dim+1 >::Identity();
}
else
@@ -229,7 +229,7 @@ int _Execute( int argc , char* argv[] )
for( int i=0 ; i<4 ; i++ ) for( int j=0 ; j<4 ; j++ )
{
float f;
- if( fscanf( fp , " %f " , &f )!=1 ) fprintf( stderr , "[ERROR] Execute: Failed to read xform\n" ) , exit( 0 );
+ if( fscanf( fp , " %f " , &f )!=1 ) ERROR_OUT( "Failed to read xform" );
xForm(i,j) = (Real)f;
}
fclose( fp );
@@ -253,7 +253,7 @@ int _Execute( int argc , char* argv[] )
if( !In.set )
{
ShowUsage( argv[0] );
- return 0;
+ return;
}
std::vector< NodeAndPointSample< Dim , Real > > geometrySamples;
@@ -271,7 +271,8 @@ int _Execute( int argc , char* argv[] )
std::vector< PlyVertex< float , Dim > > _vertices;
std::vector< std::vector< int > > _polygons;
std::vector< std::string > comments;
- PlyReadPolygons( In.value , _vertices , _polygons , PlyVertex< float , Dim >::PlyReadProperties() , PlyVertex< float , Dim >::PlyReadNum , file_type , comments );
+ if( !PlyReadPolygons( In.value , _vertices , _polygons , PlyVertex< float , Dim >::PlyReadProperties() , PlyVertex< float , Dim >::PlyReadNum , file_type , comments ) )
+ ERROR_OUT( "Failed to read ply file: %s\n" , In.value );
vertices.resize( _vertices.size() );
for( int i=0 ; iGradientCutOff ) g /= len;
Point< Real , Dim+1 >* leafValue = leafValues(leaf);
if( leafValue ) for( int d=0 ; d::WriteParameter( fp );
DenseNodeData< Real , IsotropicUIntPack< Dim , FEMSig > >::WriteSignatures( fp );
tree.write( fp );
@@ -529,13 +530,11 @@ int _Execute( int argc , char* argv[] )
fclose( fp );
}
}
-
- return 1;
}
#ifndef FAST_COMPILE
template< unsigned int Dim , class Real >
-int Execute( int argc , char* argv[] )
+void Execute( int argc , char* argv[] )
{
switch( Degree.value )
{
@@ -543,7 +542,7 @@ int Execute( int argc , char* argv[] )
case 2: return _Execute< Dim , Real , FEMDegreeAndBType< 2 , BOUNDARY_FREE >::Signature >( argc , argv );
case 3: return _Execute< Dim , Real , FEMDegreeAndBType< 3 , BOUNDARY_FREE >::Signature >( argc , argv );
case 4: return _Execute< Dim , Real , FEMDegreeAndBType< 4 , BOUNDARY_FREE >::Signature >( argc , argv );
- default: fprintf( stderr , "[ERROR] Only B-Splines of degree 1 - 4 are supported" ) ; return EXIT_FAILURE;
+ default: ERROR_OUT( "Only B-Splines of degree 1 - 4 are supported" );
}
}
#endif // !FAST_COMPILE
@@ -551,7 +550,7 @@ int main( int argc , char* argv[] )
{
Timer timer;
#ifdef ARRAY_DEBUG
- fprintf( stderr , "[WARNING] Array debugging enabled\n" );
+ WARN( "Array debugging enabled" );
#endif // ARRAY_DEBUG
cmdLineParse( argc-1 , &argv[1] , params );
omp_set_num_threads( Threads.value > 1 ? Threads.value : 1 );
@@ -567,14 +566,16 @@ int main( int argc , char* argv[] )
#ifdef FAST_COMPILE
static const int Degree = DEFAULT_FEM_DEGREE;
static const BoundaryType BType = BOUNDARY_FREE;
+
+ WARN( "Compiled for degree-%d, boundary-%s, %s-precision _only_" , Degree , BoundaryNames[ BType ] , sizeof(DefaultFloatType)==4 ? "single" : "double" );
#if 1
- fprintf( stderr , "[WARNING] Compiled for degree-%d, boundary-%s, %s-precision _only_\n" , Degree , BoundaryNames[ BType ] , sizeof(Real)==4 ? "single" : "double" );
+ WARN( "Compiled for degree-%d, boundary-%s, %s-precision _only_" , Degree , BoundaryNames[ BType ] , sizeof(Real)==4 ? "single" : "double" );
#else
- fprintf( stderr , "[WARNING] Compiled for degree-%d, boundary-%s, %s-precision _only_\n" , Degree , BoundaryNames[ BType ] , sizeof(DefaultFloatType)==4 ? "single" : "double" );
+ WARN( "Compiled for degree-%d, boundary-%s, %s-precision _only_" , Degree , BoundaryNames[ BType ] , sizeof(DefaultFloatType)==4 ? "single" : "double" );
#endif
if( BaseDepth.value>FullDepth.value )
{
- if( BaseDepth.set ) fprintf( stderr , "[WARNING] Base depth must be smaller than full depth: %d <= %d\n" , BaseDepth.value , FullDepth.value );
+ if( BaseDepth.set ) WARN( "Base depth must be smaller than full depth: %d <= %d" , BaseDepth.value , FullDepth.value );
BaseDepth.value = FullDepth.value;
}
_Execute< DIMENSION , Real , FEMDegreeAndBType< Degree , BType >::Signature >( argc , argv );
diff --git a/Src/FEMTree.Evaluation.inl b/Src/FEMTree.Evaluation.inl
index ebc46b0..8fd7937 100644
--- a/Src/FEMTree.Evaluation.inl
+++ b/Src/FEMTree.Evaluation.inl
@@ -152,7 +152,7 @@ CumulativeDerivativeValues< V , Dim , _PointD > FEMTree< Dim , Real >::_getValue
{
typedef UIntPack< BSplineSupportSizes< FEMSignature< FEMSigs >::Degree >::SupportSize ... > SupportSizes;
- if( IsActiveNode< Dim >( node->children ) && _localDepth( node->children )<=maxDepth ) fprintf( stderr , "[WARNING] getValue assumes leaf node\n" );
+ if( IsActiveNode< Dim >( node->children ) && _localDepth( node->children )<=maxDepth ) WARN( "getValue assumes leaf node" );
CumulativeDerivativeValues< V , Dim , _PointD > values;
PointEvaluatorState< UIntPack< FEMSigs ... > , IsotropicUIntPack< Dim , _PointD > > state;
@@ -208,12 +208,12 @@ template< unsigned int Dim , class Real >
template< class V , unsigned int _PointD , unsigned int ... FEMSigs , unsigned int PointD >
CumulativeDerivativeValues< V , Dim , _PointD > FEMTree< Dim , Real >::_getCenterValues( const ConstPointSupportKey< UIntPack< FEMSignature< FEMSigs >::Degree ... > >& neighborKey , const FEMTreeNode* node , ConstPointer( V ) solution , ConstPointer( V ) coarseSolution , const _Evaluator< UIntPack< FEMSigs ... > , PointD >& evaluator , int maxDepth , bool isInterior ) const
{
- if( IsActiveNode< Dim >( node->children ) && _localDepth( node->children )<=maxDepth ) fprintf( stderr , "[WARNING] getCenterValues assumes leaf node\n" );
+ if( IsActiveNode< Dim >( node->children ) && _localDepth( node->children )<=maxDepth ) ERROR_OUT( "getCenterValues assumes leaf node" );
typedef _Evaluator< UIntPack< FEMSigs ... > , PointD > _Evaluator;
typedef UIntPack< BSplineSupportSizes< FEMSignature< FEMSigs >::Degree >::SupportSize ... > SupportSizes;
static const unsigned int supportSizes[] = { BSplineSupportSizes< FEMSignature< FEMSigs >::Degree >::SupportSize ... };
- if( IsActiveNode< Dim >( node->children ) && _localDepth( node->children )<=maxDepth ) fprintf( stderr , "[WARNING] getCenterValue assumes leaf node\n" );
+ if( IsActiveNode< Dim >( node->children ) && _localDepth( node->children )<=maxDepth ) ERROR_OUT( "getCenterValue assumes leaf node" );
CumulativeDerivativeValues< V , Dim , _PointD > values;
LocalDepth d ; LocalOffset cIdx;
@@ -320,7 +320,7 @@ template< unsigned int Dim , class Real >
template< class V , unsigned int _PointD , unsigned int ... FEMSigs , unsigned int PointD >
CumulativeDerivativeValues< V , Dim , _PointD > FEMTree< Dim , Real >::_getCornerValues( const ConstPointSupportKey< UIntPack< FEMSignature< FEMSigs >::Degree ... > >& neighborKey , const FEMTreeNode* node , int corner , ConstPointer( V ) solution , ConstPointer( V ) coarseSolution , const _Evaluator< UIntPack< FEMSigs ... > , PointD >& evaluator , int maxDepth , bool isInterior ) const
{
- if( IsActiveNode< Dim >( node->children ) && _localDepth( node->children )<=maxDepth ) fprintf( stderr , "[WARNING] getValue assumes leaf node\n" );
+ if( IsActiveNode< Dim >( node->children ) && _localDepth( node->children )<=maxDepth ) WARN( "getValue assumes leaf node" );
typedef _Evaluator< UIntPack< FEMSigs ... > , PointD > _Evaluator;
typedef UIntPack< BSplineSupportSizes< FEMSignature< FEMSigs >::Degree >::SupportSize ... > SupportSizes;
static const unsigned int supportSizes[] = { BSplineSupportSizes< FEMSignature< FEMSigs >::Degree >::SupportSize ... };
@@ -493,7 +493,7 @@ template< unsigned int ... FEMSigs , unsigned int PointD , typename T >
template< unsigned int _PointD >
CumulativeDerivativeValues< T , Dim , _PointD > FEMTree< Dim , Real >::_MultiThreadedEvaluator< UIntPack< FEMSigs ... > , PointD , T >::values( Point< Real , Dim > p , int thread , const FEMTreeNode* node )
{
- if( _PointD>PointD ) fprintf( stderr , "[ERROR] Evaluating more derivatives than available: %d <= %d\n" , _PointD , PointD ) , exit( 0 );
+ if( _PointD>PointD ) ERROR_OUT( "Evaluating more derivatives than available: %d <= %d" , _PointD , PointD );
if( !node ) node = _tree->leaf( p );
ConstPointSupportKey< FEMDegrees >& nKey = _pointNeighborKeys[thread];
nKey.getNeighbors( node );
@@ -504,7 +504,7 @@ template< unsigned int ... FEMSigs , unsigned int PointD , typename T >
template< unsigned int _PointD >
CumulativeDerivativeValues< T , Dim , _PointD > FEMTree< Dim , Real >::_MultiThreadedEvaluator< UIntPack< FEMSigs ... > , PointD , T >::centerValues( const FEMTreeNode* node , int thread )
{
- if( _PointD>PointD ) fprintf( stderr , "[ERROR] Evaluating more derivatives than available: %d <= %d\n" , _PointD , PointD ) , exit( 0 );
+ if( _PointD>PointD ) ERROR_OUT( "Evaluating more derivatives than available: %d <= %d" , _PointD , PointD );
ConstPointSupportKey< FEMDegrees >& nKey = _pointNeighborKeys[thread];
nKey.getNeighbors( node );
LocalDepth d ; LocalOffset off;
@@ -516,7 +516,7 @@ template< unsigned int ... FEMSigs , unsigned int PointD , typename T >
template< unsigned int _PointD >
CumulativeDerivativeValues< T , Dim , _PointD > FEMTree< Dim , Real >::_MultiThreadedEvaluator< UIntPack< FEMSigs ... > , PointD , T >::cornerValues( const FEMTreeNode* node , int corner , int thread )
{
- if( _PointD>PointD ) fprintf( stderr , "[ERROR] Evaluating more derivatives than available: %d <= %d\n" , _PointD , PointD ) , exit( 0 );
+ if( _PointD>PointD ) ERROR_OUT( "Evaluating more derivatives than available: %d <= %d" , _PointD , PointD );
ConstCornerSupportKey< FEMDegrees >& nKey = _cornerNeighborKeys[thread];
nKey.getNeighbors( node );
LocalDepth d ; LocalOffset off;
@@ -541,7 +541,7 @@ V FEMTree< Dim , Real >::_evaluate( const Coefficients& coefficients , Point< Re
{
{
const FEMTreeNode* node = dataKey.neighbors[d].neighbors.data[ WindowIndex< UIntPack< BSplineSupportSizes< FEMSignature< DataSigs >::Degree >::SupportSize ... > , UIntPack< BSplineSupportSizes< FEMSignature< DataSigs >::Degree >::SupportEnd ... > >::Index ];
- if( !node ) fprintf( stderr , "[ERROR] Point is not centered on a node\n" ) , exit( 0 );
+ if( !node ) ERROR_OUT( "Point is not centered on a node" );
pointEvaluator.initEvaluationState( p , _localDepth( node ) , state );
}
double scratch[Dim+1];
diff --git a/Src/FEMTree.Initialize.inl b/Src/FEMTree.Initialize.inl
index 750c889..21237fd 100644
--- a/Src/FEMTree.Initialize.inl
+++ b/Src/FEMTree.Initialize.inl
@@ -92,7 +92,7 @@ int FEMTreeInitializer< Dim , Real >::Initialize( FEMTreeNode& root , InputPoint
}
pointStream.reset();
}
- if( outOfBoundPoints ) fprintf( stderr , "[WARNING] Found out-of-bound points: %d\n" , outOfBoundPoints );
+ if( outOfBoundPoints ) WARN( "Found out-of-bound points: %d" , outOfBoundPoints );
FEMTree< Dim , Real >::MemoryUsage();
return pointCount;
}
@@ -163,8 +163,8 @@ int FEMTreeInitializer< Dim , Real >::Initialize( FEMTreeNode& root , InputPoint
}
pointStream.reset();
}
- if( outOfBoundPoints ) fprintf( stderr , "[WARNING] Found out-of-bound points: %d\n" , outOfBoundPoints );
- if( badData ) fprintf( stderr , "[WARNING] Found bad data: %d\n" , badData );
+ if( outOfBoundPoints ) WARN( "Found out-of-bound points: %d" , outOfBoundPoints );
+ if( badData ) WARN( "Found bad data: %d" , badData );
FEMTree< Dim , Real >::MemoryUsage();
return pointCount;
}
diff --git a/Src/FEMTree.IsoSurface.specialized.inl b/Src/FEMTree.IsoSurface.specialized.inl
index a69ad58..9f6744e 100644
--- a/Src/FEMTree.IsoSurface.specialized.inl
+++ b/Src/FEMTree.IsoSurface.specialized.inl
@@ -1070,7 +1070,7 @@ protected:
typename HyperCube::Cube< Dim >::template Element< 1 > e( zDir , _e.index );
const typename HyperCube::Cube< Dim >::template Element< 0 > *c = SliceData::template HyperCubeTables< Dim , 1 , 0 >::OverlapElements[e.index];
// [SANITY CHECK]
- // if( tree._isValidSpaceNode( tree._sNodes.treeNodes[i]->children + c[0].index )!=tree._isValidSpaceNode( tree._sNodes.treeNodes[i]->children + c[1].index ) ) fprintf( stderr , "[WARNING] Finer edges should both be valid or invalid\n" ) , exit( 0 );
+ // if( tree._isValidSpaceNode( tree._sNodes.treeNodes[i]->children + c[0].index )!=tree._isValidSpaceNode( tree._sNodes.treeNodes[i]->children + c[1].index ) ) ERROR_OUT( "Finer edges should both be valid or invalid" );
if( !tree._isValidSpaceNode( tree._sNodes.treeNodes[i]->children + c[0].index ) || !tree._isValidSpaceNode( tree._sNodes.treeNodes[i]->children + c[1].index ) ) continue;
int cIndex1 = cSliceData.edgeIndices( tree._sNodes.treeNodes[i]->children + c[0].index )[_e.index];
@@ -1125,7 +1125,7 @@ protected:
typename HyperCube::Cube< Dim >::template Element< 0 > c0( HyperCube::BACK , _c.index ) , c1( HyperCube::FRONT , _c.index );
// [SANITY CHECK]
- // if( tree._isValidSpaceNode( tree._sNodes.treeNodes[i]->children + c0 )!=tree._isValidSpaceNode( tree._sNodes.treeNodes[i]->children + c1 ) ) fprintf( stderr , "[ERROR] Finer edges should both be valid or invalid\n" ) , exit( 0 );
+ // if( tree._isValidSpaceNode( tree._sNodes.treeNodes[i]->children + c0 )!=tree._isValidSpaceNode( tree._sNodes.treeNodes[i]->children + c1 ) ) ERROR_OUT( "Finer edges should both be valid or invalid" );
if( !tree._isValidSpaceNode( tree._sNodes.treeNodes[i]->children + c0.index ) || !tree._isValidSpaceNode( tree._sNodes.treeNodes[i]->children + c1.index ) ) continue;
int cIndex0 = cSliceData0.edgeIndices( tree._sNodes.treeNodes[i]->children + c0.index )[_c.index];
@@ -1190,7 +1190,7 @@ protected:
fe.count = HyperCube::MarchingSquares::AddEdgeIndices( mcIndex , isoEdges );
for( int j=0 ; j& _edges = iter->second;
for( size_t j=0 ; j<_edges.size() ; j++ ) edges.push_back( _IsoEdge( _edges[j][flip] , _edges[j][1-flip] ) );
}
- else fprintf( stderr , "[ERROR] Invalid faces 1: %d %s\n" , i , fDir==HyperCube::BACK ? "back" : ( fDir==HyperCube::FRONT ? "front" : ( fDir==HyperCube::CROSS ? "cross" : "unknown" ) ) ) , exit( 0 );
+ else ERROR_OUT( "Invalid faces: %d %d" , i , fDir==HyperCube::BACK ? "back" : ( fDir==HyperCube::FRONT ? "front" : ( fDir==HyperCube::CROSS ? "cross" : "unknown" ) ) );
}
}
else
@@ -1352,7 +1352,7 @@ protected:
const std::vector< _IsoEdge >& _edges = iter->second;
for( size_t j=0 ; j<_edges.size() ; j++ ) edges.push_back( _IsoEdge( _edges[j][flip] , _edges[j][1-flip] ) );
}
- else fprintf( stderr , "[ERROR] Invalid faces 2: %d %s\n" , i , fDir==HyperCube::BACK ? "back" : ( fDir==HyperCube::FRONT ? "front" : ( fDir==HyperCube::CROSS ? "cross" : "unknown" ) ) ) , exit( 0 );
+ else ERROR_OUT( "Invalid faces: %d %s" , i , fDir==HyperCube::BACK ? "back" : ( fDir==HyperCube::FRONT ? "front" : ( fDir==HyperCube::CROSS ? "cross" : "unknown" ) ) );
}
}
}
@@ -1378,8 +1378,7 @@ protected:
{
LocalDepth d ; LocalOffset off;
tree._localDepthAndOffset( leaf , d , off );
- fprintf( stderr , "[ERROR] Failed to close loop [%d: %d %d %d] | (%d): %lld\n" , d-1 , off[0] , off[1] , off[2] , i , current );
- exit( 0 );
+ ERROR_OUT( "Failed to close loop [%d: %d %d %d] | (%d): %lld" , d-1 , off[0] , off[1] , off[2] , i , current );
}
}
else
@@ -1403,7 +1402,7 @@ protected:
if ( ( iter=bValues.edgeVertexMap.find( key ) )!=bValues.edgeVertexMap.end() ) polygon[kk] = iter->second;
else if( ( iter=fValues.edgeVertexMap.find( key ) )!=fValues.edgeVertexMap.end() ) polygon[kk] = iter->second;
else if( ( iter=xValues.edgeVertexMap.find( key ) )!=xValues.edgeVertexMap.end() ) polygon[kk] = iter->second;
- else fprintf( stderr , "[ERROR] Couldn't find vertex in edge map\n" ) , exit( 0 );
+ else ERROR_OUT( "Couldn't find vertex in edge map" );
}
_AddIsoPolygons( mesh , polygon , polygonMesh , addBarycenter , vOffset );
}
@@ -1467,13 +1466,12 @@ protected:
// We have a linear function L, with L(0) = x0 and L(1) = x1
// => L(t) = x0 + t * (x1-x0)
// => L(t) = isoValue <=> t = ( isoValue - x0 ) / ( x1 - x0 )
- if( x0==x1 ) fprintf( stderr , "[ERROR] Not a zero-crossing root: %g %g\n" , x0 , x1 ) , exit( 0 );
+ if( x0==x1 ) ERROR_OUT( "Not a zero-crossing root: %g %g" , x0 , x1 );
averageRoot = ( isoValue - x0 ) / ( x1 - x0 );
}
if( averageRoot<=0 || averageRoot>=1 )
{
- fprintf( stderr , "[WARNING] Bad average root: %f\n" , averageRoot );
- fprintf( stderr , "\t(%f %f) (%f)\n" , x0 , x1 , isoValue );
+ WARN( "Bad average root: %f\t(%f %f) (%f)" , averageRoot , x0 , x1 , isoValue );
if( averageRoot<0 ) averageRoot = 0;
if( averageRoot>1 ) averageRoot = 1;
}
@@ -1548,13 +1546,12 @@ protected:
// We have a linear function L, with L(0) = x0 and L(1) = x1
// => L(t) = x0 + t * (x1-x0)
// => L(t) = isoValue <=> t = ( isoValue - x0 ) / ( x1 - x0 )
- if( x0==x1 ) fprintf( stderr , "[ERROR] Not a zero-crossing root: %g %g\n" , x0 , x1 ) , exit( 0 );
+ if( x0==x1 ) ERROR_OUT( "Not a zero-crossing root: %g %g" , x0 , x1 );
averageRoot = ( isoValue - x0 ) / ( x1 - x0 );
}
if( averageRoot<=0 || averageRoot>=1 )
{
- fprintf( stderr , "[WARNING] Bad average root: %f\n" , averageRoot );
- fprintf( stderr , "\t(%f %f) (%f)\n" , x0 , x1 , isoValue );
+ WARN( "Bad average root: %f\t(%f %f) (%f)" , averageRoot , x0 , x1 , isoValue );
if( averageRoot<0 ) averageRoot = 0;
if( averageRoot>1 ) averageRoot = 1;
}
@@ -1627,7 +1624,7 @@ protected:
std::vector< Point< Real , Dim > > vertices( polygon.size() );
for( int i=0 ; i<(int)polygon.size() ; i++ ) vertices[i] = polygon[i].second.point;
std::vector< TriangleIndex > triangles = MinimalAreaTriangulation< Real , Dim >( ( ConstPointer( Point< Real , Dim > ) )GetPointer( vertices ) , vertices.size() );
- if( triangles.size()!=polygon.size()-2 ) fprintf( stderr , "[ERROR] Minimal area triangulation failed: %d != %d\n" , (int)triangles.size() , (int)polygon.size()-2 ) , exit( 0 );
+ if( triangles.size()!=polygon.size()-2 ) ERROR_OUT( "Minimal area triangulation failed: %d != %d" , (int)triangles.size() , (int)polygon.size()-2 );
for( int i=0 ; i<(int)triangles.size() ; i++ )
{
for( int j=0 ; j<3 ; j++ ) triangle[2-j] = polygon[ triangles[i].idx[j] ].first;
@@ -1658,7 +1655,7 @@ public:
tree._setFEM1ValidityFlags( UIntPack< FEMSigs ... >() );
static const unsigned int DataDegree = FEMSignature< DataSig >::Degree;
static const int FEMDegrees[] = { FEMSignature< FEMSigs >::Degree ... };
- for( int d=0 ; d::_addPointValues( UIntPack< FEMSigs ... > , StaticWin
typedef UIntPack< ( -BSplineSupportSizes< FEMSignature< FEMSigs >::Degree >::SupportStart ) ... > RightPointSupportRadii;
typedef UIntPack< BSplineSupportSizes< FEMSignature< FEMSigs >::Degree >::SupportSize ... > SupportSizes;
- if( !( FEMDegrees() >= IsotropicUIntPack< Dim , PointD >() ) )
- {
- fprintf( stderr , "[ERROR] FEMTree::_addPointValues: Insufficient derivatives: " );
- IsotropicUIntPack< Dim , PointD >::Print( stderr );
- fprintf( stderr , " > " );
- FEMDegrees::Print( stderr );
- fprintf( stderr , "\n" );
- exit( 0 );
- }
+ if( !( FEMDegrees() >= IsotropicUIntPack< Dim , PointD >() ) ) ERROR_OUT( "Insufficient derivatives" );
if( !interpolationInfo ) return;
const InterpolationInfo< T , PointD >& iInfo = *interpolationInfo;
@@ -962,7 +954,7 @@ void FEMTree< Dim , Real >::_addProlongedPointValues( UIntPack< FEMSigs ... > ,
#pragma message( "[WARNING] This code is broken" )
#endif // SHOW_WARNINGS
#if 1
- fprintf( stderr , "[ERROR] Broken code\n" ) , exit( 0 );
+ ERROR_OUT( "Broken code" );
#else
if( !interpolationInfo ) return;
const InterpolationInfo< T , PointD >& iInfo = *interpolationInfo;
@@ -1559,7 +1551,7 @@ SparseMatrix< Real > FEMTree< Dim , Real >::systemMatrix( UIntPack< FEMSigs ...
{
_setFEM1ValidityFlags( UIntPack< FEMSigs ... >() );
typedef typename BaseFEMIntegrator::template System< UIntPack< FEMSignature< FEMSigs >::Degree ... > > BaseSystem;
- if( depth<0 || depth>_maxDepth ) fprintf( stderr , "[ERROR] System depth out of bounds: %d <= %d <= %d\n" , 0 , depth , _maxDepth ) , exit( 0 );
+ if( depth<0 || depth>_maxDepth ) ERROR_OUT( "System depth out of bounds: %d <= %d <= %d" , 0 , depth , _maxDepth );
SparseMatrix< Real > matrix;
F.init( depth );
PointEvaluator< UIntPack< FEMSigs ... > , UIntPack< FEMSignature< FEMSigs >::Degree ... > > bsData( depth );
@@ -1599,7 +1591,7 @@ template< typename T , unsigned int ... PointDs , unsigned int ... FEMSigs >
SparseMatrix< Real > FEMTree< Dim , Real >::prolongedSystemMatrix( UIntPack< FEMSigs ... > , typename BaseFEMIntegrator::template System< UIntPack::Degree ... > >& F , LocalDepth highDepth , const InterpolationInfo< T , PointDs >* ... interpolationInfo ) const
{
_setFEM1ValidityFlags( UIntPack< FEMSigs ... >() );
- if( highDepth<=0 || highDepth>_maxDepth ) fprintf( stderr , "[ERROR] System depth out of bounds: %d < %d <= %d\n" , 0 , highDepth , _maxDepth ) , exit( 0 );
+ if( highDepth<=0 || highDepth>_maxDepth ) ERROR_OUT( "System depth out of bounds: %d < %d <= %d" , 0 , highDepth , _maxDepth );
LocalDepth lowDepth = highDepth-1;
SparseMatrix< Real > matrix;
@@ -2380,7 +2372,7 @@ template< unsigned int ... FEMSigs , typename T , typename TDotT , unsigned int
void FEMTree< Dim , Real >::solveSystem( UIntPack< FEMSigs ... > , typename BaseFEMIntegrator::template System< UIntPack< FEMSignature< FEMSigs >::Degree ... > >& F , const DenseNodeData< T , UIntPack< FEMSigs ... > >& constraints , DenseNodeData< T , UIntPack< FEMSigs ... > >& solution , TDotT Dot , LocalDepth maxSolveDepth , const typename FEMTree< Dim , Real >::SolverInfo& solverInfo , InterpolationInfo< T , PointDs >* ... interpolationInfo ) const
{
int baseDepth = solverInfo.baseDepth;
- if( baseDepth>getFullDepth( UIntPack< FEMSignature< FEMSigs >::Degree ... >() ) ) fprintf( stderr , "[ERROR] Base depth cannot excceed full depth: %d <= %d\n" , baseDepth , getFullDepth( UIntPack< FEMSignature< FEMSigs >::Degree ... >() ) ) , exit( 0 );
+ if( baseDepth>getFullDepth( UIntPack< FEMSignature< FEMSigs >::Degree ... >() ) ) ERROR_OUT( "Base depth cannot excceed full depth: %d <= %d" , baseDepth , getFullDepth( UIntPack< FEMSignature< FEMSigs >::Degree ... >() ) );
static_assert( Dim==sizeof ... ( FEMSigs ) , "[ERROR] FEMTree:solveSystem: Dimensions and number of signatures don't match" );
_setFEM1ValidityFlags( UIntPack< FEMSigs ... >() );
diff --git a/Src/FEMTree.WeightedSamples.inl b/Src/FEMTree.WeightedSamples.inl
index 7d5452a..e33ca8a 100644
--- a/Src/FEMTree.WeightedSamples.inl
+++ b/Src/FEMTree.WeightedSamples.inl
@@ -133,7 +133,7 @@ void FEMTree< Dim , Real >::_getSampleDepthAndWeight( const DensityEstimator< We
temp = _spaceRoot;
while( _localDepth( temp )( temp->children ) ) break;// fprintf( stderr , "[ERROR] FEMTree::GetSampleDepthAndWeight\n" ) , exit( 0 );
+ if( !IsActiveNode< Dim >( temp->children ) ) break; // ERROR_OUT( "" );
int cIndex = FEMTreeNode::ChildIndex( myCenter , position );
temp = temp->children + cIndex;
myWidth /= 2;
diff --git a/Src/FEMTree.h b/Src/FEMTree.h
index e2407d2..33a6e60 100644
--- a/Src/FEMTree.h
+++ b/Src/FEMTree.h
@@ -261,9 +261,9 @@ struct BlockedVector
if( size<=_size )
{
#ifdef _MSC_VER
- fprintf( stderr , "[WARNING] BlockedVector::resize: new size must be greater than old size: %llu > %llu\n" , size , _size );
+ WARN( "BlockedVector::resize: new size must be greater than old size: %llu > %llu" , size , _size );
#else // !MSC_VER
- fprintf( stderr , "[WARNING] BlockedVector::resize: new size must be greater than old size: %lu > %lu\n" , size , _size );
+ WARN( "BlockedVector::resize: new size must be greater than old size: %lu > %lu" , size , _size );
#endif // _MSC_VER
return _size;
}
@@ -395,11 +395,11 @@ struct DenseNodeData< Data , UIntPack< FEMSigs ... > > : public _SparseOrDenseNo
fwrite( femSigs , sizeof(unsigned int) , dim , fp );
}
void write( FILE* fp ) const { fwrite( &_sz , sizeof(size_t) , 1 , fp ) ; fwrite( _data , sizeof(Data) , _sz , fp ); }
- void read ( FILE* fp )
+ void read( FILE* fp )
{
- if( fread( &_sz , sizeof(size_t) , 1 , fp )!=1 ) fprintf( stderr , "[ERROR] DenseNodeData::read: Failed to read size\n" ) , exit( 0 );
+ if( fread( &_sz , sizeof(size_t) , 1 , fp )!=1 ) ERROR_OUT( "Failed to read size" );
_data = NewPointer< Data >( _sz );
- if( fread ( _data , sizeof(Data) , _sz , fp )!=_sz ) fprintf( stderr , "[ERROR] DenseNodeData::read failed to read data\n" ) , exit( 0 );
+ if( fread ( _data , sizeof(Data) , _sz , fp )!=_sz ) ERROR_OUT( "failed to read data" );
}
Data& operator[] ( int idx ) { return _data[idx]; }
@@ -437,14 +437,14 @@ const char* FEMTreeRealNames[] = { "float" , "double" };
void ReadFEMTreeParameter( FILE* fp , FEMTreeRealType& realType , int &dimension )
{
- if( fread( &realType , sizeof(FEMTreeRealType) , 1 , fp )!=1 ) fprintf( stderr , "[ERROR] ReadFEMTreeParameter: Failed to read real type\n" ) , exit( 0 );
- if( fread( &dimension , sizeof(int) , 1 , fp )!=1 ) fprintf( stderr , "[ERROR] ReadFEMTreeParameter: Failed to read dimension\n" ) , exit( 0 );
+ if( fread( &realType , sizeof(FEMTreeRealType) , 1 , fp )!=1 ) ERROR_OUT( "Failed to read real type" );
+ if( fread( &dimension , sizeof(int) , 1 , fp )!=1 ) ERROR_OUT( "Failed to read dimension" );
}
unsigned int* ReadDenseNodeDataSignatures( FILE* fp , unsigned int &dim )
{
- if( fread( &dim , sizeof(unsigned int) , 1 , fp )!=1 ) fprintf( stderr , "[ERROR] ReadDenseNodeDataSignatures: Failed to read dimension\n" ) , exit( 0 );
+ if( fread( &dim , sizeof(unsigned int) , 1 , fp )!=1 ) ERROR_OUT( "Failed to read dimension" );
unsigned int* femSigs = new unsigned int[dim];
- if( fread( femSigs , sizeof(unsigned int) , dim , fp )!=dim ) fprintf( stderr , "[ERROR] ReadDenseNodeDataSignatures: Failed to read signatures\n" ) , exit( 0 );
+ if( fread( femSigs , sizeof(unsigned int) , dim , fp )!=dim ) ERROR_OUT( "Failed to read signatures" );
return femSigs;
}
@@ -496,7 +496,7 @@ struct CumulativeDerivatives
{
int dCount = 0;
for( int d=0 ; d=D ) fprintf( stderr , "[ERROR] CumulativeDerivatives::Index: more derivatives than allowed\n" ) , exit( 0 );
+ if( dCount>=D ) ERROR_OUT( "More derivatives than allowed" );
else if( dCount;
@@ -1144,8 +1144,9 @@ public:
case INTEGRATE_CHILD_CHILD: return std::get< D >( _integrators ).ccIntegrator.dot( off1[D] , off2[D] , d1[D] , d2[D] ) * remainingIntegral;
case INTEGRATE_PARENT_CHILD: return std::get< D >( _integrators ).pcIntegrator.dot( off1[D] , off2[D] , d1[D] , d2[D] ) * remainingIntegral;
case INTEGRATE_CHILD_PARENT: return std::get< D >( _integrators ).cpIntegrator.dot( off2[D] , off1[D] , d2[D] , d1[D] ) * remainingIntegral;
- default: fprintf( stderr , "[ERORR] FEMIntegrator::Test::Constraint::_integral: Undefined integration type\n" ) , exit( 0 );
+ default: ERROR_OUT( "Undefined integration type" );
}
+ return 0;
}
Point< double , CDim > _integrate( IntegrationType iType , const int off1[] , const int off[] ) const;
};
@@ -2231,7 +2232,7 @@ public:
FEMTreeRealType realType;
if ( typeid( Real )==typeid( float ) ) realType=FEM_TREE_REAL_FLOAT;
else if( typeid( Real )==typeid( double ) ) realType=FEM_TREE_REAL_DOUBLE;
- else fprintf( stderr , "[ERROR] FEMTree::WriteParameter: Unrecognized real type\n" ) , exit( 0 );
+ else ERROR_OUT( "Unrecognized real type" );
fwrite( &realType , sizeof(FEMTreeRealType) , 1 , fp );
int dim = Dim;
fwrite( &dim , sizeof(int) , 1 , fp );
@@ -2561,7 +2562,7 @@ struct IsoSurfaceExtractor
)
{
// The unspecialized implementation is not supported
- fprintf( stderr , "[WARNING] Iso-surface extraction not supported for dimension %d\n" , Dim );
+ WARN( "Iso-surface extraction not supported for dimension %d" , Dim );
return IsoStats();
}
};
diff --git a/Src/FEMTree.inl b/Src/FEMTree.inl
index 763f682..bf00596 100644
--- a/Src/FEMTree.inl
+++ b/Src/FEMTree.inl
@@ -80,7 +80,7 @@ FEMTree< Dim , Real >::FEMTree( FILE* fp , int blockSize )
else nodeAllocator = NULL;
if( fp )
{
- if( fread( &_depthOffset , sizeof( int ) , 1 , fp )!=1 ) fprintf( stderr , "[ERROR] FEMTree::FEMTree: failed to read depth offset\n" ) , exit( 0 );
+ if( fread( &_depthOffset , sizeof( int ) , 1 , fp )!=1 ) ERROR_OUT( "Failed to read depth offset" );
_tree = FEMTreeNode::NewBrood( nodeAllocator , _NodeInitializer( *this ) );
_tree->read( fp , nodeAllocator , _NodeInitializer( *this ) );
_maxDepth = _tree->maxDepth() - _depthOffset;
@@ -91,7 +91,7 @@ FEMTree< Dim , Real >::FEMTree( FILE* fp , int blockSize )
{
_spaceRoot = _tree->children + (1<children ) fprintf( stderr , "[ERROR] FEMTree::FEMTree expected children\n" ) , exit( 0 );
+ if( !_spaceRoot->children ) ERROR_OUT( "Expected children" );
else _spaceRoot = _spaceRoot->children;
}
_sNodes.set( *_tree , NULL );
@@ -348,9 +348,7 @@ SparseNodeData< Point< Real , Dim > , UIntPack< NormalSigs ... > > FEMTree< Dim
weightSum += sample.weight;
if( !_InBounds(p) )
{
- fprintf( stderr , "[WARNING] FEMTree:setNormalField: Point sample is out of bounds:" );
- for( int d=0 ; d > FEMTree< Dim , Real
Point< Real , Dim > p = sample.weight==0 ? sample.data : sample.data / sample.weight;
if( !_InBounds(p) )
{
- fprintf( stderr , "[WARNING] Point is out of bounds:" );
- for( int d=0 ; d( *density , p , data * sample.weight , dataField , densityKey , dataKey , 0 , maxDepth , Dim );
@@ -423,11 +417,7 @@ SparseNodeData< ProjectiveData< Data , Real > , IsotropicUIntPack< Dim , DataSig
Point< Real , Dim > p = sample.weight==0 ? sample.data : sample.data / sample.weight;
if( !_InBounds(p) )
{
- fprintf( stderr , "[WARNING] Point is out of bounds:" );
- for( int d=0 ; d( density , (FEMTreeNode*)samples[i].node , p , ProjectiveData< Data , Real >( data , sample.weight ) , dataField , densityKey , 2 );
@@ -1006,7 +996,7 @@ template< unsigned int Dim , class Real >
std::vector< int > FEMTree< Dim , Real >::merge( FEMTree* tree )
{
std::vector< int > map;
- if( _depthOffset!=tree->_depthOffset ) fprintf( stderr , "[ERROR] FEMTree::merge: depthOffsets don't match: %d != %d\n" , _depthOffset , tree->_depthOffset ) , exit( 0 );
+ if( _depthOffset!=tree->_depthOffset ) ERROR_OUT( "depthOffsets don't match: %d != %d" , _depthOffset , tree->_depthOffset );
// Compute the next available index
int nextIndex = 0;
diff --git a/Src/Geometry.h b/Src/Geometry.h
index 8071039..7e52c76 100644
--- a/Src/Geometry.h
+++ b/Src/Geometry.h
@@ -49,7 +49,7 @@ struct Point
void _init( int d )
{
if( !d ) memset( coords , 0 , sizeof(Real)*Dim );
- else fprintf( stderr , "[ERROR] Point::_init: Should never be called\n" ) , exit( 0 );
+ else ERROR_OUT( "Should never be called" );
}
template< class _Real , class ... _Reals > void _init( int d , _Real v , _Reals ... values )
{
@@ -355,7 +355,7 @@ protected:
void _init( int k )
{
if( !k ) memset( idx , 0 , sizeof(idx) );
- else fprintf( stderr , "[ERROR] SimplexIndex::_init: Should never be called\n" ) , exit( 0 );
+ else ERROR_OUT( "Should never be called" );
}
template< class ... Ints > void _init( int k , int v , Ints ... values )
{
@@ -527,7 +527,7 @@ public:
#endif // _WIN32
tempFile = true;
}
- if( !_fp ) fprintf( stderr , "[ERROR] Failed to open file: %s\n" , _fileName ) , exit( 0 );
+ if( !_fp ) ERROR_OUT( "Failed to open file: %s" , _fileName );
_buffer = (char*) malloc( _bufferSize );
}
~BufferedReadWriteFile( void )
diff --git a/Src/Geometry.inl b/Src/Geometry.inl
index 2756182..5f26907 100644
--- a/Src/Geometry.inl
+++ b/Src/Geometry.inl
@@ -362,7 +362,7 @@ int CoredFileMeshData< Vertex >::nextPolygon( std::vector< CoredVertexIndex >& v
else vertices[i].idx = polygon[i] , vertices[i].inCore = true;
return 1;
}
- fprintf( stderr , "[ERROR] Failed to read polygon from file\n" ) , exit( 0 );
+ ERROR_OUT( "Failed to read polygon from file" );
}
else threadIndex++;
}
diff --git a/Src/Image.h b/Src/Image.h
index b2bf7b7..78c2874 100644
--- a/Src/Image.h
+++ b/Src/Image.h
@@ -4,6 +4,7 @@
#define SUPPORT_TILES
#include
+#include "MyMiscellany.h"
struct ImageReader
{
@@ -22,7 +23,7 @@ struct ImageReader
unsigned int channels;
ImageReader* reader = Get( fileName );
width = reader->width() , height = reader->height();
- if( channels!=1 && channels!=3 ) fprintf( stderr , "[ERROR] ImageReader::ReadColor requres one- or three-channel input\n" ) , exit( 0 );
+ if( channels!=1 && channels!=3 ) ERROR_OUT( "Requres one- or three-channel input" );
unsigned char* pixels = new unsigned char[ width*height*3 ];
unsigned char* pixelRow = new unsigned char[ width*channels];
for( unsigned int j=0 ; j_width = width;
writer->_height = height;
writer->_channels = channels;
@@ -229,22 +230,22 @@ bool TiledImageReader::GetInfo( const char* fileName , unsigned int& width , uns
unsigned int *_tileHeights , *_tileWidths;
unsigned int _tileRows , _tileColumns , _channels;
FILE* fp = fopen( fileName , "r" );
- if( !fp ){ fprintf( stderr , "[WARNING] TiledImageReader::GetInfo: Couldn't open file for reading: %s\n" , fileName ) ; return false; }
+ if( !fp ){ WARN( "Couldn't open file for reading: %s" , fileName ) ; return false; }
{
char line[1024];
- if( !fgets( line , 1024 , fp ) ) fprintf( stderr , "[ERROR] TiledImageReader::GetInfo: Failed to read column line from: %s\n" , fileName ) , exit( 0 );
+ if( !fgets( line , 1024 , fp ) ) ERROR_OUT( "Failed to read column line from: %s" , fileName );
line[strlen(line)-1] = 0;
- if( sscanf( line , "Columns: %d" , &_tileColumns )!=1 ) fprintf( stderr , "[ERROR] TiledImageReader::GetInfo: Failed to read column count from: %s (%s)\n" , fileName , line ) , exit( 0 );
- if( !fgets( line , 1024 , fp ) ) fprintf( stderr , "[ERROR] TiledImageReader::GetInfo: Failed to read row line from: %s\n" , fileName ) , exit( 0 );
+ if( sscanf( line , "Columns: %d" , &_tileColumns )!=1 ) ERROR_OUT( "Failed to read column count from: %s (%s)" , fileName , line );
+ if( !fgets( line , 1024 , fp ) ) ERROR_OUT( "Failed to read row line from: %s" , fileName );
line[strlen(line)-1] = 0;
- if( sscanf( line , "Rows: %d" , &_tileRows )!=1 ) fprintf( stderr , "[ERROR] TiledImageReader::GetInfo: Failed to read row count from: %s (%s)\n" , fileName , line ) , exit( 0 );
+ if( sscanf( line , "Rows: %d" , &_tileRows )!=1 ) ERROR_OUT( "Failed to read row count from: %s (%s)" , fileName , line );
_tileHeights = new unsigned int[ _tileRows+1 ];
_tileWidths = new unsigned int[ _tileColumns+1 ];
char tileName[1024];
for( unsigned int r=0 ; r<_tileRows ; r++ ) for( unsigned int c=0 ; c<_tileColumns ; c++ )
{
- if( !fgets( line , 1024 , fp ) ) fprintf( stderr , "[ERROR] TiledImageReader::GetInfo: Failed to read tile name from: %s\n" , fileName ) , exit( 0 );
+ if( !fgets( line , 1024 , fp ) ) ERROR_OUT( "Failed to read tile name from: %s" , fileName );
line[strlen(line)-1] = 0;
if( fileDir ) sprintf( tileName , "%s%c%s" , fileDir , FileNameParser::Separator , line );
else sprintf( tileName , "%s" , line );
@@ -252,11 +253,11 @@ bool TiledImageReader::GetInfo( const char* fileName , unsigned int& width , uns
unsigned int _w , _h , _c;
ImageReader::GetInfo( tileName , _w , _h , _c );
if( !r && !c ) _channels = _c;
- else if( _channels!=_c ) fprintf( stderr , "[ERROR] TiledImageReader::GetInfo: Number of color channels don't match: %d != %d\n" , _channels , _c ) , exit( 0 );
+ else if( _channels!=_c ) ERROR_OUT( "Number of color channels don't match: %d != %d" , _channels , _c );
if( !r ) _tileWidths[c+1] = _w;
- else if( _tileWidths[c+1]!=_w ) fprintf( stderr , "[ERROR] TiledImageReader::GetInfo: Images in the same column must have the same width: %d != %d\n" , _tileWidths[c+1] , _w ) , exit( 0 );
+ else if( _tileWidths[c+1]!=_w ) ERROR_OUT( "Images in the same column must have the same width: %d != %d" , _tileWidths[c+1] , _w );
if( !c ) _tileHeights[r+1] = _h;
- else if( _tileHeights[r+1]!=_h ) fprintf( stderr , "[ERROR] TiledImageReader::GetInfo: Images in the same row must have the same heights: %d != %d\n" , _tileHeights[r+1] , _h ) , exit( 0 );
+ else if( _tileHeights[r+1]!=_h ) ERROR_OUT( "Images in the same row must have the same heights: %d != %d" , _tileHeights[r+1] , _h );
}
}
fclose( fp );
@@ -272,15 +273,15 @@ TiledImageReader::TiledImageReader( const char* fileName , unsigned int& width ,
{
char* fileDir = FileNameParser::Dir( fileName );
FILE* fp = fopen( fileName , "r" );
- if( !fp ) fprintf( stderr , "[ERROR] TiledImageReader::TiledImageReader: Couldn't open file for reading: %s\n" , fileName ) , exit( 0 );
+ if( !fp ) ERROR_OUT( "Couldn't open file for reading: %s" , fileName );
{
char line[1024];
- if( !fgets( line , 1024 , fp ) ) fprintf( stderr , "[ERROR] TiledImageReader::TiledImageReader: Failed read column line from: %s\n" , fileName ) , exit( 0 );
+ if( !fgets( line , 1024 , fp ) ) ERROR_OUT( "Failed read column line from: %s" , fileName );
line[strlen(line)-1] = 0;
- if( sscanf( line , "Columns: %d" , &_tileColumns )!=1 ) fprintf( stderr , "[ERROR] TiledImageReader::TiledImageReader: Failed to read column count from: %s (%s)\n" , fileName , line ) , exit( 0 );
- if( !fgets( line , 1024 , fp ) ) fprintf( stderr , "[ERROR] TiledImageReader::TiledImageReader: Failed read row line from: %s\n" , fileName ) , exit( 0 );
+ if( sscanf( line , "Columns: %d" , &_tileColumns )!=1 ) ERROR_OUT( "Failed to read column count from: %s (%s)" , fileName , line );
+ if( !fgets( line , 1024 , fp ) ) ERROR_OUT( "Failed read row line from: %s" , fileName );
line[strlen(line)-1] = 0;
- if( sscanf( line , "Rows: %d" , &_tileRows )!=1 ) fprintf( stderr , "[ERROR] TiledImageReader::TiledImageReader: Failed to read row count from: %s (%s)\n" , fileName , line ) , exit( 0 );
+ if( sscanf( line , "Rows: %d" , &_tileRows )!=1 ) ERROR_OUT( "Failed to read row count from: %s (%s)" , fileName , line );
_tileReaders = new ImageReader*[ _tileColumns ];
_tileHeights = new unsigned int[ _tileRows+1 ];
@@ -290,7 +291,7 @@ TiledImageReader::TiledImageReader( const char* fileName , unsigned int& width ,
char tileName[1024];
for( unsigned int r=0 ; r<_tileRows ; r++ ) for( unsigned int c=0 ; c<_tileColumns ; c++ )
{
- if( !fgets( line , 1024 , fp ) ) fprintf( stderr , "[ERROR] TiledImageReader::TiledImageReader: Failed read tile name from: %s\n" , fileName ) , exit( 0 );
+ if( !fgets( line , 1024 , fp ) ) ERROR_OUT( "Failed to read tile name from: %s" , fileName );
line[strlen(line)-1] = 0;
if( fileDir ) sprintf( tileName , "%s%c%s" , fileDir , FileNameParser::Separator , line );
else sprintf( tileName , "%s" , line );
@@ -305,11 +306,11 @@ TiledImageReader::TiledImageReader( const char* fileName , unsigned int& width ,
unsigned int _w , _h , _c;
ImageReader::GetInfo( _tileNames[r*_tileColumns+c] , _w , _h , _c );
if( !r && !c ) _channels = _c;
- else if( _channels!=_c ) fprintf( stderr , "[ERROR] TiledImageReader::TiledImageReader: Number of color channels don't match: %d != %d\n" , _channels , _c ) , exit( 0 );
+ else if( _channels!=_c ) ERROR_OUT( "Number of color channels don't match: %d != %d" , _channels , _c );
if( !r ) _tileWidths[c+1] = _w;
- else if( _tileWidths[c+1]!=_w ) fprintf( stderr , "[ERROR] TiledImageReader::TiledImageReader: Images in the same column must have the same width: %d != %d\n" , _tileWidths[c+1] , _w ) , exit( 0 );
+ else if( _tileWidths[c+1]!=_w ) ERROR_OUT( "Images in the same column must have the same width: %d != %d" , _tileWidths[c+1] , _w );
if( !c ) _tileHeights[r+1] = _h;
- else if( _tileHeights[r+1]!=_h ) fprintf( stderr , "[ERROR] TiledImageReader::TiledImageReader: Images in the same row must have the same heights: %d != %d\n" , _tileHeights[r+1] , _h ) , exit( 0 );
+ else if( _tileHeights[r+1]!=_h ) ERROR_OUT( "Images in the same row must have the same heights: %d != %d" , _tileHeights[r+1] , _h );
}
_tileWidths[0] = _tileHeights[0] = 0;
for( unsigned int c=0 ; c<_tileColumns ; c++ ) _tileWidths[c+1] += _tileWidths[c];
@@ -361,7 +362,7 @@ TiledImageWriter::TiledImageWriter( const char* fileName , unsigned int width ,
}
delete[] tileHeader;
FILE* fp = fopen( fileName , "w" );
- if( !fp ) fprintf( stderr , "[ERROR] TiledImageWriter::TiledImageWriter: Failed to open file for writing: %s\n" , fileName ) , exit( 0 );
+ if( !fp ) ERROR_OUT( "Failed to open file for writing: %s" , fileName );
fprintf( fp , "Columns: %d\n" , _tileColumns );
fprintf( fp , "Rows: %d\n" , _tileRows );
for( unsigned int i=0 ; i<_tileRows*_tileColumns ; i++ )
diff --git a/Src/ImageStitching.cpp b/Src/ImageStitching.cpp
index b76895e..fa90c36 100644
--- a/Src/ImageStitching.cpp
+++ b/Src/ImageStitching.cpp
@@ -139,8 +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 ) )
- fprintf( stderr , "[ERROR] Could not write image to: %s\n" , fileName ) , exit( 0 );
+ if( !ImageWriter::Write( fileName , (const unsigned char*)pixels , _w , _h , _c ) ) ERROR_OUT( "Could not write image to: %s" , fileName );
}
struct Profiler
@@ -183,8 +182,8 @@ struct BufferedImageDerivativeStream : public FEMTreeInitializer< DIMENSION , Re
_labelRows[i] = new RGBPixel[ _resolution[0] ];
_maskRows [i] = new int[ _resolution[0] ];
}
- if( pixels->channels()!=3 && pixels->channels()!=1 ) fprintf( stderr , "[ERROR] Pixel input must have 1 or 3 channels: %d\n" , pixels->channels() ) , exit( 0 );
- if( labels->channels()!=3 && labels->channels()!=1 ) fprintf( stderr , "[ERROR] Label input must have 1 or 3 channels: %d\n" , labels->channels() ) , exit( 0 );
+ if( pixels->channels()!=3 && pixels->channels()!=1 ) ERROR_OUT( "Pixel input must have 1 or 3 channels: %d" , pixels->channels() );
+ if( labels->channels()!=3 && labels->channels()!=1 ) ERROR_OUT( "Label input must have 1 or 3 channels: %d" , labels->channels() );
__pixelRow = pixels->channels()==3 ? NULL : new unsigned char[ _resolution[0] ];
__labelRow = labels->channels()==3 ? NULL : new unsigned char[ _resolution[0] ];
_r = -2 ; prefetch();
@@ -278,7 +277,7 @@ void _Execute( void )
ImageReader::GetInfo( In.values[0] , _w , _h , _c );
w = _w , h = _h;
ImageReader::GetInfo( In.values[1] , _w , _h , _c );
- if( w!=_w || h!=_h ) fprintf( stderr , "[ERROR] Pixel and label dimensions don't match: %d x %d != %d x %d\n" , _w , _h , w , h ) , exit( 0 );
+ if( w!=_w || h!=_h ) ERROR_OUT( "Pixel and label dimensions don't match: %d x %d != %d x %d" , _w , _h , w , h );
}
if( Verbose.set ) printf( "Resolution: %d x %d\n" , w , h );
@@ -488,7 +487,7 @@ void _Execute( void )
case 2: _Execute< Real , 2 >() ; break;
// case 3: _Execute< Real , 3 >() ; break;
// case 4: _Execute< Real , 4 >() ; break;
- default: fprintf( stderr , "[ERROR] Only B-Splines of degree 1 - 2 are supported" ) ; exit( 0 );
+ default: ERROR_OUT( "Only B-Splines of degree 1 - 2 are supported" );
}
}
#endif // FAST_COMPILE
@@ -515,7 +514,7 @@ int main( int argc , char* argv[] )
}
if( BaseDepth.value>FullDepth.value )
{
- if( BaseDepth.set ) fprintf( stderr , "[WARNING] Base depth must be smaller than full depth: %d <= %d\n" , BaseDepth.value , FullDepth.value );
+ if( BaseDepth.set ) WARN( "Base depth must be smaller than full depth: %d <= %d" , BaseDepth.value , FullDepth.value );
BaseDepth.value = FullDepth.value;
}
@@ -527,7 +526,7 @@ int main( int argc , char* argv[] )
#ifdef FAST_COMPILE
static const int Degree = DEFAULT_FEM_DEGREE;
- fprintf( stderr , "[WARNING] Compiled for degree-%d, %s-precision _only_\n" , Degree , sizeof(DefaultFloatType)==4 ? "single" : "double" );
+ WARN( "Compiled for degree-%d, %s-precision _only_" , Degree , sizeof(DefaultFloatType)==4 ? "single" : "double" );
_Execute< Real , Degree >();
#else // !FAST_COMPILE
_Execute< Real >();
diff --git a/Src/JPEG.inl b/Src/JPEG.inl
index 35d8ab8..e98b643 100644
--- a/Src/JPEG.inl
+++ b/Src/JPEG.inl
@@ -19,7 +19,7 @@ my_error_exit (j_common_ptr cinfo)
inline bool JPEGReader::GetInfo( const char* fileName , unsigned int& width , unsigned int& height , unsigned int& channels )
{
FILE* fp = fopen( fileName , "rb" );
- if( !fp ) fprintf( stderr , "[ERROR] JPEGReader: Failed to open: %s\n" , fileName ) , exit(0);
+ if( !fp ) ERROR_OUT( "Failed to open: %s" , fileName );
struct jpeg_decompress_struct cInfo;
struct my_error_mgr jErr;
@@ -29,8 +29,7 @@ inline bool JPEGReader::GetInfo( const char* fileName , unsigned int& width , un
if( setjmp( jErr.setjmp_buffer ) )
{
jpeg_destroy_decompress( &cInfo );
- fprintf( stderr , "[ERROR] JPEGReader: JPEG error occured\n" );
- exit( 0 );
+ ERROR_OUT( "JPEG error occured" );
}
jpeg_create_decompress( &cInfo );
@@ -51,15 +50,14 @@ inline JPEGReader::JPEGReader( const char* fileName , unsigned int& width , unsi
{
_currentRow = 0;
_fp = fopen( fileName , "rb" );
- if( !_fp ) fprintf( stderr , "[ERROR] JPEGReader: Failed to open: %s\n" , fileName ) , exit(0);
+ if( !_fp ) ERROR_OUT( "Failed to open: %s" , fileName );
_cInfo.err = jpeg_std_error( &_jErr.pub );
_jErr.pub.error_exit = my_error_exit;
if( setjmp( _jErr.setjmp_buffer ) )
{
jpeg_destroy_decompress( &_cInfo );
- fprintf( stderr , "[ERROR] JPEGReader: JPEG error occured\n" );
- exit( 0 );
+ ERROR_OUT( "JPEG error occured" );
}
jpeg_create_decompress( &_cInfo );
@@ -90,7 +88,7 @@ inline JPEGWriter::JPEGWriter( const char* fileName , unsigned int width , unsig
{
_currentRow = 0;
_fp = fopen( fileName , "wb" );
- if( !_fp ) fprintf( stderr , "[ERROR] JPEGWriter: Failed to open: %s\n" , fileName ) , exit(0);
+ if( !_fp ) ERROR_OUT( "Failed to open: %s" , fileName );
_cInfo.err = jpeg_std_error( &_jErr.pub );
jpeg_create_compress( &_cInfo );
diff --git a/Src/MarchingCubes.h b/Src/MarchingCubes.h
index 39ef51f..a4b0e5a 100644
--- a/Src/MarchingCubes.h
+++ b/Src/MarchingCubes.h
@@ -337,7 +337,7 @@ namespace HyperCube
case BACK: index = coIndex ; break;
case CROSS: index = coIndex + HyperCube::ElementNum< D-1 , K >::Value ; break;
case FRONT: index = coIndex + HyperCube::ElementNum< D-1 , K >::Value + HyperCube::ElementNum< D-1 , K-1 >::Value ; break;
- default: fprintf( stderr , "[ERROR] Element::Element: bad direction: %d\n" , dir ) , exit( 0 );
+ default: ERROR_OUT( "Bad direction: %d" , dir );
}
}
template< unsigned int D > template< unsigned int K > template< unsigned int _D , unsigned int _K >
@@ -347,7 +347,7 @@ namespace HyperCube
{
case BACK: index = coIndex ; break;
case FRONT: index = coIndex + HyperCube::ElementNum< D-1 , K >::Value ; break;
- default: fprintf( stderr , "[ERROR] Element::Element: bad direction: %d\n" , dir ) , exit( 0 );
+ default: ERROR_OUT( "Bad direction: %d" , dir );
}
}
template< unsigned int D > template< unsigned int K > template< unsigned int _D , unsigned int _K >
diff --git a/Src/MyMiscellany.h b/Src/MyMiscellany.h
index 897e814..96904cb 100644
--- a/Src/MyMiscellany.h
+++ b/Src/MyMiscellany.h
@@ -28,6 +28,8 @@ DAMAGE.
#ifndef MY_MISCELLANY_INCLUDED
#define MY_MISCELLANY_INCLUDED
+#undef VERBOSE_MESSAGING
+
//////////////////
// OpenMP Stuff //
//////////////////
@@ -181,6 +183,189 @@ struct MessageWriter
}
};
+/////////////////////////////////////
+// Exception, Warnings, and Errors //
+/////////////////////////////////////
+#include
+#include
+namespace MKExceptions
+{
+#ifdef VERBOSE_MESSAGING
+ inline char *_MakeMessageString( const char *header , const char *fileName , int line , const char *functionName , const char *format , ... )
+ {
+ va_list args;
+ va_start( args , format );
+
+ // Formatting is:
+ // (Line )
+ //
+ //
+ char lineBuffer[25];
+ sprintf( lineBuffer , "(Line %d)" , line );
+ size_t _size , size=0;
+
+ // Line 1
+ size += strlen(header)+1;
+ size += strlen(fileName)+1;
+ size += strlen(lineBuffer)+1;
+
+ // Line 2
+ size += strlen(header)+1;
+ size += strlen(functionName)+1;
+
+ // Line 3
+ size += strlen(header)+1;
+ size += vsnprintf( NULL , 0 , format , args );
+
+ char *_buffer , *buffer = new char[ size+1 ];
+ _size = size , _buffer = buffer;
+
+ // Line 1
+ sprintf( _buffer , "%s " , header );
+ _buffer += strlen(header)+1;
+ _size -= strlen(header)+1;
+
+ sprintf( _buffer , "%s " , fileName );
+ _buffer += strlen(fileName)+1;
+ _size -= strlen(fileName)+1;
+
+ sprintf( _buffer , "%s\n" , lineBuffer );
+ _buffer += strlen(lineBuffer)+1;
+ _size -= strlen(lineBuffer)+1;
+
+ // Line 2
+ for( int i=0 ; i
+ Exception( const char *fileName , int line , const char *functionName , const char *format , Args ... args )
+ {
+ char *buffer = _MakeMessageString( "[EXCEPTION]" , fileName , line , functionName , format , args ... );
+ _message = std::string( buffer );
+ delete[] buffer;
+ }
+ protected:
+ std::string _message;
+ };
+
+ template< typename ... Args > void Throw( const char *fileName , int line , const char *functionName , const char *format , Args ... args ){ throw Exception( fileName , line , functionName , format , args ... ); }
+ template< typename ... Args >
+ void Warn( const char *fileName , int line , const char *functionName , const char *format , Args ... args )
+ {
+ char *buffer = _MakeMessageString( "[WARNING]" , fileName , line , functionName , format , args ... );
+ fprintf( stderr , "%s\n" , buffer );
+ delete[] buffer;
+ }
+ template< typename ... Args >
+ void ErrorOut( const char *fileName , int line , const char *functionName , const char *format , Args ... args )
+ {
+ char *buffer = _MakeMessageString( "[ERROR]" , fileName , line , functionName , format , args ... );
+ fprintf( stderr , "%s\n" , buffer );
+ delete[] buffer;
+ exit(0);
+ }
+#else // !VERBOSE_MESSAGING
+ inline char *_MakeMessageString( const char *header , const char *functionName , const char *format , ... )
+ {
+ va_list args;
+ va_start( args , format );
+
+ size_t _size , size = vsnprintf( NULL , 0 , format , args );
+ size += strlen(header)+1;
+ size += strlen(functionName)+2;
+
+ char *_buffer , *buffer = new char[ size+1 ];
+ _size = size , _buffer = buffer;
+
+ sprintf( _buffer , "%s " , header );
+ _buffer += strlen(header)+1;
+ _size -= strlen(header)+1;
+
+ sprintf( _buffer , "%s: " , functionName );
+ _buffer += strlen(functionName)+2;
+ _size -= strlen(functionName)+2;
+
+ vsnprintf( _buffer , _size+1 , format , args );
+
+ return buffer;
+ }
+ struct Exception : public std::exception
+ {
+ const char *what( void ) const noexcept { return _message.c_str(); }
+ template< typename ... Args >
+ Exception( const char *functionName , const char *format , Args ... args )
+ {
+ char *buffer = _MakeMessageString( "[EXCEPTION]" , functionName , format , args ... );
+ _message = std::string( buffer );
+ delete[] buffer;
+ exit(0);
+ }
+ protected:
+ std::string _message;
+ };
+ template< typename ... Args > void Throw( const char *functionName , const char *format , Args ... args ){ throw Exception( functionName , format , args ... ); }
+ template< typename ... Args >
+ void Warn( const char *functionName , const char *format , Args ... args )
+ {
+ char *buffer = _MakeMessageString( "[WARNING]" , functionName , format , args ... );
+ fprintf( stderr , "%s\n" , buffer );
+ delete[] buffer;
+ }
+ template< typename ... Args >
+ void ErrorOut( const char *functionName , const char *format , Args ... args )
+ {
+ char *buffer = _MakeMessageString( "[ERROR]" , functionName , format , args ... );
+ fprintf( stderr , "%s\n" , buffer );
+ delete[] buffer;
+ }
+#endif // VERBOSE_MESSAGING
+}
+#ifdef VERBOSE_MESSAGING
+#ifndef WARN
+#define WARN( ... ) MKExceptions::Warn( __FILE__ , __LINE__ , __FUNCTION__ , __VA_ARGS__ )
+#endif // WARN
+#ifndef WARN_ONCE
+#define WARN_ONCE( ... ) { static bool firstTime = true ; if( firstTime ) MKExceptions::Warn( __FILE__ , __LINE__ , __FUNCTION__ , __VA_ARGS__ ) ; firstTime = false; }
+#endif // WARN_ONCE
+#ifndef THROW
+#define THROW( ... ) MKExceptions::Throw( __FILE__ , __LINE__ , __FUNCTION__ , __VA_ARGS__ )
+#endif // THROW
+#ifndef ERROR_OUT
+#define ERROR_OUT( ... ) MKExceptions::ErrorOut( __FILE__ , __LINE__ , __FUNCTION__ , __VA_ARGS__ )
+#endif // ERROR_OUT
+#else // !VERBOSE_MESSAGING
+#ifndef WARN
+#define WARN( ... ) MKExceptions::Warn( __FUNCTION__ , __VA_ARGS__ )
+#endif // WARN
+#ifndef WARN_ONCE
+#define WARN_ONCE( ... ) { static bool firstTime = true ; if( firstTime ) MKExceptions::Warn( __FUNCTION__ , __VA_ARGS__ ) ; firstTime = false; }
+#endif // WARN_ONCE
+#ifndef THROW
+#define THROW( ... ) MKExceptions::Throw( __FUNCTION__ , __VA_ARGS__ )
+#endif // THROW
+#ifndef ERROR_OUT
+#define ERROR_OUT( ... ) MKExceptions::ErrorOut( __FUNCTION__ , __VA_ARGS__ )
+#endif // ERROR_OUT
+#endif // VERBOSE_MESSAGING
+
//////////////////
// Memory Stuff //
//////////////////
@@ -205,7 +390,7 @@ inline void SetPeakMemoryMB( size_t sz )
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 };
jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_JOB_MEMORY;
jeli.JobMemoryLimit = peakMemory;
- if( !SetInformationJobObject( h , JobObjectExtendedLimitInformation , &jeli , sizeof( jeli ) ) ) fprintf( stderr , "Failed to set memory limit\n" );
+ if( !SetInformationJobObject( h , JobObjectExtendedLimitInformation , &jeli , sizeof( jeli ) ) ) WARN( "Failed to set memory limit" );
}
#else // !_WIN32 && !_WIN64
#include
diff --git a/Src/PNG.inl b/Src/PNG.inl
index 6565c10..da5daae 100644
--- a/Src/PNG.inl
+++ b/Src/PNG.inl
@@ -11,16 +11,16 @@ inline PNGReader::PNGReader( const char* fileName , unsigned int& width , unsign
_currentRow = 0;
_png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING , 0 , 0 , 0);
- if( !_png_ptr ) fprintf( stderr , "[ERROR] PNGReader: failed to create png pointer\n" ) , exit( 0 );
+ if( !_png_ptr ) ERROR_OUT( "Failed to create png pointer" );
_info_ptr = png_create_info_struct( _png_ptr );
- if( !_info_ptr ) fprintf( stderr , "[ERROR] PNGReader: failed to create info pointer\n" ) , exit( 0 );
+ if( !_info_ptr ) ERROR_OUT( "Failed to create info pointer" );
_end_info = png_create_info_struct( _png_ptr );
- if( !_end_info ) fprintf( stderr , "[ERROR] PNGReader: failed to create end pointer\n" ) , exit( 0 );
+ if( !_end_info ) ERROR_OUT( "Failed to create end pointer" );
_fp = fopen( fileName , "rb" );
- if( !_fp ) fprintf( stderr , "[ERROR] PNGReader: Failed to open file for reading: %s\n" , fileName ) , exit( 0 );
+ if( !_fp ) ERROR_OUT( "Failed to open file for reading: %s" , fileName );
png_init_io( _png_ptr , _fp );
png_read_info( _png_ptr, _info_ptr );
@@ -32,12 +32,12 @@ inline PNGReader::PNGReader( const char* fileName , unsigned int& width , unsign
int color_type = png_get_color_type( _png_ptr , _info_ptr );
if( bit_depth==16 )
{
- fprintf( stderr , "[WARNING] Converting 16-bit image to 8-bit image\n" );
+ WARN( "Converting 16-bit image to 8-bit image" );
_scratchRow = new unsigned char[ channels*width*2 ];
}
else
{
- if( bit_depth!=8 ) fprintf( stderr , "[ERROR] PNGReader: expected 8 bits per channel\n" ) , exit( 0 );
+ if( bit_depth!=8 ) ERROR_OUT( "Expected 8 bits per channel" );
_scratchRow = NULL;
}
if( color_type==PNG_COLOR_TYPE_PALETTE ) png_set_expand( _png_ptr ) , printf( "Expanding PNG color pallette\n" );
@@ -78,14 +78,14 @@ inline bool PNGReader::GetInfo( const char* fileName , unsigned int& width , uns
FILE* fp;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING , 0 , 0 , 0);
- if( !png_ptr ) fprintf( stderr , "[ERROR] PNGReader: failed to create png pointer\n" ) , exit( 0 );
+ if( !png_ptr ) ERROR_OUT( "Failed to create png pointer" );
info_ptr = png_create_info_struct( png_ptr );
- if( !info_ptr ) fprintf( stderr , "[ERROR] PNGReader: failed to create info pointer\n" ) , exit( 0 );
+ if( !info_ptr ) ERROR_OUT( "Failed to create info pointer" );
end_info = png_create_info_struct( png_ptr );
- if( !end_info ) fprintf( stderr , "[ERROR] PNGReader: failed to create end pointer\n" ) , exit( 0 );
+ if( !end_info ) ERROR_OUT( "Failed to create end pointer" );
fp = fopen( fileName , "rb" );
- if( !fp ) fprintf( stderr , "[ERROR] PNGReader: Failed to open file for reading: %s\n" , fileName ) , exit( 0 );
+ if( !fp ) ERROR_OUT( "Failed to open file for reading: %s" , fileName );
png_init_io( png_ptr , fp );
png_read_info( png_ptr, info_ptr );
@@ -105,12 +105,12 @@ PNGWriter::PNGWriter( const char* fileName , unsigned int width , unsigned int h
_currentRow = 0;
_png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING , 0 , 0 , 0 );
- if( !_png_ptr ) fprintf( stderr , "[ERROR] PNGWriter: Failed to create png write struct\n" ) , exit(0);
+ if( !_png_ptr ) ERROR_OUT( "Failed to create png write struct" );
_info_ptr = png_create_info_struct( _png_ptr );
- if( !_info_ptr ) fprintf( stderr , "[ERROR] PNGWriter: Failed to create png info struct\n") , exit(0);
+ if( !_info_ptr ) ERROR_OUT( "Failed to create png info struct");
_fp = fopen( fileName , "wb" );
- if( !_fp ) fprintf( stderr , "[ERROR] PNGWriter: Failed to open file for writing: %s\n" , fileName ) , exit( 0 );
+ if( !_fp ) ERROR_OUT( "Failed to open file for writing: %s" , fileName );
png_init_io( _png_ptr , _fp );
png_set_compression_level( _png_ptr , Z_BEST_SPEED );
@@ -121,7 +121,7 @@ PNGWriter::PNGWriter( const char* fileName , unsigned int width , unsigned int h
case 1: pngColorType = PNG_COLOR_TYPE_GRAY ; break;
case 3: pngColorType = PNG_COLOR_TYPE_RGB ; break;
case 4: pngColorType = PNG_COLOR_TYPE_RGBA ; break;
- default: fprintf( stderr , "[ERROR] PNGWriter: Only 1, 3, or 4 channel PNGs are supported\n" ) , exit( 0 );
+ default: ERROR_OUT( "Only 1, 3, or 4 channel PNGs are supported" );
};
png_set_IHDR( _png_ptr , _info_ptr, width , height, 8 , pngColorType , PNG_INTERLACE_NONE , PNG_COMPRESSION_TYPE_DEFAULT , PNG_FILTER_TYPE_DEFAULT );
png_write_info( _png_ptr , _info_ptr );
@@ -153,7 +153,7 @@ unsigned int PNGWriter::nextRows( const unsigned char* rows , unsigned int rowNu
void PNGWriteColor( const char* fileName , const unsigned char* pixels , int width , int height )
{
FILE* fp = fopen( fileName , "wb" );
- if( !fp ) fprintf( stderr , "[ERROR] Failed to open file for writing: %s\n" , fileName ) , exit( 0 );
+ if( !fp ) ERROR_OUT( "Failed to open file for writing: %s" , fileName );
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0);
if(!png_ptr) return;
png_infop info_ptr = png_create_info_struct(png_ptr);
diff --git a/Src/Ply.h b/Src/Ply.h
index 575d1c1..1c99add 100644
--- a/Src/Ply.h
+++ b/Src/Ply.h
@@ -44,7 +44,7 @@ template<> inline int PLYType< char >( void ){ return PLY_CHAR ; }
template<> inline int PLYType< unsigned char >( void ){ return PLY_UCHAR ; }
template<> inline int PLYType< float >( void ){ return PLY_FLOAT ; }
template<> inline int PLYType< double >( void ){ return PLY_DOUBLE; }
-template< class Real > inline int PLYType( void ){ fprintf( stderr , "[ERROR] Unrecognized type\n" ) , exit( 0 ); }
+template< class Real > inline int PLYType( void ){ ERROR_OUT( "Unrecognized type" ); }
typedef struct PlyFace
{
diff --git a/Src/PlyFile.cpp b/Src/PlyFile.cpp
index 5dfc116..2af0aa1 100644
--- a/Src/PlyFile.cpp
+++ b/Src/PlyFile.cpp
@@ -36,6 +36,7 @@ WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
#include
#include
#include "PlyFile.h"
+#include "MyMiscellany.h"
const char *type_names[] =
{
@@ -226,7 +227,7 @@ void PlyFile::describe_element( const std::string &elem_name , int nelems , int
{
/* look for appropriate element */
PlyElement *elem = find_element( elem_name );
- if( elem==NULL ) fprintf( stderr , "[ERROR] PlyFile::describe_element: can't find element '%s'\n" , elem_name.c_str() ) , exit(-1);
+ if( elem==NULL ) ERROR_OUT( "Can't find element '%s'" , elem_name.c_str() );
elem->num = nelems;
@@ -250,7 +251,7 @@ void PlyFile::describe_property( const std::string &elem_name , const PlyPropert
PlyElement *elem = find_element( elem_name );
if( elem == NULL )
{
- fprintf( stderr , "[WARNING] PlyFile::describe_property: can't find element '%s'\n" , elem_name.c_str() );
+ WARN( "Can't find element '%s'" , elem_name.c_str() );
return;
}
@@ -269,7 +270,7 @@ void PlyFile::describe_other_properties( const PlyOtherProp &other , int offset
PlyElement *elem = find_element( other.name );
if( elem==NULL )
{
- fprintf( stderr , "[WARNING] PlyFile::describe_other_properties: can't find element '%s'\n" , other.name.c_str() );
+ WARN( "Can't find element '%s'" , other.name.c_str() );
return;
}
@@ -293,7 +294,7 @@ void PlyFile::element_count( const std::string &elem_name , int nelems )
{
/* look for appropriate element */
PlyElement *elem = find_element( elem_name );
- if( elem==NULL ) fprintf( stderr , "[ERROR] PlyFile::element_count: can't find element '%s'\n" , elem_name.c_str() ) , exit(-1);
+ if( elem==NULL ) ERROR_OUT( "Can't find element '%s'" , elem_name.c_str() );
elem->num = nelems;
}
@@ -312,7 +313,7 @@ void PlyFile::header_complete( void )
case PLY_ASCII: fprintf( fp , "format ascii 1.0\n" ) ; break;
case PLY_BINARY_BE: fprintf( fp , "format binary_big_endian 1.0\n" ) ; break;
case PLY_BINARY_LE: fprintf( fp , "format binary_little_endian 1.0\n" ) ; break;
- default: fprintf( stderr , "[ERROR] PlyFile::header_complete: bad file type = %d\n" , file_type ) , exit(-1);
+ default: ERROR_OUT( "Bad file type = %d" , file_type );
}
/* write out the comments */
@@ -360,7 +361,7 @@ elem_name - name of element we're talking about
void PlyFile::put_element_setup( const std::string &elem_name )
{
PlyElement *elem = find_element( elem_name );
- if( elem==NULL ) fprintf( stderr , "[ERROR] PlyFile::put_element_setup: can't find element '%s'\n" , elem_name.c_str() ) , exit(-1);
+ if( elem==NULL ) ERROR_OUT( "Can't find element '%s'" , elem_name.c_str() );
which_elem = elem;
}
@@ -641,7 +642,7 @@ void PlyFile::get_element_setup( const std::string &elem_name , int nprops , Ply
PlyProperty *prop = elem->find_property( prop_list[i].name , index );
if( prop==NULL )
{
- fprintf( stderr , "Warning: Can't find property '%s' in element '%s'\n" , prop_list[i].name.c_str() , elem_name.c_str() );
+ WARN( "Can't find property '%s' in element '%s'" , prop_list[i].name.c_str() , elem_name.c_str() );
continue;
}
@@ -808,7 +809,7 @@ bool PlyFile::set_other_properties( const std::string &elem_name , int offset ,
PlyElement *elem = find_element( elem_name );
if( elem==NULL )
{
- fprintf( stderr , "[WARNING] PlyFile::get_other_properties: Can't find element '%s'\n" , elem_name.c_str() );
+ WARN( "Can't find element '%s'" , elem_name.c_str() );
return false;
}
@@ -854,7 +855,7 @@ PlyOtherElems *PlyFile::get_other_element( std::string &elem_name , int elem_cou
{
/* look for appropriate element */
PlyElement *elem = find_element( elem_name );
- if( elem==NULL ) fprintf( stderr, "[ERROR] PlyFile::get_other_element: can't find element '%s'\n" , elem_name.c_str() ) , exit(-1);
+ if( elem==NULL ) ERROR_OUT( "Can't find element '%s'" , elem_name.c_str() ) , exit(-1);
if( other_elems==NULL ) other_elems = new PlyOtherElems();
other_elems->other_list.resize( other_elems->other_list.size()+1 );
@@ -1029,7 +1030,7 @@ void PlyFile::_ascii_get_element( void *elem_ptr )
/* read in the element */
words = get_words( fp , &orig_line );
- if( !words.size() ) fprintf( stderr , "[ERROR] PlyFile::get_element: unexpected end of file\n" ) , exit(-1);
+ if( !words.size() ) ERROR_OUT( "Unexpected end of file" );
which_word = 0;
@@ -1206,7 +1207,7 @@ code - code for type
void write_scalar_type( FILE *fp , int code )
{
/* make sure this is a valid code */
- if( code<=PLY_START_TYPE || code>=PLY_END_TYPE ) fprintf ( stderr , "[ERROR] write_scalar_type: bad data code = %d\n" , code ) , exit(-1);
+ if( code<=PLY_START_TYPE || code>=PLY_END_TYPE ) ERROR_OUT( "Bad data code = %d" , code );
/* write the code to a file */
fprintf( fp , "%s" , type_names[code] );
@@ -1250,7 +1251,7 @@ void get_native_binary_type()
test.int_value = 1;
if ( test.byte_values[0]==1 ) native_binary_type = PLY_BINARY_LE;
else if( test.byte_values[sizeof(int)-1] == 1) native_binary_type = PLY_BINARY_BE;
- else fprintf(stderr, "[ERROR] get_native_binary_type: couldn't determine machine endianness" ), exit(1);
+ else ERROR_OUT( "Couldn't determine machine endianness" );
}
/******************************************************************************
@@ -1269,10 +1270,7 @@ void check_types()
(ply_type_size[PLY_UINT] != sizeof(unsigned int)) ||
(ply_type_size[PLY_FLOAT] != sizeof(float)) ||
(ply_type_size[PLY_DOUBLE] != sizeof(double)))
- {
- fprintf( stderr, "[ERROR] check_types: type sizes do not match built-in types\n" );
- exit(1);
- }
+ ERROR_OUT( "Type sizes do not match built-in types" );
types_checked = 1;
}
@@ -1393,8 +1391,9 @@ double get_item_value( const void *item , int type )
case PLY_FLOAT_32: return (double)*(const float *)item;
case PLY_DOUBLE:
case PLY_FLOAT_64: return (double)*(const double *)item;
- default: fprintf( stderr , "[ERROR] get_item_value: bad type = %d\n" , type ) , exit(-1);
+ default: ERROR_OUT( "Bad type = %d" , type );
}
+ return 0;
}
@@ -1456,12 +1455,12 @@ void write_binary_item( FILE *fp , int file_type , int int_val , unsigned int ui
case PLY_FLOAT_64:
value = &double_val;
break;
- default: fprintf( stderr , "[ERROR] write_binary_item: bad type = %d\n" , type ) ; exit(-1);
+ default: ERROR_OUT( "Bad type = %d" , type );
}
if( (file_type!=native_binary_type) && (ply_type_size[type]>1) ) swap_bytes( (char *)value , ply_type_size[type] );
- if( fwrite( value , ply_type_size[type] , 1 , fp )!=1 ) fprintf( stderr , "[ERROR] write_binary_item failed\n" ) , exit(1);
+ if( fwrite( value , ply_type_size[type] , 1 , fp )!=1 ) ERROR_OUT( "Failed to write binary item" );
}
@@ -1486,11 +1485,7 @@ void write_ascii_item( FILE *fp , int int_val , unsigned int uint_val , double d
case PLY_INT_16:
case PLY_INT:
case PLY_INT_32:
- if (fprintf (fp, "%d ", int_val) <= 0)
- {
- fprintf(stderr, "PLY ERROR: fprintf() failed -- aborting.\n");
- exit(1);
- }
+ if( fprintf( fp , "%d " , int_val )<=0 ) ERROR_OUT( "fprintf() failed -- aborting" );
break;
case PLY_UCHAR:
case PLY_UINT_8:
@@ -1498,23 +1493,15 @@ void write_ascii_item( FILE *fp , int int_val , unsigned int uint_val , double d
case PLY_UINT_16:
case PLY_UINT:
case PLY_UINT_32:
- if (fprintf (fp, "%u ", uint_val) <= 0)
- {
- fprintf(stderr, "PLY ERROR: fprintf() failed -- aborting.\n");
- exit(1);
- }
+ if( fprintf( fp , "%u " , uint_val )<=0 ) ERROR_OUT( "fprintf() failed -- aborting" );
break;
case PLY_FLOAT:
case PLY_FLOAT_32:
case PLY_DOUBLE:
case PLY_FLOAT_64:
- if (fprintf (fp, "%g ", double_val) <= 0)
- {
- fprintf(stderr, "PLY ERROR: fprintf() failed -- aborting.\n");
- exit(1);
- }
+ if( fprintf( fp , "%g " , double_val )<=0 ) ERROR_OUT( "fprintf() failed -- aborting" );
break;
- default: fprintf (stderr, "[ERROR] write_ascii_item: bad type = %d\n" , type ) ; exit(-1);
+ default: ERROR_OUT( "Bad type = %d" , type );
}
}
@@ -1584,7 +1571,7 @@ void get_stored_item( void *ptr , int type , int &int_val , unsigned int &uint_v
int_val = (int)double_val;
uint_val = (unsigned int)double_val;
break;
- default: fprintf( stderr , "[ERROR] get_stored_item: bad type = %d\n" , type ) ; exit(-1);
+ default: ERROR_OUT( "Bad type = %d" , type );
}
}
@@ -1609,7 +1596,7 @@ void get_binary_item( FILE *fp , int file_type , int type , int &int_val , unsig
ptr = ( void * )c;
- if( fread( ptr , ply_type_size[type] , 1 , fp )!=1 ) fprintf( stderr, "[ERROR] get_binary_item: fread() failed -- aborting.\n" ) , exit(1);
+ if( fread( ptr , ply_type_size[type] , 1 , fp )!=1 ) ERROR_OUT( "fread() failed -- aborting." );
if( ( file_type!=native_binary_type ) && ( ply_type_size[type]>1 ) ) swap_bytes( (char *)ptr , ply_type_size[type] );
switch( type )
@@ -1662,8 +1649,7 @@ void get_binary_item( FILE *fp , int file_type , int type , int &int_val , unsig
int_val = (int)double_val;
uint_val = (unsigned int)double_val;
break;
- default:
- fprintf( stderr , "[ERROR] get_binary_item: bad type = %d\n" , type ) , exit(-1);
+ default: ERROR_OUT( "Bad type = %d" , type );
}
}
@@ -1714,7 +1700,7 @@ void get_ascii_item( const std::string &word , int type , int &int_val , unsigne
int_val = (int)double_val;
uint_val = (unsigned int)double_val;
break;
- default: fprintf( stderr, "[ERROR] get_ascii_item: bad type = %d\n" , type ) , exit(-1);
+ default: ERROR_OUT( "Bad type = %d" , type );
}
}
@@ -1752,7 +1738,7 @@ void store_item( void *item , int type , int int_val , unsigned int uint_val , d
case PLY_FLOAT_32: *( float *)item = ( float)double_val ; break;
case PLY_DOUBLE:
case PLY_FLOAT_64: *( double *)item = ( double)double_val ; break;
- default: fprintf( stderr , "[ERROR] store_item: bad type = %d\n" , type ) , exit(-1);
+ default: ERROR_OUT( "Bad type = %d" , type );
}
}
diff --git a/Src/PointStream.inl b/Src/PointStream.inl
index 6fbf118..139672f 100644
--- a/Src/PointStream.inl
+++ b/Src/PointStream.inl
@@ -51,7 +51,7 @@ template< class Real , int Dim >
ASCIIInputPointStream< Real , Dim >::ASCIIInputPointStream( const char* fileName )
{
_fp = fopen( fileName , "r" );
- if( !_fp ) fprintf( stderr , "Failed to open file for reading: %s\n" , fileName ) , exit( 0 );
+ if( !_fp ) ERROR_OUT( "Failed to open file for reading: %s" , fileName );
}
template< class Real , int Dim >
ASCIIInputPointStream< Real , Dim >::~ASCIIInputPointStream( void )
@@ -78,7 +78,7 @@ template< class Real , int Dim >
ASCIIOutputPointStream< Real , Dim >::ASCIIOutputPointStream( const char* fileName )
{
_fp = fopen( fileName , "w" );
- if( !_fp ) fprintf( stderr , "Failed to open file for writing: %s\n" , fileName ) , exit( 0 );
+ if( !_fp ) ERROR_OUT( "Failed to open file for writing: %s" , fileName );
}
template< class Real , int Dim >
ASCIIOutputPointStream< Real , Dim >::~ASCIIOutputPointStream( void )
@@ -100,7 +100,7 @@ template< class Real , int Dim >
BinaryInputPointStream< Real , Dim >::BinaryInputPointStream( const char* fileName )
{
_fp = fopen( fileName , "rb" );
- if( !_fp ) fprintf( stderr , "Failed to open file for reading: %s\n" , fileName ) , exit( 0 );
+ if( !_fp ) ERROR_OUT( "Failed to open file for reading: %s" , fileName );
}
template< class Real , int Dim >
bool BinaryInputPointStream< Real , Dim >::nextPoint( Point< Real , Dim >& p ){ return fread( &p , sizeof(Point< Real , Dim >) , 1 , _fp )==1; }
@@ -112,7 +112,7 @@ template< class Real , int Dim >
BinaryOutputPointStream< Real , Dim >::BinaryOutputPointStream( const char* fileName )
{
_fp = fopen( fileName , "wb" );
- if( !_fp ) fprintf( stderr , "Failed to open file for writing: %s\n" , fileName ) , exit( 0 );
+ if( !_fp ) ERROR_OUT( "Failed to open file for writing: %s" , fileName );
}
template< class Real , int Dim >
void BinaryOutputPointStream< Real , Dim >::nextPoint( const Point< Real , Dim >& p ){ fwrite( &p , sizeof(Point< Real , Dim >) , 1 , _fp )==1; }
@@ -136,42 +136,27 @@ void PLYInputPointStream< Real , Dim >::reset( void )
std::vector< PlyProperty * > plist;
if( _ply ) _free();
_ply = PlyFile::Read( _fileName, _elist, fileType, version );
- if( !_ply )
- {
- fprintf( stderr, "[ERROR] Failed to open ply file for reading: %s\n" , _fileName );
- exit( 0 );
- }
+ if( !_ply ) ERROR_OUT( "Failed to open ply file for reading: %s" , _fileName );
+
bool foundVertices = false;
for( int i=0 ; i<_elist.size() ; i++ )
{
int num_elems;
std::string &elem_name = _elist[i];
plist = _ply->get_element_description( elem_name , num_elems );
- if( !plist.size() )
- {
- fprintf( stderr , "[ERROR] Failed to get element description: %s\n" , elem_name );
- exit( 0 );
- }
+ if( !plist.size() ) ERROR_OUT( "Failed to get element description: %s" , elem_name );
- if( elem_name=="vertex" , elem_name )
+ if( elem_name=="vertex" )
{
foundVertices = true;
_pCount = num_elems , _pIdx = 0;
for( int i=0 ; i::ReadComponents ; i++ )
- if( !_ply->get_property( elem_name , &(PlyVertex< Real , Dim >::Properties()[i]) ) )
- {
- fprintf( stderr , "[ERROR] Failed to find property in ply file: %s\n" , PlyVertex< Real , Dim >::Properties()[i].name );
- exit( 0 );
- }
+ if( !_ply->get_property( elem_name , &(PlyVertex< Real , Dim >::Properties()[i]) ) ) ERROR_OUT( "Failed to find property in ply file: %s" , PlyVertex< Real , Dim >::Properties()[i].name );
}
for( int j=0 ; j
void PLYInputPointStream< Real , Dim >::_free( void ){ delete _ply; }
@@ -222,7 +207,7 @@ template< class Real , int Dim , class Data >
ASCIIInputPointStreamWithData< Real , Dim , Data >::ASCIIInputPointStreamWithData( const char* fileName , void (*ReadData)( FILE* , Data& ) ) : _ReadData( ReadData )
{
_fp = fopen( fileName , "r" );
- if( !_fp ) fprintf( stderr , "Failed to open file for reading: %s\n" , fileName ) , exit( 0 );
+ if( !_fp ) ERROR_OUT( "Failed to open file for reading: %s" , fileName );
}
template< class Real , int Dim , class Data >
ASCIIInputPointStreamWithData< Real , Dim , Data >::~ASCIIInputPointStreamWithData( void )
@@ -250,7 +235,7 @@ template< class Real , int Dim , class Data >
ASCIIOutputPointStreamWithData< Real , Dim , Data >::ASCIIOutputPointStreamWithData( const char* fileName , void (*WriteData)( FILE* , const Data& ) ) : _WriteData( WriteData )
{
_fp = fopen( fileName , "w" );
- if( !_fp ) fprintf( stderr , "Failed to open file for writing: %s\n" , fileName ) , exit( 0 );
+ if( !_fp ) ERROR_OUT( "Failed to open file for writing: %s" , fileName );
}
template< class Real , int Dim , class Data >
ASCIIOutputPointStreamWithData< Real , Dim , Data >::~ASCIIOutputPointStreamWithData( void )
@@ -274,7 +259,7 @@ template< class Real , int Dim , class Data >
BinaryInputPointStreamWithData< Real , Dim , Data >::BinaryInputPointStreamWithData( const char* fileName , void (*ReadData)( FILE* , Data& ) ) : _ReadData(ReadData)
{
_fp = fopen( fileName , "rb" );
- if( !_fp ) fprintf( stderr , "Failed to open file for reading: %s\n" , fileName ) , exit( 0 );
+ if( !_fp ) ERROR_OUT( "Failed to open file for reading: %s" , fileName );
}
template< class Real , int Dim , class Data >
bool BinaryInputPointStreamWithData< Real , Dim , Data >::nextPoint( Point< Real , Dim >& p , Data& d )
@@ -294,7 +279,7 @@ template< class Real , int Dim , class Data >
BinaryOutputPointStreamWithData< Real , Dim , Data >::BinaryOutputPointStreamWithData( const char* fileName , void (*WriteData)( FILE* , const Data& ) ) : _WriteData(WriteData)
{
_fp = fopen( fileName , "wb" );
- if( !_fp ) fprintf( stderr , "Failed to open file for writing: %s\n" , fileName ) , exit( 0 );
+ if( !_fp ) ERROR_OUT( "Failed to open file for writing: %s" , fileName );
}
template< class Real , int Dim , class Data >
void BinaryOutputPointStreamWithData< Real , Dim , Data >::nextPoint( const Point< Real , Dim >& p , const Data& d )
@@ -325,7 +310,7 @@ void PLYInputPointStreamWithData< Real , Dim , Data >::reset( void )
std::vector< PlyProperty * > plist;
if( _ply ) _free();
_ply = PlyFile::Read( _fileName , _elist , fileType , version );
- if( !_ply ) fprintf( stderr, "[ERROR] Failed to open ply file for reading: %s\n" , _fileName ) , exit( 0 );
+ if( !_ply ) ERROR_OUT( "Failed to open ply file for reading: %s" , _fileName );
bool foundVertices = false;
for( int i=0 ; i<_elist.size() ; i++ )
@@ -333,7 +318,7 @@ void PLYInputPointStreamWithData< Real , Dim , Data >::reset( void )
int num_elems;
std::string &elem_name = _elist[i];
plist = _ply->get_element_description( elem_name , num_elems );
- if( !plist.size() ) fprintf( stderr , "[ERROR] Failed to get element description: %s\n" , elem_name.c_str() ) , exit( 0 );
+ if( !plist.size() ) ERROR_OUT( "Failed to get element description: %s" , elem_name.c_str() );
if( elem_name=="vertex" )
{
@@ -341,8 +326,7 @@ void PLYInputPointStreamWithData< Real , Dim , Data >::reset( void )
_pCount = num_elems , _pIdx = 0;
const PlyProperty* PlyReadProperties = PlyVertex< Real , Dim >::PlyReadProperties();
for( int i=0 ; i::PlyReadNum ; i++ )
- if( !_ply->get_property( elem_name , &(PlyReadProperties[i]) ) )
- fprintf( stderr , "[ERROR] Failed to find property in ply file: %s\n" , PlyReadProperties[i].name.c_str() ) , exit( 0 );
+ if( !_ply->get_property( elem_name , &(PlyReadProperties[i]) ) ) ERROR_OUT( "Failed to find property in ply file: %s" , PlyReadProperties[i].name.c_str() );
if( _validationFunction )
{
@@ -352,23 +336,18 @@ void PLYInputPointStreamWithData< Real , Dim , Data >::reset( void )
else properties[i] = true;
bool valid = _validationFunction( properties );
delete[] properties;
- if( !valid ) fprintf( stderr , "[ERROR] Failed to validate properties in file\n" ) , exit( 0 );
+ if( !valid ) ERROR_OUT( "Failed to validate properties in file" );
}
else
{
for( int i=0 ; i<_dataPropertiesCount ; i++ )
- if( !_ply->get_property( elem_name , &(_dataProperties[i]) ) )
- fprintf( stderr , "[WARNING] Failed to find property in ply file: %s\n" , _dataProperties[i].name.c_str() );
+ if( !_ply->get_property( elem_name , &(_dataProperties[i]) ) ) WARN( "Failed to find property in ply file: %s" , _dataProperties[i].name.c_str() );
}
}
for( int j=0 ; j
void PLYInputPointStreamWithData< Real , Dim , Data >::_free( void ){ delete _ply; }
@@ -404,11 +383,7 @@ PLYOutputPointStream< Real , Dim >::PLYOutputPointStream( const char* fileName ,
float version;
std::vector< std::string > elem_names = { std::string( "vertex" ) };
_ply = PlyFile::Write( fileName , elem_names , fileType , version );
- if( !_ply )
- {
- fprintf( stderr, "[ERROR] Failed to open ply file for writing: %s\n" , fileName );
- exit( 0 );
- }
+ if( !_ply ) ERROR_OUT( "Failed to open ply file for writing: %s" , fileName );
_pIdx = 0;
_pCount = count;
@@ -420,21 +395,13 @@ PLYOutputPointStream< Real , Dim >::PLYOutputPointStream( const char* fileName ,
template< class Real , int Dim >
PLYOutputPointStream< Real , Dim >::~PLYOutputPointStream( void )
{
- if( _pIdx!=_pCount )
- {
- fprintf( stderr , "[ERROR] Streamed points not equal to total count: %d!=%d\n" , _pIdx , _pCount );
- exit( 0 );
- }
+ if( _pIdx!=_pCount ) ERROR_OUT( "Streamed points not equal to total count: %d!=%d" , _pIdx , _pCount );
delete _ply;
}
template< class Real , int Dim >
void PLYOutputPointStream< Real , Dim >::nextPoint( const Point< Real , Dim >& p )
{
- if( _pIdx==_pCount )
- {
- fprintf( stderr , "[ERROR] Trying to add more points than total: %d<%d\n" , _pIdx , _pCount );
- exit( 0 );
- }
+ if( _pIdx==_pCount ) ERROR_OUT( "Trying to add more points than total: %d<%d" , _pIdx , _pCount );
PlyVertex< Real , Dim > op;
op.point = p;
_ply->put_element( (void *)&op );
@@ -450,11 +417,7 @@ PLYOutputPointStreamWithData< Real , Dim , Data >::PLYOutputPointStreamWithData(
float version;
std::vector< std::string > elem_names = { std::string( "vertex" ) };
_ply = PlyFile::Write( fileName , elem_names , fileType , version );
- if( !_ply )
- {
- fprintf( stderr, "[ERROR] Failed to open ply file for writing: %s\n" , fileName );
- exit( 0 );
- }
+ if( !_ply ) ERROR_OUT( "Failed to open ply file for writing: %s" , fileName );
_pIdx = 0;
_pCount = (int)count;
@@ -473,21 +436,13 @@ PLYOutputPointStreamWithData< Real , Dim , Data >::PLYOutputPointStreamWithData(
template< class Real , int Dim , class Data >
PLYOutputPointStreamWithData< Real , Dim , Data >::~PLYOutputPointStreamWithData( void )
{
- if( _pIdx!=_pCount )
- {
- fprintf( stderr , "[ERROR] Streamed points not equal to total count: %d!=%d\n" , _pIdx , _pCount );
- exit( 0 );
- }
+ if( _pIdx!=_pCount ) ERROR_OUT( "Streamed points not equal to total count: %d!=%d" , _pIdx , _pCount );
delete _ply;
}
template< class Real , int Dim , class Data >
void PLYOutputPointStreamWithData< Real , Dim , Data >::nextPoint( const Point< Real , Dim >& p , const Data& d )
{
- if( _pIdx==_pCount )
- {
- fprintf( stderr , "[ERROR] Trying to add more points than total: %d<%d\n" , _pIdx , _pCount );
- exit( 0 );
- }
+ if( _pIdx==_pCount ) ERROR_OUT( "Trying to add more points than total: %d<%d" , _pIdx , _pCount );
_PlyVertexWithData op;
op.point = p;
op.data = d;
diff --git a/Src/PointStreamData.h b/Src/PointStreamData.h
index 1c4ef45..d215417 100644
--- a/Src/PointStreamData.h
+++ b/Src/PointStreamData.h
@@ -88,14 +88,14 @@ struct PointStreamPosition : public PointStreamData< Real , Point< Real , Dim >
{
float f;
for( int i=0 ; i >
{
float f;
for( int i=0 ; i >
static void ReadASCII( FILE* fp , PointStreamColor& p )
{
unsigned char c[3];
- if( fscanf( fp , " %c %c %c " , &c[0] , &c[1] , &c[2] )!=3 ) fprintf( stderr , "[ERROR] PointStreamColor::readASCII: Failed to read color\n" ) , exit( 0 );
+ if( fscanf( fp , " %c %c %c " , &c[0] , &c[1] , &c[2] )!=3 ) ERROR_OUT( "Failed to read color" );
p.data[0] = (Real)c[0] , p.data[1] = (Real)c[1] , p.data[2] = (Real)c[2];
};
static void ReadBinary( FILE* fp , PointStreamColor& p )
{
unsigned char c[3];
- if( fread( c , sizeof(unsigned char) , 3 , fp )!=3 ) fprintf( stderr , "[ERROR] PointStreamColor::readBinary: Failed to read color\n" ) , exit( 0 );
+ if( fread( c , sizeof(unsigned char) , 3 , fp )!=3 ) ERROR_OUT( "Failed to read color" );
p.data[0] = (Real)c[0] , p.data[1] = (Real)c[1] , p.data[2] = (Real)c[2];
}
static void WriteASCII( FILE* fp , const PointStreamColor& p )
@@ -325,8 +325,8 @@ struct PointStreamValue : public PointStreamData< Real , Real >
template< typename X > Transform( const X& ){}
PointStreamValue operator() ( const PointStreamValue& r ) const { return r; }
};
- static void ReadASCII ( FILE* fp , PointStreamValue& p ){ float f ; if( fscanf( fp , " %f " , &f )!=1 ) fprintf( stderr , "[ERROR] PointStreamValue::readASCII: Failed to read color\n" ) , exit( 0 ) ; p.data = (Real)f; }
- static void ReadBinary( FILE* fp , PointStreamValue& p ){ float f ; if( fread( &f , sizeof(float) , 1 , fp )!=1 ) fprintf( stderr , "[ERROR] PointStreamValue::readBinary: Failed to read color\n" ) , exit( 0 ) ; p.data = (Real)f; }
+ static void ReadASCII ( FILE* fp , PointStreamValue& p ){ float f ; if( fscanf( fp , " %f " , &f )!=1 ) ERROR_OUT( "Failed to read color" ) ; p.data = (Real)f; }
+ static void ReadBinary( FILE* fp , PointStreamValue& p ){ float f ; if( fread( &f , sizeof(float) , 1 , fp )!=1 ) ERROR_OUT( "Failed to read color" ) ; p.data = (Real)f; }
static void WriteASCII ( FILE* fp , const PointStreamValue& p ){ float f = (float)p.data ; fprintf( fp , " %f " , f ); }
static void WriteBinary( FILE* fp , const PointStreamValue& p ){ float f = (float)p.data ; fwrite( &f , sizeof(Real) , 1 , fp ); }
static const int PlyReadNum = 1;
@@ -357,8 +357,8 @@ struct PointStreamRoughness : public PointStreamData< Real , Real >
template< typename X > Transform( const X& ){}
PointStreamRoughness operator() ( const PointStreamRoughness& r ) const { return r; }
};
- static void ReadASCII ( FILE* fp , PointStreamRoughness& p ){ float f ; if( fscanf( fp , " %f " , &f )!=1 ) fprintf( stderr , "[ERROR] PointStreamRoughness::readASCII: Failed to read color\n" ) , exit( 0 ) ; p.data = (Real)f; }
- static void ReadBinary( FILE* fp , PointStreamRoughness& p ){ float f ; if( fread( &f , sizeof(float) , 1 , fp )!=1 ) fprintf( stderr , "[ERROR] PointStreamRoughness::readBinary: Failed to read color\n" ) , exit( 0 ) ; p.data = (Real)f; }
+ static void ReadASCII ( FILE* fp , PointStreamRoughness& p ){ float f ; if( fscanf( fp , " %f " , &f )!=1 ) ERROR_OUT( "Failed to read color" ) ; p.data = (Real)f; }
+ static void ReadBinary( FILE* fp , PointStreamRoughness& p ){ float f ; if( fread( &f , sizeof(float) , 1 , fp )!=1 ) ERROR_OUT( "Failed to read color" ) ; p.data = (Real)f; }
static void WriteASCII ( FILE* fp , const PointStreamRoughness& p ){ float f = (float)p.data ; fprintf( fp , " %f " , f ); }
static void WriteBinary( FILE* fp , const PointStreamRoughness& p ){ float f = (float)p.data ; fwrite( &f , sizeof(Real) , 1 , fp ); }
static const int PlyReadNum = 1;
diff --git a/Src/PoissonRecon.cpp b/Src/PoissonRecon.cpp
index f742f90..c9c1680 100644
--- a/Src/PoissonRecon.cpp
+++ b/Src/PoissonRecon.cpp
@@ -340,11 +340,11 @@ void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTr
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 ) )
- fprintf( stderr , "[ERROR] Could not write mesh to: %s\n" , Out.value ) , exit( 0 );
+ ERROR_OUT( "Could not write mesh to: %s" , Out.value );
}
template< class Real , typename ... SampleData , unsigned int ... FEMSigs >
-int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
+void Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
{
static const int Dim = sizeof ... ( FEMSigs );
typedef UIntPack< FEMSigs ... > Sigs;
@@ -371,7 +371,7 @@ int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
FILE* fp = fopen( Transform.value , "r" );
if( !fp )
{
- fprintf( stderr , "[WARNING] Could not read x-form from: %s\n" , Transform.value );
+ WARN( "Could not read x-form from: %s" , Transform.value );
xForm = XForm< Real , Dim+1 >::Identity();
}
else
@@ -379,7 +379,7 @@ int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
for( int i=0 ; i )
if( Depth.set && Width.value>0 )
{
- fprintf( stderr , "[WARNING] Both --%s and --%s set, ignoring --%s\n" , Depth.name , Width.name , Width.name );
+ WARN( "Both --%s and --%s set, ignoring --%s" , Depth.name , Width.name , Width.name );
Width.value = 0;
}
@@ -459,7 +459,7 @@ int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
int kernelDepth = KernelDepth.set ? KernelDepth.value : Depth.value-2;
if( kernelDepth>Depth.value )
{
- fprintf( stderr,"[WARNING] %s can't be greater than %s: %d <= %d\n" , KernelDepth.name , Depth.name , KernelDepth.value , Depth.value );
+ WARN( "%s can't be greater than %s: %d <= %d" , KernelDepth.name , Depth.name , KernelDepth.value , Depth.value );
kernelDepth = Depth.value;
}
@@ -567,7 +567,7 @@ int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
if( Tree.set )
{
FILE* fp = fopen( Tree.value , "wb" );
- if( !fp ) fprintf( stderr , "[ERROR] Failed to open file for writing: %s\n" , Tree.value ) , exit( 0 );
+ if( !fp ) ERROR_OUT( "Failed to open file for writing: %s" , Tree.value );
FEMTree< Dim , Real >::WriteParameter( fp );
DenseNodeData< Real , Sigs >::WriteSignatures( fp );
tree.write( fp );
@@ -578,7 +578,7 @@ int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
if( VoxelGrid.set )
{
FILE* fp = fopen( VoxelGrid.value , "wb" );
- if( !fp ) fprintf( stderr , "Failed to open voxel file for writing: %s\n" , VoxelGrid.value );
+ if( !fp ) WARN( "Failed to open voxel file for writing: %s" , VoxelGrid.value );
else
{
int res = 0;
@@ -637,13 +637,11 @@ 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() );
-
- return 1;
}
#ifndef FAST_COMPILE
template< unsigned int Dim , class Real , typename ... SampleData >
-int Execute( int argc , char* argv[] )
+void Execute( int argc , char* argv[] )
{
switch( BType.value )
{
@@ -655,7 +653,7 @@ int Execute( int argc , char* argv[] )
case 2: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 2 , BOUNDARY_FREE >::Signature >() );
// case 3: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 3 , BOUNDARY_FREE >::Signature >() );
// case 4: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 4 , BOUNDARY_FREE >::Signature >() );
- default: fprintf( stderr , "[ERROR] Only B-Splines of degree 1 - 2 are supported" ) ; return EXIT_FAILURE;
+ default: ERROR_OUT( "Only B-Splines of degree 1 - 2 are supported" );
}
}
case BOUNDARY_NEUMANN+1:
@@ -666,7 +664,7 @@ int Execute( int argc , char* argv[] )
case 2: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 2 , BOUNDARY_NEUMANN >::Signature >() );
// case 3: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 3 , BOUNDARY_NEUMANN >::Signature >() );
// case 4: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 4 , BOUNDARY_NEUMANN >::Signature >() );
- default: fprintf( stderr , "[ERROR] Only B-Splines of degree 1 - 2 are supported" ) ; return EXIT_FAILURE;
+ default: ERROR_OUT( "Only B-Splines of degree 1 - 2 are supported" );
}
}
case BOUNDARY_DIRICHLET+1:
@@ -677,10 +675,10 @@ int Execute( int argc , char* argv[] )
case 2: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 2 , BOUNDARY_DIRICHLET >::Signature >() );
// case 3: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 3 , BOUNDARY_DIRICHLET >::Signature >() );
// case 4: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 4 , BOUNDARY_DIRICHLET >::Signature >() );
- default: fprintf( stderr , "[ERROR] Only B-Splines of degree 1 - 2 are supported" ) ; return EXIT_FAILURE;
+ default: ERROR_OUT( "Only B-Splines of degree 1 - 2 are supported" );
}
}
- default: fprintf( stderr , "[ERROR] Not a valid boundary type: %d\n" , BType.value ) ; return EXIT_FAILURE;
+ default: ERROR_OUT( "Not a valid boundary type: %d" , BType.value );
}
}
#endif // !FAST_COMPILE
@@ -689,7 +687,7 @@ int main( int argc , char* argv[] )
{
Timer timer;
#ifdef ARRAY_DEBUG
- fprintf( stderr , "[WARNING] Array debugging enabled\n" );
+ WARN( "Array debugging enabled" );
#endif // ARRAY_DEBUG
cmdLineParse( argc-1 , &argv[1] , params );
@@ -705,7 +703,7 @@ int main( int argc , char* argv[] )
if( DataX.value<=0 ) Normals.set = Colors.set = false;
if( BaseDepth.value>FullDepth.value )
{
- if( BaseDepth.set ) fprintf( stderr , "[WARNING] Base depth must be smaller than full depth: %d <= %d\n" , BaseDepth.value , FullDepth.value );
+ if( BaseDepth.set ) WARN( "Base depth must be smaller than full depth: %d <= %d" , BaseDepth.value , FullDepth.value );
BaseDepth.value = FullDepth.value;
}
@@ -719,7 +717,7 @@ int main( int argc , char* argv[] )
static const int Degree = DEFAULT_FEM_DEGREE;
static const BoundaryType BType = DEFAULT_FEM_BOUNDARY;
typedef IsotropicUIntPack< DIMENSION , FEMDegreeAndBType< Degree , BType >::Signature > FEMSigs;
- fprintf( stderr , "[WARNING] Compiled for degree-%d, boundary-%s, %s-precision _only_\n" , Degree , BoundaryNames[ BType ] , sizeof(Real)==4 ? "single" : "double" );
+ WARN( "Compiled for degree-%d, boundary-%s, %s-precision _only_" , Degree , BoundaryNames[ BType ] , sizeof(DefaultFloatType)==4 ? "single" : "double" );
if( !PointWeight.set ) PointWeight.value = DefaultPointWeightMultiplier*Degree;
if( Colors.set ) Execute< Real , PointStreamColor< DefaultFloatType > >( argc , argv , FEMSigs() );
else Execute< Real >( argc , argv , FEMSigs() );
diff --git a/Src/RegularTree.h b/Src/RegularTree.h
index aa41061..f7c5892 100644
--- a/Src/RegularTree.h
+++ b/Src/RegularTree.h
@@ -214,9 +214,7 @@ public:
ConstNeighborKey( void );
ConstNeighborKey( const ConstNeighborKey& key );
~ConstNeighborKey( void );
-#if 1
ConstNeighborKey& operator = ( const ConstNeighborKey& key );
-#endif
int depth( void ) const { return _depth; }
void set( int depth );
diff --git a/Src/RegularTree.inl b/Src/RegularTree.inl
index e3d69fd..2382344 100644
--- a/Src/RegularTree.inl
+++ b/Src/RegularTree.inl
@@ -134,7 +134,7 @@ int RegularTreeNode< Dim , NodeData , DepthAndOffsetType >::initChildren( Alloca
if( children ) delete[] children;
children = new RegularTreeNode[ 1<::read( const char* f
template< unsigned int Dim , class NodeData , class DepthAndOffsetType >
bool RegularTreeNode< Dim , NodeData , DepthAndOffsetType >::read( FILE* fp , Allocator< RegularTreeNode >* nodeAllocator , std::function< void ( RegularTreeNode& ) > Initializer )
{
- if( fread( this , sizeof( RegularTreeNode< Dim , NodeData , DepthAndOffsetType > ) , 1 , fp )!=1 ) fprintf( stderr , "[ERROR] RegularTreeNode::read: Failed to read node\n" ) , exit( 0 );
+ if( fread( this , sizeof( RegularTreeNode< Dim , NodeData , DepthAndOffsetType > ) , 1 , fp )!=1 ) ERROR_OUT( "Failed to read node" );
parent = NULL;
if( children )
{
@@ -624,15 +624,13 @@ RegularTreeNode< Dim , NodeData , DepthAndOffsetType >::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 )
+typename RegularTreeNode< Dim , NodeData , DepthAndOffsetType >::template 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 f9e760f..f873cec 100644
--- a/Src/SSDRecon.cpp
+++ b/Src/SSDRecon.cpp
@@ -360,11 +360,11 @@ void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTr
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 ) )
- fprintf( stderr , "[ERROR] Could not write mesh to: %s\n" , Out.value ) , exit( 0 );
+ ERROR_OUT( "Could not write mesh to: %s" , Out.value );
}
template< class Real , typename ... SampleData , unsigned int ... FEMSigs >
-int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
+void Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
{
static const int Dim = sizeof ... ( FEMSigs );
typedef UIntPack< FEMSigs ... > Sigs;
@@ -391,7 +391,7 @@ int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
FILE* fp = fopen( Transform.value , "r" );
if( !fp )
{
- fprintf( stderr , "[WARNING] Could not read x-form from: %s\n" , Transform.value );
+ WARN( "Could not read x-form from: %s" , Transform.value );
xForm = XForm< Real , Dim+1 >::Identity();
}
else
@@ -399,7 +399,7 @@ int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
for( int i=0 ; i )
if( Depth.set && Width.value>0 )
{
- fprintf( stderr , "[WARNING] Both --%s and --%s set, ignoring --%s\n" , Depth.name , Width.name , Width.name );
+ WARN( "Both --%s and --%s set, ignoring --%s" , Depth.name , Width.name , Width.name );
Width.value = 0;
}
@@ -479,7 +479,7 @@ int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
int kernelDepth = KernelDepth.set ? KernelDepth.value : Depth.value-2;
if( kernelDepth>Depth.value )
{
- fprintf( stderr,"[WARNING] %s can't be greater than %s: %d <= %d\n" , KernelDepth.name , Depth.name , KernelDepth.value , Depth.value );
+ WARN( "%s can't be greater than %s: %d <= %d" , KernelDepth.name , Depth.name , KernelDepth.value , Depth.value );
kernelDepth = Depth.value;
}
@@ -568,7 +568,7 @@ int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
if( Tree.set )
{
FILE* fp = fopen( Tree.value , "wb" );
- if( !fp ) fprintf( stderr , "[ERROR] Failed to open file for writing: %s\n" , Tree.value ) , exit( 0 );
+ if( !fp ) ERROR_OUT( "Failed to open file for writing: %s" , Tree.value );
FEMTree< Dim , Real >::WriteParameter( fp );
DenseNodeData< Real , Sigs >::WriteSignatures( fp );
tree.write( fp );
@@ -579,7 +579,7 @@ int Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
if( VoxelGrid.set )
{
FILE* fp = fopen( VoxelGrid.value , "wb" );
- if( !fp ) fprintf( stderr , "Failed to open voxel file for writing: %s\n" , VoxelGrid.value );
+ if( !fp ) WARN( "Failed to open voxel file for writing: %s" , VoxelGrid.value );
else
{
int res = 0;
@@ -638,13 +638,11 @@ 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() );
-
- return 1;
}
#ifndef FAST_COMPILE
template< unsigned int Dim , class Real , typename ... SampleData >
-int Execute( int argc , char* argv[] )
+void Execute( int argc , char* argv[] )
{
switch( BType.value )
{
@@ -655,7 +653,7 @@ int Execute( int argc , char* argv[] )
case 2: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 2 , BOUNDARY_FREE >::Signature >() );
case 3: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 3 , BOUNDARY_FREE >::Signature >() );
// case 4: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 4 , BOUNDARY_FREE >::Signature >() );
- default: fprintf( stderr , "[ERROR] Only B-Splines of degree 2 - 3 are supported" ) ; return EXIT_FAILURE;
+ default: ERROR_OUT( "Only B-Splines of degree 2 - 3 are supported" );
}
}
case BOUNDARY_NEUMANN+1:
@@ -665,7 +663,7 @@ int Execute( int argc , char* argv[] )
case 2: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 2 , BOUNDARY_NEUMANN >::Signature >() );
case 3: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 3 , BOUNDARY_NEUMANN >::Signature >() );
// case 4: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 4 , BOUNDARY_NEUMANN >::Signature >() );
- default: fprintf( stderr , "[ERROR] Only B-Splines of degree 2 - 3 are supported" ) ; return EXIT_FAILURE;
+ default: ERROR_OUT( "Only B-Splines of degree 2 - 3 are supported" );
}
}
case BOUNDARY_DIRICHLET+1:
@@ -675,10 +673,10 @@ int Execute( int argc , char* argv[] )
case 2: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 2 , BOUNDARY_DIRICHLET >::Signature >() );
case 3: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 3 , BOUNDARY_DIRICHLET >::Signature >() );
// case 4: return Execute< Real , SampleData ... >( argc , argv , IsotropicUIntPack< Dim , FEMDegreeAndBType< 4 , BOUNDARY_DIRICHLET >::Signature >() );
- default: fprintf( stderr , "[ERROR] Only B-Splines of degree 2- 3 are supported" ) ; return EXIT_FAILURE;
+ default: ERROR_OUT( "Only B-Splines of degree 2 - 3 are supported" );
}
}
- default: fprintf( stderr , "[ERROR] Not a valid boundary type: %d\n" , BType.value ) ; return EXIT_FAILURE;
+ default: ERROR_OUT( "Not a valid boundary type: %d" , BType.value );
}
}
#endif // !FAST_COMPILE
@@ -687,7 +685,7 @@ int main( int argc , char* argv[] )
{
Timer timer;
#ifdef ARRAY_DEBUG
- fprintf( stderr , "[WARNING] Array debugging enabled\n" );
+ WARN( "Array debugging enabled" );
#endif // ARRAY_DEBUG
cmdLineParse( argc-1 , &argv[1] , params );
@@ -700,12 +698,12 @@ int main( int argc , char* argv[] )
ShowUsage( argv[0] );
return 0;
}
- if( GradientWeight.value<=0 ) fprintf( stderr , "[ERROR] Gradient weight must be positive: %g>0\n" , GradientWeight.value ) , exit( 0 );
- if( BiLapWeight.value<=0 ) fprintf( stderr , "[ERROR] Bi-Laplacian weight must be positive: %g>0\n" , BiLapWeight.value ) , exit( 0 );
+ if( GradientWeight.value<=0 ) ERROR_OUT( "Gradient weight must be positive: %g>0" , GradientWeight.value );
+ if( BiLapWeight.value<=0 ) ERROR_OUT( "Bi-Laplacian weight must be positive: %g>0" , BiLapWeight.value );
if( DataX.value<=0 ) Normals.set = Colors.set = false;
if( BaseDepth.value>FullDepth.value )
{
- if( BaseDepth.set ) fprintf( stderr , "[WARNING] Base depth must be smaller than full depth: %d <= %d\n" , BaseDepth.value , FullDepth.value );
+ if( BaseDepth.set ) WARN( "Base depth must be smaller than full depth: %d <= %d" , BaseDepth.value , FullDepth.value );
BaseDepth.value = FullDepth.value;
}
ValueWeight.value *= (float)BaseSSDWeights[0];
@@ -722,7 +720,7 @@ int main( int argc , char* argv[] )
static const int Degree = DEFAULT_FEM_DEGREE;
static const BoundaryType BType = DEFAULT_FEM_BOUNDARY;
typedef IsotropicUIntPack< DIMENSION , FEMDegreeAndBType< Degree , BType >::Signature > FEMSigs;
- fprintf( stderr , "[WARNING] Compiled for degree-%d, boundary-%s, %s-precision _only_\n" , Degree , BoundaryNames[ BType ] , sizeof(Real)==4 ? "single" : "double" );
+ WARN( "Compiled for degree-%d, boundary-%s, %s-precision _only_" , Degree , BoundaryNames[ BType ] , sizeof(DefaultFloatType)==4 ? "single" : "double" );
if( Colors.set ) Execute< Real , PointStreamColor< DefaultFloatType > >( argc , argv , FEMSigs() );
else Execute< Real >( argc , argv , FEMSigs() );
#else // !FAST_COMPILE
diff --git a/Src/SparseMatrix.inl b/Src/SparseMatrix.inl
index 0c9056e..44d2b3d 100644
--- a/Src/SparseMatrix.inl
+++ b/Src/SparseMatrix.inl
@@ -175,7 +175,7 @@ void SparseMatrix< T , IndexType >::setRowSize( size_t row , size_t count )
}
rowSizes[row] = count;
}
- else fprintf( stderr , "[ERROR] SparseMatrix::setRowSize: Row is out of bounds: 0 <= %d < %d\n" , (int)row , (int)rowNum ) , exit( 0 );
+ else ERROR_OUT( "Row is out of bounds: 0 <= %d < %d" , (int)row , (int)rowNum );
}
template< class T , class IndexType >
void SparseMatrix< T , IndexType >::resetRowSize( size_t row , size_t count )
@@ -187,7 +187,7 @@ void SparseMatrix< T , IndexType >::resetRowSize( size_t row , size_t count )
if( count>oldCount ) memset( _entries[row]+oldCount , 0 , sizeof( MatrixEntry< T , IndexType > ) * ( count - oldCount ) );
rowSizes[row] = count;
}
- else fprintf( stderr , "[ERROR] SparseMatrix::ResetRowSize: Row is out of bounds: 0 <= %d < %d\n" , (int)row , (int)rowNum ) , exit( 0 );
+ else ERROR_OUT( "Row is out of bounds: 0 <= %d < %d" , (int)row , (int)rowNum );
}
template< class T , class IndexType >
@@ -252,7 +252,7 @@ SparseMatrix< T , IndexType > SparseMatrix< T , IndexType >::operator * ( const
size_t bCols = 0 , bRows = B.rowNum;
for( int i=0 ; i SparseMatrix< T , IndexType >::transpose( size_t a
const SparseMatrix& At = *this;
size_t _aRows = 0 , aCols = At.rowNum;
for( int i=0 ; iaRows )
- {
- fprintf( stderr , "[Error] SparseMatrix::transpose: prescribed output dimension too low: %d < %zu\n" , (int)aRows , _aRows );
- return false;
- }
+ if( _aRows>aRows ) ERROR_OUT( "Prescribed output dimension too low: %d < %zu" , (int)aRows , _aRows );
A.resize( aRows );
for( int i=0 ; i SparseMatrix< T , IndexType >::Multiply( const Spa
size_t bCols = 0 , bRows = B.rows();
for( int i=0 ; iN ) aCols = iter->N+1;
for( int i=0 ; iN ) bCols = iter->N+1;
- if( bRows SparseMatrix< T , IndexType >::Transpose( const Sp
SparseMatrix< T , IndexType > A;
size_t _aRows = 0 , aCols = At.rows() , aRows = outRows;
for( size_t i=0 ; iN ) _aRows = iter->N+1;
- if( _aRows>aRows ) fprintf( stderr , "[ERROR] Transpose: prescribed output dimension too low: %d < %zu\n" , aRows , _aRows ) , exit( 0 );
+ if( _aRows>aRows ) ERROR_OUT( "Prescribed output dimension too low: %d < %zu" , aRows , _aRows );
A.resize( aRows );
for( size_t i=0 ; i( Out.value , vertices , gtPolygons , Vertex::PlyWriteProperties() , Vertex::PlyWriteNum , ft , comments ) )
- fprintf( stderr , "[ERROR] Could not write mesh to: %s\n" , Out.value ) , exit( 0 );
-
+ ERROR_OUT( "Could not write mesh to: %s" , Out.value );
+
return EXIT_SUCCESS;
}
int main( int argc , char* argv[] )
@@ -384,13 +384,13 @@ int main( int argc , char* argv[] )
typedef MultiPointStreamData< float , PointStreamValue< float > , PointStreamNormal< float , DIMENSION > , PointStreamColor< float > > VertexData;
typedef PlyVertexWithData< float , DIMENSION , VertexData > Vertex;
bool readFlags[ Vertex::PlyReadNum ];
- if( !PlyReadHeader( In.value , Vertex::PlyReadProperties() , Vertex::PlyReadNum , readFlags ) ) fprintf( stderr , "[ERROR] Failed to read ply header: %s\n" , In.value ) , exit( 0 );
+ if( !PlyReadHeader( In.value , Vertex::PlyReadProperties() , Vertex::PlyReadNum , readFlags ) ) ERROR_OUT( "Failed to read ply header: %s" , In.value );
bool hasValue = VertexData::ValidPlyReadProperties< 0 >( readFlags + DIMENSION );
bool hasNormal = VertexData::ValidPlyReadProperties< 1 >( readFlags + DIMENSION );
bool hasColor = VertexData::ValidPlyReadProperties< 2 >( readFlags + DIMENSION );
- if( !hasValue ) fprintf( stderr , "[ERROR] Ply file does not contain values\n" ) , exit( 0 );
+ if( !hasValue ) ERROR_OUT( "Ply file does not contain values" );
if( hasColor )
if( hasNormal ) return Execute< PointStreamNormal< float , DIMENSION > , PointStreamColor< float > >();
diff --git a/Src/Window.inl b/Src/Window.inl
index a18b7c0..4a7a511 100644
--- a/Src/Window.inl
+++ b/Src/Window.inl
@@ -356,23 +356,23 @@ protected:
friend struct _WindowLoop< WindowDimension , IterationDimensions , CurrentIteration+1 >;
template< typename UpdateFunction , typename ProcessFunction , class ... Windows >
- static void Run( int begin , int end , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ fprintf( stderr , "[ERROR] _WindowLoop::Run: shouldn't be here\n" ) , exit( 0 ); }
+ static void Run( int begin , int end , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ ERROR_OUT( "Shouldn't be here" ); }
template< typename UpdateFunction , typename ProcessFunction , class ... Windows >
- static void Run( const int* begin , const int* end , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ fprintf( stderr , "[ERROR] _WindowLoop::Run: shouldn't be here\n" ) , exit( 0 ); }
+ static void Run( const int* begin , const int* end , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ ERROR_OUT( "Shouldn't be here" ); }
template< unsigned int ... Begin , unsigned int ... End , typename UpdateFunction , typename ProcessFunction , class ... Windows >
- static void Run( UIntPack< Begin ... > begin , UIntPack< End ... > end , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ fprintf( stderr , "[ERROR] _WindowLoop::Run: shouldn't be here\n" ) , exit( 0 ); }
+ static void Run( UIntPack< Begin ... > begin , UIntPack< End ... > end , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ ERROR_OUT( "Shouldn't be here" ); }
template< typename UpdateFunction , typename ProcessFunction , class ... Windows >
- static void RunParallel( int begin , int end , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ fprintf( stderr , "[ERROR] _WindowLoop::RunParallel: shouldn't be here\n" ) , exit( 0 ); }
+ static void RunParallel( int begin , int end , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ ERROR_OUT( "Shouldn't be here" ); }
template< typename UpdateFunction , typename ProcessFunction , class ... Windows >
- static void RunParallel( const int* begin , const int* end , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ fprintf( stderr , "[ERROR] _WindowLoop::RunParallel: shouldn't be here\n" ) , exit( 0 ); }
+ static void RunParallel( const int* begin , const int* end , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ ERROR_OUT( "Shouldn't be here" ); }
template< unsigned int ... Begin , unsigned int ... End , typename UpdateFunction , typename ProcessFunction , class ... Windows >
- static void RunParallel( UIntPack< Begin ... > begin , UIntPack< End ... > end , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ fprintf( stderr , "[ERROR] _WindowLoop::RunParallel: shouldn't be here\n" ) , exit( 0 ); }
+ static void RunParallel( UIntPack< Begin ... > begin , UIntPack< End ... > end , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ ERROR_OUT( "Shouldn't be here" ); }
template< typename UpdateFunction , typename ProcessFunction , class ... Windows >
- static void RunThread( int begin , int end , int thread , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ fprintf( stderr , "[ERROR] _WindowLoop::RunThread: shouldn't be here\n" ) , exit( 0 ); }
+ static void RunThread( int begin , int end , int thread , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ ERROR_OUT( "Shouldn't be here" ); }
template< typename UpdateFunction , typename ProcessFunction , class ... Windows >
- static void RunThread( const int* begin , const int* end , int thread , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ fprintf( stderr , "[ERROR] _WindowLoop::RunThread: shouldn't be here\n" ) , exit( 0 ); }
+ static void RunThread( const int* begin , const int* end , int thread , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ ERROR_OUT( "Shouldn't be here" ); }
template< unsigned int ... Begin , unsigned int ... End , typename UpdateFunction , typename ProcessFunction , class ... Windows >
- static void RunThread( UIntPack< Begin ... > begin , UIntPack< End ... > end , int thread , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ fprintf( stderr , "[ERROR] _WindowLoop::RunThread: shouldn't be here\n" ) , exit( 0 ); }
+ static void RunThread( UIntPack< Begin ... > begin , UIntPack< End ... > end , int thread , UpdateFunction& updateState , ProcessFunction& function , Windows ... w ){ ERROR_OUT( "Shouldn't be here" ); }
};
diff --git a/ZLIB.vcxproj b/ZLIB.vcxproj
index 38c7fde..2514f45 100644
--- a/ZLIB.vcxproj
+++ b/ZLIB.vcxproj
@@ -164,7 +164,7 @@
MultiThreadedDLL
- Level3
+ TurnOffAllWarnings
ProgramDatabase
.