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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Tue Nov 27 13:13:54 CST 2007


Author: janehu
Date: 2007-11-27 13:13:54 -0600 (Tue, 27 Nov 2007)
New Revision: 1424

Modified:
   cgm/trunk/geom/OCC/OCCBody.cpp
   cgm/trunk/geom/OCC/OCCBody.hpp
   cgm/trunk/geom/OCC/OCCCurve.hpp
   cgm/trunk/geom/OCC/OCCLump.cpp
   cgm/trunk/geom/OCC/OCCLump.hpp
   cgm/trunk/geom/OCC/OCCPoint.hpp
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.hpp
   cgm/trunk/geom/OCC/OCCSurface.hpp
Log:
updated for populate_topology_bridge for CompSolid type, and correponding other changes

Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp	2007-11-27 15:53:56 UTC (rev 1423)
+++ cgm/trunk/geom/OCC/OCCBody.cpp	2007-11-27 19:13:54 UTC (rev 1424)
@@ -60,18 +60,15 @@
 OCCBody::OCCBody(TopoDS_CompSolid *theShape)
 {
   myTopoDSShape = theShape;
-  TopExp_Explorer Ex;
-  for (Ex.Init(*theShape, TopAbs_SOLID); Ex.More(); Ex.Next())
-  {
-     TopoDS_Solid *posolid = new TopoDS_Solid;
-     *posolid = TopoDS::Solid(Ex.Current());
-     OCCLump *lump = new OCCLump(posolid);
-     myLumps.append(lump);
-  }
   
   update_bounding_box();
 }
 
