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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Thu May 15 15:10:24 CDT 2008


Author: janehu
Date: 2008-05-15 15:10:24 -0500 (Thu, 15 May 2008)
New Revision: 1815

Added:
   cgm/trunk/geom/OCC/OCCCoFace.cpp
   cgm/trunk/geom/OCC/OCCCoFace.hpp
Modified:
   cgm/trunk/geom/OCC/OCCLump.cpp
   cgm/trunk/geom/OCC/OCCLump.hpp
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/geom/OCC/OCCShell.cpp
   cgm/trunk/geom/OCC/OCCShell.hpp
   cgm/trunk/geom/OCC/OCCSurface.cpp
   cgm/trunk/geom/OCC/OCCSurface.hpp
Log:
Added for imprint keeping old surfaces.

Added: cgm/trunk/geom/OCC/OCCCoFace.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCoFace.cpp	                        (rev 0)
+++ cgm/trunk/geom/OCC/OCCCoFace.cpp	2008-05-15 20:10:24 UTC (rev 1815)
@@ -0,0 +1,93 @@
+//-------------------------------------------------------------------------
+// Filename      : OCCCoFace.cpp
+//
+// Purpose       : 
+//
+// Special Notes :
+//
+// Creator       : Jane Hu
+//
+// Creation Date : 04/28/08
+//
+//-------------------------------------------------------------------------
+
+// ********** BEGIN STANDARD INCLUDES      **********
+// ********** END STANDARD INCLUDES        **********
+#include "config.h"
+// ********** BEGIN CUBIT INCLUDES         **********
+#include "CubitDefines.h"
+#include "CastTo.hpp"
+#include "OCCCoFace.hpp"
+#include "OCCLoop.hpp"
+#include "OCCQueryEngine.hpp"
+#include "CubitUtil.hpp"
+
+#include "OCCBody.hpp"
+#include "OCCLump.hpp"
+#include "OCCShell.hpp"
+#include "OCCSurface.hpp"
+#include "OCCCurve.hpp"
+// ********** END CUBIT INCLUDES           **********
+
+// ********** BEGIN FORWARD DECLARATIONS   **********
+// ********** END FORWARD DECLARATIONS     **********
+
+// ********** BEGIN STATIC DECLARATIONS    **********
+// ********** END STATIC DECLARATIONS      **********
+
+// ********** BEGIN PUBLIC FUNCTIONS       **********
+
+
+OCCCoFace::OCCCoFace( OCCSurface *surf_ptr, 
+	  	      OCCShell *shell_ptr, CubitSense sense )
+	 	    : mySurface(surf_ptr), 
+ 	  	      myShell(shell_ptr),faceSense(sense)
+{
+}
+
+//-------------------------------------------------------------------------
+// Purpose       : The destructor
+//
+// Special Notes :
+//
+// Creator       : Jane HU  
+//
+// Creation Date : 04/28/08
+//-------------------------------------------------------------------------
+OCCCoFace::~OCCCoFace()
+{
+}
+
+GeometryQueryEngine*
+OCCCoFace::get_geometry_query_engine() const
+{
+}
+
+
+void OCCCoFace::get_parents_virt( DLIList<TopologyBridge*>& parents )
+{
+  parents.append(shell());
+}
+
+void OCCCoFace::get_children_virt( DLIList<TopologyBridge*>& children )
+{
+  children.append(surface());
+}
+
+// ********** END PUBLIC FUNCTIONS         **********
+
+// ********** BEGIN PROTECTED FUNCTIONS    **********
+// ********** END PROTECTED FUNCTIONS      **********
+
+// ********** BEGIN PRIVATE FUNCTIONS      **********
+// ********** END PRIVATE FUNCTIONS        **********
+
+// ********** BEGIN HELPER CLASSES         **********
+// ********** END HELPER CLASSES           **********
+
+// ********** BEGIN EXTERN FUNCTIONS       **********
+// ********** END EXTERN FUNCTIONS         **********
+
+// ********** BEGIN STATIC FUNCTIONS       **********
+// ********** END STATIC FUNCTIONS         **********
+


Property changes on: cgm/trunk/geom/OCC/OCCCoFace.cpp
___________________________________________________________________
Name: svn:executable
   + *

