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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Thu Dec 6 13:00:43 CST 2007


Author: janehu
Date: 2007-12-06 13:00:43 -0600 (Thu, 06 Dec 2007)
New Revision: 1440

Modified:
   cgm/trunk/geom/OCC/OCCBody.hpp
   cgm/trunk/geom/OCC/OCCCurve.hpp
   cgm/trunk/geom/OCC/OCCLoop.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/OCCShell.cpp
   cgm/trunk/geom/OCC/OCCShell.hpp
   cgm/trunk/geom/OCC/OCCSurface.cpp
   cgm/trunk/geom/OCC/OCCSurface.hpp
Log:
Added mass_property for lump; Added geometry_type for Surface; Removed reverse_sence for surface; Added set_TopoDS_** for all types, this is because the translate call for OCC is sometimes 'applied to a duplicate of S' which can be accessed using Shape(). Testing on this part is not successful yet.

Modified: cgm/trunk/geom/OCC/OCCBody.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.hpp	2007-12-05 19:09:43 UTC (rev 1439)
+++ cgm/trunk/geom/OCC/OCCBody.hpp	2007-12-06 19:00:43 UTC (rev 1440)
@@ -61,6 +61,7 @@
     //- associated with the object.
   
   TopoDS_CompSolid *get_TopoDS_Shape() {return myTopoDSShape; }
+  void set_TopoDS_Shape( TopoDS_CompSolid shape){*myTopoDSShape = shape;}
 
   virtual CubitStatus get_transforms( CubitTransformMatrix &tfm );
   //R CubitStatus

Modified: cgm/trunk/geom/OCC/OCCCurve.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.hpp	2007-12-05 19:09:43 UTC (rev 1439)
+++ cgm/trunk/geom/OCC/OCCCurve.hpp	2007-12-06 19:00:43 UTC (rev 1440)
@@ -318,6 +318,7 @@
 
   TopoDS_Edge *get_TopoDS_Edge( )
     { return myTopoDSEdge; } 
+  void set_TopoDS_Edge(TopoDS_Edge edge){*myTopoDSEdge = edge;}
 
 protected: 
   

Modified: cgm/trunk/geom/OCC/OCCLoop.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLoop.hpp	2007-12-05 19:09:43 UTC (rev 1439)
+++ cgm/trunk/geom/OCC/OCCLoop.hpp	2007-12-06 19:00:43 UTC (rev 1440)
@@ -45,6 +45,7 @@
   void disconnect_all_curves();
 
   inline TopoDS_Wire* get_TopoDS_Wire() {return myTopoDSWire;}
+  void set_TopoDS_Wire(TopoDS_Wire loop){ *myTopoDSWire = loop;}
 
   virtual ~OCCLoop() ;
     //- The destructor

Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp	2007-12-05 19:09:43 UTC (rev 1439)
+++ cgm/trunk/geom/OCC/OCCLump.cpp	2007-12-06 19:00:43 UTC (rev 1440)
@@ -71,6 +71,27 @@
 {}
 
 //-------------------------------------------------------------------------
+// Purpose       : Find centroid
+//
+// Special Notes :
+//
+// Author       : Jane Hu
+//
+// Creation Date : 12/06/07
+//-------------------------------------------------------------------------
+CubitStatus OCCLump::mass_properties( CubitVector& centroid,
+                                      double& volume )
+{
+  GProp_GProps myProps;
+  BRepGProp::VolumeProperties(*myTopoDSSolid, myProps);
+  volume = myProps.Mass();
+  gp_Pnt pt = myProps.CentreOfMass();
+  centroid.set(pt.X(), pt.Y(), pt.Z());
+
+  return CUBIT_SUCCESS;
+}
+
+//-------------------------------------------------------------------------
 // Purpose       : The purpose of this function is to append a
 //                 attribute to the GE. The name is attached to the 
 //                 underlying solid model entity this one points to.

