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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Mon Jun 2 13:49:18 CDT 2008


Author: janehu
Date: 2008-06-02 13:49:17 -0500 (Mon, 02 Jun 2008)
New Revision: 1868

Modified:
   cgm/trunk/geom/OCC/OCCBody.cpp
   cgm/trunk/geom/OCC/OCCBody.hpp
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/geom/OCC/OCCModifyEngine.hpp
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
Log:
make sure the TopoDS_shapes get updated correctly after first edge imprint, getting ready to make a second edge imprint before update OCC entities, still has error showing a curve with no vertices, checking on it.

Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp	2008-05-30 23:45:17 UTC (rev 1867)
+++ cgm/trunk/geom/OCC/OCCBody.cpp	2008-06-02 18:49:17 UTC (rev 1868)
@@ -94,6 +94,15 @@
 OCCBody::OCCBody(DLIList<Lump*>& my_lumps)
 {
   myLumps += my_lumps;
+  TopoDS_CompSolid* new_top = make_CompSolid(my_lumps);
+  myTopoDSShape = new_top;
+  IsSheetBody = CUBIT_FALSE;
+  myShell = NULL;
+  update_bounding_box();
+}
+
+TopoDS_CompSolid* OCCBody::make_CompSolid(DLIList<Lump*>& my_lumps)
+{
   BRep_Builder B;
   TopoDS_CompSolid Co;
   B.MakeCompSolid(Co);
@@ -102,10 +111,8 @@
      TopoDS_Solid * solid = CAST_TO(myLumps.get_and_step(), OCCLump)->get_TopoDS_Solid();
      B.Add(Co, *solid);
   }
-  myTopoDSShape = new TopoDS_CompSolid(Co);
-  IsSheetBody = CUBIT_FALSE;
-  myShell = NULL;
-  update_bounding_box();
+  TopoDS_CompSolid* new_top = new TopoDS_CompSolid(Co);
+  return new_top; 
 }
 
 OCCBody::~OCCBody() 

Modified: cgm/trunk/geom/OCC/OCCBody.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.hpp	2008-05-30 23:45:17 UTC (rev 1867)
+++ cgm/trunk/geom/OCC/OCCBody.hpp	2008-06-02 18:49:17 UTC (rev 1868)
@@ -184,8 +184,8 @@
 
   virtual CubitBoolean is_sheet_body(){return IsSheetBody;}
 
+  TopoDS_CompSolid* make_CompSolid(DLIList<Lump*>& my_lumps);
 protected: 
-  
 private:
 
   DLIList<Lump*> myLumps;

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-05-30 23:45:17 UTC (rev 1867)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-06-02 18:49:17 UTC (rev 1868)
@@ -1927,6 +1927,7 @@
  
   //indicate if there's more faces to be imprinted
   CubitBoolean more_face = CUBIT_TRUE; 
+  DLIList<TopoDS_Face*> list_for_delete;
 
   //list of face on from_shape that has been imprinted
   DLIList<TopoDS_Face*> from_faces; 
@@ -1943,18 +1944,28 @@
     {
       if(count == 1)
         break;
-      common_edge = find_imprinting_edge(*from_shape, TopoDS::Edge(*tool_shape),from_face);
+      
+      DLIList<TopoDS_Face*> faces;
+      //need to delete TopoDS_Face* in faces
+      common_edge = find_imprinting_edge(*from_shape, TopoDS::Edge(*tool_shape),faces);
       if (common_edge)
       {
         if (on_faces)
           qualified = CUBIT_FALSE;
-        for (int i = 0; on_faces && i < on_faces->size(); i++)
+        for(int j = 0; j < faces.size(); j++)
         {
-          if (from_face.IsSame(*(on_faces->get_and_step())))
+          from_face = *faces.get();
+          for (int i = 0; on_faces && i < on_faces->size(); i++)
           {
-            qualified = CUBIT_TRUE; 
-            break;
+            if (from_face.IsSame(*(on_faces->get_and_step())))
+            {
+              qualified = CUBIT_TRUE; 
+              break;
+            }
           }
+          faces.get()->Nullify();
+          delete faces.get();
+          faces.step();
         }
         if (qualified && (from_faces.size() == 0 || (from_faces.size() && !from_face.IsSame(*from_faces.get()))) )
           list_of_edges.Append(*common_edge);
@@ -2092,6 +2103,13 @@
           topo_face->Nullify();
           delete topo_face;
         }
+        
+        for (int iii=0; iii < list_for_delete.size(); iii++)
+        {
+           TopoDS_Face* topo_face = list_for_delete.get_and_step();
+           topo_face->Nullify();
+           delete topo_face;
+        }
         continue;
       }
   
