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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Wed Apr 16 15:19:10 CDT 2008


Author: janehu
Date: 2008-04-16 15:19:10 -0500 (Wed, 16 Apr 2008)
New Revision: 1769

Modified:
   cgm/trunk/geom/OCC/OCCBody.cpp
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.hpp
   cgm/trunk/geom/OCC/OCCShell.cpp
   cgm/trunk/geom/OCC/OCCSurface.cpp
   cgm/trunk/geom/OCC/OCCSurface.hpp
Log:
Figured out several places that need to update after a boolean operation for mapping up the surfaces and below entity, stitch_surfs now passed testing with 'owner attributes' setting up correctly.

Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp	2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCBody.cpp	2008-04-16 20:19:10 UTC (rev 1769)
@@ -165,7 +165,7 @@
   {
     TopoDS_Face * face = mySheetSurface->get_TopoDS_Face();
     aBRepTrsf.Perform(*face);
-    OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
+    OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, &aBRepTrsf);
   }
   else if(myShell)
   {
@@ -208,7 +208,7 @@
   {
     TopoDS_Face * face = mySheetSurface->get_TopoDS_Face();
     aBRepTrsf.Perform(*face);
-    OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
+    OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, &aBRepTrsf);
   }
   else if(myShell)
   {
@@ -245,7 +245,7 @@
   {
     TopoDS_Face * face = mySheetSurface->get_TopoDS_Face();
     aBRepTrsf.Perform(*face);
-    OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
+    OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, &aBRepTrsf);
   }
   else if(myShell)
   {
@@ -302,7 +302,7 @@
   {
     TopoDS_Face * face = mySheetSurface->get_TopoDS_Face();
     aBRepTrsf.Perform(*face);
-    OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
+    OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, &aBRepTrsf);
   }
   else if(myShell)
   {

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-04-16 20:19:10 UTC (rev 1769)
@@ -71,6 +71,7 @@
 #include "Handle_Geom_RectangularTrimmedSurface.hxx"
 #include "TopOpeBRep_EdgesIntersector.hxx"
 #include "TopExp_Explorer.hxx"
+#include "TopExp.hxx"
 #include "OCCModifyEngine.hpp"
 #include "OCCQueryEngine.hpp"
 #include "CubitMessage.hpp"
@@ -1540,9 +1541,23 @@
      second_face = faces_to_stitch[i];
      BRepAlgoAPI_Fuse fuser(*second_face, *first_face);
      fuse = fuser.Shape();
-     first_face = &fuse;
      OCCBody* occ_body = CAST_TO(surf_bodies[i], OCCBody);
      occ_body->my_sheet_surface()->update_OCC_entity(NULL, &fuser);
+     TopoDS_Shape new_shape ;
+     TopTools_IndexedMapOfShape M;
+     TopExp::MapShapes(*first_face, TopAbs_FACE, M);
+     for(int ii=1; ii<=M.Extent(); ii++)
+     {
+	TopoDS_Face face = TopoDS::Face(M(ii));
+        TopTools_ListOfShape shapes;
+        shapes.Assign(fuser.Modified(face));
+        if (shapes.Extent() > 0)
+        {
+          new_shape = shapes.First();
+          OCCSurface::update_OCC_entity(face, TopoDS::Face(new_shape), &fuser);
+        }
+      }
+      first_face = &fuse;
   }
 
   TopExp_Explorer Ex;

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-04-16 20:19:10 UTC (rev 1769)
@@ -28,6 +28,7 @@
 #include "TColgp_Array1OfPnt.hxx"
 #include "Poly_Array1OfTriangle.hxx"
 #include "Poly_Triangle.hxx"
+#include "BRepAlgoAPI_BooleanOperation.hxx"
 #include "Handle_Poly_Triangulation.hxx"
 #include "Poly_Polygon3D.hxx"
 #include "Handle_Poly_Polygon3D.hxx"
@@ -1116,22 +1117,24 @@
       OccToCGM->insert(valType(iTotalTBCreated,
 			       (TopologyBridge*)body));
       BodyList->append(body);
-
-      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);
-          CAST_TO(lump, OCCLump)->add_body(body);
-        }
-      body->lumps(lumps);
     }
   else
     {
       int k = OCCMap->Find(*posolid);
       body = (OCCBody*)(OccToCGM->find(k))->second;
+      body->set_TopoDS_Shape(*posolid);
     }
+
+  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);
+     CAST_TO(lump, OCCLump)->add_body(body);
+  }
+  body->lumps(lumps);
+
   return body;
 }
 
