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;
}
예제 #2
0
파일: a2b.c 프로젝트: ChappedSky/hancock
int main(){
  scampRec_t current;
  while (readAscii(stdin, &current) != EOF)
    writeBinary(stdout, &current);
  return 0;
}