[cgma-dev] r2043 - in cgm/trunk: geom/OCC test

janehu at mcs.anl.gov janehu at mcs.anl.gov
Mon Aug 18 11:45:25 CDT 2008


Author: janehu
Date: 2008-08-18 11:45:24 -0500 (Mon, 18 Aug 2008)
New Revision: 2043

Modified:
   cgm/trunk/geom/OCC/OCCCoEdge.cpp
   cgm/trunk/geom/OCC/OCCCoEdge.hpp
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
   cgm/trunk/geom/OCC/OCCShell.cpp
   cgm/trunk/geom/OCC/OCCSurface.cpp
   cgm/trunk/test/modify.cpp
   cgm/trunk/test/r_w.cpp
Log:
Coedge wasn't cleaned totally when deleting, fixed this bug,updated testcases.

Modified: cgm/trunk/geom/OCC/OCCCoEdge.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCoEdge.cpp	2008-08-18 16:40:10 UTC (rev 2042)
+++ cgm/trunk/geom/OCC/OCCCoEdge.cpp	2008-08-18 16:45:24 UTC (rev 2043)
@@ -41,7 +41,7 @@
 
 OCCCoEdge::OCCCoEdge( Curve *curv_ptr, 
 	  	      LoopSM *loop_ptr, CubitSense sense )
-	 	    : myCurve(curv_ptr), 
+	 	    : myMark(0), myCurve(curv_ptr), 
  	  	      myLoop(loop_ptr),edgeSense(sense)
 {
 }

Modified: cgm/trunk/geom/OCC/OCCCoEdge.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCoEdge.hpp	2008-08-18 16:40:10 UTC (rev 2042)
+++ cgm/trunk/geom/OCC/OCCCoEdge.hpp	2008-08-18 16:45:24 UTC (rev 2043)
@@ -64,6 +64,9 @@
 
   inline void set_loop(LoopSM * loop) {myLoop = loop;}
 
+  inline int get_mark(){return myMark;}
+  inline void set_mark(int k){myMark = k;}
+
   virtual GeometryQueryEngine*
   get_geometry_query_engine() const;
     //R GeometryQueryEngine*
@@ -120,6 +123,7 @@
   LoopSM *myLoop;
   Curve *myCurve;
   CubitSense edgeSense;
+  int myMark;
 };
 
 

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-08-18 16:40:10 UTC (rev 2042)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-08-18 16:45:24 UTC (rev 2043)
@@ -3541,12 +3541,6 @@
     BRepAlgoAPI_Fuse fuser(*first_shape, *second_shape);
     TopoDS_Shape new_shape = fuser.Shape();
 
-    //Debug:: check how many faces are there in new_shape.
-    TopExp_Explorer Ex;
-    int count = 0;
-    for (Ex.Init(new_shape, TopAbs_FACE);Ex.More(); Ex.Next())
-      count++;
- 
     CubitBoolean has_changed;
     check_operation(new_shape, first_shape, first_is_volume, has_changed, &fuser);
  

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-08-18 16:40:10 UTC (rev 2042)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-08-18 16:45:24 UTC (rev 2043)
@@ -1421,6 +1421,7 @@
       coedge = coedges_old.get_and_step();
       if(coedge->curve() == curve)
       {
+        coedge->set_mark(1);
         exist = CUBIT_TRUE;
         coedge->set_sense(sense);
         coedges_new.append(coedge);
@@ -1459,6 +1460,15 @@
     coedges_new.reverse();
   loop->coedges(coedges_new);
 
+  //remove unused coedges
+  for(int i = 0; i < coedges_old.size(); i++)
+  {
+    OCCCoEdge *coedge = coedges_old.get_and_step();
+    if(coedge->get_mark() != 1)
+      delete coedge;
+    else
+      coedge->set_mark(0);
+  }
   return loop;
 }
 

Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp	2008-08-18 16:40:10 UTC (rev 2042)
+++ cgm/trunk/geom/OCC/OCCShell.cpp	2008-08-18 16:45:24 UTC (rev 2043)
@@ -232,10 +232,8 @@
           OCCQueryEngine::instance()->copy_attributes(*get_TopoDS_Shell(), 
                                                       shape);
         }
-        shape.Nullify();
       }
-      else
-        shape = shapes.First();
+      shape = shapes.First();
     }
     else if(op->IsDeleted(*get_TopoDS_Shell()))
       ;
@@ -294,20 +292,19 @@
 
     if(shapes.Extent() == 1)
       shape = shapes.First();
-    else
+    else if(shapes.Extent() > 1)
     {
-      if(shapes.Extent() > 1)
+      TopTools_ListIteratorOfListOfShape it;
+      it.Initialize(shapes);
+      for(it; it.More(); it.Next())
       {
-        TopTools_ListIteratorOfListOfShape it;
-        it.Initialize(shapes);
-        for(it; it.More(); it.Next())
-        {
-          shape = it.Value();
-          OCCQueryEngine::instance()->copy_attributes(face, shape);
-        }
+        shape = it.Value();
+        OCCQueryEngine::instance()->copy_attributes(face, shape);
       }
-      shape.Nullify();
+      shape = shapes.First();
     }
