57 :
MBI( impl ), geom_tag( 0 ), id_tag( 0 ), name_tag( 0 ), category_tag( 0 ), faceting_tol_tag( 0 )
59 assert( NULL != impl );
111 std::cout <<
"Subset reading not supported for RTT meshes" << std::endl;
117 file = fopen( filename,
"r" );
127 std::vector< side > side_data;
132 std::vector< cell > cell_data;
137 std::vector< node > node_data;
142 std::vector< facet > facet_data;
147 std::vector< tet > tet_data;
152 std::map< int, EntityHandle > surface_map;
167 std::vector< cell > cell_data,
168 std::map< int, EntityHandle >& surface_map )
172 std::vector< EntityHandle > entmap[4];
175 const char geom_categories[][
CATEGORY_TAG_SIZE] = {
"Vertex\0",
"Curve\0",
"Surface\0",
"Volume\0",
"Group\0" };
177 std::vector< int > surface_numbers;
180 num_ents[2] = side_data.size();
181 num_ents[3] = cell_data.size();
186 for(
int i = 0; i != num_ents[
dim]; i++ )
195 entmap[
dim].push_back( handle );
207 surface_map[side_data[i].id] = handle;
240 std::vector< facet > facet_data,
241 std::vector< tet > tet_data,
242 std::map< int, EntityHandle > surface_map )
253 std::vector< node >::iterator it;
255 for( it = node_data.begin(); it != node_data.end(); ++it )
258 double coords[3] = { tmp.
x, tmp.
y, tmp.
z };
261 mb_coords.
insert( handle );
268 Tag side_id_tag, surface_number_tag;
276 std::vector< facet >::iterator it_f;
280 for( it_f = facet_data.begin(); it_f != facet_data.end(); ++it_f )
302 mb_tris.
insert( triangle );
314 std::vector< tet >::iterator it_t;
317 for( it_t = tet_data.begin(); it_t != tet_data.end(); ++it_t )
346 std::cout <<
"Problems reading file = " << filename << std::endl;
357 if( line.compare(
"header" ) == 0 )
377 std::cout <<
"Problems reading file = " << filename << std::endl;
385 if( line.compare(
" 2 FACES\0" ) == 0 )
390 if( line.compare(
"end_side_flags\0" ) == 0 )
break;
392 side_data.push_back( data );
398 if( side_data.size() == 0 )
return MB_FAILURE;
412 std::cout <<
"Problems reading file = " << filename << std::endl;
420 if( line.compare(
" 1 REGIONS\0" ) == 0 )
425 if( line.compare(
"end_cell_flags\0" ) == 0 )
break;
427 cell_data.push_back( data );
433 if( cell_data.size() == 0 )
return MB_FAILURE;
447 std::cout <<
"Problems reading file = " << filename << std::endl;
456 if( line.compare(
"nodes\0" ) == 0 )
461 if( line.compare(
"end_nodes\0" ) == 0 )
break;
463 node_data.push_back( data );
469 if( node_data.size() == 0 )
return MB_FAILURE;
483 std::cout <<
"Problems reading file = " << filename << std::endl;
492 if( line.compare(
"sides\0" ) == 0 )
497 if( line.compare(
"end_sides\0" ) == 0 )
break;
499 facet_data.push_back( data );
505 if( facet_data.size() == 0 )
return MB_FAILURE;
519 std::cout <<
"Problems reading file = " << filename << std::endl;
527 if( line.compare(
"cells\0" ) == 0 )
532 if( line.compare(
"end_cells\0" ) == 0 )
break;
534 tet_data.push_back( data );
540 if( tet_data.size() == 0 )
return MB_FAILURE;
554 std::istringstream iss( line );
558 std::string sub_string;
564 if( line.find(
"version" ) != std::string::npos )
567 split_string[0].find(
"version" ) != std::string::npos )
573 if( line.find(
"title" ) != std::string::npos )
577 if( line.find(
"date" ) != std::string::npos )
581 if( line.find(
"end_header" ) != std::string::npos )
597 std::vector< std::string > tokens;
601 if( tokens.size() != 2 )
606 new_side.
id = std::atoi( tokens[0].c_str() );
615 if( cell_names.size() > 1 )
624 new_side.
names[1] =
"\0";
636 std::vector< std::string > tokens;
640 if( tokens.size() != 2 )
645 new_cell.
id = std::atoi( tokens[0].c_str() );
646 new_cell.
name = tokens[1];
657 std::vector< std::string > tokens;
661 if( tokens.size() != 5 )
665 new_node.
id = std::atoi( tokens[0].c_str() );
666 new_node.
x = std::atof( tokens[1].c_str() );
667 new_node.
y = std::atof( tokens[2].c_str() );
668 new_node.
z = std::atof( tokens[3].c_str() );
678 std::vector< std::string > tokens;
682 if( tokens.size() != 7 )
687 new_facet.
id = std::atoi( tokens[0].c_str() );
691 new_facet.
connectivity[0] = std::atoi( tokens[1].c_str() );
692 new_facet.
connectivity[1] = std::atoi( tokens[2].c_str() );
693 new_facet.
connectivity[2] = std::atoi( tokens[3].c_str() );
694 new_facet.
side_id = std::atoi( tokens[4].c_str() );
699 new_facet.
connectivity[0] = std::atoi( tokens[2].c_str() );
700 new_facet.
connectivity[1] = std::atoi( tokens[3].c_str() );
701 new_facet.
connectivity[2] = std::atoi( tokens[4].c_str() );
702 new_facet.
side_id = std::atoi( tokens[5].c_str() );
719 std::vector< std::string > tokens;
723 if( tokens.size() != 7 )
727 new_tet.
id = std::atoi( tokens[0].c_str() );
731 new_tet.
connectivity[0] = std::atoi( tokens[1].c_str() );
732 new_tet.
connectivity[1] = std::atoi( tokens[2].c_str() );
733 new_tet.
connectivity[2] = std::atoi( tokens[3].c_str() );
734 new_tet.
connectivity[3] = std::atoi( tokens[4].c_str() );
739 new_tet.
connectivity[0] = std::atoi( tokens[2].c_str() );
740 new_tet.
connectivity[1] = std::atoi( tokens[3].c_str() );
741 new_tet.
connectivity[2] = std::atoi( tokens[4].c_str() );
742 new_tet.
connectivity[3] = std::atoi( tokens[5].c_str() );
761 new_boundary.
sense = 0;
762 new_boundary.
name =
"\0";
764 if( atilla_cellname.find(
"+" ) != std::string::npos )
766 new_boundary.
sense = 1;
768 std::size_t found = atilla_cellname.find(
"@" );
769 if( found != std::string::npos )
770 new_boundary.
name = atilla_cellname.substr( 3, found );
772 new_boundary.
name = atilla_cellname.substr( 3, atilla_cellname.length() );
774 else if( atilla_cellname.find(
"-" ) != std::string::npos )
777 new_boundary.
sense = -1;
778 new_boundary.
name = atilla_cellname.substr( 3, atilla_cellname.length() );
788 std::istringstream ss( string_to_split );
789 std::vector< std::string > tokens;
793 std::getline( ss, x, split_char );
794 tokens.push_back( x );
798 std::vector< std::string >::iterator it;
799 for( it = tokens.begin(); it != tokens.end(); )
801 std::string
string = *it;
802 if(
string.compare(
"\0" ) == 0 )
803 it = tokens.erase( it );
814 std::vector< EntityHandle > entity_map[4],
815 std::vector< side > side_data,
816 std::vector< cell > cell_data )
820 for(
int i = 0; i < num_ents[2]; i++ )
825 for(
unsigned int shared = 0; shared <= 1; shared++ )
827 std::string parent_name = side_data[i].names[shared];
829 unsigned pos = parent_name.find(
"@" );
830 parent_name = parent_name.substr( 0, pos );
833 for(
int j = 0; j < num_ents[3]; j++ )
836 if( cell_data[j].name.compare( parent_name ) == 0 )
843 std::cerr <<
"Failed to add parent child relationship" << std::endl;
856 std::vector< EntityHandle > entity_map[4],
857 std::vector< side > side_data,
858 std::vector< cell > cell_data )
863 for(
int i = 0; i < num_ents[2]; i++ )
867 for(
unsigned int shared = 0; shared <= 1; shared++ )
869 std::string parent_name = side_data[i].names[shared];
870 unsigned pos = parent_name.find(
"@" );
871 parent_name = parent_name.substr( 0, pos );
873 for(
int j = 0; j < num_ents[3]; j++ )
876 if( cell_data[j].name.compare( parent_name ) == 0 )
881 if( side_data[i].senses[shared] == 1 )
883 else if( side_data[i].senses[shared] == -1 )
890 std::cerr <<
"Failed to set sense appropriately" << std::endl;
921 const char geom_categories[][
CATEGORY_TAG_SIZE] = {
"Vertex\0",
"Curve\0",
"Surface\0",
"Volume\0",
"Group\0" };