Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
quads_to_tris_driver.cpp
Go to the documentation of this file.
1 #include <iostream> 2 #include <cassert> 3 #include "moab/Core.hpp" 4 #include "quads_to_tris.hpp" 5  6 using namespace moab; 7  8 #define MBI mb_instance() 9 static Interface* mb_instance(); 10  11 // Read a DAGMC-style file of quads and convert it to tris 12 // Input argument is the input filename. 13 // Output file will be called input_filename_tris.h5m. 14 int main( int argc, char** argv ) 15 { 16  17  if( 2 > argc ) 18  { 19  std::cout << "Need name of input file with quads." << std::endl; 20  return 0; 21  } 22  23  // load file from input argument 24  ErrorCode result; 25  std::string filename = argv[1]; 26  result = MBI->load_file( filename.c_str() ); 27  if( MB_SUCCESS != result ) 28  { 29  std::cout << "Error reading file." << std::endl; 30  return 1; 31  } 32  33  result = quads_to_tris( MBI, 0 ); 34  if( MB_SUCCESS != result ) 35  { 36  std::cout << "Error converting to tris." << std::endl; 37  return 1; 38  } 39  40  // Write the file that has been converted from quads to tris. 41  // Cut off the .h5m 42  int len1 = filename.length(); 43  filename.erase( len1 - 4 ); 44  std::string filename_new = filename + "_tris.h5m"; 45  result = MBI->write_mesh( filename_new.c_str() ); 46  assert( MB_SUCCESS == result ); 47  48  return 0; 49 } 50 Interface* mb_instance() 51 { 52  static Core inst; 53  return &inst; 54 }