@@ -1160,16 +1163,18 @@
     OCCMap->Bind(*posolid, iTotalTBCreated);
     OccToCGM->insert(valType(iTotalTBCreated,
 		       (TopologyBridge*)lump));
-
-    TopExp_Explorer Ex;
-    for (Ex.Init(aShape, TopAbs_SHELL); Ex.More(); Ex.Next())
-      populate_topology_bridge(TopoDS::Shell(Ex.Current()));
   }
   else 
   {
     int k = OCCMap->Find(*posolid);
     lump = (OCCLump*)(OccToCGM->find(k))->second;
+    lump->set_TopoDS_Solid(*posolid);
   }
+ 
+  TopExp_Explorer Ex;
+  for (Ex.Init(aShape, TopAbs_SHELL); Ex.More(); Ex.Next())
+    populate_topology_bridge(TopoDS::Shell(Ex.Current()));
+
   return lump;
 }
 
@@ -1198,22 +1203,23 @@
       shell->set_lump(lump);
       //don't need to add body into BodyList.
     }
-
-    TopExp_Explorer Ex;
-    for (Ex.Init(aShape, TopAbs_FACE); Ex.More(); Ex.Next())
-    {
-      Surface* face =
-        populate_topology_bridge(TopoDS::Face(Ex.Current()), build_body);
-      if(standalone)
-        CAST_TO(face,OCCSurface)->set_shell(shell);
-    }
   }
   else
   {
     int k = OCCMap->Find(*poshell);
     shell = (OCCShell*)(OccToCGM->find(k))->second;
+    shell->set_TopoDS_Shell(*poshell);
   }
 
+  TopExp_Explorer Ex;
+  for (Ex.Init(aShape, TopAbs_FACE); Ex.More(); Ex.Next())
+  {
+    Surface* face =
+      populate_topology_bridge(TopoDS::Face(Ex.Current()), build_body);
+    if(standalone)
+      CAST_TO(face,OCCSurface)->set_shell(shell);
+  }
+
   return shell;
 }
 
@@ -1246,17 +1252,19 @@
       shell->set_lump(lump);
       //Doesn't need to save sheet bodies.
     }
-    TopExp_Explorer Ex;
-    for (Ex.Init(aShape, TopAbs_WIRE); Ex.More(); Ex.Next())
-      populate_topology_bridge(TopoDS::Wire(Ex.Current()));
   } 
 
   else 
   {
     int k = OCCMap->Find(*poface);
     surface = (OCCSurface*)(OccToCGM->find(k))->second;
+    surface->set_TopoDS_Face(*poface);
   }
 
+  TopExp_Explorer Ex;
+  for (Ex.Init(aShape, TopAbs_WIRE); Ex.More(); Ex.Next())
+    populate_topology_bridge(TopoDS::Wire(Ex.Current()));
+
   return surface;
 }
 
@@ -1277,26 +1285,27 @@
 			       (TopologyBridge*)loop));
       if(standalone)
 	WireList->append(loop);
-
-      BRepTools_WireExplorer Ex;
-      DLIList <OCCCoEdge*> coedges;
-      for (Ex.Init(aShape); Ex.More(); Ex.Next())
-        {
-          Curve* curve = populate_topology_bridge(Ex.Current());
-          OCCCurve *occ_curve = CAST_TO(curve, OCCCurve);
-          OCCCoEdge * coedge = new OCCCoEdge( curve, loop,
-            (Ex.Orientation() == TopAbs_FORWARD ? CUBIT_FORWARD : CUBIT_REVERSED));
-          coedges.append(coedge);
-          occ_curve->add_loop(loop);
-        }
-      loop->coedges(coedges);
     }
   else
     {
       int k = OCCMap->Find(*powire);
       loop = (OCCLoop*)(OccToCGM->find(k))->second;
+      loop->set_TopoDS_Wire(*powire);
     }
 
+  BRepTools_WireExplorer Ex;
+  DLIList <OCCCoEdge*> coedges;
+  for (Ex.Init(aShape); Ex.More(); Ex.Next())
+  {
+    Curve* curve = populate_topology_bridge(Ex.Current());
+    OCCCurve *occ_curve = CAST_TO(curve, OCCCurve);
+    OCCCoEdge * coedge = new OCCCoEdge( curve, loop,
+        (Ex.Orientation() == TopAbs_FORWARD ? CUBIT_FORWARD : CUBIT_REVERSED));
+    coedges.append(coedge);
+    occ_curve->add_loop(loop);
+  }
+  loop->coedges(coedges);
+
   return loop;
 }
 
