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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Fri Apr 11 14:44:08 CDT 2008


Author: janehu
Date: 2008-04-11 14:44:08 -0500 (Fri, 11 Apr 2008)
New Revision: 1760

Modified:
   cgm/trunk/geom/OCC/OCCBody.cpp
   cgm/trunk/geom/OCC/OCCBody.hpp
   cgm/trunk/geom/OCC/OCCCurve.cpp
   cgm/trunk/geom/OCC/OCCCurve.hpp
   cgm/trunk/geom/OCC/OCCLoop.cpp
   cgm/trunk/geom/OCC/OCCLoop.hpp
   cgm/trunk/geom/OCC/OCCLump.cpp
   cgm/trunk/geom/OCC/OCCLump.hpp
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/geom/OCC/OCCPoint.cpp
   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 the mapping part for old and new entities after boolean operation. Fuse operation in OCC seems to have a bug that doesn't return the map of modified entities, posted a question in opencascade forum.

Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCBody.cpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -163,12 +163,12 @@
   {
     TopoDS_Shell* shell = myShell->get_TopoDS_Shell();
     aBRepTrsf.Perform(*shell);
-    myShell->update_OCC_entity(aBRepTrsf);
+    myShell->update_OCC_entity(&aBRepTrsf);
   }
   else
   {
     aBRepTrsf.Perform(*myTopoDSShape);
-    update_OCC_entity(aBRepTrsf);
+    update_OCC_entity(&aBRepTrsf);
   }
 
   // calculate for bounding box
@@ -206,12 +206,12 @@
   {
     TopoDS_Shell* shell = myShell->get_TopoDS_Shell();
     aBRepTrsf.Perform(*shell);
-    myShell->update_OCC_entity(aBRepTrsf);
+    myShell->update_OCC_entity(&aBRepTrsf);
   }
   else
   {
     aBRepTrsf.Perform(*myTopoDSShape);
-    update_OCC_entity(aBRepTrsf);
+    update_OCC_entity(&aBRepTrsf);
   }
 
   // calculate for bounding box
@@ -243,12 +243,12 @@
   {
     TopoDS_Shell* shell = myShell->get_TopoDS_Shell();
     aBRepTrsf.Perform(*shell);
-    myShell->update_OCC_entity(aBRepTrsf);
+    myShell->update_OCC_entity(&aBRepTrsf);
   }
   else
   {
     aBRepTrsf.Perform(*myTopoDSShape);
-    update_OCC_entity(aBRepTrsf);
+    update_OCC_entity(&aBRepTrsf);
   }
 
   // calculate for bounding box
@@ -300,12 +300,12 @@
   {
     TopoDS_Shell* shell = myShell->get_TopoDS_Shell();
     aBRepTrsf.Perform(*shell);
-    myShell->update_OCC_entity(aBRepTrsf);
+    myShell->update_OCC_entity(&aBRepTrsf);
   }
   else
   {
     aBRepTrsf.Perform(*myTopoDSShape);
-    update_OCC_entity(aBRepTrsf);
+    update_OCC_entity(&aBRepTrsf);
   }
 
   // update underlining OCC entities
@@ -320,32 +320,37 @@
 //           as the body's lumps number.
 // Author: Jane Hu
 //----------------------------------------------------------------
