Added check if write succeeded.

This commit is contained in:
mkazhdan
2018-10-30 11:09:34 -04:00
parent 44ba73aced
commit 830de154b2
6 changed files with 11 additions and 6 deletions
+2 -1
View File
@@ -154,7 +154,8 @@ void _Execute( const FEMTree< Dim , Real >* tree , FILE* fp )
if( Verbose.set ) printf( "Vertices / Polygons: %d / %d\n" , (int)( mesh.outOfCorePointCount()+mesh.inCorePoints.size() ) , (int)mesh.polygonCount() );
std::vector< std::string > comments;
PlyWritePolygons< Vertex , Real , Dim >( OutMesh.value , &mesh , ASCII.set ? PLY_ASCII : PLY_BINARY_NATIVE , comments , XForm< Real , Dim+1 >::Identity() );
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 );
}
}
-1
View File
@@ -41,7 +41,6 @@ DAMAGE.
#include "CmdLineParser.h"
#include "PPolynomial.h"
#include "FEMTree.h"
#include "Ply.h"
MessageWriter messageWriter;
+2 -1
View File
@@ -139,7 +139,8 @@ struct RGBPixel
void WriteImage( char* fileName , RGBPixel* pixels , int w , int h )
{
unsigned int _w = w , _h = h , _c = 3;
ImageWriter::Write( fileName , (const unsigned char*)pixels , _w , _h , _c );
if( !ImageWriter::Write( fileName , (const unsigned char*)pixels , _w , _h , _c ) )
fprintf( stderr , "[ERROR] Could not write image to: %s\n" , fileName ) , exit( 0 );
}
struct Profiler
+2 -1
View File
@@ -339,7 +339,8 @@ void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTr
else profiler.dumpOutput2( comments , "# Got triangles:" );
std::vector< std::string > noComments;
PlyWritePolygons< Vertex , Real , Dim >( Out.value , &mesh , ASCII.set ? PLY_ASCII : PLY_BINARY_NATIVE , NoComments.set ? noComments : comments , iXForm );
if( !PlyWritePolygons< Vertex , Real , Dim >( Out.value , &mesh , ASCII.set ? PLY_ASCII : PLY_BINARY_NATIVE , NoComments.set ? noComments : comments , iXForm ) )
fprintf( stderr , "[ERROR] Could not write mesh to: %s\n" , Out.value ) , exit( 0 );
}
template< class Real , typename ... SampleData , unsigned int ... FEMSigs >
+2 -1
View File
@@ -359,7 +359,8 @@ void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTr
else profiler.dumpOutput2( comments , "# Got triangles:" );
std::vector< std::string > noComments;
PlyWritePolygons< Vertex , Real , Dim >( Out.value , &mesh , ASCII.set ? PLY_ASCII : PLY_BINARY_NATIVE , NoComments.set ? noComments : comments , iXForm );
if( !PlyWritePolygons< Vertex , Real , Dim >( Out.value , &mesh , ASCII.set ? PLY_ASCII : PLY_BINARY_NATIVE , NoComments.set ? noComments : comments , iXForm ) )
fprintf( stderr , "[ERROR] Could not write mesh to: %s\n" , Out.value ) , exit( 0 );
}
template< class Real , typename ... SampleData , unsigned int ... FEMSigs >
+3 -1
View File
@@ -365,7 +365,9 @@ int Execute( void )
char comment[1024];
sprintf( comment , "#Trimmed In: %9.1f (s)" , Time()-t );
comments.push_back( comment );
if( Out.set ) PlyWritePolygons< Vertex >( Out.value , vertices , gtPolygons , Vertex::PlyWriteProperties() , Vertex::PlyWriteNum , ft , comments );
if( Out.set )
if( !PlyWritePolygons< Vertex >( Out.value , vertices , gtPolygons , Vertex::PlyWriteProperties() , Vertex::PlyWriteNum , ft , comments ) )
fprintf( stderr , "[ERROR] Could not write mesh to: %s\n" , Out.value ) , exit( 0 );
return EXIT_SUCCESS;
}