@@ -1315,17 +1324,18 @@
       OccToCGM->insert(valType(iTotalTBCreated,
 			       (TopologyBridge*)curve));
       CurveList->append((OCCCurve*)curve);
-
-      TopExp_Explorer Ex;
-      for (Ex.Init(aShape, TopAbs_VERTEX); Ex.More(); Ex.Next())
-        populate_topology_bridge(TopoDS::Vertex(Ex.Current()));
     }
   else 
     {
       int i = OCCMap->Find(*poedge);
       curve = (OCCCurve*)(OccToCGM->find(i))->second;
+      CAST_TO(curve, OCCCurve)->set_TopoDS_Edge(*poedge);
     }
 
+  TopExp_Explorer Ex;
+  for (Ex.Init(aShape, TopAbs_VERTEX); Ex.More(); Ex.Next())
+    populate_topology_bridge(TopoDS::Vertex(Ex.Current()));
+
   return curve;
 }
 
@@ -1348,6 +1358,7 @@
     {
       int i = OCCMap->Find(*povertex);
       point = (OCCPoint*)(OccToCGM->find(i))->second;
+      point->set_TopoDS_Vertex(*povertex);
     }
   return point;
 }
@@ -2147,34 +2158,35 @@
 
   BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
   
-  update_entity_shape(entity, aBRepTrsf);
+  update_entity_shape(entity, &aBRepTrsf);
   return CUBIT_SUCCESS;
 }
 
 CubitStatus OCCQueryEngine::update_entity_shape(GeometryEntity* entity_ptr,
-						BRepBuilderAPI_Transform& aBRepTrsf)
+					BRepBuilderAPI_Transform* aBRepTrsf,
+                                        BRepAlgoAPI_BooleanOperation *op)
 {
   if (OCCBody *body_ptr = CAST_TO( entity_ptr, OCCBody))
     {
-      body_ptr->update_OCC_entity(&aBRepTrsf);
+      body_ptr->update_OCC_entity(aBRepTrsf, op);
       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, op);
       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, op); 
        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, op);
       return CUBIT_SUCCESS;
     }
 
@@ -2203,7 +2215,7 @@
   aTrsf.SetRotation(anAxis, a);
 
   BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
-  update_entity_shape(entity, aBRepTrsf);
+  update_entity_shape(entity, &aBRepTrsf);
   return CUBIT_SUCCESS;
 }
 
@@ -2221,7 +2233,7 @@
   aTrsf.SetScaleFactor(f);
 
   BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
-  update_entity_shape(entity, aBRepTrsf);
+  update_entity_shape(entity, &aBRepTrsf);
   return CUBIT_SUCCESS;
 }
 
@@ -2251,7 +2263,7 @@
   aTrsf.SetMirror(anAx2);
 
   BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
-  update_entity_shape(entity, aBRepTrsf);
+  update_entity_shape(entity, &aBRepTrsf);
   return CUBIT_SUCCESS;
 }
 

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2008-04-16 20:19:10 UTC (rev 1769)
@@ -78,6 +78,7 @@
  
 class BRepBuilderAPI_Transform;
 class TopTools_DataMapOfShapeInteger;
+class BRepAlgoAPI_BooleanOperation;
 class TopoDS_Vertex;
 class TopoDS_Edge;
 class TopoDS_Shape;
