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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Wed Apr 30 13:36:10 CDT 2008


Author: janehu
Date: 2008-04-30 13:36:10 -0500 (Wed, 30 Apr 2008)
New Revision: 1787

Modified:
   cgm/trunk/geom/OCC/OCCCurve.cpp
   cgm/trunk/geom/OCC/OCCLoop.cpp
   cgm/trunk/geom/OCC/OCCLump.cpp
   cgm/trunk/geom/OCC/OCCPoint.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
Log:
Reviewed with Jason and now think that CoEdge hasn't been cleaned out correctly so it still has free ref edges. will update and check on it tomorrow.

Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp	2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp	2008-04-30 18:36:10 UTC (rev 1787)
@@ -918,13 +918,15 @@
     shapes.Assign(op->Modified(*get_TopoDS_Edge()));
     if(shapes.Extent())
       shape = shapes.First();
+    else if (op->IsDeleted(*get_TopoDS_Edge()))
+      ;
     else
       return ;
   }
-  TopoDS_Edge curve = TopoDS::Edge(shape);
+  TopoDS_Edge curve;
+  if(!shape.IsNull())
+    curve = TopoDS::Edge(shape);
 
-  OCCQueryEngine::instance()->update_OCC_map(*myTopoDSEdge, curve);
-
   //set the vertices
   DLIList<TopologyBridge*> vertices;
   get_children_virt(vertices);
@@ -936,7 +938,7 @@
        point->update_OCC_entity(aBRepTrsf, op);
   }
   myMarked = 1;
-  set_TopoDS_Edge(curve);
+  OCCQueryEngine::instance()->update_OCC_map(*myTopoDSEdge, curve);
 }
 
 //===============================================================================

Modified: cgm/trunk/geom/OCC/OCCLoop.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLoop.cpp	2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCLoop.cpp	2008-04-30 18:36:10 UTC (rev 1787)
@@ -238,22 +238,23 @@
     shapes.Assign(op->Modified(*get_TopoDS_Wire()));
     if(shapes.Extent())
       shape = shapes.First();
+    else if (op->IsDeleted(*get_TopoDS_Wire()))
+      ;
     else
       need_update = CUBIT_FALSE;
   }
-  TopoDS_Wire loop;
-  if (need_update)
-  {
-    loop = TopoDS::Wire(shape);
-    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, op);
   }
+  TopoDS_Wire loop;
   if (need_update)
-    set_TopoDS_Wire(loop);
+  {
+    loop = TopoDS::Wire(shape);
+    OCCQueryEngine::instance()->update_OCC_map(*myTopoDSWire, loop);
+  }
 }
 

Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp	2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCLump.cpp	2008-04-30 18:36:10 UTC (rev 1787)
@@ -315,13 +315,16 @@
     shapes.Assign(op->Modified(*get_TopoDS_Solid()));
     if(shapes.Extent() > 0)
       shape = shapes.First();
+    else if(op->IsDeleted(*get_TopoDS_Solid()))
+      ;
     else
       return CUBIT_SUCCESS;
   }
-  TopoDS_Solid solid = TopoDS::Solid(shape);
+  
+  TopoDS_Solid solid;
+  if(!op->IsDeleted(*get_TopoDS_Solid()))
+    solid = TopoDS::Solid(shape);
 
-  OCCQueryEngine::instance()->update_OCC_map(*myTopoDSSolid, solid);
-
   //set the lumps
   DLIList<TopologyBridge *> shells;
   this->get_children_virt(shells);
@@ -330,6 +333,7 @@
      OCCShell *shell = CAST_TO(shells.get_and_step(), OCCShell);
      shell->update_OCC_entity(aBRepTrsf, op);
   }
-  set_TopoDS_Solid(solid);
+  OCCQueryEngine::instance()->update_OCC_map(*myTopoDSSolid, solid);
+
 }
 

Modified: cgm/trunk/geom/OCC/OCCPoint.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.cpp	2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCPoint.cpp	2008-04-30 18:36:10 UTC (rev 1787)
@@ -278,10 +278,14 @@
     shapes.Assign(op->Modified(*get_TopoDS_Vertex()));
     if(shapes.Extent())
       shape = shapes.First();
+    else if(op->IsDeleted(*get_TopoDS_Vertex()))
+      ;
     else
       return ;
   }