-CubitStatus OCCBody::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf) 
+CubitStatus OCCBody::update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                                       BRepAlgoAPI_BooleanOperation *op) 
 {
   if(IsSheetBody || myShell)
     return CUBIT_FAILURE;
 
-  TopoDS_Shape shape = aBRepTrsf.Shape();
-  TopoDS_CompSolid compsolid = TopoDS::CompSolid(shape);
+  assert(aBRepTrsf != NULL || op != NULL);
 
-  if(OCCQueryEngine::instance()->OCCMap->IsBound(*myTopoDSShape) )
+  TopoDS_CompSolid compsolid;
+  if(aBRepTrsf)
   {
-     int k = OCCQueryEngine::instance()->OCCMap->Find(*myTopoDSShape);
-     assert (k > 0 && k <= OCCQueryEngine::instance()->iTotalTBCreated);
-     OCCQueryEngine::instance()->OCCMap->UnBind(*myTopoDSShape);
-     OCCQueryEngine::instance()->OCCMap->Bind(shape, k);
+    TopoDS_Shape shape = aBRepTrsf->Shape();
+    TopoDS_CompSolid compsolid = TopoDS::CompSolid(shape);
+  
+    if(OCCQueryEngine::instance()->OCCMap->IsBound(*myTopoDSShape) )
+       OCCQueryEngine::instance()->update_OCC_map(*myTopoDSShape, shape);
   }
 
+  //Boolean operation works only on one lump body
   //set the lumps
   DLIList<Lump *> lumps;
   lumps = this->lumps();
   for (int i = 1; i <= lumps.size(); i++)
   {
      OCCLump *lump = CAST_TO(lumps.get_and_step(), OCCLump);
-     lump->update_OCC_entity(aBRepTrsf);
+     lump->update_OCC_entity(aBRepTrsf, op);
   }
-  set_TopoDS_Shape(compsolid);
 
+  if (aBRepTrsf)
+    set_TopoDS_Shape(compsolid);
+
   update_bounding_box(); 
 
   //unset marks.

Modified: cgm/trunk/geom/OCC/OCCBody.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.hpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCBody.hpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -39,7 +39,7 @@
 class OCCCurve;
 class OCCPoint;
 class BRepBuilderAPI_Transform;
-
+class BRepAlgoAPI_BooleanOperation;
 // ********** END FORWARD DECLARATIONS     **********
 
 class OCCBody : public BodySM
@@ -175,7 +175,8 @@
   virtual CubitPointContainment point_containment( const CubitVector& pos );
 
   //update the underlining CompSolid
-  CubitStatus update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf);
+  CubitStatus update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                                 BRepAlgoAPI_BooleanOperation *op = NULL);
 
   OCCSurface* my_sheet_surface(){if(IsSheetBody) return mySheetSurface;
 				 return (OCCSurface*) NULL;} 

Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -56,6 +56,7 @@
 #include "TColgp_Array1OfPnt.hxx"
 #include "GeomAdaptor_Curve.hxx"
 #include "GCPnts_QuasiUniformAbscissa.hxx"
+#include "BRepAlgoAPI_BooleanOperation.hxx"
 #include "TopTools_ListOfShape.hxx"
 #include "BRepAlgo_NormalProjection.hxx"
 #include "TopExp_Explorer.hxx"
@@ -899,18 +900,26 @@
 //           for any movement of the body/surface/curve.
 // Author: Jane Hu
 //----------------------------------------------------------------
-void OCCCurve::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf)
+void OCCCurve::update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                                 BRepAlgoAPI_BooleanOperation *op)
 {
   if (myMarked == 1) 
      return;
 
-  TopoDS_Shape shape = aBRepTrsf.ModifiedShape(*get_TopoDS_Edge());
+  assert(aBRepTrsf != NULL || op != NULL);
+  
+  TopoDS_Shape shape;
+  if (aBRepTrsf)
+    shape = aBRepTrsf->ModifiedShape(*get_TopoDS_Edge());
+  else
+  {
+    TopTools_ListOfShape shapes;
+    shapes.Assign(op->Modified(*get_TopoDS_Edge()));
+    shape = shapes.First();
+  }
   TopoDS_Edge curve = TopoDS::Edge(shape);
 
-  int k = OCCQueryEngine::instance()->OCCMap->Find(*myTopoDSEdge);
-  assert (k > 0 && k <= OCCQueryEngine::instance()->iTotalTBCreated);
-  OCCQueryEngine::instance()->OCCMap->UnBind(*myTopoDSEdge);
-  OCCQueryEngine::instance()->OCCMap->Bind(curve, k);
+  OCCQueryEngine::instance()->update_OCC_map(*myTopoDSEdge, curve);
 
   //set the vertices
   DLIList<TopologyBridge*> vertices;
@@ -920,7 +929,7 @@
      TopologyBridge* tb = vertices.get_and_step();
      OCCPoint *point = CAST_TO(tb, OCCPoint);
      if (point)
-       point->update_OCC_entity(aBRepTrsf);
+       point->update_OCC_entity(aBRepTrsf, op);
   }
   myMarked = 1;
   set_TopoDS_Edge(curve);

