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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Thu Dec 11 15:18:43 CST 2008


Author: janehu
Date: 2008-12-11 15:18:43 -0600 (Thu, 11 Dec 2008)
New Revision: 2481

Modified:
   cgm/trunk/geom/OCC/OCCBody.cpp
   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/OCCShell.cpp
   cgm/trunk/geom/OCC/OCCSurface.cpp
Log:
Partially fix for the coedge problem for subtraction, still has test case failure/crash.

Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp	2008-12-11 00:55:42 UTC (rev 2480)
+++ cgm/trunk/geom/OCC/OCCBody.cpp	2008-12-11 21:18:43 UTC (rev 2481)
@@ -85,6 +85,9 @@
 
 void OCCBody::set_TopoDS_Shape( TopoDS_CompSolid theshape)
 {
+  if(theshape.IsEqual(*myTopoDSShape))
+    return;
+
   TopoDS_CompSolid * the_comp = new TopoDS_CompSolid(theshape);
   if(myTopoDSShape)
     delete myTopoDSShape;

Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp	2008-12-11 00:55:42 UTC (rev 2480)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp	2008-12-11 21:18:43 UTC (rev 2481)
@@ -116,6 +116,9 @@
 
 void OCCCurve::set_TopoDS_Edge(TopoDS_Edge edge)
 {
+  if(edge.IsEqual(*myTopoDSEdge))
+    return;
+
   TopoDS_Edge* the_edge = new TopoDS_Edge(edge);
   if(myTopoDSEdge)
     delete myTopoDSEdge;

Modified: cgm/trunk/geom/OCC/OCCLoop.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLoop.cpp	2008-12-11 00:55:42 UTC (rev 2480)
+++ cgm/trunk/geom/OCC/OCCLoop.cpp	2008-12-11 21:18:43 UTC (rev 2481)
@@ -70,15 +70,6 @@
    if(loop.IsEqual(*myTopoDSWire))
      return;
    TopoDS_Wire* the_wire = new TopoDS_Wire(loop);
-   DLIList<OCCCoEdge *> coedges = this->coedges();
-   for(int i = 0; i < coedges.size(); i++)
-   {
-     OCCCoEdge *coedge = coedges.get_and_step();
-     Curve* curve = coedge->curve();
-     CAST_TO(curve, OCCCurve)->remove_loop(this);
-     this->remove_coedge(coedge);
-     delete coedge;
-   }
    if(myTopoDSWire)
      delete myTopoDSWire;
    myTopoDSWire = the_wire;

Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp	2008-12-11 00:55:42 UTC (rev 2480)
+++ cgm/trunk/geom/OCC/OCCLump.cpp	2008-12-11 21:18:43 UTC (rev 2481)
@@ -82,6 +82,9 @@
 
 void OCCLump::set_TopoDS_Solid(TopoDS_Solid solid)
 {
+  if(solid.IsEqual(*myTopoDSSolid) )
+    return;
+
   TopoDS_Solid* the_solid = new TopoDS_Solid(solid);
   if(myTopoDSSolid)
     delete myTopoDSSolid ;

Modified: cgm/trunk/geom/OCC/OCCPoint.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.cpp	2008-12-11 00:55:42 UTC (rev 2480)
+++ cgm/trunk/geom/OCC/OCCPoint.cpp	2008-12-11 21:18:43 UTC (rev 2481)
@@ -86,6 +86,8 @@
 
 void OCCPoint::set_TopoDS_Vertex(TopoDS_Vertex vertex)
 {
+  if(vertex.IsEqual(*myTopoDSVertex))
+    return;
   TopoDS_Vertex* the_vertex = new TopoDS_Vertex(vertex);
   if(myTopoDSVertex)
     delete myTopoDSVertex;
@@ -282,7 +284,7 @@
       //update all attributes first.
       TopTools_ListIteratorOfListOfShape it;
       it.Initialize(shapes);
-      for(it; it.More(); it.Next())
+      for(; it.More(); it.Next())
       {
         shape = it.Value();
         OCCQueryEngine::instance()->copy_attributes(*get_TopoDS_Vertex(),shape);

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-12-11 00:55:42 UTC (rev 2480)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-12-11 21:18:43 UTC (rev 2481)
@@ -1358,6 +1358,25 @@
     }
     if(!exist)
     {
+      DLIList<OCCShell*> shells = occ_surface->shells();
+      for(int i = 0; i < shells.size() ; i++)
+      {
+        OCCShell* shell = shells.get_and_step();
+        TopoDS_Shell* topo_shell = shell->get_TopoDS_Shell();
+        if (!OCCMap->IsBound(*topo_shell))
+        {
+          DLIList<OCCCoFace*> coface_list = shell->cofaces();
+          for(int j = 0; j < coface_list.size(); j++)
+          {
+            OCCCoFace * test_coface = coface_list.get_and_step();
+            occ_surface->remove_shell(shell);
+            shell->remove_coface(test_coface);
+            delete test_coface;
+          }
+          if(!topo_shell->IsNull())
+            topo_shell->Nullify();
+        }
+      } 
       OCCCoFace * coface = new OCCCoFace( occ_surface, shell, sense);
       cofaces_new.append(coface);
       occ_surface->add_shell(shell);
@@ -1490,20 +1509,20 @@
       for(int i = 0; i < loops.size() ; i++)
       {
         OCCLoop* occ_loop = loops.get_and_step();
-        if (!OCCMap->IsBound(*occ_loop->get_TopoDS_Wire()))
+        TopoDS_Wire* wire = occ_loop->get_TopoDS_Wire();
+        if (wire->IsNull() || !OCCMap->IsBound(*wire))
         { 
           DLIList<OCCCoEdge*> coedge_list = occ_loop->coedges();
           for(int j = 0; j < coedge_list.size(); j++)
           {
             OCCCoEdge * test_coedge = coedge_list.get_and_step();
-            if (test_coedge->curve() == curve)
-            {
-              occ_loop->remove_coedge(test_coedge);
-              occ_curve->remove_loop(occ_loop);
-              delete test_coedge;
-            }
+            occ_loop->remove_coedge(test_coedge);
+            occ_curve->remove_loop(occ_loop);
+            delete test_coedge;
           }
-          delete occ_loop;
+          if(!wire->IsNull())
+            wire->Nullify();
+          WireList->remove(occ_loop);
         }
       }
       //for the cylinder side face, there are 4 coedges, 2 of them are seam
@@ -1520,7 +1539,31 @@
         }
       }
 
-      assert(occ_curve->loops().size() <2);
+      if(occ_curve->loops().size() == 2)
+      {
+        //there must be a loop which doesn't have this curve anymore
+        //this is been found in subtract cases while one solid becomes
+        //2 solid, and one face becomes two faces. One face uses/updates
+        //the old face while the other face generates face and wire from
+        //new. However, in order to uses the curves, the old curve is kept
+        //as possible, so curve's loops get kept, but since it's going to 
+        //associate with new loop, the old loop should be removed from the 
+        //loop list.
+        DLIList<OCCLoop*> old_loops = occ_curve->loops();
+        for (int i = 0; i < 2; i++)
+        {
+          OCCLoop* old_loop = old_loops.get_and_step();
+          DLIList<OCCCoEdge*> test_coedges = old_loop->coedges();
+          int found = 0;
+          if(test_coedges.get()->curve() != curve)
+            test_coedges.step();
+          else
+            found = 1;
+          if(!found)
+            occ_curve->remove_loop(old_loop); 
+        }  
+      }
+      assert(occ_curve->loops().size() < 2);
       coedge = new OCCCoEdge( curve, loop, sense);
       coedges_new.append(coedge);
       occ_curve->add_loop(loop);

Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp	2008-12-11 00:55:42 UTC (rev 2480)
+++ cgm/trunk/geom/OCC/OCCShell.cpp	2008-12-11 21:18:43 UTC (rev 2481)
@@ -82,6 +82,9 @@
 
 void OCCShell::set_TopoDS_Shell(TopoDS_Shell shell)
 {
+  if(shell.IsEqual(*myTopoDSShell))
+    return;
+
   TopoDS_Shell* the_shell = new TopoDS_Shell(shell);
   if (myTopoDSShell)
     delete myTopoDSShell;

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2008-12-11 00:55:42 UTC (rev 2480)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2008-12-11 21:18:43 UTC (rev 2481)
@@ -99,6 +99,9 @@
 
 void OCCSurface::set_TopoDS_Face(TopoDS_Face& face)
 {
+  if(face.IsEqual(*myTopoDSFace))
+    return;
+
   TopoDS_Face* face_ptr = new TopoDS_Face(face);
   if(myTopoDSFace)
     delete myTopoDSFace;
@@ -906,7 +909,11 @@
      {
        TopoDS_Edge edge = Ex.Current();
        if(op)
+       {
          shapes.Assign(op->Modified(edge));
+         if(shapes.Extent() == 0)
+           shapes.Assign(op->Generated(edge));
+       }
        else if(sp)
          shapes.Assign(sp->DescendantShapes(edge));
 




More information about the cgma-dev mailing list