@@ -2250,6 +2268,25 @@
         topo_changed = CUBIT_FALSE;
         if(splitor.IsDone())
         {
+          //take care of on_faces list first.
+          if (on_faces && on_faces->size())
+          {
+            TopoDS_Face* compare_face = on_faces->get();
+            if(from_face.IsSame(*compare_face))
+            {
+              on_faces->remove(compare_face);
+              TopTools_ListOfShape shapes;
+              shapes.Assign(splitor.Modified(from_face)); 
+              while(shapes.Extent() > 0)
+              {
+                TopoDS_Face* face = 
+                  new TopoDS_Face(TopoDS::Face(shapes.First())); 
+                shapes.RemoveFirst();
+                on_faces->append(face);
+                list_for_delete.append(face);
+              }
+            }
+          }
           TopoDS_Shape new_from_shape = splitor.Shape();
           if(from_shape->TShape()->ShapeType() == TopAbs_COMPSOLID)
           {
@@ -2339,16 +2376,16 @@
 // Date       : 05/08
 //===============================================================================
 TopoDS_Edge* OCCModifyEngine::find_imprinting_edge(TopoDS_Shape& from_shape,
-                                                TopoDS_Edge& tool_shape,
-                                                TopoDS_Face& face)const
+                                        TopoDS_Edge& tool_shape,
+                                        DLIList<TopoDS_Face*>& from_faces)const
 {
   TopoDS_Edge* edge = NULL;
   //list of face on from_shape that has been imprinted
-  DLIList<TopoDS_Face*> from_faces;
+  from_faces.clean_out();
   TopExp_Explorer Ex;
   for (Ex.Init(from_shape, TopAbs_FACE); Ex.More(); Ex.Next())
   {
-    face = TopoDS::Face(Ex.Current());
+    TopoDS_Face face = TopoDS::Face(Ex.Current());
     BRepAlgoAPI_Common intersector(face, tool_shape);
     TopTools_ListOfShape shapes;
     shapes.Assign(intersector.Modified(tool_shape));
@@ -2361,10 +2398,10 @@
     }
     if (shapes.First().TShape()->ShapeType() != TopAbs_EDGE)
       continue;
-    edge = new TopoDS_Edge(TopoDS::Edge(shapes.First()));
-    return edge;
+    if(edge == NULL)
+      edge = new TopoDS_Edge(TopoDS::Edge(shapes.First()));
+    from_faces.append(new TopoDS_Face(face));
   }
-  face.Nullify();
   return edge;
 }
 