Modified: cgm/trunk/geom/OCC/OCCCurve.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.hpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCCurve.hpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -38,7 +38,7 @@
 class OCCCoEdge;
 class OCCPoint;
 class BRepBuilderAPI_Transform; 
-
+class BRepAlgoAPI_BooleanOperation;
 // ********** END FORWARD DECLARATIONS     **********
 
 class OCCCurve : public Curve
@@ -324,7 +324,8 @@
     { return myTopoDSEdge; } 
   void set_TopoDS_Edge(TopoDS_Edge edge){*myTopoDSEdge = edge;}
 
-  void update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf);
+  void update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                          BRepAlgoAPI_BooleanOperation *op = NULL );
  
   Curve* project_curve(Surface* face_ptr,
                        CubitBoolean closed,

Modified: cgm/trunk/geom/OCC/OCCLoop.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLoop.cpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCLoop.cpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -34,7 +34,7 @@
 #include "TopTools_DataMapOfShapeInteger.hxx"
 #include "TopTools_IndexedDataMapOfShapeListOfShape.hxx"
 #include "BRepBuilderAPI_Transform.hxx"
-
+#include "BRepAlgoAPI_BooleanOperation.hxx"
 // ********** END CUBIT INCLUDES           **********
 
 // ********** BEGIN STATIC DECLARATIONS    **********
@@ -221,21 +221,29 @@
 //           for any movement of the body/surface.
 // Author: Jane Hu
 //----------------------------------------------------------------
-CubitStatus OCCLoop::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf)
+CubitStatus OCCLoop::update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                                        BRepAlgoAPI_BooleanOperation *op)
 {
-  TopoDS_Shape shape = aBRepTrsf.ModifiedShape(*get_TopoDS_Wire());
+  assert(aBRepTrsf != NULL || op != NULL);
+
+  TopoDS_Shape shape;
+  if (aBRepTrsf)
+    shape = aBRepTrsf->ModifiedShape(*get_TopoDS_Wire());
+  else
+  {
+    TopTools_ListOfShape shapes; 
+    shapes.Assign(op->Modified(*get_TopoDS_Wire()));
+    shape = shapes.First();
+  }
   TopoDS_Wire loop = TopoDS::Wire(shape);
 
-  int k = OCCQueryEngine::instance()->OCCMap->Find(*myTopoDSWire);
-  assert (k > 0 && k <= OCCQueryEngine::instance()->iTotalTBCreated);
-  OCCQueryEngine::instance()->OCCMap->UnBind(*myTopoDSWire);
-  OCCQueryEngine::instance()->OCCMap->Bind(loop, k);
+  OCCQueryEngine::instance()->update_OCC_map(*myTopoDSWire, loop);
 
   //set the curves
   for (int i = 1; i <= myCoEdgeList.size(); i++)
   {
      OCCCurve *curve = CAST_TO(myCoEdgeList.get_and_step()->curve(), OCCCurve);
-     curve->update_OCC_entity(aBRepTrsf);
+     curve->update_OCC_entity(aBRepTrsf, op);
   }
   set_TopoDS_Wire(loop);
 }

Modified: cgm/trunk/geom/OCC/OCCLoop.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLoop.hpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCLoop.hpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -32,7 +32,7 @@
 class OCCCurve;
 class OCCPoint;
 class BRepBuilderAPI_Transform;
