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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Thu May 29 15:06:23 CDT 2008


Author: janehu
Date: 2008-05-29 15:06:23 -0500 (Thu, 29 May 2008)
New Revision: 1863

Modified:
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/geom/OCC/OCCModifyEngine.hpp
   cgm/trunk/geom/OCC/OCCSurface.cpp
   cgm/trunk/test/modify.cpp
Log:
Test-passed edge imprint on surface.

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-05-29 17:58:25 UTC (rev 1862)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-05-29 20:06:23 UTC (rev 1863)
@@ -122,7 +122,7 @@
 #include "SphereEvaluator.hpp"
 #include "CylinderEvaluator.hpp"
 OCCModifyEngine* OCCModifyEngine::instance_ = 0;
-
+#define DEBUG
 //===============================================================================
 // Function   : OCCModifyEngine
 // Member Type: PUBLIC
@@ -1897,11 +1897,14 @@
 // Description: imprint boolean operation on OCC-based bodies.
 //              from_shape must be TopoDS_Face or above, tool_shape can be
 //              TopoDS_Edge or above. 
+//              on_faces works only when tool_shape is an Edge, indicates that
+//              those edges only imprint on the on_faces.
 // Author     : Jane HU
 // Date       : 03/08
 //===============================================================================
 CubitStatus OCCModifyEngine::imprint_toposhapes(TopoDS_Shape*& from_shape, 
-                                                TopoDS_Shape* tool_shape)const
+                                             TopoDS_Shape* tool_shape,
+                                             DLIList<TopoDS_Face*>*on_faces)const
 {
   int count = 0;   //number of imprinting
  
@@ -1918,13 +1921,27 @@
     DLIList<TopoDS_Shape*> tool_faces_edges;
     TopTools_ListOfShape list_of_edges;
     BRepFeat_SplitShape splitor(*from_shape);
+    CubitBoolean qualified = CUBIT_TRUE;
     if (tool_shape->TShape()->ShapeType() == TopAbs_EDGE)
     {
       if(count == 1)
         break;
       common_edge = find_imprinting_edge(*from_shape, TopoDS::Edge(*tool_shape),from_face);
       if (common_edge)
-        list_of_edges.Append(*common_edge);
+      {
+        for (int i = 0; on_faces && i < on_faces->size(); i++)
+        {
+          if (from_face.IsSame(*(on_faces->get_and_step())))
+          {
+            qualified = CUBIT_FALSE; 
+            break;
+          }
+        }
+        if (qualified && (from_faces.size() == 0 || (from_faces.size() && !from_face.IsSame(*from_faces.get()))) )
+          list_of_edges.Append(*common_edge);
+        else
+          from_face.Nullify();
+      }
     }
     else 
     {
@@ -2278,7 +2295,10 @@
      num_face++;
   }
   
+#ifdef DEBUG  
   PRINT_INFO("Total %d cuts performed, with from_shape having %d faces.\n", count, num_face); 
+#endif
+
   if (count > 0)
      return CUBIT_SUCCESS;
   return CUBIT_FAILURE;
@@ -2299,7 +2319,6 @@
 {
   //list of face on from_shape that has been imprinted
   DLIList<TopoDS_Face*> from_faces;
-  double tol = OCCQueryEngine::instance()->get_sme_resabs_tolerance();
   TopExp_Explorer Ex;
   for (Ex.Init(from_shape, TopAbs_FACE); Ex.More(); Ex.Next())
   {
@@ -2434,7 +2453,7 @@
   bodysm_list.append(BodyPtr1);
   bodysm_list.append(BodyPtr2);
   
-  CubitStatus stat = get_the_shape_list(bodysm_list, shape_list, keep_old);
+  CubitStatus stat = get_shape_list(bodysm_list, shape_list, keep_old);
 
   if(!stat)
     return stat;
@@ -2480,7 +2499,7 @@
 // Author     : Jane Hu
 // Date       : 05/08
 //===============================================================================
-CubitStatus OCCModifyEngine::get_the_shape_list(DLIList<BodySM*> BodySM_list, 
+CubitStatus OCCModifyEngine::get_shape_list(DLIList<BodySM*> BodySM_list, 
                                          DLIList<TopoDS_Shape*>& shape_list,
                                          bool  keep_old) const
 {
@@ -2557,7 +2576,7 @@
   CubitStatus success = CUBIT_SUCCESS;
   DLIList<TopoDS_Shape*> shape_list;
 
-  CubitStatus stat = get_the_shape_list(from_body_list, shape_list, keep_old);
+  CubitStatus stat = get_shape_list(from_body_list, shape_list, keep_old);
 
   if(!stat)
     return stat;
@@ -2627,7 +2646,7 @@
   CubitStatus success = CUBIT_SUCCESS;
   DLIList<TopoDS_Shape*> shape_list, tool_shapes;
 
-  CubitStatus stat = get_the_shape_list(body_list, shape_list, keep_old);
+  CubitStatus stat = get_shape_list(body_list, shape_list, keep_old);
   if (!stat)
     return stat;
 
@@ -2690,17 +2709,104 @@
 //===============================================================================
 // Function   : imprint
 // Member Type: PUBLIC
-// Description: imprint boolean operation on facet-based bodies
-// Author     : John Fowler
-// Date       : 10/02
+// Description: to be consistante with Acis imprint.
+//              The surfaces must be part of a body, but the curves 
+//              just have to be valid OCC edge.
+// Author     : Jane Hu
+// Date       : 05/08
 //===============================================================================
-CubitStatus     OCCModifyEngine::imprint( DLIList<Surface*> &/*ref_face_list*/,
-                                           DLIList<Curve*> &/*ref_edge_list*/,
-                                           DLIList<BodySM*>& /*new_body_list*/,
-                                           bool /*keep_old_body*/ ) const
+CubitStatus     OCCModifyEngine::imprint( DLIList<Surface*> &ref_face_list,
+                                          DLIList<Curve*> &edge_list,
+                                          DLIList<BodySM*>& new_body_list,
+                                          bool keep_old ) const
 {
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
+  DLIList<TopoDS_Face*> face_list;
+  DLIList<TopoDS_Shape*> shape_list;
+  for(int i = 0; i <ref_face_list.size(); i++)
+  {
+    OCCSurface* surface = CAST_TO(ref_face_list.get_and_step(), OCCSurface);
+    if(!surface)
+      continue;
+   
+    TopoDS_Face* topo_face = surface->get_TopoDS_Face();
+    face_list.append(topo_face);
+
+    if(surface->my_shell() && !surface->my_body())//shell body
+      shape_list.append(surface->my_shell()->get_TopoDS_Shell());
+    else if(surface->my_body()) //a sheet body
+      shape_list.append(topo_face);
+    else 
+    {
+      int size = shape_list.size();
+      OCCQueryEngine* oqe = OCCQueryEngine::instance();
+      DLIList <OCCBody* > *bodies = oqe->BodyList;
+      TopTools_IndexedDataMapOfShapeListOfShape M;
+      OCCBody * body = NULL;
+      for(int i = 0; i <  bodies->size(); i++)
+      {
+        body = bodies->get_and_step();
+        TopExp::MapShapesAndAncestors(*(body->get_TopoDS_Shape()),
+                                 TopAbs_FACE, TopAbs_SOLID, M);
+        if(!M.Contains(*topo_face))
+          continue; 
+        const TopTools_ListOfShape& ListOfShapes =
+                              M.FindFromKey(*topo_face);
+        if (!ListOfShapes.IsEmpty())
+        {
+          TopTools_ListIteratorOfListOfShape it(ListOfShapes) ;
+          for (;it.More(); it.Next())
+          {
+            TopoDS_Solid solid = TopoDS::Solid(it.Value());
+            int k = oqe->OCCMap->Find(solid);
+            OCCLump* lump = (OCCLump*)oqe->OccToCGM->find(k)->second;
+            if(lump && lump->get_TopoDS_Solid())
+              shape_list.append_unique(lump->get_TopoDS_Solid());
+          }
+        }
+      }
+      assert(size < shape_list.size());
+    }
+  }
+
+  if(keep_old)
+  {
+    for(int i = 0; i < shape_list.size(); i++)
+    {
+      TopoDS_Shape* shape = shape_list.get();
+      BRepBuilderAPI_Copy api_copy(*shape);
+      TopoDS_Shape newShape = api_copy.ModifiedShape(*shape);
+      TopoDS_Shape* Shape1 = new TopoDS_Shape(newShape);
+      shape_list.change_to(Shape1);
+      shape_list.step();
+    }
+  } 
+
+  for (int i = 0; i < edge_list.size(); i++)
+  {
+    OCCCurve* curve = CAST_TO(edge_list.get_and_step(), OCCCurve) ;
+    if (!curve)
+      continue;
+
+    TopoDS_Edge* edge = curve->get_TopoDS_Edge();
+    if (edge->IsNull())
+      continue;
+
+    for(int j = 0; j < shape_list.size(); j ++)
+    {
+      TopoDS_Shape* shape = shape_list.get_and_step();
+      imprint_toposhapes(shape, (TopoDS_Shape*)edge, &face_list);
+    }
+  }
+
+  for(int j = 0; j < shape_list.size(); j ++)
+  {
+    DLIList<TopologyBridge*> tbs;
+    TopoDS_Shape* shape = shape_list.get_and_step();
+    tbs += OCCQueryEngine::instance()->populate_topology_bridge(*shape);
+    new_body_list.append(CAST_TO(tbs.get(),BodySM));
+  }
+
+  return CUBIT_SUCCESS;
 }
 
 //===============================================================================

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.hpp	2008-05-29 17:58:25 UTC (rev 1862)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.hpp	2008-05-29 20:06:23 UTC (rev 1863)
@@ -652,14 +652,14 @@
                                   DLIList<TopologyBridge*>*,
                                   DLIList<TopologyBridge*>* ) const; 
 
-  CubitStatus imprint_toposhapes(TopoDS_Shape*&, TopoDS_Shape*) const;
 protected:
 
  const TopoDS_Face* make_TopoDS_Face( GeometryType surface_type,
   	                        DLIList<DLIList<TopoDS_Edge*>*> topo_edges, 
                                 Surface* old_surface_ptr) const;     
 
- //CubitStatus imprint_toposhapes(TopoDS_Shape*&, TopoDS_Shape*) const;
+ CubitStatus imprint_toposhapes(TopoDS_Shape*&, TopoDS_Shape*,
+                                DLIList<TopoDS_Face*>*on_faces = NULL) const;
 
  TopoDS_Edge* find_imprinting_edge(TopoDS_Shape& from_shape,
                                    TopoDS_Edge& tool_shape,
@@ -673,7 +673,7 @@
 private:
  int check_intersection(DLIList<TopoDS_Edge*>* edge_list,
                         TopoDS_Face from_face)const;
- CubitStatus get_the_shape_list(DLIList<BodySM*> BodySM_list,
+ CubitStatus get_shape_list(DLIList<BodySM*> BodySM_list,
                          DLIList<TopoDS_Shape*>& shape_list,
                          bool  keep_old) const;
   

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2008-05-29 17:58:25 UTC (rev 1862)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2008-05-29 20:06:23 UTC (rev 1863)
@@ -683,7 +683,7 @@
 
 void OCCSurface::get_parents_virt( DLIList<TopologyBridge*>& parents )
 { 
-  if(myShell) //shell body
+  if(myShell) //shell or sheet body
   {
     parents.append(myShell);
     return;

Modified: cgm/trunk/test/modify.cpp
===================================================================
--- cgm/trunk/test/modify.cpp	2008-05-29 17:58:25 UTC (rev 1862)
+++ cgm/trunk/test/modify.cpp	2008-05-29 20:06:23 UTC (rev 1863)
@@ -293,6 +293,7 @@
   CubitVector v_move4(0,1,-1);
   gti->translate(from_body,v_move4);
   Body* cp_from_body = gmti->copy_body(from_body);
+  Body* cp_from_body2 = gmti->copy_body(from_body);
   Body* cp_tool_body = gmti->copy_body(tool_body);
   from_bodies.clean_out();
   from_bodies.append(from_body);
@@ -311,6 +312,22 @@
   from_bodies.append(cp_from_body);
   CubitStatus stat = gmti->imprint(from_bodies, ref_edges, new_bodies, CUBIT_FALSE, CUBIT_TRUE );
 
+  //test edge imprint on surface
+  CubitVector vv(5,1,4.0);
+  face_list.clean_out();
+  cp_from_body2->ref_faces(face_list);
+  int size = face_list.size();
+  for(int i = 0; i < size; i++)
+  {
+    CubitVector v = face_list.get()->center_point();
+    if(!v.about_equal(vv))
+      face_list.remove();
+    else
+      face_list.step();
+  }
+  assert(face_list.size() == 1);
+  stat = gmti->imprint(face_list, ref_edges, new_bodies, CUBIT_FALSE);
+
   bodies.clean_out();
   gti->bodies(bodies);
   //delete all entities
@@ -395,7 +412,7 @@
   from_bodies.clean_out();
   from_bodies.append(tool_body);
   
-  //test a shell cutting a body, failed operation with a warning message.
+  //test a shell cutting a body, failed operation with an Error message.
   rsl = gmti->subtract(from_body2, from_bodies, new_bodies,
                        CUBIT_TRUE, CUBIT_TRUE);
 
@@ -404,10 +421,6 @@
   CubitVector v_move5(0,0.5,0);
   gti->translate(tool_body,v_move5);
   from_body = gmti->brick(1,1,1);
-  //from_shape = CAST_TO(from_body->get_body_sm_ptr(), OCCBody)->get_TopoDS_Shape();
-  //tool_shape = CAST_TO(tool_body->get_body_sm_ptr(),OCCBody)->get_TopoDS_Shape();
-//  ome->imprint_toposhapes(tool_shape, from_shape);
-//  ome->imprint_toposhapes(from_shape, tool_shape);
   from_bodies.clean_out();
   new_bodies.clean_out();
   from_bodies.append(from_body);




More information about the cgma-dev mailing list