MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 #include <iostream> 00002 #include <cassert> 00003 #include "moab/Core.hpp" 00004 #include "quads_to_tris.hpp" 00005 00006 using namespace moab; 00007 00008 #define MBI mb_instance() 00009 static Interface* mb_instance(); 00010 00011 // Read a DAGMC-style file of quads and convert it to tris 00012 // Input argument is the input filename. 00013 // Output file will be called input_filename_tris.h5m. 00014 int main( int argc, char** argv ) 00015 { 00016 00017 if( 2 > argc ) 00018 { 00019 std::cout << "Need name of input file with quads." << std::endl; 00020 return 0; 00021 } 00022 00023 // load file from input argument 00024 ErrorCode result; 00025 std::string filename = argv[1]; 00026 result = MBI->load_file( filename.c_str() ); 00027 if( MB_SUCCESS != result ) 00028 { 00029 std::cout << "Error reading file." << std::endl; 00030 return 1; 00031 } 00032 00033 result = quads_to_tris( MBI, 0 ); 00034 if( MB_SUCCESS != result ) 00035 { 00036 std::cout << "Error converting to tris." << std::endl; 00037 return 1; 00038 } 00039 00040 // Write the file that has been converted from quads to tris. 00041 // Cut off the .h5m 00042 int len1 = filename.length(); 00043 filename.erase( len1 - 4 ); 00044 std::string filename_new = filename + "_tris.h5m"; 00045 result = MBI->write_mesh( filename_new.c_str() ); 00046 assert( MB_SUCCESS == result ); 00047 00048 return 0; 00049 } 00050 Interface* mb_instance() 00051 { 00052 static Core inst; 00053 return &inst; 00054 }