17 size_t found = line.find_first_not_of(
" \t" );
18 if( found == string::npos )
return 1;
19 if(
'#' == line[found] )
return 1;
32 cout <<
"Can't get interface.\n";
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 rval =
iface->get_node_coords( 2, num_nodes, 0, startv, arrays );
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;
105 rval =
iface->get_element_connect( num_triangles, 3,
MBTRI, 0, starte, starth );
107 for(
int j = 0; j < num_triangles; j++ )
109 getline( eleFile, line );
115 stringstream tokens( line );
119 for(
int k = 0; k < 3; k++ )
123 starth[3 * j + k] = startv + node - 1;
137 int main(
int argc,
char** argv )
141 cout <<
"Usage: " << argv[0] <<
" <filename> <outFile> " << endl;
142 cout <<
" <filename> is the base file name; *.ele and *.node file are read; outFile "
143 "is a file with an extension recognized by MOAB "
148 string filename = argv[1];
149 char* outfile = argv[2];
158 cout <<
"Writing output file " << outfile << endl;