Added: cgm/trunk/geom/OCC/OCCCoFace.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCoFace.hpp	                        (rev 0)
+++ cgm/trunk/geom/OCC/OCCCoFace.hpp	2008-05-15 20:10:24 UTC (rev 1815)
@@ -0,0 +1,96 @@
+//-------------------------------------------------------------------------
+// Filename      : OCCCoFace.hpp
+//
+// Purpose       : 
+//
+// Special Notes :
+//
+// Creator       : Jane Hu 
+//
+// Creation Date : 04/23/08
+//
+//-------------------------------------------------------------------------
+
+#ifndef OCCCOFACE_HPP
+#define OCCCOFACE_HPP
+
+// ********** BEGIN STANDARD INCLUDES      **********
+// ********** END STANDARD INCLUDES        **********
+
+// ********** BEGIN CUBIT INCLUDES         **********
+#include "CubitDefines.h"
+#include "CubitEntity.hpp"
+#include <TopoDS_Face.hxx>
+#include "DLIList.hpp"
+// ********** END CUBIT INCLUDES           **********
+
+// ********** BEGIN FORWARD DECLARATIONS   **********
+class GeometryQueryEngine;
+class TopologyEntity;
+class TopologyBridge;
+class LoopSM;
+
+class OCCBody;
+class OCCLump;
+class OCCShell;
+class OCCSurface;
+class OCCLoop;
+class OCCCurve;
+class OCCPoint;
+// ********** END FORWARD DECLARATIONS     **********
+
+class OCCCoFace
+{
+public:
+  
+  OCCCoFace(OCCSurface *surf_ptr, OCCShell *shell_ptr, CubitSense sense);
+    //- A constructor
+  
+  virtual ~OCCCoFace() ;
+    //- The destructor
+    
+  inline CubitSense sense(){return faceSense;}
+    //- returns the sense of the underlying coface wrt the underlying face
+
+  inline void set_sense(CubitSense sense) {faceSense = sense;}
+
+  inline OCCSurface *surface()
+    {return mySurface;}
+    //- get the surface associated with this coedge
+    
+  inline void set_surface(OCCSurface* surface) {mySurface = surface;}
+
+  inline OCCShell* shell() const { return myShell; }
+
+  inline void set_shell(OCCShell * shell) {myShell = shell;}
+
+  GeometryQueryEngine*
+  get_geometry_query_engine() const;
+    //R GeometryQueryEngine*
+    //R- A pointer to the geometric modeling engine associated with
+    //R- the object.
+    //- This function returns a pointer to the geometric modeling engine
+    //- associated with the object.
+
+  void get_parents_virt( DLIList<TopologyBridge*>& parents );
+  void get_children_virt( DLIList<TopologyBridge*>& children );
+protected: 
+  
+private:
+  OCCShell *myShell;
+  OCCSurface *mySurface;
+  CubitSense faceSense;
+};
+
+
+// ********** BEGIN INLINE FUNCTIONS       **********
+// ********** END INLINE FUNCTIONS         **********
+
+// ********** BEGIN FRIEND FUNCTIONS       **********
+// ********** END FRIEND FUNCTIONS         **********
+
+// ********** BEGIN EXTERN FUNCTIONS       **********
+// ********** END EXTERN FUNCTIONS         **********
+
+#endif
+


Property changes on: cgm/trunk/geom/OCC/OCCCoFace.hpp
___________________________________________________________________
Name: svn:executable
   + *

Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp	2008-05-15 19:56:01 UTC (rev 1814)
+++ cgm/trunk/geom/OCC/OCCLump.cpp	2008-05-15 20:10:24 UTC (rev 1815)
@@ -40,6 +40,7 @@
 #include "BRepBuilderAPI_Transform.hxx"
 #include "TopTools_DataMapOfShapeInteger.hxx"
 #include "BRepAlgoAPI_BooleanOperation.hxx"
+#include "BRepBuilderAPI_MakeShape.hxx"
 #include "Bnd_Box.hxx"
 #include "BRepBndLib.hxx"
 #include "GProp_GProps.hxx"
