23 size_t found = line.find_first_not_of(
" \t" );
24 if( found == string::npos )
return 1;
25 if(
'#' == line[found] )
return 1;
36 string nodeFileName = fileBase +
".node";
37 ifstream nodeFile( nodeFileName.c_str() );
38 if( !nodeFile.is_open() )
40 cout <<
"can't open node file .\n";
43 cout <<
"reading nodes from file " << nodeFileName.c_str() << endl;
45 string eleFileName = fileBase +
".ele";
46 ifstream eleFile( eleFileName.c_str() );
47 if( !eleFile.is_open() )
49 cout <<
"can't open element file .\n";
52 cout <<
"reading elements from file " << eleFileName.c_str() << endl;
58 int num_nodes = 0, num_triangles = 0;
59 while( num_nodes == 0 )
61 getline( nodeFile, line );
63 stringstream tks( line );
66 cout <<
"num nodes:" << num_nodes << endl;
73 vector< double* > arrays;
75 MB_CHK_SET_ERR(
iface->get_node_coords( 2, num_nodes, 0, startv, arrays ),
"Failed to get node coordinates" );
76 for(
int i = 0; i < num_nodes; i++ )
78 getline( nodeFile, line );
84 stringstream tokens( line );
86 tokens >> nodeId >> arrays[0][i] >> arrays[1][i];
92 while( num_triangles == 0 )
94 getline( eleFile, line );
96 stringstream tks( line );
98 cout <<
"num triangles:" << num_triangles << endl;
106 "Failed to get element connectivity" );
108 for(
int j = 0; j < num_triangles; j++ )
110 getline( eleFile, line );
116 stringstream tokens( line );
120 for(
int k = 0; k < 3; k++ )
124 starth[3 * j + k] = startv + node - 1;
138 int main(
int argc,
char** argv )
142 cout <<
"Usage: " << argv[0] <<
" <filename> <outFile> " << endl;
143 cout <<
" <filename> is the base file name; *.ele and *.node file are read; outFile "
144 "is a file with an extension recognized by MOAB "
149 string filename = argv[1];
150 char* outfile = argv[2];
157 cout <<
"Writing output file " << outfile << endl;