Modified: cgm/trunk/geom/OCC/OCCLump.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.hpp	2007-12-05 19:09:43 UTC (rev 1439)
+++ cgm/trunk/geom/OCC/OCCLump.hpp	2007-12-06 19:00:43 UTC (rev 1440)
@@ -54,6 +54,7 @@
     {myBodyPtr = new_body;}
     
   TopoDS_Solid *get_TopoDS_Solid(){ return myTopoDSSolid; }
+  void set_TopoDS_Solid(TopoDS_Solid solid) {*myTopoDSSolid = solid;}
 
   virtual void append_simple_attribute_virt(CubitSimpleAttrib*);
     //R void

Modified: cgm/trunk/geom/OCC/OCCPoint.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.hpp	2007-12-05 19:09:43 UTC (rev 1439)
+++ cgm/trunk/geom/OCC/OCCPoint.hpp	2007-12-06 19:00:43 UTC (rev 1440)
@@ -63,6 +63,7 @@
     //- The destructor
 
   TopoDS_Vertex *get_TopoDS_Vertex(){return myTopoDSVertex; }
+  void set_TopoDS_Vertex(TopoDS_Vertex vertex){*myTopoDSVertex = vertex;}
 
   virtual void append_simple_attribute_virt(CubitSimpleAttrib*);
     //R void

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2007-12-05 19:09:43 UTC (rev 1439)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2007-12-06 19:00:43 UTC (rev 1440)
@@ -109,17 +109,9 @@
 const int OCCQueryEngine::OCCQE_MINOR_VERSION = 2;
 const int OCCQueryEngine::OCCQE_SUBMINOR_VERSION = 0;
 
-TopTools_DataMapOfShapeInteger *OCCMap = new TopTools_DataMapOfShapeInteger;
-
-std::map<int, TopologyBridge*>* OccToCGM = new std::map<int, TopologyBridge*>;
-
-DLIList<OCCBody*> *BodyList = new DLIList<OCCBody*>;
-DLIList<OCCSurface*> *SurfaceList = new DLIList<OCCSurface*>;
-DLIList<OCCCurve*> *CurveList = new DLIList<OCCCurve*>;
-
 typedef std::map<int, TopologyBridge*>::value_type valType;
-int iTotalTBCreated = 0;
-CubitBoolean *PRINT_RESULT = CUBIT_FALSE;
+int OCCQueryEngine::iTotalTBCreated = 0;
+CubitBoolean OCCQueryEngine::PRINT_RESULT = CUBIT_FALSE;
 //================================================================================
 // Description:
 // Author     :
@@ -141,6 +133,12 @@
 OCCQueryEngine::OCCQueryEngine()
 {
   GeometryQueryTool::instance()->add_gqe( this );
+  OCCMap = new TopTools_DataMapOfShapeInteger;
+  OccToCGM = new std::map<int, TopologyBridge*>;
+
+  BodyList = new DLIList<OCCBody*>;
+  SurfaceList = new DLIList<OCCSurface*>;
+  CurveList = new DLIList<OCCCurve*>;
 }
 
 //================================================================================
@@ -998,7 +996,7 @@
   BRep_Builder aBuilder;
   Standard_Boolean result = BRepTools::Read(*aShape, (char*) file_name, aBuilder);
   if (result==0) return CUBIT_FAILURE;
-  *PRINT_RESULT = print_results;
+  PRINT_RESULT = print_results;
   
   imported_entities = populate_topology_bridge(*aShape);
   return CUBIT_SUCCESS;