-  TopoDS_Vertex vertex = TopoDS::Vertex(shape);
+  TopoDS_Vertex vertex;
+  if(!shape.IsNull())
+    vertex = TopoDS::Vertex(shape);
 
   OCCQueryEngine::instance()->update_OCC_map(*myTopoDSVertex, vertex);
 

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-04-30 18:36:10 UTC (rev 1787)
@@ -2471,23 +2471,61 @@
 
   OCCMap->UnBind(old_shape);
 
+  std::map<int, TopologyBridge*>::iterator it = OccToCGM->find(k);
+  TopologyBridge* tb = NULL;
+  if (it != OccToCGM->end())
+     tb = (*it).second;
+
+  else
+     assert(0);
+
   if ((!new_shape.IsNull() && !old_shape.IsSame(new_shape)&& 
       OCCMap->IsBound(new_shape))|| new_shape.IsNull()) 
   //already has a TB built on new_shape
   {
     //delete the second TB corresponding to old_shape
-    std::map<int, TopologyBridge*>::iterator it = OccToCGM->find(k);
-    TopologyBridge* tb = NULL;
-    if (it != OccToCGM->end())
-    {
-       OccToCGM->erase(k);
-       tb = (*it).second;
-       delete_solid_model_entities( tb);
-    }
+    OccToCGM->erase(k);
+    delete_solid_model_entities( tb);
   }
 
   else
+  {   
     OCCMap->Bind(new_shape, k);
+    set_TopoDS_Shape(tb, new_shape);
+  }
   return k;
 }
+
+void OCCQueryEngine::set_TopoDS_Shape(TopologyBridge* tb,
+                                      TopoDS_Shape shape)
+{
+  BodySM* body = CAST_TO(tb, BodySM);
+  if(body)
+    return CAST_TO(body, OCCBody)->set_TopoDS_Shape(TopoDS::CompSolid(shape));
+
+  Lump* lump = CAST_TO(tb, Lump);
+  if(lump)
+    return CAST_TO(lump, OCCLump)->set_TopoDS_Solid(TopoDS::Solid(shape));
+
+  ShellSM* shell = CAST_TO(tb, ShellSM);
+  if(shell)
+    return CAST_TO(shell, OCCShell)->set_TopoDS_Shell(TopoDS::Shell(shape));
+
+  Surface* surface = CAST_TO(tb, Surface);
+  if (surface)
+    return CAST_TO(surface, OCCSurface)->set_TopoDS_Face(TopoDS::Face(shape));
+
+  LoopSM* loop =  CAST_TO(tb, LoopSM);
+  if(loop)
+    return CAST_TO(loop, OCCLoop)->set_TopoDS_Wire(TopoDS::Wire(shape));
+
+  Curve* curve = CAST_TO(tb, Curve);
+  if (curve)
+    return CAST_TO(curve, OCCCurve)->set_TopoDS_Edge(TopoDS::Edge(shape));
+
+  Point* point = CAST_TO(tb, Point);
+  if(point)
+    return CAST_TO(point, OCCPoint)->set_TopoDS_Vertex(TopoDS::Vertex(shape));
+  
+}
 //EOF

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2008-04-30 18:36:10 UTC (rev 1787)
@@ -310,6 +310,7 @@
                                   BRepBuilderAPI_Transform* aTranf,
                                   BRepAlgoAPI_BooleanOperation *op = NULL);
 
+  void set_TopoDS_Shape(TopologyBridge* tb, TopoDS_Shape new_shape);
   CubitStatus translate( BodySM* body, const CubitVector& offset );
   CubitStatus rotate   ( BodySM* body, const CubitVector& axis, double angle );
   CubitStatus scale    ( BodySM* body, double factor );

Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp	2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCShell.cpp	2008-04-30 18:36:10 UTC (rev 1787)
@@ -218,13 +218,15 @@
     shapes.Assign(op->Modified(*get_TopoDS_Shell()));
     if (shapes.Extent())
       shape = shapes.First();
+    else if(op->IsDeleted(*get_TopoDS_Shell()))
+      ;
     else
       return CUBIT_SUCCESS;
   } 
-  TopoDS_Shell shell = TopoDS::Shell(shape);
+  TopoDS_Shell shell;
+  if (!shape.IsNull())
+    shell = TopoDS::Shell(shape);
 
-  OCCQueryEngine::instance()->update_OCC_map(*myTopoDSShell, shell);
-
   //set the surfaces
   DLIList<TopologyBridge *> surfaces;
   this->get_children_virt(surfaces);
