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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Tue Apr 1 13:41:51 CDT 2008


Author: janehu
Date: 2008-04-01 13:41:51 -0500 (Tue, 01 Apr 2008)
New Revision: 1732

Modified:
   cgm/trunk/geom/OCC/OCCLump.cpp
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/geom/OCC/OCCModifyEngine.hpp
   cgm/trunk/geom/OCC/OCCShell.cpp
   cgm/trunk/geom/OCC/OCCShell.hpp
Log:
Test-modified for shell-solid subtraction case: a solid can suntract a shell while a shell can't subtract a solid, which gives a warning and returns failure.

Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp	2008-04-01 15:49:58 UTC (rev 1731)
+++ cgm/trunk/geom/OCC/OCCLump.cpp	2008-04-01 18:41:51 UTC (rev 1732)
@@ -218,8 +218,11 @@
 //-------------------------------------------------------------------------
 double OCCLump::measure()
 {
-  if(mySheetSurface || myShell)
-    return 0.0;
+  if(mySheetSurface) 
+    return mySheetSurface->measure();
+  else if(myShell)
+    return myShell->measure();
+
   GProp_GProps myProps;
   BRepGProp::VolumeProperties(*myTopoDSSolid, myProps);
   return myProps.Mass();

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-04-01 15:49:58 UTC (rev 1731)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-04-01 18:41:51 UTC (rev 1732)
@@ -71,6 +71,7 @@
 #include "CubitDefines.h"
 #include "TopTools_DataMapOfShapeInteger.hxx"
 #include "BRepFeat_SplitShape.hxx"
+#include "TopOpeBRep_trace.cxx"
 #include "TopOpeBRep_ShapeIntersector.hxx"
 #include "TopTools_ListIteratorOfListOfShape.hxx"
 #include "CubitUtil.hpp"
@@ -1612,6 +1613,8 @@
     }
   }
 
+  //for subtract function, tool-body has to be solid, 
+  //otherwise it's just imprint
   DLIList<CubitBox*> tool_boxes;
   for (int i = 0; i < tool_body_list.size(); i++)
   {
@@ -1619,22 +1622,11 @@
     OCCBody* occ_body = CAST_TO(body, OCCBody);     
     OCCSurface* surface = occ_body->my_sheet_surface();
     OCCShell*   shell = occ_body->shell();
-    if(surface)
+    if(surface || shell)
     {
-       TopoDS_Face* topo_face = surface->get_TopoDS_Face();
-       BRepBuilderAPI_Copy api_copy(*topo_face);
-       TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_face);
-       TopoDS_Shape* newShape_ptr = new TopoDS_Shape(newShape);
-       tool_bodies_copy.append(newShape_ptr);
+       PRINT_WARNING("Surfaces or Shells can't be used to cut a body.\n");
+       return CUBIT_FAILURE;
     }
-    else if(shell)
-    {
-       TopoDS_Shell* topo_shell = shell->get_TopoDS_Shell();
-       BRepBuilderAPI_Copy api_copy(*topo_shell);
-       TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_shell);
-       TopoDS_Shape* newShape_ptr = new TopoDS_Shape(newShape);
-       tool_bodies_copy.append(newShape_ptr);
-    }
     else
     {
        DLIList<Lump*> lumps = occ_body->lumps();
@@ -1817,7 +1809,8 @@
           CubitBoolean is_same_tool_face = CUBIT_FALSE;
           for (int j = 0; j < tool_faces.size(); j++)
           {
-  	    if(face2.IsSame(*(tool_faces.get_and_step())))
+            TopoDS_Face* topo_face = tool_faces.get_and_step();
+  	    if(face2.IsSame(*topo_face))
             {
               is_same_tool_face = CUBIT_TRUE;
 	      break;
@@ -1829,9 +1822,10 @@
 	      max_edge =  num_edges ;
 	      from_face = TopoDS::Face(face1);
               tool_face = TopoDS::Face(face2);
+              TopoDS_Face* topo_face = new TopoDS_Face(tool_face);
               tool_faces.clean_out();
               for(int i = 0 ; i < num_edges; i++)
-                tool_faces.append(&tool_face);
+                tool_faces.append(topo_face);
 	    }
           else if(num_edges == max_edge && is_same && !is_same_tool_face) 
           //multi tool faces cut the same face
@@ -1855,7 +1849,8 @@
               if(!same_edge)
               {
                 list_of_edges.Append(temp_edge);
-                tool_faces.append(&(TopoDS::Face(face2)));
+                TopoDS_Face* topo_face = new TopoDS_Face(TopoDS::Face(face2));
+                tool_faces.append(topo_face);
  	      }
             }
           }
