moab
|
#include <ReadCGM.hpp>
Public Member Functions | |
void | tokenize (const std::string &str, std::vector< std::string > &tokens, const char *delimiters) |
ErrorCode | load_file (const char *file_name, const EntityHandle *file_set, const FileOptions &opts, const SubsetList *subset_list=0, const Tag *file_id_tag=0) |
load a CGM file | |
ErrorCode | read_tag_values (const char *file_name, const char *tag_name, const FileOptions &opts, std::vector< int > &tag_values_out, const SubsetList *subset_list=0) |
Read tag values from a file. | |
ReadCGM (Interface *impl=NULL) | |
Constructor. | |
virtual | ~ReadCGM () |
Destructor. | |
Static Public Member Functions | |
static ReaderIface * | factory (Interface *) |
Private Member Functions | |
const char * | get_geom_file_type (const char *filename) |
const char * | get_geom_fptr_type (FILE *file) |
int | is_cubit_file (FILE *file) |
int | is_step_file (FILE *file) |
int | is_iges_file (FILE *file) |
int | is_acis_txt_file (FILE *file) |
int | is_acis_bin_file (FILE *file) |
int | is_occ_brep_file (FILE *file) |
Private Attributes | |
ReadUtilIface * | readUtilIface |
GeomTopoTool * | myGeomTool |
Interface * | mdbImpl |
interface instance | |
Tag | geom_tag |
Tag | id_tag |
Tag | name_tag |
Tag | category_tag |
Tag | faceting_tol_tag |
Tag | geometry_resabs_tag |
Definition at line 44 of file ReadCGM.hpp.
moab::ReadCGM::ReadCGM | ( | Interface * | impl = NULL | ) |
Constructor.
Definition at line 66 of file ReadCGM.cpp.
: geom_tag(0), id_tag(0), name_tag(0), category_tag(0), faceting_tol_tag(0), geometry_resabs_tag(0) { assert(NULL != impl); mdbImpl = impl; myGeomTool = new GeomTopoTool(impl); impl->query_interface( readUtilIface ); assert(NULL != readUtilIface); ErrorCode rval; // get some tag handles int negone = -1, zero = 0 /*, negonearr[] = {-1, -1, -1, -1}*/; rval = mdbImpl->tag_get_handle( GEOM_DIMENSION_TAG_NAME, 1, MB_TYPE_INTEGER, geom_tag, MB_TAG_SPARSE|MB_TAG_CREAT, &negone); assert(!rval); rval = mdbImpl->tag_get_handle( GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, id_tag, MB_TAG_DENSE|MB_TAG_CREAT, &zero); assert(!rval); rval = mdbImpl->tag_get_handle( NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE, name_tag, MB_TAG_SPARSE|MB_TAG_CREAT ); assert(!rval); rval = mdbImpl->tag_get_handle( CATEGORY_TAG_NAME, CATEGORY_TAG_SIZE, MB_TYPE_OPAQUE, category_tag, MB_TAG_SPARSE|MB_TAG_CREAT ); assert(!rval); rval = mdbImpl->tag_get_handle("FACETING_TOL", 1, MB_TYPE_DOUBLE, faceting_tol_tag, MB_TAG_SPARSE|MB_TAG_CREAT ); assert(!rval); rval = mdbImpl->tag_get_handle("GEOMETRY_RESABS", 1, MB_TYPE_DOUBLE, geometry_resabs_tag, MB_TAG_SPARSE|MB_TAG_CREAT); assert(!rval); }
moab::ReadCGM::~ReadCGM | ( | ) | [virtual] |
Destructor.
Definition at line 101 of file ReadCGM.cpp.
{ mdbImpl->release_interface(readUtilIface); delete myGeomTool; }
ReaderIface * moab::ReadCGM::factory | ( | Interface * | iface | ) | [static] |
Definition at line 63 of file ReadCGM.cpp.
const char * moab::ReadCGM::get_geom_file_type | ( | const char * | filename | ) | [private] |
Definition at line 675 of file ReadCGM.cpp.
{ FILE* file; const char* result = 0; file = fopen( name, "r" ); if (file) { result = get_geom_fptr_type( file ); fclose( file ); } return result; }
const char * moab::ReadCGM::get_geom_fptr_type | ( | FILE * | file | ) | [private] |
Definition at line 689 of file ReadCGM.cpp.
{ static const char* CUBIT_NAME = GF_CUBIT_FILE_TYPE; static const char* STEP_NAME = GF_STEP_FILE_TYPE; static const char* IGES_NAME = GF_IGES_FILE_TYPE; static const char* SAT_NAME = GF_ACIS_TXT_FILE_TYPE; static const char* SAB_NAME = GF_ACIS_BIN_FILE_TYPE; static const char* BREP_NAME = GF_OCC_BREP_FILE_TYPE; if (is_cubit_file(file)) return CUBIT_NAME; else if (is_step_file(file)) return STEP_NAME; else if (is_iges_file(file)) return IGES_NAME; else if (is_acis_bin_file(file)) return SAB_NAME; else if (is_acis_txt_file(file)) return SAT_NAME; else if (is_occ_brep_file(file)) return BREP_NAME; else return 0; }
int moab::ReadCGM::is_acis_bin_file | ( | FILE * | file | ) | [private] |
Definition at line 738 of file ReadCGM.cpp.
{ char buffer[15]; return !fseek(file, 0, SEEK_SET) && fread(buffer, 15, 1, file) && !memcmp(buffer, "ACIS BinaryFile", 9); }
int moab::ReadCGM::is_acis_txt_file | ( | FILE * | file | ) | [private] |
Definition at line 746 of file ReadCGM.cpp.
{ char buffer[5]; int version, length; if (fseek(file,0,SEEK_SET) || 2 != fscanf( file, "%d %*d %*d %*d %d ", &version, &length )) return 0; if (version < 1 || version >0xFFFF) return 0; // Skip appliation name if (fseek(file, length, SEEK_CUR)) return 0; // Read length of version string followed by first 5 characters if (2 != fscanf(file, "%d %4s", &length, buffer)) return 0; return !strcmp( buffer, "ACIS" ); }
int moab::ReadCGM::is_cubit_file | ( | FILE * | file | ) | [private] |
Definition at line 714 of file ReadCGM.cpp.
{ unsigned char buffer[4]; return !fseek(file, 0, SEEK_SET) && fread(buffer, 4, 1, file) && !memcmp(buffer, "CUBE", 4); }
int moab::ReadCGM::is_iges_file | ( | FILE * | file | ) | [private] |
Definition at line 730 of file ReadCGM.cpp.
{ unsigned char buffer[10]; return !fseek(file, 72, SEEK_SET) && fread(buffer, 10, 1, file) && !memcmp(buffer, "S 1", 8); }
int moab::ReadCGM::is_occ_brep_file | ( | FILE * | file | ) | [private] |
Definition at line 769 of file ReadCGM.cpp.
{ unsigned char buffer[6]; return !fseek(file, 0, SEEK_SET) && fread(buffer, 6, 1, file) && !memcmp(buffer, "DBRep_", 6); }
int moab::ReadCGM::is_step_file | ( | FILE * | file | ) | [private] |
Definition at line 722 of file ReadCGM.cpp.
{ unsigned char buffer[9]; return !fseek(file, 0, SEEK_SET) && fread(buffer, 9, 1, file) && !memcmp(buffer, "ISO-10303", 9); }
ErrorCode moab::ReadCGM::load_file | ( | const char * | file_name, |
const EntityHandle * | file_set, | ||
const FileOptions & | opts, | ||
const SubsetList * | subset_list = 0 , |
||
const Tag * | file_id_tag = 0 |
||
) | [virtual] |
load a CGM file
Implements moab::ReaderIface.
Definition at line 120 of file ReadCGM.cpp.
{ // blocks_to_load and num_blocks are ignored. ErrorCode rval; if (subset_list) { readUtilIface->report_error( "Reading subset of files not supported for CGM data." ); return MB_UNSUPPORTED_OPERATION; } int norm_tol, DEFAULT_NORM = 5; double faceting_tol, DEFAULT_FACET_TOL = 0.001, len_tol, DEFAULT_LEN_TOL = 0.0; bool act_att = true; //check for the options. if (MB_SUCCESS != opts.get_int_option( "FACET_NORMAL_TOLERANCE", norm_tol )) norm_tol = DEFAULT_NORM; if (MB_SUCCESS != opts.get_real_option("FACET_DISTANCE_TOLERANCE", faceting_tol)) faceting_tol = DEFAULT_FACET_TOL; if (MB_SUCCESS != opts.get_real_option("MAX_FACET_EDGE_LENGTH", len_tol)) len_tol = DEFAULT_LEN_TOL; bool verbose_warnings = false; if (MB_SUCCESS == opts.get_null_option("VERBOSE_CGM_WARNINGS")) verbose_warnings = true; const char* name = "CGM_ATTRIBS"; const char* value = "no"; rval = opts.match_option(name,value); if(MB_SUCCESS == rval) act_att = false; // always tag with the faceting_tol and geometry absolute resolution // if file_set is defined, use that, otherwise (file_set == NULL) tag the interface EntityHandle set = file_set ? *file_set : 0; rval = mdbImpl->tag_set_data( faceting_tol_tag, &set, 1, &faceting_tol ); if(MB_SUCCESS != rval) return rval; rval = mdbImpl->tag_set_data( geometry_resabs_tag, &set, 1, &GEOMETRY_RESABS ); if(MB_SUCCESS != rval) return rval; // CGM data std::map<RefEntity*,EntityHandle> entmap[5]; // one for each dim, and one for groups std::map<RefEntity*,EntityHandle>::iterator ci; const char geom_categories[][CATEGORY_TAG_SIZE] = {"Vertex\0", "Curve\0", "Surface\0", "Volume\0", "Group\0"}; const char* const names[] = { "Vertex", "Curve", "Surface", "Volume"}; DLIList<RefEntity*> entlist; DLIList<ModelEntity*> me_list; // Initialize CGM InitCGMA::initialize_cgma(); if (act_att) { CGMApp::instance()->attrib_manager()->set_all_auto_read_flags( act_att ); CGMApp::instance()->attrib_manager()->set_all_auto_actuate_flags( act_att ); } if( !verbose_warnings ){ CGMApp::instance()->attrib_manager()->silent_flag( true ); } CubitStatus s; // Get CGM file type const char* file_type = 0; file_type = get_geom_file_type( cgm_file_name ); if (!file_type || !strcmp(file_type ,"CUBIT")) return MB_FAILURE; s = CubitCompat_import_solid_model( cgm_file_name, file_type ); if (CUBIT_SUCCESS != s) { readUtilIface->report_error( "%s: Failed to read file of type \"%s\"", cgm_file_name, file_type ); return MB_FAILURE; } // create entity sets for all geometric entities for (int dim = 0; dim < 4; ++dim) { entlist.clean_out(); GeometryQueryTool::instance()->ref_entity_list( names[dim], entlist, true ); entlist.reset(); for (int i = entlist.size(); i--; ) { RefEntity* ent = entlist.get_and_step(); EntityHandle handle; rval = mdbImpl->create_meshset( dim == 1 ? MESHSET_ORDERED : MESHSET_SET, handle ); if (MB_SUCCESS != rval) return rval; entmap[dim][ent] = handle; rval = mdbImpl->tag_set_data( geom_tag, &handle, 1, &dim ); if (MB_SUCCESS != rval) return rval; int id = ent->id(); rval = mdbImpl->tag_set_data( id_tag, &handle, 1, &id ); if (MB_SUCCESS != rval) return rval; rval = mdbImpl->tag_set_data( category_tag, &handle, 1, &geom_categories[dim] ); if (MB_SUCCESS != rval) return rval; } } // create topology for all geometric entities for (int dim = 1; dim < 4; ++dim) { for (ci = entmap[dim].begin(); ci != entmap[dim].end(); ++ci) { entlist.clean_out(); ci->first->get_child_ref_entities( entlist ); entlist.reset(); for (int i = entlist.size(); i--; ) { RefEntity* ent = entlist.get_and_step(); EntityHandle h = entmap[dim-1][ent]; rval = mdbImpl->add_parent_child( ci->second, h ); if (MB_SUCCESS != rval) return rval; } } } // store CoFace senses for (ci = entmap[2].begin(); ci != entmap[2].end(); ++ci) { RefFace* face = (RefFace*)(ci->first); BasicTopologyEntity *forward = 0, *reverse = 0; for (SenseEntity* cf = face->get_first_sense_entity_ptr(); cf; cf = cf->next_on_bte()) { BasicTopologyEntity* vol = cf->get_parent_basic_topology_entity_ptr(); if (cf->get_sense() == CUBIT_UNKNOWN || cf->get_sense() != face->get_surface_ptr()->bridge_sense()) { if (reverse) { std::cout << "Surface " << face->id() << " has reverse senes " << "with multiple volume " << reverse->id() << " and " << "volume " << vol->id() << std::endl; return MB_FAILURE; } reverse = vol; } if (cf->get_sense() == CUBIT_UNKNOWN || cf->get_sense() == face->get_surface_ptr()->bridge_sense()) { if (forward) { std::cout << "Surface " << face->id() << " has forward senes " << "with multiple volume " << forward->id() << " and " << "volume " << vol->id() << std::endl; return MB_FAILURE; } forward = vol; } } if (forward) { rval = myGeomTool->set_sense( ci->second, entmap[3][forward], SENSE_FORWARD ); if (MB_SUCCESS != rval) return rval; } if (reverse) { rval = myGeomTool->set_sense( ci->second, entmap[3][reverse], SENSE_REVERSE ); if (MB_SUCCESS != rval) return rval; } } // store CoEdge senses std::vector<EntityHandle> ents; std::vector<int> senses; for (ci = entmap[1].begin(); ci != entmap[1].end(); ++ci) { RefEdge* edge = (RefEdge*)(ci->first); ents.clear(); senses.clear(); for (SenseEntity* ce = edge->get_first_sense_entity_ptr(); ce; ce = ce->next_on_bte()) { BasicTopologyEntity* fac = ce->get_parent_basic_topology_entity_ptr(); EntityHandle face = entmap[2][fac]; if (ce->get_sense() == CUBIT_UNKNOWN || ce->get_sense() != edge->get_curve_ptr()->bridge_sense()) { ents.push_back(face); senses.push_back(SENSE_REVERSE); } if (ce->get_sense() == CUBIT_UNKNOWN || ce->get_sense() == edge->get_curve_ptr()->bridge_sense()) { ents.push_back(face); senses.push_back(SENSE_FORWARD); } } rval = myGeomTool->set_senses( ci->second, ents, senses); if (MB_SUCCESS != rval) return rval; } // create entity sets for all ref groups std::vector<Tag> extra_name_tags; #if CGM_MAJOR_VERSION>13 DLIList<CubitString> name_list; #else DLIList<CubitString*> name_list; #endif entlist.clean_out(); GeometryQueryTool::instance()->ref_entity_list( "group", entlist ); entlist.reset(); for (int i = entlist.size(); i--; ) { RefEntity* grp = entlist.get_and_step(); name_list.clean_out(); #if CGM_MAJOR_VERSION>13 RefEntityName::instance()->get_refentity_name(grp, name_list); #else //true argument is optional, but for large multi-names situation, it should save //some cpu time RefEntityName::instance()->get_refentity_name(grp, name_list,true); #endif if (name_list.size() == 0) continue; name_list.reset(); #if CGM_MAJOR_VERSION>13 CubitString name1 = name_list.get(); #else CubitString name1 = *name_list.get(); #endif EntityHandle h; rval = mdbImpl->create_meshset( MESHSET_SET, h ); if (MB_SUCCESS != rval) return rval; char namebuf[NAME_TAG_SIZE]; memset( namebuf, '\0', NAME_TAG_SIZE ); strncpy( namebuf, name1.c_str(), NAME_TAG_SIZE - 1 ); if (name1.length() >= (unsigned)NAME_TAG_SIZE) std::cout << "WARNING: group name '" << name1.c_str() << "' truncated to '" << namebuf << "'" << std::endl; rval = mdbImpl->tag_set_data( name_tag, &h, 1, namebuf ); if (MB_SUCCESS != rval) return MB_FAILURE; int id = grp->id(); rval = mdbImpl->tag_set_data( id_tag, &h, 1, &id ); if (MB_SUCCESS != rval) return MB_FAILURE; rval = mdbImpl->tag_set_data( category_tag, &h, 1, &geom_categories[4] ); if (MB_SUCCESS != rval) return MB_FAILURE; if (name_list.size() > 1) { for (int j = extra_name_tags.size(); j < name_list.size(); ++j) { sprintf( namebuf, "EXTRA_%s%d", NAME_TAG_NAME, j ); Tag t; rval = mdbImpl->tag_get_handle( namebuf, NAME_TAG_SIZE, MB_TYPE_OPAQUE, t, MB_TAG_SPARSE|MB_TAG_CREAT ); assert(!rval); extra_name_tags.push_back(t); } for (int j = 0; j < name_list.size(); ++j) { #if CGM_MAJOR_VERSION>13 name1 = name_list.get_and_step(); #else name1 = *name_list.get_and_step(); #endif memset( namebuf, '\0', NAME_TAG_SIZE ); strncpy( namebuf, name1.c_str(), NAME_TAG_SIZE - 1 ); if (name1.length() >= (unsigned)NAME_TAG_SIZE) std::cout << "WARNING: group name '" << name1.c_str() << "' truncated to '" << namebuf << "'" << std::endl; rval = mdbImpl->tag_set_data( extra_name_tags[j], &h, 1, namebuf ); if (MB_SUCCESS != rval) return MB_FAILURE; } } entmap[4][grp] = h; } // store contents for each group entlist.reset(); for (ci = entmap[4].begin(); ci != entmap[4].end(); ++ci) { RefGroup* grp = (RefGroup*)(ci->first); entlist.clean_out(); grp->get_child_ref_entities( entlist ); Range entities; while (entlist.size()) { RefEntity* ent = entlist.pop(); int dim = ent->dimension(); if (dim < 0) { Body* body; if (entmap[4].find(ent) != entmap[4].end()){ // child is another group; examine its contents entities.insert( entmap[4][ent] ); } else if( (body = dynamic_cast<Body*>(ent)) != NULL ){ // Child is a CGM Body, which presumably comprises some volumes-- // extract volumes as if they belonged to group. DLIList<RefVolume*> vols; body->ref_volumes( vols ); for( int vi = vols.size(); vi--; ){ RefVolume* vol = vols.get_and_step(); if( entmap[3].find(vol) != entmap[3].end() ){ entities.insert( entmap[3][vol] ); } else{ std::cerr << "Warning: CGM Body has orphan RefVolume" << std::endl; } } } else{ // otherwise, warn user. std::cerr << "Warning: A dim<0 entity is being ignored by ReadCGM." << std::endl; } } else if (dim < 4) { if (entmap[dim].find(ent) != entmap[dim].end()) entities.insert( entmap[dim][ent] ); } } if (!entities.empty()) { rval = mdbImpl->add_entities( ci->second, entities ); if (MB_SUCCESS != rval) return MB_FAILURE; } } // done with volumes and groups entmap[3].clear(); entmap[4].clear(); // create geometry for all vertices and replace // vertex set handles with vertex handles in map for (ci = entmap[0].begin(); ci != entmap[0].end(); ++ci) { CubitVector pos = dynamic_cast<RefVertex*>(ci->first)->coordinates(); double coords[3] = {pos.x(), pos.y(), pos.z()}; EntityHandle vh; rval = mdbImpl->create_vertex( coords, vh ); if (MB_SUCCESS != rval) return MB_FAILURE; rval = mdbImpl->add_entities( ci->second, &vh, 1 ); if (MB_SUCCESS != rval) return MB_FAILURE; ci->second = vh; } // maximum allowable curve-endpoint proximity warnings // if this integer becomes negative, then abs(curve_warnings) is the // number of warnings that were suppressed. int curve_warnings = 10; // create geometry for all curves GMem data; for (ci = entmap[1].begin(); ci != entmap[1].end(); ++ci) { RefEdge* edge = dynamic_cast<RefEdge*>(ci->first); Curve* curve = edge->get_curve_ptr(); data.clean_out(); #if CGM_MAJOR_VERSION>12 edge->get_graphics( data, norm_tol, faceting_tol); #else edge->get_graphics( data, faceting_tol); #endif if (CUBIT_SUCCESS != s) return MB_FAILURE; std::vector<CubitVector> points; for (int i = 0; i < data.pointListCount; ++i) points.push_back( CubitVector( data.point_list()[i].x, data.point_list()[i].y, data.point_list()[i].z ) ); // need to reverse data? if (curve->bridge_sense() == CUBIT_REVERSED) std::reverse( points.begin(), points.end() ); // check for closed curve RefVertex *start_vtx, *end_vtx; start_vtx = edge->start_vertex(); end_vtx = edge->end_vertex(); // Special case for point curve if (points.size() < 2) { if (start_vtx != end_vtx || curve->measure() > GEOMETRY_RESABS ) { std::cerr << "Warning: No facetting for curve " << edge->id() << std::endl; continue; } EntityHandle h = entmap[0][start_vtx]; rval = mdbImpl->add_entities( ci->second, &h, 1 ); if (MB_SUCCESS != rval) return MB_FAILURE; continue; } const bool closed = (points.front() - points.back()).length() < GEOMETRY_RESABS; if (closed != (start_vtx == end_vtx)) { std::cerr << "Warning: topology and geometry inconsistant for possibly closed curve " << edge->id() << std::endl; } // check proximity of vertices to end coordinates if ((start_vtx->coordinates() - points.front()).length() > GEOMETRY_RESABS || ( end_vtx->coordinates() - points.back() ).length() > GEOMETRY_RESABS ) { curve_warnings--; if( curve_warnings >= 0 || verbose_warnings ){ std::cerr << "Warning: vertices not at ends of curve " << edge->id() << std::endl; if( curve_warnings == 0 && !verbose_warnings ){ std::cerr << " further instances of this warning will be suppressed..." << std::endl; } } } // create interior points std::vector<EntityHandle> verts, edges; verts.push_back( entmap[0][start_vtx] ); for (size_t i = 1; i < points.size() - 1; ++i) { double coords[] = { points[i].x(), points[i].y(), points[i].z() }; EntityHandle h; rval = mdbImpl->create_vertex( coords, h ); if (MB_SUCCESS != rval) return MB_FAILURE; verts.push_back( h ); } verts.push_back( entmap[0][end_vtx] ); // create edges for (size_t i = 0; i < verts.size()-1; ++i) { EntityHandle h; rval = mdbImpl->create_element( MBEDGE, &verts[i], 2, h ); if (MB_SUCCESS != rval) return MB_FAILURE; edges.push_back( h ); } // if closed, remove duplicate if (verts.front() == verts.back()) verts.pop_back(); rval = mdbImpl->add_entities( ci->second, &verts[0], verts.size() ); if (MB_SUCCESS != rval) return MB_FAILURE; rval = mdbImpl->add_entities( ci->second, &edges[0], edges.size() ); if (MB_SUCCESS != rval) return MB_FAILURE; } if( !verbose_warnings && curve_warnings < 0 ){ std::cerr << "Suppressed " << -curve_warnings << " 'vertices not at ends of curve' warnings." << std::endl; std::cerr << "To see all warnings, use reader param VERBOSE_CGM_WARNINGS." << std::endl; } // create geometry for all surfaces for (ci = entmap[2].begin(); ci != entmap[2].end(); ++ci) { RefFace* face = dynamic_cast<RefFace*>(ci->first); data.clean_out(); s = face->get_graphics( data, norm_tol, faceting_tol, len_tol ); if (CUBIT_SUCCESS != s) return MB_FAILURE; // declare array of all vertex handles std::vector<EntityHandle> verts( data.pointListCount, 0 ); // get list of vertices in surface me_list.clean_out(); ModelQueryEngine::instance()->query_model( *face, DagType::ref_vertex_type(), me_list ); // for each vertex, find coincident point in facets for (int i = me_list.size(); i--; ) { RefVertex* vtx = dynamic_cast<RefVertex*>(me_list.get_and_step()); CubitVector pos = vtx->coordinates(); for (int j = 0; j < data.pointListCount; ++j) { CubitVector vpos( data.point_list()[j].x, data.point_list()[j].y, data.point_list()[j].z ); if ((pos - vpos).length_squared() < GEOMETRY_RESABS*GEOMETRY_RESABS ) { if (verts[j]) std::cerr << "Warning: Coincident vertices in surface " << face->id() << std::endl; verts[j] = entmap[0][vtx]; break; } } } // now create vertices for the remaining points in the facetting for (int i = 0; i < data.pointListCount; ++i) { if (verts[i]) // if a geometric vertex continue; double coords[] = { data.point_list()[i].x, data.point_list()[i].y, data.point_list()[i].z }; rval = mdbImpl->create_vertex( coords, verts[i] ); if (MB_SUCCESS != rval) return rval; } // now create facets Range facets; std::vector<EntityHandle> corners; for (int i = 0; i < data.fListCount; i += data.facet_list()[i]+1) { int* facet = data.facet_list() + i; corners.resize( *facet ); for (int j = 1; j <= *facet; ++j) { if (facet[j] >= (int)verts.size()) { std::cerr << "ERROR: Invalid facet data for surface " << face->id() << std::endl; return MB_FAILURE; } corners[j-1] = verts[facet[j]]; } EntityType type; if (*facet == 3) type = MBTRI; else { std::cerr << "Warning: non-triangle facet in surface " << face->id() << std::endl; std::cerr << " entity has " << *facet << " edges" << std::endl; if (*facet == 4) type = MBQUAD; else type = MBPOLYGON; } // if (surf->bridge_sense() == CUBIT_REVERSED) // std::reverse( corners.begin(), corners.end() ); EntityHandle h; rval = mdbImpl->create_element( type, &corners[0], corners.size(), h ); if (MB_SUCCESS != rval) return MB_FAILURE; facets.insert( h ); } // add vertices and facets to surface set rval = mdbImpl->add_entities( ci->second, &verts[0], verts.size() ); if (MB_SUCCESS != rval) return MB_FAILURE; rval = mdbImpl->add_entities( ci->second, facets ); if (MB_SUCCESS != rval) return MB_FAILURE; } return MB_SUCCESS; }
ErrorCode moab::ReadCGM::read_tag_values | ( | const char * | file_name, |
const char * | tag_name, | ||
const FileOptions & | opts, | ||
std::vector< int > & | tag_values_out, | ||
const SubsetList * | subset_list = 0 |
||
) | [virtual] |
Read tag values from a file.
Read the list if all integer tag values from the file for a tag that is a single integer value per entity.
file_name | The file to read. |
tag_name | The tag for which to read values |
tag_values_out | Output: The list of tag values. |
subset_list | An array of tag name and value sets specifying the subset of the file to read. If multiple tags are specified, the sets that match all tags (intersection) should be read. |
subset_list_length | The length of the 'subset_list' array. |
Implements moab::ReaderIface.
Definition at line 108 of file ReadCGM.cpp.
{ return MB_NOT_IMPLEMENTED; }
void moab::ReadCGM::tokenize | ( | const std::string & | str, |
std::vector< std::string > & | tokens, | ||
const char * | delimiters | ||
) |
Definition at line 777 of file ReadCGM.cpp.
{ std::string::size_type last = str.find_first_not_of( delimiters, 0 ); std::string::size_type pos = str.find_first_of( delimiters, last ); while (std::string::npos != pos && std::string::npos != last) { tokens.push_back( str.substr( last, pos - last ) ); last = str.find_first_not_of( delimiters, pos ); pos = str.find_first_of( delimiters, last ); if(std::string::npos == pos) pos = str.size(); } }
Tag moab::ReadCGM::category_tag [private] |
Definition at line 101 of file ReadCGM.hpp.
Tag moab::ReadCGM::faceting_tol_tag [private] |
Definition at line 101 of file ReadCGM.hpp.
Tag moab::ReadCGM::geom_tag [private] |
Definition at line 101 of file ReadCGM.hpp.
Tag moab::ReadCGM::geometry_resabs_tag [private] |
Definition at line 101 of file ReadCGM.hpp.
Tag moab::ReadCGM::id_tag [private] |
Definition at line 101 of file ReadCGM.hpp.
Interface* moab::ReadCGM::mdbImpl [private] |
interface instance
Definition at line 99 of file ReadCGM.hpp.
GeomTopoTool* moab::ReadCGM::myGeomTool [private] |
Definition at line 83 of file ReadCGM.hpp.
Tag moab::ReadCGM::name_tag [private] |
Definition at line 101 of file ReadCGM.hpp.
ReadUtilIface* moab::ReadCGM::readUtilIface [private] |
Definition at line 81 of file ReadCGM.hpp.