-
+class BRepAlgoAPI_BooleanOperation;
 class OCCLoop : public LoopSM
 {
 public :
@@ -107,7 +107,8 @@
     virtual void get_parents_virt(DLIList<TopologyBridge*>&);
     virtual void get_children_virt(DLIList<TopologyBridge*>&);
 
-    CubitStatus update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf);
+    CubitStatus update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                                   BRepAlgoAPI_BooleanOperation *op =NULL);
 protected: 
 
 private:

Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCLump.cpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -39,6 +39,7 @@
 #include <TopTools_IndexedMapOfShape.hxx>
 #include "BRepBuilderAPI_Transform.hxx"
 #include "TopTools_DataMapOfShapeInteger.hxx"
+#include "BRepAlgoAPI_BooleanOperation.hxx"
 #include "Bnd_Box.hxx"
 #include "BRepBndLib.hxx"
 #include "GProp_GProps.hxx"
@@ -294,18 +295,26 @@
 //           for any movement of the lump.
 // Author: Jane Hu
 //----------------------------------------------------------------
-CubitStatus OCCLump::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf)
+CubitStatus OCCLump::update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                                        BRepAlgoAPI_BooleanOperation *op)
 {
   if(mySheetSurface || myShell)
     return CUBIT_FAILURE;
 
-  TopoDS_Shape shape = aBRepTrsf.ModifiedShape(*get_TopoDS_Solid());
+  assert(aBRepTrsf != NULL || op != NULL);
+ 
+  TopoDS_Shape shape;
+  if (aBRepTrsf)
+    shape = aBRepTrsf->ModifiedShape(*get_TopoDS_Solid());
+  else
+  {
+    TopTools_ListOfShape shapes;
+    shapes.Assign(op->Modified(*get_TopoDS_Solid()));
+    shape = shapes.First();
+  }
   TopoDS_Solid solid = TopoDS::Solid(shape);
 
-  int k = OCCQueryEngine::instance()->OCCMap->Find(*myTopoDSSolid);
-  assert (k > 0 && k <= OCCQueryEngine::instance()->iTotalTBCreated);
-  OCCQueryEngine::instance()->OCCMap->UnBind(*myTopoDSSolid);
-  OCCQueryEngine::instance()->OCCMap->Bind(solid, k);
+  OCCQueryEngine::instance()->update_OCC_map(*myTopoDSSolid, solid);
 
   //set the lumps
   DLIList<TopologyBridge *> shells;
@@ -313,7 +322,7 @@
   for (int i = 1; i <= shells.size(); i++)
   {
      OCCShell *shell = CAST_TO(shells.get_and_step(), OCCShell);
-     shell->update_OCC_entity(aBRepTrsf);
+     shell->update_OCC_entity(aBRepTrsf, op);
   }
   set_TopoDS_Solid(solid);
 }

Modified: cgm/trunk/geom/OCC/OCCLump.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.hpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCLump.hpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -37,7 +37,7 @@
 class OCCCurve;
 class OCCPoint;
 class BRepBuilderAPI_Transform;
-
+class BRepAlgoAPI_BooleanOperation;
 // ********** END FORWARD DECLARATIONS     **********
 
 class OCCLump : public Lump
@@ -147,7 +147,8 @@
 
   CubitPointContainment point_containment( const CubitVector &point );
 
-  CubitStatus update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf);
+  CubitStatus update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                                BRepAlgoAPI_BooleanOperation *op = NULL);
 
 protected: 
   

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -1529,14 +1529,20 @@
        faces_to_stitch.append(topods_face);
   }
 
-  TopoDS_Shape* first_face  = faces_to_stitch.get();
+  faces_to_stitch.reset();
+  surf_bodies.reset();
+  TopoDS_Shape* first_face  = faces_to_stitch.pop();
+  surf_bodies.pop(); //make consistance with faces_to_stitch.
+
   TopoDS_Face* second_face = NULL;
   TopoDS_Shape fuse;
-  for(int i = 1; i < faces_to_stitch.size(); i++)
+  for( int i = faces_to_stitch.size()-1; i >= 0; i --)
   {
      second_face = faces_to_stitch[i];
-     fuse = BRepAlgoAPI_Fuse(*first_face, *second_face);
+     BRepAlgoAPI_Fuse fuser(*second_face, *first_face);
+     fuse = fuser.Shape();
      first_face = &fuse;
+     CAST_TO(surf_bodies[i], OCCBody)->my_sheet_surface()->update_OCC_entity(NULL, &fuser);      
   }
 
   TopExp_Explorer Ex;