+void OCCBody::lumps(DLIList<Lump*>& my_lumps)
+{
+  myLumps += my_lumps;
+}
+
 OCCBody::OCCBody(DLIList<Lump*>& my_lumps)
 {
   myLumps += my_lumps;

Modified: cgm/trunk/geom/OCC/OCCBody.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.hpp	2007-11-27 15:53:56 UTC (rev 1423)
+++ cgm/trunk/geom/OCC/OCCBody.hpp	2007-11-27 19:13:54 UTC (rev 1424)
@@ -47,6 +47,8 @@
   
   OCCBody(TopoDS_CompSolid *theShape);
   OCCBody(DLIList<Lump*>& my_lumps);
+  void lumps(DLIList<Lump*>& my_lumps); //add lump list to myLumps
+  DLIList<Lump*> lumps(){return myLumps;} 
 
   virtual ~OCCBody() ;
     //- The destructor.
@@ -169,8 +171,8 @@
   CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
     // Read FactAttribs from file
 
-  void get_parents_virt( DLIList<TopologyBridge*>& parents );
-  void get_children_virt( DLIList<TopologyBridge*>& children );
+  virtual void get_parents_virt( DLIList<TopologyBridge*>& parents );
+  virtual void get_children_virt( DLIList<TopologyBridge*>& children );
   
   void disconnect_all_lumps();
 

Modified: cgm/trunk/geom/OCC/OCCCurve.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.hpp	2007-11-27 15:53:56 UTC (rev 1423)
+++ cgm/trunk/geom/OCC/OCCCurve.hpp	2007-11-27 19:13:54 UTC (rev 1424)
@@ -307,8 +307,8 @@
   CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
     // Read FactAttribs from file
   
-  void get_parents_virt( DLIList<TopologyBridge*>& parents );
-  void get_children_virt( DLIList<TopologyBridge*>& children );
+  virtual void get_parents_virt( DLIList<TopologyBridge*>& parents );
+  virtual void get_children_virt( DLIList<TopologyBridge*>& children );
 
   void get_points(DLIList<OCCPoint*>& point_list);
     //- Gets the list of points describing this curve.

Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp	2007-11-27 15:53:56 UTC (rev 1423)
+++ cgm/trunk/geom/OCC/OCCLump.cpp	2007-11-27 19:13:54 UTC (rev 1424)
@@ -39,6 +39,8 @@
 #include <TopTools_IndexedMapOfShape.hxx>
 #include "Bnd_Box.hxx"
 #include "BRepBndLib.hxx"
+#include "GProp_GProps.hxx"
+#include "BRepGProp.hxx"
 // ********** END CUBIT INCLUDES           **********
 
 // ********** BEGIN FORWARD DECLARATIONS   **********
@@ -185,51 +187,11 @@
 //-------------------------------------------------------------------------
 double OCCLump::measure()
 {
-  DLIList<CubitFacet*> bounding_facets;
-  DLIList<CubitPoint*> bounding_points;
-  DLIList<OCCSurface*> surfaces;
-  Surface *curr_surface;
-  OCCSurface *facet_surface;
-  
-  int ii;
-  get_surfaces(surfaces);
-  if (surfaces.size() > 0)
-  { 
-    for ( ii = surfaces.size(); ii > 0; ii-- )
-    {
-      curr_surface = surfaces.get_and_step();
-      facet_surface = CAST_TO(curr_surface, OCCSurface);
-      if ( facet_surface == NULL )
-      {
-        PRINT_ERROR("Facet lump has surfaces that aren't facets?");
-        return 1;
-      }
-      //facet_surface->get_my_facets(bounding_facets, bounding_points);
-    }
-  }
-  double volume, curr_facet_area, summation = 0.0;
-  CubitFacet *curr_facet;
-  CubitVector normal_of_curr_facet, vector_of_point;
-  CubitPoint *point_1, *point_2, *point_3;
-
-  for( int jj = bounding_facets.size(); jj > 0; jj-- )
-  {
-    curr_facet = bounding_facets.get_and_step();
-    curr_facet_area = curr_facet->area();  // Current facet's area
-    
-    normal_of_curr_facet = curr_facet->normal(); // Current facet's normal
-
-    curr_facet->points(point_1, point_2, point_3); // Current facet's points
-
-    vector_of_point = point_1->coordinates(); // One point's vector
-
-    summation += ( double(vector_of_point % normal_of_curr_facet) * curr_facet_area);
-  }
-
-  volume = summation / 3;
-  
-  return volume;
+  GProp_GProps myProps;
+  BRepGProp::VolumeProperties(*myTopoDSSolid, myProps);
+  return myProps.Mass();
 }
+
 void OCCLump::get_parents_virt(DLIList<TopologyBridge*> &bodies) 
 {
   if (myBodyPtr != NULL )

Modified: cgm/trunk/geom/OCC/OCCLump.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.hpp	2007-11-27 15:53:56 UTC (rev 1423)
+++ cgm/trunk/geom/OCC/OCCLump.hpp	2007-11-27 19:13:54 UTC (rev 1424)
@@ -137,8 +137,8 @@
   CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
     // Read FactAttribs from file
   
-  void get_parents_virt( DLIList<TopologyBridge*>& parents );
-  void get_children_virt( DLIList<TopologyBridge*>& children );
+  virtual void get_parents_virt( DLIList<TopologyBridge*>& parents );
+  virtual void get_children_virt( DLIList<TopologyBridge*>& children );
 
   inline BodySM* get_body() const { return myBodyPtr; }
     

Modified: cgm/trunk/geom/OCC/OCCPoint.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.hpp	2007-11-27 15:53:56 UTC (rev 1423)
+++ cgm/trunk/geom/OCC/OCCPoint.hpp	2007-11-27 19:13:54 UTC (rev 1424)
@@ -125,8 +125,8 @@
     //- This function returns a pointer to the geometric modeling engine
     //- associated with the object.
   
-  void get_parents_virt( DLIList<TopologyBridge*>& parents );
-  void get_children_virt( DLIList<TopologyBridge*>& children );
+  virtual void get_parents_virt( DLIList<TopologyBridge*>& parents );
+  virtual void get_children_virt( DLIList<TopologyBridge*>& children );
 
   CubitStatus save_attribs( FILE *file_ptr );
 

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2007-11-27 15:53:56 UTC (rev 1423)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2007-11-27 19:13:54 UTC (rev 1424)
@@ -991,9 +991,12 @@
 	DLIList<TopologyBridge*> tblist;
         // suitable to popolate for a TopoDS_CompSolid or TopoDS_Compound shape.
         TopExp_Explorer Ex;
-        for (Ex.Init(aShape, TopAbs_SOLID); Ex.More(); Ex.Next())
- 	  tblist.append(populate_topology_bridge(TopoDS::Solid(Ex.Current())));
+        for (Ex.Init(aShape, TopAbs_COMPSOLID); Ex.More(); Ex.Next())
+          tblist.append(populate_topology_bridge(TopoDS::Solid(Ex.Current())));
 
+        for (Ex.Init(aShape, TopAbs_SOLID, TopAbs_COMPSOLID); Ex.More(); Ex.Next())
+ 	  tblist.append(populate_topology_bridge(TopoDS::Solid(Ex.Current()), CUBIT_TRUE));
+
 	for (Ex.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); Ex.More(); Ex.Next())
           tblist.append(populate_topology_bridge(TopoDS::Shell(Ex.Current())));
 
@@ -1011,8 +1014,40 @@
 	return tblist;
 }
 
