20 #pragma warning( disable : 4786 )
38 const char*
WriteGMV::gmvTypeNames[] = {
"",
"line",
"tri",
"quad",
"",
"tet",
"pyramid",
"prism",
"",
"hex",
"",
"" };
47 assert( impl != NULL );
74 int dum_val_array[] = { -1, -1, -1, -1 };
86 const int user_dimension,
88 const bool poly_mesh )
98 result =
local_write_mesh( file_name, output_set, user_dimension,
true,
false );
104 result =
local_write_mesh( file_name, output_set, user_dimension,
false,
true );
115 const int num_output_sets,
116 const std::vector< std::string >&,
122 if( output_sets && num_output_sets > 0 )
124 if( num_output_sets > 1 )
return MB_FAILURE;
125 output_set = output_sets[0];
133 return write_file( filename, output_set, dimension,
true,
true );
138 const int user_dimension,
140 const bool poly_mesh )
148 std::string tmp_name( file_name );
150 ofile.open( tmp_name.c_str() );
155 std::string tmp_name( file_name );
156 tmp_name +=
".poly.gmv";
157 ofile.open( tmp_name.c_str() );
160 ofile <<
"gmvinput ascii" << std::endl;
163 Range dum_range, elements, all_verts;
188 int num_verts = all_verts.
size();
191 double* xcoord =
new double[num_verts];
192 double* ycoord =
new double[num_verts];
193 double* zcoord =
new double[num_verts];
194 std::vector< double* > coord_arrays;
195 coord_arrays.push_back( xcoord );
196 coord_arrays.push_back( ycoord );
197 coord_arrays.push_back( zcoord );
208 ofile <<
"nodev " << num_verts << std::endl;
209 for( i = 0; i < num_verts; i++ )
210 ofile << xcoord[i] <<
" " << ycoord[i] <<
" " << zcoord[i] << std::endl;
220 std::vector< int > connect;
221 std::vector< EntityHandle > connecth;
227 ofile <<
"cells " << elements.
size() << std::endl;
241 if( lower == upper )
continue;
249 if( connect.size() < verts_per * sub_range.
size() ) connect.resize( verts_per * sub_range.
size() );
259 for( i = 0; i < (int)sub_range.
size(); i++ )
261 ofile <<
gmvTypeNames[otype] <<
" " << verts_per << std::endl;
262 for( j = i * verts_per; j < (int)( i + 1 ) * verts_per; j++ )
263 ofile << connect[j] <<
" ";
275 Range polygons, polyhedra;
282 if( polygons.
size() == 0 )
return result;
288 ofile <<
"faces " << polygons.
size() <<
" " << polyhedra.
size() << std::endl;
297 if( 0 == connecth.size() )
continue;
300 if( user_dimension == 3 )
307 connecth.push_back( ( polyhedra.
size() > 0 ? *polyhedra.
begin() : 0 ) );
308 connecth.push_back( ( polyhedra.
size() > 1 ? *polyhedra.
rbegin() : 0 ) );
312 connect.resize( connecth.size() + 2 );
315 connect[connecth.size()] = 0;
316 connect[connecth.size() + 1] = 0;
322 ofile << connecth.size() - 2;
324 for( i = 0; i < (int)connecth.size(); i++ )
325 ofile <<
" " << connect[i];
331 ofile << std::endl <<
"endgmv" << std::endl;