@@ -1694,9 +1700,11 @@
         continue;
       } 
       TopoDS_Shape* tool_shape = tool_bodies_copy.get_and_step();
+
       //bodies overlap, proceed with the subtract
-      TopoDS_Shape cut_shape = BRepAlgoAPI_Cut(*from_shape, *tool_shape);
- 
+      BRepAlgoAPI_Cut cutter(*from_shape, *tool_shape);
+      TopoDS_Shape cut_shape = cutter.Shape(); 
+
       //compare to see if the from_shape has gotten cut.
       CubitStatus stat;
       if(is_volume[i])

Modified: cgm/trunk/geom/OCC/OCCPoint.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.cpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCPoint.cpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -32,6 +32,7 @@
 #include "TopTools_DataMapOfShapeInteger.hxx"
 #include "TopTools_IndexedDataMapOfShapeListOfShape.hxx"
 #include "BRepBuilderAPI_Transform.hxx"
+#include "BRepAlgoAPI_BooleanOperation.hxx"
 // ********** END CUBIT INCLUDES           **********
 
 // ********** BEGIN STATIC DECLARATIONS    **********
@@ -258,18 +259,26 @@
 //           for any movement of the body/surface/curve/vertex.
 // Author: Jane Hu
 //----------------------------------------------------------------
-void OCCPoint::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf)
+void OCCPoint::update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                                  BRepAlgoAPI_BooleanOperation *op)
 {
   if (this->myMarked == CUBIT_TRUE)
     return;
 
-  TopoDS_Shape shape = aBRepTrsf.ModifiedShape(*get_TopoDS_Vertex());
+  assert(aBRepTrsf != NULL || op != NULL);
+
+  TopoDS_Shape shape;
+  if(aBRepTrsf)
+    shape = aBRepTrsf->ModifiedShape(*get_TopoDS_Vertex());
+  else
+  {
+    TopTools_ListOfShape shapes;
+    shapes.Assign(op->Modified(*get_TopoDS_Vertex()));
+    shape = shapes.First();
+  }
   TopoDS_Vertex vertex = TopoDS::Vertex(shape);
 
-  int k = OCCQueryEngine::instance()->OCCMap->Find(*myTopoDSVertex);
-  assert (k > 0 && k <= OCCQueryEngine::instance()->iTotalTBCreated);
-  OCCQueryEngine::instance()->OCCMap->UnBind(*myTopoDSVertex);
-  OCCQueryEngine::instance()->OCCMap->Bind(vertex, k);
+  OCCQueryEngine::instance()->update_OCC_map(*myTopoDSVertex, vertex);
 
   set_myMarked(CUBIT_TRUE);
   set_TopoDS_Vertex(vertex);

Modified: cgm/trunk/geom/OCC/OCCPoint.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.hpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCPoint.hpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -30,6 +30,7 @@
 // ********** BEGIN FORWARD DECLARATIONS   **********
 class CubitSimpleAttrib;
 class BRepBuilderAPI_Transform;
+class BRepAlgoAPI_BooleanOperation;
 // ********** END FORWARD DECLARATIONS     **********
 
 class OCCPoint : public Point
@@ -136,7 +137,8 @@
 
   CubitStatus restore_attribs( FILE *file_ptr, unsigned int endian );
 
-  void update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf);
+  void update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                          BRepAlgoAPI_BooleanOperation *op = NULL);
 };
 
 

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -2154,25 +2154,25 @@
 {
   if (OCCBody *body_ptr = CAST_TO( entity_ptr, OCCBody))
     {
-      body_ptr->update_OCC_entity(aBRepTrsf);
+      body_ptr->update_OCC_entity(&aBRepTrsf);
       return CUBIT_SUCCESS;
     }
 
   else if( OCCSurface *surface_ptr = CAST_TO( entity_ptr, OCCSurface))
     {
-      surface_ptr->update_OCC_entity(aBRepTrsf);
+      surface_ptr->update_OCC_entity(&aBRepTrsf);
       return CUBIT_SUCCESS;
     }
 
   else if( OCCCurve *curve_ptr = CAST_TO( entity_ptr, OCCCurve))
     {
-       curve_ptr->update_OCC_entity(aBRepTrsf); 
+       curve_ptr->update_OCC_entity(&aBRepTrsf); 
        return CUBIT_SUCCESS;
     }
 
   else if( OCCPoint *point_ptr = CAST_TO( entity_ptr, OCCPoint))
     {
-      point_ptr->update_OCC_entity(aBRepTrsf);
+      point_ptr->update_OCC_entity(&aBRepTrsf);
       return CUBIT_SUCCESS;
     }
 
@@ -2343,4 +2343,12 @@
   return CUBIT_FALSE;
 }
 