@@ -233,7 +235,7 @@
      OCCSurface *surface = CAST_TO(surfaces.get_and_step(), OCCSurface);
      surface->update_OCC_entity(aBRepTrsf, op);
   }
-  set_TopoDS_Shell(shell);
+  OCCQueryEngine::instance()->update_OCC_map(*myTopoDSShell, shell);
   return CUBIT_SUCCESS;
 }
 

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2008-04-30 18:36:10 UTC (rev 1787)
@@ -784,17 +784,18 @@
     shapes.Assign(op->Modified(*get_TopoDS_Face()));
     if (shapes.Extent() > 0)
       shape = shapes.First();
+    else if(op->IsDeleted(*get_TopoDS_Face()))
+      ;
     else
       return CUBIT_SUCCESS;
   }
  
   TopoDS_Face surface; 
-  surface = TopoDS::Face(shape);
+  if(!shape.IsNull())
+    surface = TopoDS::Face(shape);
 
   if (aBRepTrsf) 
   {
-    OCCQueryEngine::instance()->update_OCC_map(*myTopoDSFace, surface);
-
     //set the loops
     DLIList<OCCLoop *> loops;
     this->get_loops(loops);
@@ -803,7 +804,7 @@
        OCCLoop *loop = loops.get_and_step();
        loop->update_OCC_entity(aBRepTrsf, op);
     }
-    set_TopoDS_Face(surface);
+    OCCQueryEngine::instance()->update_OCC_map(*myTopoDSFace, surface);
   }
 
   else if(op)
@@ -821,17 +822,16 @@
                                           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;
+  TopoDS_Shape shape, shape_edge, shape_vertex;
   TopExp::MapShapes(old_surface, TopAbs_WIRE, M);
   double tol = OCCQueryEngine::instance()->get_sme_resabs_tolerance();
   int ii;
   TopTools_ListOfShape shapes;  
 
-  for (ii=1; ii<=M.Extent(); ii++) {
+  for (ii=1; ii<=M.Extent(); ii++) 
+  {
      TopoDS_Wire wire = TopoDS::Wire(M(ii));
 
      if(!new_surface.IsNull())
@@ -846,45 +846,41 @@
          TopExp::MapShapes(new_surface, TopAbs_WIRE, M_new);
          shape = M_new(ii);
        }
-  
-       OCCQueryEngine::instance()->update_OCC_map(wire, shape);
      } 
      //set curves
      BRepTools_WireExplorer Ex;
+     
      for(Ex.Init(wire); Ex.More();Ex.Next())
      {
        TopoDS_Edge edge = Ex.Current();
        shapes.Assign(op->Modified(edge));
-       shape.Nullify();
        if (shapes.Extent() > 0)
-         shape = shapes.First();
+         shape_edge = shapes.First();
        else if (op->IsDeleted(edge))
          ; 
        else 
          continue;
 
-       if(wire.Orientation() == TopAbs_REVERSED && !shape.IsNull())
+       if(wire.Orientation() == TopAbs_REVERSED && !shape_edge.IsNull())
        {
-         shape.Orientation(
-          shape.Orientation()==TopAbs_FORWARD? TopAbs_REVERSED:TopAbs_FORWARD);
+         shape_edge.Orientation(
+          shape_edge.Orientation()==TopAbs_FORWARD? TopAbs_REVERSED:TopAbs_FORWARD);
        }
-       OCCQueryEngine::instance()->update_OCC_map(edge, shape); 
-       if (shape.IsNull())
-         continue;
 
        //update vertex
        TopoDS_Vertex vertex = Ex.CurrentVertex();
        shapes.Assign(op->Modified(vertex));
-       shape.Nullify();
        if (shapes.Extent() > 0)
-       {
-         shape = shapes.First();
-         OCCQueryEngine::instance()->update_OCC_map(vertex, shape);
-       }
-       else if(op->IsDeleted(vertex))
-         OCCQueryEngine::instance()->update_OCC_map(vertex, shape);
+         shape_vertex = shapes.First();
+
+       if(shapes.Extent() > 0 || op->IsDeleted(vertex))
+         OCCQueryEngine::instance()->update_OCC_map(vertex, shape_vertex);
+
+       OCCQueryEngine::instance()->update_OCC_map(edge, shape_edge);
      }
+     OCCQueryEngine::instance()->update_OCC_map(wire, shape);
   }
+  OCCQueryEngine::instance()->update_OCC_map(old_surface, new_surface);
   return CUBIT_SUCCESS;
 }
 




More information about the cgma-dev mailing list