@@ -2763,7 +2800,7 @@
       shape_list.append(topo_face);
     else 
     {
-      int size = shape_list.size();
+      //int size = shape_list.size();
       OCCQueryEngine* oqe = OCCQueryEngine::instance();
       DLIList <OCCBody* > *bodies = oqe->BodyList;
       TopTools_IndexedDataMapOfShapeListOfShape M;
@@ -2773,11 +2810,19 @@
         body = bodies->get_and_step();
         TopExp_Explorer Ex;
         TopoDS_Face the_face;
-        for (Ex.Init(*(body->get_TopoDS_Shape()), TopAbs_FACE);Ex.More(); Ex.Next())
-          the_face = TopoDS::Face(Ex.Current());
- 
-        TopExp::MapShapesAndAncestors(*(body->get_TopoDS_Shape()),
-                                 TopAbs_FACE, TopAbs_SOLID, M);
+        TopoDS_Shape ashape = *(body->get_TopoDS_Shape());
+        if (OCCQueryEngine::instance()->OCCMap->IsBound(ashape))
+          TopExp::MapShapesAndAncestors(ashape, TopAbs_FACE, TopAbs_SOLID, M);
+        else
+	{
+          DLIList<Lump*> lumps = body->lumps();
+          for(int i = 0; i < lumps.size(); i++)
+          {
+            OCCLump *occ_lump = (OCCLump *) lumps.get_and_step();
+            TopExp::MapShapesAndAncestors(*occ_lump->get_TopoDS_Solid(),
+                                    TopAbs_FACE, TopAbs_SOLID, M);
+          }
+        }  
         if(!M.Contains(*topo_face))
           continue; 
         const TopTools_ListOfShape& ListOfShapes =
@@ -2806,6 +2851,20 @@
       BRepBuilderAPI_Copy api_copy(*shape);
       TopoDS_Shape newShape = api_copy.ModifiedShape(*shape);
       TopoDS_Shape* Shape1 = new TopoDS_Shape(newShape);
+      for(int j = 0; j < face_list.size(); j++)
+      {
+        TopoDS_Face* face = face_list.get();
+        TopExp_Explorer Ex;
+        for (Ex.Init(*shape, TopAbs_FACE); Ex.More(); Ex.Next())
+        {
+          if(face->IsSame(Ex.Current()))
+          {
+            face = new TopoDS_Face(TopoDS::Face(api_copy.ModifiedShape(*face)));
+            face_list.change_to(face);
+          }
+        }
+        face_list.step(); 
+      }
       shape_list.change_to(Shape1);
       shape_list.step();
     }
@@ -2836,6 +2895,15 @@
     new_body_list.append(CAST_TO(tbs.get(),BodySM));
   }
 
+  if (keep_old)
+  {
+    for(int i = 0; i < face_list.size(); i++)
+    {
+      TopoDS_Face* face = face_list.get();
+      face->Nullify();
+      delete face;
+    }
+  }
   return CUBIT_SUCCESS;
 }
 

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.hpp	2008-05-30 23:45:17 UTC (rev 1867)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.hpp	2008-06-02 18:49:17 UTC (rev 1868)
@@ -663,7 +663,7 @@
 
  TopoDS_Edge* find_imprinting_edge(TopoDS_Shape& from_shape,
                                    TopoDS_Edge& tool_shape,
-                                   TopoDS_Face& face)const;
+                                   DLIList<TopoDS_Face*>& faces)const;
 
  CubitStatus sort_curves(DLIList<Curve*> curve_list,
                          DLIList<DLIList<TopoDS_Edge*>*>& topo_edges_loops)const;

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-05-30 23:45:17 UTC (rev 1867)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-06-02 18:49:17 UTC (rev 1868)
@@ -1170,7 +1170,16 @@
   {
     int k = OCCMap->Find(aShape);
     lump = (OCCLump*)(OccToCGM->find(k))->second;
-    lump->set_TopoDS_Solid(aShape);
+    if (!aShape.IsSame(*lump->get_TopoDS_Solid()))
+    {
+      lump->set_TopoDS_Solid(aShape);
+      OCCBody* body = CAST_TO(lump->get_body(), OCCBody);
+      DLIList<Lump*> lumps = body->lumps();
+      TopoDS_CompSolid* new_top = body->make_CompSolid(lumps);
+      body->set_TopoDS_Shape(*new_top);
+      new_top->Nullify();
+      delete new_top;
+    }
   }
  
   TopExp_Explorer Ex;




More information about the cgma-dev mailing list