-BodySM* OCCQueryEngine::populate_topology_bridge(TopoDS_Solid aShape)
+BodySM* OCCQueryEngine::populate_topology_bridge(TopoDS_CompSolid aShape)
 {
+        TopoDS_CompSolid *posolid =  new TopoDS_CompSolid;
+        *posolid = aShape;
+        OCCBody *body;
+        if (!OCCMap->IsBound(*posolid))
+        {
+                if(PRINT_RESULT)
+                        PRINT_INFO("Adding Bodies.\n");
+                iTotalTBCreated++;
+                body = new OCCBody(posolid);
+                OCCMap->Bind(*posolid, iTotalTBCreated);
+                OccToCGM->insert(valType(iTotalTBCreated,
+                                (TopologyBridge*)body));
+        }
+        else
+        {
+                int k = OCCMap->Find(*posolid);
+                body = (OCCBody*)(OccToCGM->find(k))->second;
+        }
+        TopExp_Explorer Ex;
+        DLIList<Lump*> lumps;
+        for (Ex.Init(aShape, TopAbs_SOLID); Ex.More(); Ex.Next())
+        {
+           Lump* lump = populate_topology_bridge(TopoDS::Solid(Ex.Current()));
+  	   lumps.append(lump);
+	}
+	body->lumps(lumps);
+        return body;
+}
+
+Lump* OCCQueryEngine::populate_topology_bridge(TopoDS_Solid aShape,
+						 CubitBoolean build_body)
+{
 	//one OCCBody corresponds one OCCLump
 	TopoDS_Solid *posolid =  new TopoDS_Solid;
  	*posolid = aShape;
@@ -1024,22 +1059,25 @@
 			PRINT_INFO("Adding solids.\n");
                 iTotalTBCreated++;
 		lump = new OCCLump(posolid);
-                DLIList<Lump*> lumps;
-		lumps.append(lump);
-		body = new OCCBody(lumps);
+   		if (build_body)
+		{
+                   DLIList<Lump*> lumps;
+		   lumps.append(lump);
+		   body = new OCCBody(lumps);
+		}
 		OCCMap->Bind(*posolid, iTotalTBCreated);
                 OccToCGM->insert(valType(iTotalTBCreated,
-				(TopologyBridge*)body));
+				(TopologyBridge*)lump));
 	}
 	else 
 	{
 		int k = OCCMap->Find(*posolid);
-		body = (OCCBody*)(OccToCGM->find(k))->second;
+		lump = (OCCLump*)(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 body;
+	return lump;
 }
 
 OCCShell* OCCQueryEngine::populate_topology_bridge(TopoDS_Shell aShape)

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2007-11-27 15:53:56 UTC (rev 1423)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2007-11-27 19:13:54 UTC (rev 1424)
@@ -44,7 +44,6 @@
 class ShellSM;
 class Loop;
 class Chain;
-class CoEdgeSM;
 class LoopSM;
 class RefVolume;
 class RefFace;
@@ -58,10 +57,8 @@
 
 class GeometryEntity;
 class BodySM;
-class Lump;
 class ShellSM;
 class Surface;
-class LoopSM;
 class Curve;
 class CoEdgeSM;
 class Point;
@@ -87,6 +84,7 @@
 class TopoDS_Face;
 class TopoDS_Solid;
 class TopoDS_Shell;
+class TopoDS_CompSolid;
 // ********** END FORWARD DECLARATIONS        **********
 
 // ********** BEGIN MACRO DEFINITIONS         **********
@@ -321,7 +319,9 @@
   virtual CubitBoolean volumes_overlap (Lump *lump1, Lump *lump2 ) const ;
 
   DLIList<TopologyBridge*> populate_topology_bridge(TopoDS_Shape aShape);
-  BodySM* populate_topology_bridge(TopoDS_Solid aShape);
+  BodySM* populate_topology_bridge(TopoDS_CompSolid aShape);
+  Lump* populate_topology_bridge(TopoDS_Solid aShape, 
+				   CubitBoolean build_body = CUBIT_FALSE);
   Surface* populate_topology_bridge(TopoDS_Face aShape);
   Curve* populate_topology_bridge(TopoDS_Edge aShape);
   Point* populate_topology_bridge(TopoDS_Vertex aShape);

Modified: cgm/trunk/geom/OCC/OCCSurface.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.hpp	2007-11-27 15:53:56 UTC (rev 1423)
+++ cgm/trunk/geom/OCC/OCCSurface.hpp	2007-11-27 19:13:54 UTC (rev 1424)
@@ -376,8 +376,8 @@
   CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
     // Read FactAttribs from file
   
-  void get_parents_virt( DLIList<TopologyBridge*>& parents );
-  void get_children_virt( DLIList<TopologyBridge*>& children );
+  virtual void get_parents_virt( DLIList<TopologyBridge*>& parents );
+  virtual void get_children_virt( DLIList<TopologyBridge*>& children );
 
   CubitBoolean is_flat();     //// Not in SurfaceACIS
   CubitBoolean is_spherical(); //// Not in SurfaceACIS




More information about the cgma-dev mailing list