@@ -306,7 +307,8 @@
                                 CubitBox& super_box );
 
   CubitStatus update_entity_shape(GeometryEntity* entity_ptr,
-                                  BRepBuilderAPI_Transform& aTranf);
+                                  BRepBuilderAPI_Transform* aTranf,
+                                  BRepAlgoAPI_BooleanOperation *op = NULL);
 
   CubitStatus translate( BodySM* body, const CubitVector& offset );
   CubitStatus rotate   ( BodySM* body, const CubitVector& axis, double angle );

Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp	2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCShell.cpp	2008-04-16 20:19:10 UTC (rev 1769)
@@ -179,7 +179,7 @@
 {
   if(mySheetSurface && op == NULL)
     return CUBIT_FAILURE;
-
+/*
   else if(mySheetSurface && op)//stitch surface body into shell body
   {
     mySheetSurface->update_OCC_entity(aBRepTrsf, op); 
@@ -199,6 +199,7 @@
     }   
     return CUBIT_SUCCESS;
   }
+*/
   assert (aBRepTrsf != NULL || op != NULL);
 
   TopoDS_Shape shape;

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2008-04-16 20:19:10 UTC (rev 1769)
@@ -44,8 +44,9 @@
 #include "LoopSM.hpp"
 #include "CubitPointData.hpp"
 #include "BRepAlgoAPI_BooleanOperation.hxx"
+#include "BRepTools_WireExplorer.hxx"
+#include "BRep_Tool.hxx"
 
-
 // ********** END CUBIT INCLUDES           **********
 
 
@@ -764,7 +765,7 @@
 
 //----------------------------------------------------------------
 // Function: to update the core Surface
-//           for any movement of the body.
+//           for any movement  or Boolean operation of the body.
 // Author: Jane Hu
 //----------------------------------------------------------------
 CubitStatus OCCSurface::update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
@@ -788,21 +789,89 @@
   TopoDS_Face surface; 
   surface = TopoDS::Face(shape);
 
-  OCCQueryEngine::instance()->update_OCC_map(*myTopoDSFace, surface);
+  if (aBRepTrsf)
+  {
+    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, op);
+    //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, op);
+    }
+    set_TopoDS_Face(surface);
   }
-  set_TopoDS_Face(surface);
 
+  else
+    update_OCC_entity(*myTopoDSFace, surface, op);
+
   return CUBIT_SUCCESS;
 }
 
+//----------------------------------------------------------------
+// Function: TopoDS_Shape level function to update the core Surface
+//           for any movement  or Boolean operation of the body.
+// Author: Jane Hu
+//----------------------------------------------------------------
+CubitStatus OCCSurface::update_OCC_entity(TopoDS_Face& old_surface,
+                                          TopoDS_Face& new_surface,
+                                          BRepAlgoAPI_BooleanOperation *op)
+{
+  OCCQueryEngine::instance()->update_OCC_map(old_surface, new_surface);
+
+  //set the Wires
+  TopTools_IndexedMapOfShape M;
+  TopoDS_Shape shape;
+  TopExp::MapShapes(old_surface, TopAbs_WIRE, M);
+  double tol = OCCQueryEngine::instance()->get_sme_resabs_tolerance();
+  int ii;
+  for (ii=1; ii<=M.Extent(); ii++) {
+     TopoDS_Wire wire = TopoDS::Wire(M(ii)); 
+     TopTools_ListOfShape shapes;
+     shapes.Assign(op->Modified(wire));
+     if (shapes.Extent() > 0)
+       shape = shapes.First();
+     else
+     {
+       TopTools_IndexedMapOfShape M_new;
+       TopExp::MapShapes(new_surface, TopAbs_WIRE, M_new);
+       shape = M_new(ii);
+     }
+  
+     OCCQueryEngine::instance()->update_OCC_map(wire, shape);
+      
+     //set curves
+     CubitBoolean need_update = CUBIT_TRUE;
+     BRepTools_WireExplorer Ex;
+     for(Ex.Init(wire); Ex.More();Ex.Next())
+     {
+       TopoDS_Edge edge = Ex.Current();
+       shapes.Assign(op->Modified(edge));
+       if (shapes.Extent() > 0)
+         shape = shapes.First();
+       else
+         need_update = CUBIT_FALSE; 
+
+       if (need_update)
+         OCCQueryEngine::instance()->update_OCC_map(edge, shape); 
+  
+       //update vertex
+       TopoDS_Vertex vertex = Ex.CurrentVertex();
+       shapes.Assign(op->Modified(vertex));
+       need_update = CUBIT_TRUE;
+       if (shapes.Extent() > 0)
+       {
+         shape = shapes.First();
+         OCCQueryEngine::instance()->update_OCC_map(vertex, shape);
+       }
+     }
+  }
+  return CUBIT_SUCCESS;
+}
+
+
 // ********** END PUBLIC FUNCTIONS         **********
 
 // ********** BEGIN PROTECTED FUNCTIONS    **********

Modified: cgm/trunk/geom/OCC/OCCSurface.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.hpp	2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCSurface.hpp	2008-04-16 20:19:10 UTC (rev 1769)
@@ -61,6 +61,11 @@
   virtual ~OCCSurface() ;
     //- The destructor
    
+  static CubitStatus update_OCC_entity(TopoDS_Face& old_surface,
+                                       TopoDS_Face& new_surface,
+                                       BRepAlgoAPI_BooleanOperation *op);
+
+
   virtual void append_simple_attribute_virt(CubitSimpleAttrib*);
     //R void
     //I 




More information about the cgma-dev mailing list