+void OCCQueryEngine::update_OCC_map(TopoDS_Shape old_shape, 
+                                    TopoDS_Shape new_shape)
+{
+  int k = OCCMap->Find(old_shape);
+  assert (k > 0 && k <= iTotalTBCreated);
+  OCCMap->UnBind(old_shape);
+  OCCMap->Bind(new_shape, k);
+}
 //EOF

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -109,6 +109,8 @@
     //- Singleton pattern
     //- Controlled access and creation of the sole instance of this class.
 
+  void update_OCC_map(TopoDS_Shape old_shape, TopoDS_Shape new_shape);
+
   virtual ~OCCQueryEngine();
   
   const char* modeler_type()

Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCShell.cpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -40,6 +40,7 @@
 #include "TopTools_DataMapOfShapeInteger.hxx"
 #include "TopTools_ListOfShape.hxx"
 #include "BRepBuilderAPI_Transform.hxx"
+#include "BRepAlgoAPI_BooleanOperation.hxx"
 // ********** END CUBIT INCLUDES           **********
 
 // ********** BEGIN STATIC DECLARATIONS    **********
@@ -165,26 +166,34 @@
 //           for any movement of the body.
 // Author: Jane Hu
 //----------------------------------------------------------------
-CubitStatus OCCShell::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf)
+CubitStatus OCCShell::update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                                        BRepAlgoAPI_BooleanOperation *op)
 {
   if(mySheetSurface)
     return CUBIT_FAILURE;
 
-  TopoDS_Shape shape = aBRepTrsf.ModifiedShape(*get_TopoDS_Shell());
+  assert (aBRepTrsf != NULL || op != NULL);
+
+  TopoDS_Shape shape;
+  if (aBRepTrsf)
+    shape = aBRepTrsf->ModifiedShape(*get_TopoDS_Shell());
+  else
+  {
+    TopTools_ListOfShape shapes;
+    shapes.Assign(op->Modified(*get_TopoDS_Shell()));
+    shape = shapes.First();
+  } 
   TopoDS_Shell shell = TopoDS::Shell(shape);
 
-  int k = OCCQueryEngine::instance()->OCCMap->Find(*myTopoDSShell);
-  assert (k > 0 && k <= OCCQueryEngine::instance()->iTotalTBCreated);
-  OCCQueryEngine::instance()->OCCMap->UnBind(*myTopoDSShell);
-  OCCQueryEngine::instance()->OCCMap->Bind(shell, k);
+  OCCQueryEngine::instance()->update_OCC_map(*myTopoDSShell, shell);
 
-  //set the lumps
+  //set the surfaces
   DLIList<TopologyBridge *> surfaces;
   this->get_children_virt(surfaces);
   for (int i = 1; i <= surfaces.size(); i++)
   {
      OCCSurface *surface = CAST_TO(surfaces.get_and_step(), OCCSurface);
-     surface->update_OCC_entity(aBRepTrsf);
+     surface->update_OCC_entity(aBRepTrsf, op);
   }
   set_TopoDS_Shell(shell);
   return CUBIT_SUCCESS;

Modified: cgm/trunk/geom/OCC/OCCShell.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.hpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCShell.hpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -35,6 +35,7 @@
 class OCCCurve;
 class OCCPoint;
 class BRepBuilderAPI_Transform;
+class BRepAlgoAPI_BooleanOperation;
 
 // ********** END CUBIT INCLUDES           **********
 
@@ -106,7 +107,8 @@
   virtual void get_parents_virt( DLIList<TopologyBridge*>& parents );
   virtual void get_children_virt( DLIList<TopologyBridge*>& children );
 
-  CubitStatus update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf);
+  CubitStatus update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                                 BRepAlgoAPI_BooleanOperation *op = NULL);
   double measure(); //area of the shell
 protected: 
   

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -43,6 +43,7 @@
 #include "Lump.hpp"
 #include "LoopSM.hpp"
 #include "CubitPointData.hpp"
