208 std::vector< CartVect3D >::iterator iter;
214 if( !strcmp( argv[idx],
"-p" ) )
216 else if( !strcmp( argv[idx],
"-g" ) )
218 else if( !strcmp( argv[idx],
"-s" ) )
229 surface_id = strtol( argv[idx], &endptr, 0 );
234 result =
moab->load_mesh( argv[idx] );
238 std::cerr << argv[idx] <<
" : open failed.\n";
240 std::cerr << argv[idx] <<
" : error reading file.\n";
246 const int dimension = 2;
253 std::cerr <<
"No geometry tag.\n";
256 tags[1] =
moab->globalId_tag();
259 const void* tag_values[] = { &dimension, &surface_id };
261 moab->get_entities_by_type_and_tag( 0,
MBENTITYSET, tags, tag_values, 2, surfaces );
262 if( surfaces.
size() != 1 )
264 std::cerr <<
"Found " << surfaces.
size() <<
" surfaces with ID " << surface_id << std::endl;
267 surface = *surfaces.
begin();
276 result =
moab->get_entities_by_dimension( surface, dimension, elements );
279 std::cerr <<
"Internal error\n";
285 std::vector< EntityHandle > vertices;
286 std::vector< CartVect3D > coords;
290 result =
moab->get_connectivity( &*i, 1, vertices,
true );
293 std::cerr <<
"Internal error\n";
297 coords.resize( vertices.size() );
298 result =
moab->get_coords( &vertices[0], vertices.size(),
reinterpret_cast< double*
>( &coords[0] ) );
301 std::cerr <<
"Internal error\n";
305 for(
size_t j = 0; j < coords.size(); ++j )
307 CartVect3D v1 = coords[( j + 1 ) % coords.size()] - coords[j];
308 CartVect3D v2 = coords[( j + 1 ) % coords.size()] - coords[( j + 2 ) % coords.size()];
309 normal += ( v1 * v2 );
312 normal /= normal.
len();
316 result =
moab->get_adjacencies( elements, 1,
true, edge_range, Interface::UNION );
319 std::cerr <<
"Internal error\n";
324 std::vector< EntityHandle > edges( edge_range.
size() );
325 std::copy( edge_range.
begin(), edge_range.
end(), edges.begin() );
327 result =
moab->get_connectivity( &edges[0], edges.size(), vertices,
true );
330 std::cerr <<
"Internal error\n";
334 coords.resize( vertices.size() );
335 result =
moab->get_coords( &vertices[0], vertices.size(),
reinterpret_cast< double*
>( &coords[0] ) );
338 std::cerr <<
"Internal error\n";
346 std::cerr <<
"Plane normal: [" << normal.x <<
' ' << normal.y <<
' ' << normal.z <<
']' << std::endl;
347 double transform[3][3];
350 for( iter = coords.begin(); iter != coords.end(); ++iter )
358 write_eps( std::cout, coords, surface_id );