@@ -1039,7 +1037,7 @@
   OCCBody *body;
   if (!OCCMap->IsBound(*posolid))
     {
-      if(*PRINT_RESULT)
+      if(PRINT_RESULT)
 	PRINT_INFO("Adding Bodies.\n");
       (iTotalTBCreated)++;
       body = new OCCBody(posolid);
@@ -1075,7 +1073,7 @@
   OCCBody *body;
   if (!OCCMap->IsBound(*posolid))
     {
-      if(*PRINT_RESULT)
+      if(PRINT_RESULT)
 	PRINT_INFO("Adding solids.\n");
       iTotalTBCreated++;
       lump = new OCCLump(posolid);
@@ -1109,7 +1107,7 @@
   OCCShell *shell ;
   if (!OCCMap->IsBound(*poshell))
     {
-      if(*PRINT_RESULT)
+      if(PRINT_RESULT)
 	PRINT_INFO("Adding shells.\n");
       iTotalTBCreated++;
       shell = new OCCShell(poshell);
@@ -1136,7 +1134,7 @@
   OCCSurface *surface;
   if (!OCCMap->IsBound(*poface))
     {
-      if(*PRINT_RESULT)
+      if(PRINT_RESULT)
 	PRINT_INFO("Adding faces.\n");
       iTotalTBCreated++;
       surface = new OCCSurface(poface);
@@ -1165,7 +1163,7 @@
   OCCLoop *loop ;
   if (!OCCMap->IsBound(*powire))
     {
-      if(*PRINT_RESULT)
+      if(PRINT_RESULT)
 	PRINT_INFO("Adding loops.\n");
       iTotalTBCreated++;
       loop = new OCCLoop(powire);
@@ -1202,7 +1200,7 @@
   *poedge = aShape;
   if (!OCCMap->IsBound(*poedge)) 
     {
-      if(*PRINT_RESULT)
+      if(PRINT_RESULT)
 	PRINT_INFO("Adding edges.\n");
       iTotalTBCreated++;
       curve = new OCCCurve(poedge);
@@ -1228,9 +1226,9 @@
   OCCPoint *point;
   TopoDS_Vertex *povertex = new TopoDS_Vertex;
   *povertex = aShape;
-  if (!OCCMap->IsBound(*povertex)) 
+  if (iTotalTBCreated == 0 || !OCCMap->IsBound(*povertex)) 
     {
-      if(*PRINT_RESULT)
+      if(PRINT_RESULT)
 	PRINT_INFO("Adding vertices.\n");
       iTotalTBCreated++;
       point = new OCCPoint(povertex);
@@ -1746,10 +1744,85 @@
   gp_Trsf aTrsf;  
   aTrsf.SetTranslation(aVec);
 
-  BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
+  BRepBuilderAPI_Transform aBRepTrsf( aTrsf);
+  aBRepTrsf.Perform(*shape);
+  TopoDS_Shape translated_shape = aBRepTrsf.Shape();
+  
+  update_entity_shape(entity, &translated_shape);
   return CUBIT_SUCCESS;
 }
 
+CubitStatus OCCQueryEngine::update_entity_shape(GeometryEntity* entity_ptr,
+						TopoDS_Shape *shape)
+{
+  if (OCCBody *body_ptr = CAST_TO( entity_ptr, OCCBody))
+    {
+      TopoDS_CompSolid* theShape = (TopoDS_CompSolid*) shape;
+      if (!theShape)
+        {
+          PRINT_ERROR("Entity and TopoDS_Shape don't match.\n" );
+          return CUBIT_FAILURE;
+        }
+      body_ptr->set_TopoDS_Shape(*theShape);
+      return CUBIT_SUCCESS;
+    }
+
+  else if (OCCLump * lump_ptr = CAST_TO( entity_ptr,OCCLump))
+    {
+      TopoDS_Solid * theSolid = (TopoDS_Solid *) shape;
+      if(theSolid)
+        {
+	  lump_ptr->set_TopoDS_Solid(*theSolid);
+          return CUBIT_SUCCESS;
+        }
+      else
+        {
+          PRINT_ERROR("Entity and TopoDS_Shape don't match.\n" );
+          return CUBIT_FAILURE;
+        }
+    }
+
+  else if( OCCSurface *surface_ptr = CAST_TO( entity_ptr, OCCSurface))
+    {
+      TopoDS_Face *theFace = (TopoDS_Face *)shape;
+      if(!theFace)
+        {
+          PRINT_ERROR("Entity and TopoDS_Shape don't match.\n" );
+          return CUBIT_FAILURE;
+        }
+
+      surface_ptr->set_TopoDS_Face(*theFace);
+      return CUBIT_SUCCESS;
+    }
+
+  else if( OCCCurve *curve_ptr = CAST_TO( entity_ptr, OCCCurve))
+    {
+      TopoDS_Edge *theEdge = (TopoDS_Edge *) shape;
+      if (!theEdge)
+        {
+          PRINT_ERROR("Entity and TopoDS_Shape don't match.\n" );
+          return CUBIT_FAILURE;
+        }
+       curve_ptr->set_TopoDS_Edge(*theEdge); 
+       return CUBIT_SUCCESS;
+    }
+
+  else if( OCCPoint *point_ptr = CAST_TO( entity_ptr, OCCPoint))
+    {
+      TopoDS_Vertex *thePoint = (TopoDS_Vertex*) shape;
+      if (!thePoint)
+        {           
+          PRINT_ERROR("Entity and TopoDS_Shape don't match.\n" );
+          return CUBIT_FAILURE;
+        }
+
+      point_ptr->set_TopoDS_Vertex(*thePoint);
+      return CUBIT_SUCCESS;
+    }
+
+  PRINT_ERROR("Non-OCC TopologyBridge at %s:%d.\n", __FILE__, __LINE__ );
+  return CUBIT_FAILURE;
+}
 //a is angular value of rotation in radians
 CubitStatus OCCQueryEngine::rotate( GeometryEntity* entity,
                                     const CubitVector& v, double a )

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2007-12-05 19:09:43 UTC (rev 1439)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2007-12-06 19:00:43 UTC (rev 1440)
@@ -290,6 +290,9 @@
                                 DLIList<BodySM*>& body_list,
                                 CubitBox& super_box );
 
+  CubitStatus update_entity_shape(GeometryEntity* entity_ptr,
+                                  TopoDS_Shape *shape);
+
   CubitStatus translate( BodySM* body, const CubitVector& offset );
   CubitStatus rotate   ( BodySM* body, const CubitVector& axis, double angle );
   CubitStatus scale    ( BodySM* body, double factor );
@@ -349,8 +352,8 @@
                               DLIList<OCCCurve*> &facet_curves,
                               DLIList<OCCPoint*> &facet_points );
 
-  int iTotalTBCreated ;
-  CubitBoolean *PRINT_RESULT;
+  static int iTotalTBCreated ;
+  static CubitBoolean PRINT_RESULT;
 
   static OCCQueryEngine* instance_;
     //- static pointer to unique instance of this class

Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp	2007-12-05 19:09:43 UTC (rev 1439)
+++ cgm/trunk/geom/OCC/OCCShell.cpp	2007-12-06 19:00:43 UTC (rev 1440)
@@ -65,27 +65,7 @@
 {
 }
 
-
 //-------------------------------------------------------------------------
-// Purpose       : Get the bounding box of the object.
-//
-// Special Notes :
-//
-//-------------------------------------------------------------------------
-CubitBox OCCShell::bounding_box() const
-{
-   CubitBox cBox;
-   DLIList<TopologyBridge*> surfs;
-   get_children_virt(surfs);
-   for(int i = 0; i < surfs.size(); i ++)
-   {
-      OCCSurface* occ_surf = CAST_TO(surfs.get_and_step(), OCCSurface);  
-      cBox |= occ_surf->bounding_box(); 
-   }
-   return cBox;
-}
-
-//-------------------------------------------------------------------------
 // Purpose       : Get geometry modeling engine: OCCQueryEngine
 //
 // Special Notes :

Modified: cgm/trunk/geom/OCC/OCCShell.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.hpp	2007-12-05 19:09:43 UTC (rev 1439)
+++ cgm/trunk/geom/OCC/OCCShell.hpp	2007-12-06 19:00:43 UTC (rev 1440)
@@ -47,8 +47,8 @@
     //- Destructor.
 
   TopoDS_Shell* get_TopoDS_Shell() {return myTopoDSShell;}
-  virtual CubitBox bounding_box() const;
-  
+  void set_TopoDS_Shell(TopoDS_Shell shell){*myTopoDSShell = shell;} 
+
   virtual GeometryQueryEngine* 
   get_geometry_query_engine() const;
     //R GeometryQueryEngine*

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2007-12-05 19:09:43 UTC (rev 1439)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2007-12-06 19:00:43 UTC (rev 1440)
@@ -166,6 +166,46 @@
 }                 
 
 //-------------------------------------------------------------------------
+// Purpose       : Returns a surface type ID -- the values of these are
+//                 determined by OCC.
+//
+// Special Notes : 
+//                 This code is very ACIS-specific and could change with
+//                 new versions of ACIS.  There are #defines for the
+//                 various surface type ID's.  These are defined in the
+//                 header files of each of the specific surface classes
+//                 in ACIS.
+//
+//
+// Creator       : Jane HU
+//
+// Creation Date : 12/06/07
+//-------------------------------------------------------------------------
+GeometryType OCCSurface::geometry_type()
+{
+  BRepAdaptor_Surface asurface(*myTopoDSFace);
+  if (asurface.GetType() == GeomAbs_BezierSurface)
+     return BEZIER_SURFACE_TYPE;
+  if (asurface.GetType() == GeomAbs_BSplineSurface)
+     return SPLINE_SURFACE_TYPE;
+  if (asurface.GetType() == GeomAbs_Plane)      
+     return PLANE_SURFACE_TYPE;
+  if (asurface.GetType() == GeomAbs_Cylinder ||
+      asurface.GetType() == GeomAbs_Cone)
+     return CONE_SURFACE_TYPE;
+  if (asurface.GetType() == GeomAbs_Sphere)
+     return SPHERE_SURFACE_TYPE;
+  if (asurface.GetType() == GeomAbs_Torus)
+      return TORUS_SURFACE_TYPE;
+  if (asurface.GetType() == GeomAbs_SurfaceOfRevolution)
+     return REVOLUTION_SURFACE_TYPE;
+  if (asurface.GetType() == GeomAbs_SurfaceOfExtrusion)
+     return EXTRUSION_SURFACE_TYPE;
+  if (asurface.GetType() == GeomAbs_OffsetSurface)
+     return OFFSET_SURFACE_TYPE;
+  return UNDEFINED_SURFACE_TYPE;  
+}
+//-------------------------------------------------------------------------
 // Purpose       : Get the bounding box of the object.
 //
 // Special Notes :

Modified: cgm/trunk/geom/OCC/OCCSurface.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.hpp	2007-12-05 19:09:43 UTC (rev 1439)
+++ cgm/trunk/geom/OCC/OCCSurface.hpp	2007-12-06 19:00:43 UTC (rev 1440)
@@ -290,6 +290,7 @@
     //- values.
   
   TopoDS_Face *get_TopoDS_Face(){return myTopoDSFace;}
+  void set_TopoDS_Face(TopoDS_Face face) {*myTopoDSFace = face;}
 
   void get_loops(DLIList<OCCLoop*>&);
 
@@ -364,12 +365,6 @@
   virtual CubitSense get_geometry_sense();
     //- Return the relative surface sense. (see below)
   
-  virtual void reverse_sense();
-    //- Switch the sense of this Surface wrt the RefFace that owns it:
-    //- For Facet, this means switch the sense of the RefFace that
-    //- owns this Surface with respect to the positive sense of the
-    //- first FACE in FACEPtrList_.
-  
   CubitStatus save_attribs( FILE* file_ptr );
     // Write FactAttribs out to file
 




More information about the cgma-dev mailing list