@@ -1865,6 +1860,7 @@
       Itor.Initialize(list_of_edges);
       DLIList<Curve*> curve_list;
       CubitBoolean topo_changed = CUBIT_FALSE;
+      tool_faces.reset();
       for(; Itor.More(); Itor.Next())
       {
         TopoDS_Edge edge = TopoDS::Edge(Itor.Value());
@@ -1872,6 +1868,10 @@
         //edge to split it.
 	TopExp_Explorer Ex;
 	CubitBoolean added = CUBIT_FALSE;
+        //temp. set TopOpeBRep_contextNOFEI to be true to avoid calculating
+        //intersecting points from 2d to 3d space.
+        CubitBoolean contextNOFEI = TopOpeBRep_trace::TopOpeBRep_contextNOFEI;
+        TopOpeBRep_trace::TopOpeBRep_contextNOFEI =CUBIT_TRUE;
 	for (Ex.Init(from_face, TopAbs_EDGE); Ex.More(); Ex.Next())
 	{
 	  TopoDS_Edge from_edge = TopoDS::Edge(Ex.Current());
@@ -1887,6 +1887,7 @@
 	      break;
 	    }
         } 
+        TopOpeBRep_trace::TopOpeBRep_contextNOFEI = contextNOFEI; 
         if(added)
         {
           topo_changed = CUBIT_TRUE;
@@ -1895,6 +1896,7 @@
 	Curve* curve = OCCQueryEngine::instance()->populate_topology_bridge(edge);
 	curve_list.append(curve);
       }
+
       DLIList<DLIList<TopoDS_Edge*>*> edge_lists;
       if (max_edge >= 1)
 	{      
@@ -1922,7 +1924,7 @@
       if(edge_lists.size()==0)
 	num_cuts--;
   }
-  /*
+  
   TopExp_Explorer Ex;
   int num_face = 0;
   for (Ex.Init(*from_shape, TopAbs_FACE); Ex.More(); Ex.Next())
@@ -1930,7 +1932,7 @@
      TopoDS_Face face = TopoDS::Face(Ex.Current());
      num_face++;
   }
-  */
+ 
   return stat;
 }
 //===============================================================================

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.hpp	2008-04-01 15:49:58 UTC (rev 1731)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.hpp	2008-04-01 18:41:51 UTC (rev 1732)
@@ -653,13 +653,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*) const;
  
  CubitStatus sort_curves(DLIList<Curve*> curve_list,
                          DLIList<DLIList<TopoDS_Edge*>*>& topo_edges_loops)const;

Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp	2008-04-01 15:49:58 UTC (rev 1731)
+++ cgm/trunk/geom/OCC/OCCShell.cpp	2008-04-01 18:41:51 UTC (rev 1732)
@@ -35,6 +35,8 @@
 #include "TopTools_IndexedDataMapOfShapeListOfShape.hxx"
 #include "TopoDS.hxx"
 #include "TopTools_ListIteratorOfListOfShape.hxx"
+#include "GProp_GProps.hxx"
+#include "BRepGProp.hxx"
 #include "TopTools_DataMapOfShapeInteger.hxx"
 #include "TopTools_ListOfShape.hxx"
 #include "BRepBuilderAPI_Transform.hxx"
@@ -188,6 +190,17 @@
   return CUBIT_SUCCESS;
 }
 
+//-------------------------------------------------------------------------
+// Purpose       : Returns the area of the Shell
+//
+//-------------------------------------------------------------------------
+double OCCShell::measure()
+{
+  GProp_GProps myProps;
+  BRepGProp::SurfaceProperties(*myTopoDSShell, myProps);
+  return myProps.Mass();
+}
+
 // ********** END PUBLIC FUNCTIONS         **********
 
 // ********** BEGIN PROTECTED FUNCTIONS    **********

Modified: cgm/trunk/geom/OCC/OCCShell.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.hpp	2008-04-01 15:49:58 UTC (rev 1731)
+++ cgm/trunk/geom/OCC/OCCShell.hpp	2008-04-01 18:41:51 UTC (rev 1732)
@@ -107,6 +107,7 @@
   virtual void get_children_virt( DLIList<TopologyBridge*>& children );
 
   CubitStatus update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf);
+  double measure(); //area of the shell
 protected: 
   
 private:




More information about the cgma-dev mailing list