57 :
MBI( impl ), geom_tag( 0 ), id_tag( 0 ), name_tag( 0 ), category_tag( 0 ), faceting_tol_tag( 0 )
59 assert( NULL != impl );
102 std::vector< int >& ,
120 std::cout <<
"Subset reading not supported for RTT meshes" << std::endl;
126 file = fopen( filename,
"r" );
136 std::vector< side > side_data;
141 std::vector< cell > cell_data;
146 std::vector< node > node_data;
151 std::vector< facet > facet_data;
156 std::vector< tet > tet_data;
161 std::map< int, EntityHandle > surface_map;
176 std::vector< cell > cell_data,
177 std::map< int, EntityHandle >& surface_map )
181 std::vector< EntityHandle > entmap[4];
184 const char geom_categories[][
CATEGORY_TAG_SIZE] = {
"Vertex\0",
"Curve\0",
"Surface\0",
"Volume\0",
"Group\0" };
186 std::vector< int > surface_numbers;
189 num_ents[2] = side_data.size();
190 num_ents[3] = cell_data.size();
195 for(
int i = 0; i != num_ents[
dim]; i++ )
204 entmap[
dim].push_back( handle );
216 surface_map[side_data[i].id] = handle;
249 std::vector< facet > facet_data,
250 std::vector< tet > tet_data,
251 std::map< int, EntityHandle > surface_map )
262 std::vector< node >::iterator it;
264 for( it = node_data.begin(); it != node_data.end(); ++it )
267 double coords[3] = { tmp.
x, tmp.
y, tmp.
z };
270 mb_coords.
insert( handle );
277 Tag side_id_tag, surface_number_tag;
285 std::vector< facet >::iterator it_f;
289 for( it_f = facet_data.begin(); it_f != facet_data.end(); ++it_f )
311 mb_tris.
insert( triangle );
323 std::vector< tet >::iterator it_t;
326 for( it_t = tet_data.begin(); it_t != tet_data.end(); ++it_t )
355 std::cout <<
"Problems reading file = " << filename << std::endl;
366 if( line.compare(
"header" ) == 0 )
386 std::cout <<
"Problems reading file = " << filename << std::endl;
394 if( line.compare(
" 2 FACES\0" ) == 0 )
399 if( line.compare(
"end_side_flags\0" ) == 0 )
break;
401 side_data.push_back( data );
407 if( side_data.size() == 0 )
return MB_FAILURE;
421 std::cout <<
"Problems reading file = " << filename << std::endl;
429 if( line.compare(
" 1 REGIONS\0" ) == 0 )
434 if( line.compare(
"end_cell_flags\0" ) == 0 )
break;
436 cell_data.push_back( data );
442 if( cell_data.size() == 0 )
return MB_FAILURE;
456 std::cout <<
"Problems reading file = " << filename << std::endl;
465 if( line.compare(
"nodes\0" ) == 0 )
470 if( line.compare(
"end_nodes\0" ) == 0 )
break;
472 node_data.push_back( data );
478 if( node_data.size() == 0 )
return MB_FAILURE;
492 std::cout <<
"Problems reading file = " << filename << std::endl;
501 if( line.compare(
"sides\0" ) == 0 )
506 if( line.compare(
"end_sides\0" ) == 0 )
break;
508 facet_data.push_back( data );
514 if( facet_data.size() == 0 )
return MB_FAILURE;
528 std::cout <<
"Problems reading file = " << filename << std::endl;
536 if( line.compare(
"cells\0" ) == 0 )
541 if( line.compare(
"end_cells\0" ) == 0 )
break;
543 tet_data.push_back( data );
549 if( tet_data.size() == 0 )
return MB_FAILURE;
563 std::istringstream iss( line );
567 std::string sub_string;
573 if( line.find(
"version" ) != std::string::npos )
576 split_string[0].find(
"version" ) != std::string::npos )
582 if( line.find(
"title" ) != std::string::npos )
586 if( line.find(
"date" ) != std::string::npos )
590 if( line.find(
"end_header" ) != std::string::npos )
606 std::vector< std::string > tokens;
610 if( tokens.size() != 2 )
615 new_side.
id = std::atoi( tokens[0].c_str() );
624 if( cell_names.size() > 1 )
633 new_side.
names[1] =
"\0";
645 std::vector< std::string > tokens;
649 if( tokens.size() != 2 )
654 new_cell.
id = std::atoi( tokens[0].c_str() );
655 new_cell.
name = tokens[1];
666 std::vector< std::string > tokens;
670 if( tokens.size() != 5 )
674 new_node.
id = std::atoi( tokens[0].c_str() );
675 new_node.
x = std::atof( tokens[1].c_str() );
676 new_node.
y = std::atof( tokens[2].c_str() );
677 new_node.
z = std::atof( tokens[3].c_str() );
687 std::vector< std::string > tokens;
691 if( tokens.size() != 7 )
696 new_facet.
id = std::atoi( tokens[0].c_str() );
700 new_facet.
connectivity[0] = std::atoi( tokens[1].c_str() );
701 new_facet.
connectivity[1] = std::atoi( tokens[2].c_str() );
702 new_facet.
connectivity[2] = std::atoi( tokens[3].c_str() );
703 new_facet.
side_id = std::atoi( tokens[4].c_str() );
708 new_facet.
connectivity[0] = std::atoi( tokens[2].c_str() );
709 new_facet.
connectivity[1] = std::atoi( tokens[3].c_str() );
710 new_facet.
connectivity[2] = std::atoi( tokens[4].c_str() );
711 new_facet.
side_id = std::atoi( tokens[5].c_str() );
728 std::vector< std::string > tokens;
732 if( tokens.size() != 7 )
736 new_tet.
id = std::atoi( tokens[0].c_str() );
740 new_tet.
connectivity[0] = std::atoi( tokens[1].c_str() );
741 new_tet.
connectivity[1] = std::atoi( tokens[2].c_str() );
742 new_tet.
connectivity[2] = std::atoi( tokens[3].c_str() );
743 new_tet.
connectivity[3] = std::atoi( tokens[4].c_str() );
748 new_tet.
connectivity[0] = std::atoi( tokens[2].c_str() );
749 new_tet.
connectivity[1] = std::atoi( tokens[3].c_str() );
750 new_tet.
connectivity[2] = std::atoi( tokens[4].c_str() );
751 new_tet.
connectivity[3] = std::atoi( tokens[5].c_str() );
770 new_boundary.
sense = 0;
771 new_boundary.
name =
"\0";
773 if( atilla_cellname.find(
"+" ) != std::string::npos )
775 new_boundary.
sense = 1;
777 std::size_t found = atilla_cellname.find(
"@" );
778 if( found != std::string::npos )
779 new_boundary.
name = atilla_cellname.substr( 3, found );
781 new_boundary.
name = atilla_cellname.substr( 3, atilla_cellname.length() );
783 else if( atilla_cellname.find(
"-" ) != std::string::npos )
786 new_boundary.
sense = -1;
787 new_boundary.
name = atilla_cellname.substr( 3, atilla_cellname.length() );
797 std::istringstream ss( string_to_split );
798 std::vector< std::string > tokens;
802 std::getline( ss, x, split_char );
803 tokens.push_back( x );
807 std::vector< std::string >::iterator it;
808 for( it = tokens.begin(); it != tokens.end(); )
810 std::string
string = *it;
811 if(
string.compare(
"\0" ) == 0 )
812 it = tokens.erase( it );
823 std::vector< EntityHandle > entity_map[4],
824 std::vector< side > side_data,
825 std::vector< cell > cell_data )
829 for(
int i = 0; i < num_ents[2]; i++ )
834 for(
unsigned int shared = 0; shared <= 1; shared++ )
836 std::string parent_name = side_data[i].names[shared];
838 unsigned pos = parent_name.find(
"@" );
839 parent_name = parent_name.substr( 0, pos );
842 for(
int j = 0; j < num_ents[3]; j++ )
845 if( cell_data[j].name.compare( parent_name ) == 0 )
852 std::cerr <<
"Failed to add parent child relationship" << std::endl;
865 std::vector< EntityHandle > entity_map[4],
866 std::vector< side > side_data,
867 std::vector< cell > cell_data )
872 for(
int i = 0; i < num_ents[2]; i++ )
876 for(
unsigned int shared = 0; shared <= 1; shared++ )
878 std::string parent_name = side_data[i].names[shared];
879 unsigned pos = parent_name.find(
"@" );
880 parent_name = parent_name.substr( 0, pos );
882 for(
int j = 0; j < num_ents[3]; j++ )
885 if( cell_data[j].name.compare( parent_name ) == 0 )
890 if( side_data[i].senses[shared] == 1 )
892 else if( side_data[i].senses[shared] == -1 )
899 std::cerr <<
"Failed to set sense appropriately" << std::endl;
930 const char geom_categories[][
CATEGORY_TAG_SIZE] = {
"Vertex\0",
"Curve\0",
"Surface\0",
"Volume\0",
"Group\0" };