@@ -352,7 +353,7 @@
 //----------------------------------------------------------------
 CubitStatus OCCLump::update_OCC_entity(TopoDS_Solid& old_solid,
                                        TopoDS_Shape& new_shape,
-                                       BRepAlgoAPI_BooleanOperation *op)
+                                       BRepBuilderAPI_MakeShape *op)
 {
   //set the Shells
   TopTools_IndexedMapOfShape M;
@@ -399,5 +400,12 @@
   TopoDS_Solid new_solid;
   if(!is_null_new_shape && !op->IsDeleted(old_solid))
     new_solid = TopoDS::Solid(new_shape);
+  else if (op->IsDeleted(old_solid))
+  {
+    M.Clear();
+    TopExp::MapShapes(new_shape, TopAbs_SOLID, M);
+    if(M.Extent() == 1)
+      new_solid = TopoDS::Solid(M(1));
+  }
   OCCQueryEngine::instance()->update_OCC_map(old_solid, new_solid);
 }

Modified: cgm/trunk/geom/OCC/OCCLump.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.hpp	2008-05-15 19:56:01 UTC (rev 1814)
+++ cgm/trunk/geom/OCC/OCCLump.hpp	2008-05-15 20:10:24 UTC (rev 1815)
@@ -37,6 +37,7 @@
 class OCCCurve;
 class OCCPoint;
 class BRepBuilderAPI_Transform;
+class BRepBuilderAPI_MakeShape;
 class BRepAlgoAPI_BooleanOperation;
 // ********** END FORWARD DECLARATIONS     **********
 
@@ -156,7 +157,7 @@
                                 BRepAlgoAPI_BooleanOperation *op = NULL);
   static CubitStatus update_OCC_entity(TopoDS_Solid& old_shape,
                                        TopoDS_Shape& new_shape,
-                                       BRepAlgoAPI_BooleanOperation *op);
+                                       BRepBuilderAPI_MakeShape *op);
 protected: 
   
 private:

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-05-15 19:56:01 UTC (rev 1814)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-05-15 20:10:24 UTC (rev 1815)
@@ -69,6 +69,7 @@
 #include "BRepPrimAPI_MakeWedge.hxx"
 #include "Handle_Geom_TrimmedCurve.hxx"
 #include "Handle_Geom_RectangularTrimmedSurface.hxx"
+#include "BndLib_Add3dCurve.hxx"
 #include "TopOpeBRep_EdgesIntersector.hxx"
 #include "TopExp_Explorer.hxx"
 #include "TopExp.hxx"
@@ -1808,7 +1809,7 @@
         double orig_mass = myProps.Mass();
         BRepGProp::VolumeProperties(cut_shape, myProps);
         double after_mass = myProps.Mass();
-        if((-after_mass + orig_mass) <= tol*tol*tol)
+        if((-after_mass + orig_mass) <= tol)
         {
           stat = CUBIT_FAILURE;
           //Add imprint code here 
@@ -1822,7 +1823,7 @@
           continue;
         }
         //got cut. Update the entities
