[MOAB-dev] r3324 - MOAB/trunk
sjackson at cae.wisc.edu
sjackson at cae.wisc.edu
Tue Nov 10 17:14:13 CST 2009
Author: sjackson
Date: 2009-11-10 17:14:13 -0600 (Tue, 10 Nov 2009)
New Revision: 3324
Modified:
MOAB/trunk/ReadCGM.cpp
Log:
Teach CGM reader to handle Body objects within RefGroups.
Modified: MOAB/trunk/ReadCGM.cpp
===================================================================
--- MOAB/trunk/ReadCGM.cpp 2009-11-10 22:50:22 UTC (rev 3323)
+++ MOAB/trunk/ReadCGM.cpp 2009-11-10 23:14:13 UTC (rev 3324)
@@ -30,6 +30,7 @@
#include "SenseEntity.hpp"
#include "Surface.hpp"
#include "Curve.hpp"
+#include "Body.hpp"
#include "InitCGMA.hpp"
#include "MBCore.hpp"
@@ -356,9 +357,34 @@
while (entlist.size()) {
RefEntity* ent = entlist.pop();
int dim = ent->dimension();
+
if (dim < 0) {
- if (entmap[4].find(ent) != entmap[4].end())
- entities.insert( entmap[4][ent] );
+
+ 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())
More information about the moab-dev
mailing list