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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Mon Feb 18 16:41:21 CST 2008


Author: janehu
Date: 2008-02-18 16:41:20 -0600 (Mon, 18 Feb 2008)
New Revision: 1600

Modified:
   cgm/trunk/geom/OCC/OCCBody.cpp
   cgm/trunk/geom/OCC/OCCBody.hpp
   cgm/trunk/geom/OCC/OCCLump.cpp
   cgm/trunk/geom/OCC/OCCLump.hpp
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.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 free surface update for all upper level entities.

Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp	2008-02-15 20:31:00 UTC (rev 1599)
+++ cgm/trunk/geom/OCC/OCCBody.cpp	2008-02-18 22:41:20 UTC (rev 1600)
@@ -59,10 +59,12 @@
 // Special Notes :
 //
 //-------------------------------------------------------------------------
-OCCBody::OCCBody(TopoDS_CompSolid *theShape)
+OCCBody::OCCBody(TopoDS_CompSolid *theShape, CubitBoolean isSheetBody,
+                 OCCSurface* surface)
 {
   myTopoDSShape = theShape;
-  
+  IsSheetBody = isSheetBody; 
+  mySheetSurface = surface;
   update_bounding_box();
 }
 
@@ -84,6 +86,7 @@
      B.Add(Co, *solid);
   }
   myTopoDSShape = new TopoDS_CompSolid(Co);
+  IsSheetBody = CUBIT_FALSE;
   update_bounding_box();
 }
 
@@ -146,10 +149,21 @@
   gp_Trsf aTrsf;
   aTrsf.SetTranslation(aVec);
 
-  BRepBuilderAPI_Transform aBRepTrsf(*myTopoDSShape, aTrsf);
+  
+  BRepBuilderAPI_Transform aBRepTrsf(aTrsf);
+  if(IsSheetBody)
+  {
+    TopoDS_Face * face = mySheetSurface->get_TopoDS_Face();
+    aBRepTrsf.Perform(*face);
+    OCCQueryEngine::update_entity_shape((GeometryEntity*)mySheetSurface, aBRepTrsf);
+  }
+  else
+  {
+    aBRepTrsf.Perform(*myTopoDSShape);
+    update_OCC_entity(aBRepTrsf);
+  }
 
   // calculate for bounding box
-  update_OCC_entity(aBRepTrsf);
   update_bounding_box();
 
   return CUBIT_SUCCESS;
@@ -173,10 +187,20 @@
   gp_Trsf aTrsf;
   aTrsf.SetRotation(anAxis, angle);
 
-  BRepBuilderAPI_Transform aBRepTrsf(*myTopoDSShape, aTrsf);
+  BRepBuilderAPI_Transform aBRepTrsf(aTrsf);
+  if(IsSheetBody)
+  {
+    TopoDS_Face * face = mySheetSurface->get_TopoDS_Face();
+    aBRepTrsf.Perform(*face);
+    OCCQueryEngine::update_entity_shape(mySheetSurface, aBRepTrsf);
+  }
+  else
+  {
+    aBRepTrsf.Perform(*myTopoDSShape);
+    update_OCC_entity(aBRepTrsf);
+  }
 
   // calculate for bounding box
-  update_OCC_entity(aBRepTrsf);
   update_bounding_box();
 
   return CUBIT_SUCCESS;
@@ -194,10 +218,20 @@
   gp_Trsf aTrsf;
   aTrsf.SetScaleFactor(scale_factor);
 
-  BRepBuilderAPI_Transform aBRepTrsf(*myTopoDSShape, aTrsf);
+  BRepBuilderAPI_Transform aBRepTrsf(aTrsf);
+  if(IsSheetBody)
+  {
+    TopoDS_Face * face = mySheetSurface->get_TopoDS_Face();
+    aBRepTrsf.Perform(*face);
+    OCCQueryEngine::update_entity_shape(mySheetSurface, aBRepTrsf);
+  }
+  else
+  {
+    aBRepTrsf.Perform(*myTopoDSShape);
+    update_OCC_entity(aBRepTrsf);
+  }
 
   // calculate for bounding box
-  update_OCC_entity(aBRepTrsf);
   update_bounding_box();
 
   return CUBIT_SUCCESS;  
@@ -235,11 +269,21 @@
   gp_Trsf aTrsf;
   aTrsf.SetMirror(anAx2);
 