-        if(after_mass > tol*tol*tol)
+        if(after_mass > tol)
         {
           TopoDS_Solid old_solid = TopoDS::Solid(cutter.Shape1());
           OCCLump::update_OCC_entity(old_solid , cut_shape, &cutter);
@@ -1835,7 +1836,7 @@
         double orig_mass = myProps.Mass();
         BRepGProp::SurfaceProperties(cut_shape, myProps);
         double after_mass = myProps.Mass();
-        if((-after_mass + orig_mass) <= tol*tol)
+        if((-after_mass + orig_mass) <= tol)
         {
           stat = CUBIT_FAILURE;
           //Add imprint code here
@@ -1849,7 +1850,7 @@
           continue;
         }
         //got cut. Update the entities
-        if(after_mass > tol*tol)
+        if(after_mass > tol)
         { 
           if(from_shape->TShape()->ShapeType() == TopAbs_SHELL)
           {
@@ -1958,6 +1959,7 @@
 	  TopTools_ListOfShape temp_list_of_edges;
 	  temp_list_of_edges.Assign(section.SectionEdges());
 	  int num_edges = temp_list_of_edges.Extent();
+  
           CubitBoolean is_same = face1.IsSame(from_face);
           CubitBoolean is_same_tool_face = CUBIT_FALSE;
           for (int j = 0; j < tool_faces.size(); j++)
@@ -2023,7 +2025,7 @@
   
       TopTools_ListIteratorOfListOfShape Itor;
 
-      //list_of_edges is the intersection edges on from_face from all tool_faces
+      //list_of_edges is the intersection edges on tool_faces 
       Itor.Initialize(list_of_edges);
       int total_edges = list_of_edges.Extent();
       DLIList<Curve*> curve_list;
@@ -2080,9 +2082,6 @@
             //check if they are the same edge, so don't need to be split
             //the overlapped edges are considered the same if they have the
             //same length
-            GProp_GProps myProps1;
-            BRepGProp::LinearProperties(edge, myProps1);
-            double d1 = myProps1.Mass();
             GProp_GProps myProps2;
             BRepGProp::LinearProperties(from_edge, myProps2);
             double d2 = myProps2.Mass();
@@ -2104,8 +2103,22 @@
         }
         if (!skipped)
         {
-	  Curve* curve = OCCQueryEngine::instance()->populate_topology_bridge(edge);
-	  curve_list.append(curve);
+          //check if edge's inside from_face by checking bounding boxes  
+          BRepAdaptor_Curve acurve(edge);
+          BRepAdaptor_Surface asurface( from_face);
+          Bnd_Box aBox_edge, aBox_face;
+          BndLib_Add3dCurve::Add(acurve, Precision::Approximation(), aBox_edge);
+          BndLib_AddSurface::Add(asurface, Precision::Approximation(), aBox_face);
+          double min[3], max[3];
+          aBox_edge.Get( min[0], min[1], min[2], max[0], max[1], max[2]);
+          CubitBox aBox_e(min, max);
+          aBox_face.Get( min[0], min[1], min[2], max[0], max[1], max[2]);
+          CubitBox aBox_f(min, max);
+          if (aBox_e <= aBox_f)
+          {
+	    Curve* curve = OCCQueryEngine::instance()->populate_topology_bridge(edge);
+	    curve_list.append(curve);
+          }
         }
       }
 
@@ -2144,8 +2157,46 @@
         splitor.Build();
         if(splitor.IsDone())
         {
-	  delete from_shape;
-          from_shape = new TopoDS_Shape(splitor.Shape());
+          TopoDS_Shape new_from_shape = splitor.Shape();
+          if(from_shape->TShape()->ShapeType() == TopAbs_COMPSOLID)
+          {
+            TopTools_IndexedMapOfShape M;
+            TopExp::MapShapes(*from_shape, TopAbs_SOLID, M);
+            if (M.Extent() == 1)
+            {
+              TopoDS_Solid old_solid = TopoDS::Solid(M(1));
+              OCCLump::update_OCC_entity(old_solid, new_from_shape, &splitor);
+              from_shape = new TopoDS_Shape(old_solid);
+            }
+          }
+
+          else if(from_shape->TShape()->ShapeType() == TopAbs_SOLID)
+          {
+            TopoDS_Solid old_solid = TopoDS::Solid(*from_shape);
+            OCCLump::update_OCC_entity(old_solid, new_from_shape, &splitor);
+            from_shape = new TopoDS_Shape(old_solid);
+          }
+          else if(from_shape->TShape()->ShapeType() == TopAbs_SHELL)
+          {
+            TopoDS_Shell old_shell = TopoDS::Shell(*from_shape);
+            OCCShell::update_OCC_entity(old_shell,new_from_shape, &splitor);
+            from_shape = new TopoDS_Shape(old_shell);
+          }
+          else if(from_shape->TShape()->ShapeType() == TopAbs_FACE)
+          {
+            TopoDS_Face old_face = TopoDS::Face(*from_shape);
+            OCCSurface::update_OCC_entity(old_face,new_from_shape, &splitor);
+            from_shape = new TopoDS_Shape(old_face);
+          }
+
+          else //imprinting an edge
+          {
+             TopoDS_Edge old_edge = TopoDS::Edge(*from_shape);
+             TopTools_IndexedMapOfShape M;
+             TopExp::MapShapes(new_from_shape, TopAbs_EDGE, M);
+             if (M.Extent() > 1) //split successfully
+               OCCQueryEngine::instance()->update_OCC_map(old_edge, M(1));
+          }
           TopTools_ListOfShape shapes;
           for(int i = 0; i < from_faces.size(); i++)
           {
@@ -2155,13 +2206,6 @@
              from_faces.change_to(topo_face);
              from_faces.step();
           } 
-          shapes.Assign(splitor.Modified(from_face)); 
-          TopTools_ListIteratorOfListOfShape It(shapes);
-          for(; It.More(); It.Next())
-          {
-	    TopoDS_Face* topo_face = new TopoDS_Face(TopoDS::Face(It.Value()));
-            from_faces.append(topo_face);
-          }
           count++;
         }
       }

Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp	2008-05-15 19:56:01 UTC (rev 1814)
+++ cgm/trunk/geom/OCC/OCCShell.cpp	2008-05-15 20:10:24 UTC (rev 1815)
@@ -42,6 +42,7 @@
 #include "TopTools_ListOfShape.hxx"
 #include "BRepBuilderAPI_Transform.hxx"
 #include "BRepAlgoAPI_BooleanOperation.hxx"
