[cgma-dev] r1367 - cgm/trunk/geom/OCC

janehu at mcs.anl.gov janehu at mcs.anl.gov
Thu Nov 8 12:34:10 CST 2007


Author: janehu
Date: 2007-11-08 12:34:04 -0600 (Thu, 08 Nov 2007)
New Revision: 1367

Modified:
   cgm/trunk/geom/OCC/OCCBody.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.hpp
Log:
Updated populate_topology_bridge for TopoDS_Shape, it's intended for TopoDS_Compound or TopoDS_CompSolid type objects. Each TopoDS_Solid will populate a lump and corresponding to a body; Added in update_bounding_box for OCCBody if when only lump_list is known.

Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp	2007-11-08 17:02:15 UTC (rev 1366)
+++ cgm/trunk/geom/OCC/OCCBody.cpp	2007-11-08 18:34:04 UTC (rev 1367)
@@ -61,6 +61,11 @@
   update_bounding_box();
 }
 
+OCCBody::OCCBody(DLIList<Lump*>& my_lumps)
+{
+  myLumps += my_lumps;
+}
+
 OCCBody::~OCCBody() 
 {
     //Not sure what to do..
@@ -231,16 +236,24 @@
 void OCCBody::update_bounding_box() 
 {
   Bnd_Box box;
-  const TopoDS_Shape shape=*myTopoDSShape;
-  //calculate the bounding box
-  BRepBndLib::Add(shape, box);
-  double min[3], max[3];
+  if (myTopoDSShape)
+  {
+    const TopoDS_Shape shape=*myTopoDSShape;
+    //calculate the bounding box
+    BRepBndLib::Add(shape, box);
+    double min[3], max[3];
   
-  //get values
-  box.Get(min[0], min[1], min[2], max[0], max[1], max[2]);
+    //get values
+    box.Get(min[0], min[1], min[2], max[0], max[1], max[2]);
 
-  //update boundingbox.
-  CubitBox cBox(min, max);
+    //update boundingbox.
+    CubitBox cBox(min, max);
+    boundingbox = cBox;
+    return;
+  }
+  CubitBox cBox;
+  for(int i = myLumps.size();i > 0; i--)
+    cBox |= myLumps.get_and_step()->bounding_box();  
   boundingbox = cBox;
 }
 

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2007-11-08 17:02:15 UTC (rev 1366)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2007-11-08 18:34:04 UTC (rev 1367)
@@ -1307,59 +1307,55 @@
   return CUBIT_SUCCESS;
 }
 
-BodySM* OCCQueryEngine::populate_topology_bridge(TopoDS_Shape aShape)
+void OCCQueryEngine::populate_topology_bridge(TopoDS_Shape aShape)
 {
-        TopoDS_Shape *poshape =  new TopoDS_Shape;
-        *poshape = aShape;
-        BodySM *body;
-        if (!OCCMap->IsBound(*poshape))
-        {
-                printf("Adding Shape\n");
-                iTotalTBCreated++;
-                body = new OCCBody(poshape);
-//              CGMList->append(lump);
-//              imported_entities.append(lump);
-                OCCMap->Bind(*poshape, iTotalTBCreated);
-                OccToCGM->insert(valType(iTotalTBCreated,
-                                (TopologyBridge*)body));
-        }
-        else
-        {
-                int k = OCCMap->Find(*poshape);
-                body = (OCCBody*)(OccToCGM->find(k))->second;
-        }
+        // suitable to popolate for a TopoDS_CompSolid or TopoDS_Compound shape.
         TopExp_Explorer Ex;
-
         for (Ex.Init(aShape, TopAbs_SOLID); Ex.More(); Ex.Next())
-                populate_topology_bridge(TopoDS::Solid(Ex.Current()));
-        return body;
+		populate_topology_bridge(TopoDS::Solid(Ex.Current()));
+
+	for (Ex.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); Ex.More(); Ex.Next())
+                populate_topology_bridge(TopoDS::Shell(Ex.Current()));
+
+        for (Ex.Init(aShape, TopAbs_FACE, TopAbs_SHELL); Ex.More(); Ex.Next())
+                populate_topology_bridge(TopoDS::Face(Ex.Current()));
+
+	for (Ex.Init(aShape, TopAbs_WIRE, TopAbs_FACE); Ex.More(); Ex.Next())
+                populate_topology_bridge(TopoDS::Wire(Ex.Current()));
+
+	for (Ex.Init(aShape, TopAbs_EDGE, TopAbs_WIRE); Ex.More(); Ex.Next())
+                populate_topology_bridge(TopoDS::Edge(Ex.Current()));
+
+	for (Ex.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); Ex.More(); Ex.Next())
+                populate_topology_bridge(TopoDS::Vertex(Ex.Current()));
 }
 
-Lump* OCCQueryEngine::populate_topology_bridge(TopoDS_Solid aShape)
+BodySM* OCCQueryEngine::populate_topology_bridge(TopoDS_Solid aShape)
 {
+	//one OCCBody corresponds one OCCLump
 	TopoDS_Solid *posolid =  new TopoDS_Solid;
  	*posolid = aShape;
 	OCCLump *lump;
+        OCCBody *body;
 	if (!OCCMap->IsBound(*posolid))
  	{
 		printf("Adding solid\n");
                 iTotalTBCreated++;
 		lump = new OCCLump(posolid);
-//		CGMList->append(lump);
-//		imported_entities.append(lump);
+		body = new OCCBody(posolid);
 		OCCMap->Bind(*posolid, iTotalTBCreated);
                 OccToCGM->insert(valType(iTotalTBCreated,
-				(TopologyBridge*)lump));
+				(TopologyBridge*)body));
 	}
 	else 
 	{
 		int k = OCCMap->Find(*posolid);
-		lump = (OCCLump*)(OccToCGM->find(k))->second;
+		body = (OCCBody*)(OccToCGM->find(k))->second;
 	}
 	TopExp_Explorer Ex;
         for (Ex.Init(aShape, TopAbs_SHELL); Ex.More(); Ex.Next())
                 populate_topology_bridge(TopoDS::Shell(Ex.Current()));
-	return lump;
+	return body;
 }
 
 OCCShell* OCCQueryEngine::populate_topology_bridge(TopoDS_Shell aShape)

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2007-11-08 17:02:15 UTC (rev 1366)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2007-11-08 18:34:04 UTC (rev 1367)
@@ -320,8 +320,8 @@
   
   virtual CubitBoolean volumes_overlap (Lump *lump1, Lump *lump2 ) const ;
 
-  BodySM* populate_topology_bridge(TopoDS_Shape aShape);
-  Lump* populate_topology_bridge(TopoDS_Solid aShape);
+  void populate_topology_bridge(TopoDS_Shape aShape);
+  BodySM* populate_topology_bridge(TopoDS_Solid aShape);
   Surface* populate_topology_bridge(TopoDS_Face aShape);
   Curve* populate_topology_bridge(TopoDS_Edge aShape);
   Point* populate_topology_bridge(TopoDS_Vertex aShape);




More information about the cgma-dev mailing list