+#include "BRepAlgoAPI_BooleanOperation.hxx"
 
 
 // ********** END CUBIT INCLUDES           **********
@@ -766,25 +767,43 @@
 //           for any movement of the body.
 // Author: Jane Hu
 //----------------------------------------------------------------
-CubitStatus OCCSurface::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf)
+CubitStatus OCCSurface::update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                                         BRepAlgoAPI_BooleanOperation *op)
 {
-  TopoDS_Shape shape = aBRepTrsf.ModifiedShape(*get_TopoDS_Face());
-  TopoDS_Face surface = TopoDS::Face(shape);
+  assert(aBRepTrsf != NULL || op != NULL);
 
-  int k = OCCQueryEngine::instance()->OCCMap->Find(*myTopoDSFace);
-  assert (k > 0 && k <= OCCQueryEngine::instance()->iTotalTBCreated);
-  OCCQueryEngine::instance()->OCCMap->UnBind(*myTopoDSFace);
-  OCCQueryEngine::instance()->OCCMap->Bind(surface, k);
+  TopoDS_Shape shape;
+  CubitBoolean need_update = CUBIT_TRUE;
+  if (aBRepTrsf)
+    shape = aBRepTrsf->ModifiedShape(*get_TopoDS_Face());
+  else
+  {
+    TopTools_ListOfShape shapes;
+    shapes.Assign(op->Modified(*get_TopoDS_Face()));
+    if (shapes.Extent() > 0)
+      shape = shapes.First();
+    else
+      need_update = CUBIT_FALSE;
+  }
+ 
+  TopoDS_Face surface; 
+  if(need_update)
+  {
+    surface = TopoDS::Face(shape);
 
+    OCCQueryEngine::instance()->update_OCC_map(*myTopoDSFace, surface);
+  }
   //set the loops
   DLIList<OCCLoop *> loops;
   this->get_loops(loops);
   for (int i = 1; i <= loops.size(); i++)
   {
      OCCLoop *loop = loops.get_and_step();
-     loop->update_OCC_entity(aBRepTrsf);
+     loop->update_OCC_entity(aBRepTrsf, op);
   }
-  set_TopoDS_Face(surface);
+  if (need_update)
+    set_TopoDS_Face(surface);
+
   return CUBIT_SUCCESS;
 }
 

Modified: cgm/trunk/geom/OCC/OCCSurface.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.hpp	2008-04-11 19:41:37 UTC (rev 1759)
+++ cgm/trunk/geom/OCC/OCCSurface.hpp	2008-04-11 19:44:08 UTC (rev 1760)
@@ -48,7 +48,7 @@
 class OCCCurve;
 class OCCPoint;
 class BRepBuilderAPI_Transform;
-
+class BRepAlgoAPI_BooleanOperation;
 //// class CubitTransformMatrix;
 
 class OCCSurface : public Surface
@@ -396,7 +396,8 @@
   CubitBoolean is_spherical(); //// Not in SurfaceACIS
   CubitBoolean is_conical();  //// Not in SurfaceACIS
 
-  CubitStatus update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf);
+  CubitStatus update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
+                                 BRepAlgoAPI_BooleanOperation *op = NULL);
 protected: 
 
 private:




More information about the cgma-dev mailing list