+#include "BRepBuilderAPI_MakeShape.hxx"
 // ********** END CUBIT INCLUDES           **********
 
 // ********** BEGIN STATIC DECLARATIONS    **********
@@ -258,7 +259,7 @@
 //----------------------------------------------------------------
 CubitStatus OCCShell::update_OCC_entity(TopoDS_Shell& old_shell,
                                         TopoDS_Shape& new_shell,
-                                        BRepAlgoAPI_BooleanOperation *op)
+                                        BRepBuilderAPI_MakeShape *op)
 {
   //set the surfaces
   TopTools_IndexedMapOfShape M;

Modified: cgm/trunk/geom/OCC/OCCShell.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.hpp	2008-05-15 19:56:01 UTC (rev 1814)
+++ cgm/trunk/geom/OCC/OCCShell.hpp	2008-05-15 20:10:24 UTC (rev 1815)
@@ -36,7 +36,7 @@
 class OCCPoint;
 class BRepBuilderAPI_Transform;
 class BRepAlgoAPI_BooleanOperation;
-
+class BRepBuilderAPI_MakeShape;
 // ********** END CUBIT INCLUDES           **********
 
 class OCCShell : public ShellSM
@@ -120,7 +120,7 @@
   double measure(); //area of the shell
   static CubitStatus update_OCC_entity(TopoDS_Shell& old_shell,
                                        TopoDS_Shape& new_shell,
-                                       BRepAlgoAPI_BooleanOperation *op);
+                                       BRepBuilderAPI_MakeShape *op);
 protected: 
   
 private:

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2008-05-15 19:56:01 UTC (rev 1814)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2008-05-15 20:10:24 UTC (rev 1815)
@@ -44,6 +44,7 @@
 #include "LoopSM.hpp"
 #include "CubitPointData.hpp"
 #include "BRepAlgoAPI_BooleanOperation.hxx"
+#include "BRepBuilderAPI_MakeShape.hxx"
 #include "BRepTools_WireExplorer.hxx"
 #include "BRep_Tool.hxx"
 
@@ -828,7 +829,7 @@
 //----------------------------------------------------------------
 CubitStatus OCCSurface::update_OCC_entity(TopoDS_Face& old_surface,
                                           TopoDS_Shape& new_surface,
-                                          BRepAlgoAPI_BooleanOperation *op)
+                                          BRepBuilderAPI_MakeShape *op)
 {
   //set the Wires
   TopTools_IndexedMapOfShape M;

Modified: cgm/trunk/geom/OCC/OCCSurface.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.hpp	2008-05-15 19:56:01 UTC (rev 1814)
+++ cgm/trunk/geom/OCC/OCCSurface.hpp	2008-05-15 20:10:24 UTC (rev 1815)
@@ -49,6 +49,7 @@
 class OCCPoint;
 class BRepBuilderAPI_Transform;
 class BRepAlgoAPI_BooleanOperation;
+class BRepBuilderAPI_MakeShape;
 //// class CubitTransformMatrix;
 
 class OCCSurface : public Surface
@@ -63,7 +64,7 @@
    
   static CubitStatus update_OCC_entity(TopoDS_Face& old_surface,
                                        TopoDS_Shape& new_surface,
-                                       BRepAlgoAPI_BooleanOperation *op);
+                                       BRepBuilderAPI_MakeShape *op);
 
 
   void add_shell(OCCShell* shell) { myShellList.append_unique(shell);}




More information about the cgma-dev mailing list