Driver_Mesh::Status DriverSTL_R_SMDS_Mesh::Perform() { // Kernel_Utils::Localizer loc; Status aResult = DRS_OK; if ( myFile.empty() ) { fprintf(stderr, ">> ERREOR : invalid file name \n"); return DRS_FAIL; } SMESH_File file( myFile, /*open=*/false ); if ( !file.open() ) { fprintf(stderr, ">> ERROR : cannot open file %s \n", myFile.c_str()); if ( file.error().empty() ) fprintf(stderr, ">> ERROR : %s \n", file.error().c_str()); return DRS_FAIL; } // we skip the header which is in Ascii for both modes const char* data = file; data += HEADER_SIZE; // we check 128 characters to detect if we have a non-ascii char myIsAscii = Standard_True; for (int i = 0; i < 128; ++i, ++data) { if ( !isascii( *data ) && data < file.end() ) { myIsAscii = Standard_False; break; } } if ( !myMesh ) { fprintf(stderr, ">> ERREOR : cannot create mesh \n"); return DRS_FAIL; } if ( myIsAscii ) aResult = readAscii( file ); else aResult = readBinary( file ); return aResult; }
int main(){ scampRec_t current; while (readAscii(stdin, ¤t) != EOF) writeBinary(stdout, ¤t); return 0; }