+    else 
+      shape.Nullify();
     if(shapes.Extent() > 0 || (op && op->IsDeleted(face)))
       OCCSurface::update_OCC_entity(face,shape, op, sp);
   }

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2008-08-18 16:40:10 UTC (rev 2042)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2008-08-18 16:45:24 UTC (rev 2043)
@@ -892,7 +892,7 @@
          it.Initialize(shapes);
          for(it; it.More(); it.Next())
          {
-           shape = it.Value();
+           shape_edge = it.Value();
            OCCQueryEngine::instance()->copy_attributes(edge, shape_edge);
          }
          shape_edge = shapes.First();
@@ -919,7 +919,7 @@
          it.Initialize(shapes);
          for(it; it.More(); it.Next())
          {
-           shape = it.Value();
+           shape_vertex = it.Value();
            OCCQueryEngine::instance()->copy_attributes(vertex, shape_vertex);
          }
          shape_vertex = shapes.First();

Modified: cgm/trunk/test/modify.cpp
===================================================================
--- cgm/trunk/test/modify.cpp	2008-08-18 16:40:10 UTC (rev 2042)
+++ cgm/trunk/test/modify.cpp	2008-08-18 16:45:24 UTC (rev 2043)
@@ -289,6 +289,7 @@
   
   free_entities.clean_out();
   gti->get_free_ref_entities(free_entities);
+  assert(free_entities.size() == 0);
   //there shouldn't be any free_entites.
 
   from_body = gmti->brick(10, 10, 10);
@@ -380,6 +381,7 @@
 
   free_entities.clean_out();
   gti->get_free_ref_entities(free_entities);
+  assert(free_entities.size() == 0);
   //there shouldn't be any free_entites.
 
   //test for shell body subtract.
@@ -484,7 +486,8 @@
 
   free_entities.clean_out();
   gti->get_free_ref_entities(free_entities);  
-  
+  assert(free_entities.size() == 0);
+ 
   OCCQueryEngine* oqe = OCCQueryEngine::instance();
   DLIList <OCCBody* > *occ_bodies = oqe->BodyList;
 
@@ -511,7 +514,7 @@
 
   free_entities.clean_out();
   gti->get_free_ref_entities(free_entities);
-
+  assert(free_entities.size() == 0);
   //test body-body intersect.
   //1. from body is the commom body, no update
   tool_body  = gmti->brick(4, 4, 4);
@@ -560,6 +563,7 @@
 
   free_entities.clean_out();
   gti->get_free_ref_entities(free_entities);
+  assert(free_entities.size() == 0);
 
   //test chop operation
   tool_body  = gmti->brick(4, 4, 4);
@@ -584,7 +588,7 @@
 
   free_entities.clean_out();
   gti->get_free_ref_entities(free_entities);
-
+  assert(free_entities.size() == 0);
   //test chop 2
   from_body = gmti->brick(4, 4, 4);
   tool_body = gmti->brick(1,1,1);
@@ -607,6 +611,7 @@
 
   free_entities.clean_out();
   gti->get_free_ref_entities(free_entities);
+  assert(free_entities.size() == 0);
 
   //test unite 1
   tool_body = gmti->brick(1,1,1);
@@ -626,11 +631,12 @@
   gti->bodies(bodies); //bodies.size() = 1
   free_entities.clean_out();
   gti->get_free_ref_entities(free_entities); //free_entities.size() = 0
+  assert(free_entities.size() == 0);
   //delete all entities
   gti->delete_Body(bodies);
   free_entities.clean_out();
   gti->get_free_ref_entities(free_entities); //free_entities.size() = 0
-
+  assert(free_entities.size() == 0);
   //test unite 2
   tool_body = gmti->brick(4, 4,4);
   gti->translate(tool_body,v_move7);
@@ -650,10 +656,12 @@
   gti->bodies(bodies); //bodies.size() = 1
   free_entities.clean_out();
   gti->get_free_ref_entities(free_entities); //free_entities.size() = 0
+  assert(free_entities.size() == 0);
   //delete all entities
   gti->delete_Body(bodies);
   free_entities.clean_out();
   gti->get_free_ref_entities(free_entities); //free_entities.size() = 0
+  assert(free_entities.size() == 0);
 
   //test making thick body.
   from_body = gmti->cylinder(10, 4, 4, 4); 

Modified: cgm/trunk/test/r_w.cpp
===================================================================
--- cgm/trunk/test/r_w.cpp	2008-08-18 16:40:10 UTC (rev 2042)
+++ cgm/trunk/test/r_w.cpp	2008-08-18 16:45:24 UTC (rev 2043)
@@ -172,8 +172,8 @@
   Body* tool_body = bodies.step_and_get();  
   rsl = gmti->subtract(tool_body,from_bodies, new_bodies,
                        CUBIT_TRUE, CUBIT_FALSE);
-  //Created volume(s): 21, 22
-  //Destroyed volume(s): 18, 20
+  //Created volume(s): 5, 6
+  //Destroyed volume(s): 3, 4
   double d = new_bodies.step_and_get()->measure();
   CubitVector v = new_bodies.get()->center_point();
   int n = new_bodies.get()->num_ref_faces();
@@ -193,5 +193,7 @@
   //delete all entities
   gti->delete_Body(bodies); 
   
+  gti->get_free_ref_entities(free_entities);
+  assert(free_entities.size() ==0);
   return CUBIT_SUCCESS;
 }




More information about the cgma-dev mailing list