-  BRepBuilderAPI_Transform aBRepTrsf(*myTopoDSShape, aTrsf); 
+  BRepBuilderAPI_Transform aBRepTrsf(aTrsf);
+  if(IsSheetBody)
+  {
+    TopoDS_Face * face = mySheetSurface->get_TopoDS_Face();
+    aBRepTrsf.Perform(*face);
+    OCCQueryEngine::update_entity_shape(mySheetSurface, aBRepTrsf);
+  }
+  else
+  {
+    aBRepTrsf.Perform(*myTopoDSShape);
+    update_OCC_entity(aBRepTrsf);
+  }
 
   // update underlining OCC entities
-  update_OCC_entity(aBRepTrsf);
-
+  update_bounding_box();
   return CUBIT_SUCCESS;
 }
 
@@ -252,6 +296,9 @@
 //----------------------------------------------------------------
 CubitStatus OCCBody::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf) 
 {
+  if(IsSheetBody)
+    return CUBIT_FAILURE;
+
   TopoDS_Shape shape = aBRepTrsf.Shape();
   TopoDS_CompSolid compsolid = TopoDS::CompSolid(shape);
 
@@ -297,7 +344,12 @@
 void OCCBody::update_bounding_box() 
 {
      Bnd_Box box;
-     const TopoDS_Shape shape=*myTopoDSShape;
+     TopoDS_Shape shape;
+     if(IsSheetBody)
+       shape = *(mySheetSurface->get_TopoDS_Face());
+     else
+       shape=*myTopoDSShape;
+
      //calculate the bounding box
      BRepBndLib::Add(shape, box);
      double min[3], max[3];
@@ -325,6 +377,12 @@
   
 void OCCBody::get_children_virt( DLIList<TopologyBridge*>& lumps )
 {
+  if (IsSheetBody)
+  { 
+    lumps.append(mySheetSurface->my_lump());
+    return;
+  }
+
   TopTools_IndexedMapOfShape M;
   TopExp::MapShapes(*myTopoDSShape, TopAbs_SOLID, M);
   int ii;
@@ -347,6 +405,8 @@
 CubitStatus OCCBody::mass_properties( CubitVector& centroid, 
                                       double& volume )
 {
+  if(IsSheetBody)
+    return CUBIT_FAILURE;
   GProp_GProps myProps;
   BRepGProp::VolumeProperties(*myTopoDSShape, myProps);
   volume = myProps.Mass();
@@ -367,6 +427,9 @@
 //-------------------------------------------------------------------------
 CubitPointContainment OCCBody::point_containment( const CubitVector &point )
 {
+  if(IsSheetBody)
+    return CUBIT_PNT_UNKNOWN;
+
   CubitPointContainment pc_value;
   OCCLump *lump;
 
@@ -396,6 +459,11 @@
 
 void OCCBody::get_all_surfaces(DLIList<OCCSurface*> &surfaces)
 {
+  if(IsSheetBody)
+  {
+    surfaces.append(mySheetSurface);
+    return;
+  }
   TopTools_IndexedMapOfShape M;
   TopExp::MapShapes(*myTopoDSShape, TopAbs_FACE, M);
   int ii;
@@ -419,8 +487,14 @@
 
 void OCCBody::get_all_curves(DLIList<OCCCurve*> &curves)
 {
+  TopoDS_Shape shape;
+  if(IsSheetBody)
+    shape = *(mySheetSurface->get_TopoDS_Face());
+  else 
+    shape = *myTopoDSShape;
+
   TopTools_IndexedMapOfShape M;
-  TopExp::MapShapes(*myTopoDSShape, TopAbs_EDGE, M);
+  TopExp::MapShapes(shape, TopAbs_EDGE, M);
   int ii;
   for (ii=1; ii<=M.Extent(); ii++) {
           TopologyBridge *curve = OCCQueryEngine::instance()->occ_to_cgm(M(ii));
@@ -442,8 +516,14 @@
 
 void OCCBody::get_all_points(DLIList<OCCPoint*> &points)
 {
+  TopoDS_Shape shape;
+  if(IsSheetBody)
+    shape = *(mySheetSurface->get_TopoDS_Face());
+  else 
+    shape = *myTopoDSShape;
+
   TopTools_IndexedMapOfShape M;
-  TopExp::MapShapes(*myTopoDSShape, TopAbs_VERTEX, M);
+  TopExp::MapShapes(shape, TopAbs_VERTEX, M);
   int ii;
   for (ii=1; ii<=M.Extent(); ii++) {
           TopologyBridge *vertex = OCCQueryEngine::instance()->occ_to_cgm(M(ii));

Modified: cgm/trunk/geom/OCC/OCCBody.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.hpp	2008-02-15 20:31:00 UTC (rev 1599)
+++ cgm/trunk/geom/OCC/OCCBody.hpp	2008-02-18 22:41:20 UTC (rev 1600)
@@ -46,7 +46,9 @@
 {
 public:
   
-  OCCBody(TopoDS_CompSolid *theShape);
+  OCCBody(TopoDS_CompSolid *theShape, CubitBoolean isSheetBody = CUBIT_FALSE, 
+          OCCSurface* surface = NULL);
+
   OCCBody(DLIList<Lump*>& my_lumps);
   void lumps(DLIList<Lump*>& my_lumps); //add lump list to myLumps
   DLIList<Lump*> lumps(){return myLumps;} 
@@ -182,6 +184,10 @@
   TopoDS_CompSolid *myTopoDSShape;
 
   CubitBox boundingbox;
+
+  CubitBoolean IsSheetBody;
+ 
+  OCCSurface* mySheetSurface;
 };
 
 

Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp	2008-02-15 20:31:00 UTC (rev 1599)
+++ cgm/trunk/geom/OCC/OCCLump.cpp	2008-02-18 22:41:20 UTC (rev 1600)
@@ -64,9 +64,10 @@
 // Special Notes :
 //
 //-------------------------------------------------------------------------
-OCCLump::OCCLump(TopoDS_Solid *theSolid)
+OCCLump::OCCLump(TopoDS_Solid *theSolid, OCCSurface* surface)
 {
   myTopoDSSolid = theSolid;
+  mySheetSurface = surface;
 }
 
 OCCLump::~OCCLump()
@@ -84,6 +85,9 @@
 CubitStatus OCCLump::mass_properties( CubitVector& centroid,
                                       double& volume )
 {
+  if (mySheetSurface)
+    return CUBIT_FAILURE;
+
   GProp_GProps myProps;
   BRepGProp::VolumeProperties(*myTopoDSSolid, myProps);
   volume = myProps.Mass();
@@ -170,7 +174,12 @@
 CubitBox OCCLump::bounding_box() const 
 {
   Bnd_Box box;
-  const TopoDS_Shape shape=*myTopoDSSolid;
+  TopoDS_Shape shape;
+  if(mySheetSurface)
+    shape = *(mySheetSurface->get_TopoDS_Face());
+  else
+    shape =*myTopoDSSolid;
+
   //calculate the bounding box
   BRepBndLib::Add(shape, box);
   double min[3], max[3];
@@ -206,6 +215,8 @@
 //-------------------------------------------------------------------------
 double OCCLump::measure()
 {
+  if(mySheetSurface)
+    return 0.0;
   GProp_GProps myProps;
   BRepGProp::VolumeProperties(*myTopoDSSolid, myProps);
   return myProps.Mass();
@@ -213,11 +224,19 @@
 
 void OCCLump::get_parents_virt(DLIList<TopologyBridge*> &bodies) 
 {
-  bodies.append(myBodyPtr);
+  if(mySheetSurface)
+    bodies.append(mySheetSurface->my_body());
+  else
+    bodies.append(myBodyPtr);
 }
 
 void OCCLump::get_children_virt(DLIList<TopologyBridge*> &shellsms)
 {
+  if (mySheetSurface)
+  {
+    shellsms.append(mySheetSurface->my_shell());
+    return;
+  }
   TopTools_IndexedMapOfShape M;
   TopExp::MapShapes(*myTopoDSSolid, TopAbs_SHELL, M);
   int ii;
@@ -231,6 +250,9 @@
 
 CubitPointContainment OCCLump::point_containment( const CubitVector &point )
 {
+  if (mySheetSurface)
+    return CUBIT_PNT_UNKNOWN;
+
   BOP_SolidClassifier ps;
   TopoDS_Solid * solid = get_TopoDS_Solid();
   gp_Pnt pnt(point.x(), point.y(), point.z());
@@ -261,6 +283,9 @@
 //----------------------------------------------------------------
 CubitStatus OCCLump::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf)
 {
+  if(mySheetSurface)
+    return CUBIT_FAILURE;
+
   TopoDS_Shape shape = aBRepTrsf.ModifiedShape(*get_TopoDS_Solid());
   TopoDS_Solid solid = TopoDS::Solid(shape);
 

Modified: cgm/trunk/geom/OCC/OCCLump.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.hpp	2008-02-15 20:31:00 UTC (rev 1599)
+++ cgm/trunk/geom/OCC/OCCLump.hpp	2008-02-18 22:41:20 UTC (rev 1600)
@@ -44,7 +44,7 @@
 {
 public:
   
-  OCCLump(TopoDS_Solid *theSolid);
+  OCCLump(TopoDS_Solid *theSolid, OCCSurface* surface = NULL);
   
   virtual ~OCCLump();
     //- The destructor
@@ -159,6 +159,8 @@
 
   OCCAttribSet attribSet;
     //List of OCCAttrib*'s instead of CubitSimpleAttribs 
+
+  OCCSurface *mySheetSurface;
 } ;
 
 

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-02-15 20:31:00 UTC (rev 1599)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-02-18 22:41:20 UTC (rev 1600)
@@ -638,8 +638,10 @@
     newFace = TopoDS::Face(newShape);
   }
   
-  Surface *temp_surface = OCCQueryEngine::instance()->populate_topology_bridge(
-				newFace);
+  Surface *surface = OCCQueryEngine::instance()->populate_topology_bridge(
+                               newFace, CUBIT_TRUE);
+
+/*
   //get new parameters
   asurface.Initialize(newFace);
   U1 = asurface.FirstUParameter();
@@ -668,7 +670,7 @@
   DLIList<Surface*> surfs;
   lump->surfaces( surfs );
   Surface *surface = surfs.get();
-
+*/
   return surface;
 }
 

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-02-15 20:31:00 UTC (rev 1599)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-02-18 22:41:20 UTC (rev 1600)
@@ -1199,45 +1199,20 @@
 
       if(build_body)
       {
-      	OCCSurface* occ_surface = CAST_TO(surface, OCCSurface);
-        if (!occ_surface)
-        {
-          PRINT_ERROR("Cannot populate an OCC surface from the given TopoDS_Face.\n");
-          return (Surface *)NULL;
-        }
-
-        double UMax, VMax, UMin, VMin;
-        occ_surface->get_param_range_U(UMin, UMax);
-        occ_surface->get_param_range_V(VMin, VMax);
-   	Handle_Geom_Surface HGeom_surface = BRep_Tool::Surface(aShape);
-        TopoDS_Shell topo_shell = 
-		BRepBuilderAPI_MakeShell(HGeom_surface, UMin, UMax,VMin, VMax);
-  	TopoDS_Solid topo_solid = BRepBuilderAPI_MakeSolid(topo_shell);
-  	Lump *lump =
-         OCCQueryEngine::instance()->populate_topology_bridge(topo_solid,
-                                                              CUBIT_TRUE);
-
-      	if (lump == NULL)
-  	{
-    	  PRINT_ERROR("In OCCQueryEngine::populate_topology_bridge\n"
-                "       Cannot make sheet body object.\n");
-          return (Surface *)NULL;
-        }
-        DLIList<Surface*> surfs;
-        lump->surfaces( surfs );
-        delete surface;
-        surface = CAST_TO(surfs.get(),OCCSurface);
+        OCCShell* shell(NULL, surface);
+        OCCLump* lump(NULL, surface);
+        OCCBody* body(NULL, CUBIT_TRUE, surface);
+        surface->set_body(body);
+        surface->set_lump(lump);
+        surface->set_shell(shell);
       }
-      else
-      {
-        if(PRINT_RESULT)
-          PRINT_INFO("Adding faces.\n");
-        iTotalTBCreated++;
-        OCCMap->Bind(*poface, iTotalTBCreated);
-        OccToCGM->insert(valType(iTotalTBCreated,
-                               (TopologyBridge*)surface));
-        SurfaceList->append(surface);
-      }
+      if(PRINT_RESULT)
+        PRINT_INFO("Adding faces.\n");
+      iTotalTBCreated++;
+      OCCMap->Bind(*poface, iTotalTBCreated);
+      OccToCGM->insert(valType(iTotalTBCreated,
+                             (TopologyBridge*)surface));
+      SurfaceList->append(surface);
     } 
   else 
     {

Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp	2008-02-15 20:31:00 UTC (rev 1599)
+++ cgm/trunk/geom/OCC/OCCShell.cpp	2008-02-18 22:41:20 UTC (rev 1600)
@@ -45,15 +45,17 @@
 
 // ********** BEGIN PUBLIC FUNCTIONS       **********
 
+
 //-------------------------------------------------------------------------
-// Purpose       : A constructor with a pointer to a ACIS SHELL.
+// Purpose       : A constructor with a pointer to an OCC SHELL.
 //
 // Special Notes :
 //
 //-------------------------------------------------------------------------
-OCCShell::OCCShell(TopoDS_Shell *theShell)
+OCCShell::OCCShell(TopoDS_Shell *theShell, OCCSurface* surface)
 {
   myTopoDSShell = theShell;
+  mySheetSurface = surface;
 }
 
 //-------------------------------------------------------------------------
@@ -106,6 +108,12 @@
 //-------------------------------------------------------------------------
 void OCCShell::get_parents_virt( DLIList<TopologyBridge*>& parents ) 
 { 
+  if(mySheetSurface)
+  {
+    parents.append(mySheetSurface->my_lump());
+    return;
+  }
+
   OCCQueryEngine* oqe = (OCCQueryEngine*) get_geometry_query_engine();
   OCCBody * body = NULL;
   DLIList <OCCBody* > *bodies = oqe->BodyList;
@@ -136,6 +144,11 @@
 
 void OCCShell::get_children_virt( DLIList<TopologyBridge*>& children )
 {
+  if(mySheetSurface)
+  {
+    children.append(mySheetSurface);
+    return;
+  }
   TopTools_IndexedMapOfShape M;
   TopExp::MapShapes(*myTopoDSShell, TopAbs_FACE, M);
   int ii;
@@ -152,6 +165,9 @@
 //----------------------------------------------------------------
 CubitStatus OCCShell::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf)
 {
+  if(mySheetSurface)
+    return CUBIT_FAILURE;
+
   TopoDS_Shape shape = aBRepTrsf.ModifiedShape(*get_TopoDS_Shell());
   TopoDS_Shell shell = TopoDS::Shell(shape);
 

Modified: cgm/trunk/geom/OCC/OCCShell.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.hpp	2008-02-15 20:31:00 UTC (rev 1599)
+++ cgm/trunk/geom/OCC/OCCShell.hpp	2008-02-18 22:41:20 UTC (rev 1600)
@@ -42,7 +42,7 @@
 {
 public:
   
-  OCCShell(TopoDS_Shell *theShell);
+  OCCShell(TopoDS_Shell *theShell, OCCSurface surface = NULL);
 
   virtual ~OCCShell() ;
     //- Destructor.
@@ -106,6 +106,7 @@
   
 private:
   TopoDS_Shell *myTopoDSShell;
+  OCCSurface* mySheetSurface;
 };
 
 

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2008-02-15 20:31:00 UTC (rev 1599)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2008-02-18 22:41:20 UTC (rev 1600)
@@ -83,6 +83,9 @@
 OCCSurface::OCCSurface(TopoDS_Face *theFace)
 {
   myTopoDSFace = theFace;
+  myShell = NULL;
+  myLump = NULL;
+  myBody = NULL;
 }
 
 

Modified: cgm/trunk/geom/OCC/OCCSurface.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.hpp	2008-02-15 20:31:00 UTC (rev 1599)
+++ cgm/trunk/geom/OCC/OCCSurface.hpp	2008-02-18 22:41:20 UTC (rev 1600)
@@ -300,6 +300,21 @@
 
   void get_curves(DLIList<OCCCurve*>&); 
 
+  void set_shell(OCCShell* shell)
+  { myShell = shell;}
+
+  void set_lump(OCCLump* lump)
+  { myLump = lump;}
+
+  void set_body(OCCBody* body)
+  { myBody = body;}
+
+  OCCShell* my_shell() {return myShell;}
+
+  OCCLump* my_lump() {return myLump;}
+
+  OCCBody* my_body() {return myBody;}
+
   virtual CubitBoolean is_parametric();
     //R CubitBoolean
     //R- CUBIT_TRUE/CUBIT_FALSE
@@ -401,6 +416,11 @@
 
   TopoDS_Face *myTopoDSFace;
 
+  //Following 3 members are only for sheeted body.
+  OCCShell* myShell;
+  OCCLump* myLump;
+  OCCBody* myBody;
+
 };
 
 




More information about the cgma-dev mailing list