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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Fri Jun 20 13:33:15 CDT 2008


Author: janehu
Date: 2008-06-20 13:33:15 -0500 (Fri, 20 Jun 2008)
New Revision: 1915

Modified:
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
Log:
Added function to make thick solid.

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-06-19 17:33:03 UTC (rev 1914)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-06-20 18:33:15 UTC (rev 1915)
@@ -52,6 +52,7 @@
 #include "BRepBuilderAPI_MakeEdge.hxx"
 #include "BRepAdaptor_Surface.hxx"
 #include "BRepBuilderAPI_MakeFace.hxx"
+#include "BRepOffsetAPI_MakeThickSolid.hxx"
 #include "BRepBuilderAPI_Sewing.hxx"
 #include "BRepBuilderAPI_Copy.hxx"
 #include "LocOpe_SplitShape.hxx"
@@ -3583,18 +3584,89 @@
 //===============================================================================
 // Function   : thicken
 // Member Type: PUBLIC
-// Description: 
-// Author     : John Fowler
-// Date       : 10/02
+// Description: Hollow existing solid body by remove one or several surfaces 
+//              Can only take one body at a time.
+//              No both (side) option.
+//              depth > 0, thick body going outside bodies
+//              depth < 0, thick body going inside bodies
+// Author     : Jane Hu 
+// Date       : 06/08
 //===============================================================================
-CubitStatus OCCModifyEngine::thicken(DLIList<BodySM*>& /*bodies*/, 
+CubitStatus OCCModifyEngine::thicken(DLIList<BodySM*>& bodies, 
                                      DLIList<Surface*>& surfs_to_remove,
-                                       DLIList<BodySM*>& /*new_bodies*/,
-                                       double /*depth*/,
-                                       bool /*both*/) const
+                                     DLIList<BodySM*>& new_bodies,
+                                     double depth,
+                                     bool /*both*/) const
 {
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
+  if(bodies.size() != 1 || surfs_to_remove.size() < 1)
+  {
+    PRINT_ERROR("Making thick solid in OCC will take one body and at least one surface at a time.\n"); 
+    return CUBIT_FAILURE;
+  }
+
+  DLIList<TopoDS_Shape*> shape_list;
+  DLIList<CubitBoolean> is_volume;
+  CubitStatus stat = get_shape_list(bodies, shape_list, is_volume, CUBIT_FALSE);
+
+  if(!stat)
+    return stat;
+
+  if(!is_volume.get())//sheet body
+  {
+    PRINT_ERROR("Making thick solid in OCC needs an initial solid body to hollow with.\n");
+    return CUBIT_FAILURE;
+  }
+
+  //make sure the body to be hollowed has only one lump
+  OCCBody* occ_body = CAST_TO(bodies.get(), OCCBody);
+  DLIList<Lump*> lumps;
+  lumps = occ_body->lumps();
+  if(lumps.size()!=1)
+  {
+    PRINT_ERROR("bodies with more than one lump can't be hollowed to make a thick body.\n");
+    return CUBIT_FAILURE;
+  }
+
+  //make sure surfs_to_remove are all in bodies
+  DLIList<OCCSurface*> surfaces;
+  TopTools_ListOfShape face_shapes;
+  occ_body->get_all_surfaces(surfaces);
+  for(int i = 0; i < surfs_to_remove.size(); i++)
+  {
+    OCCSurface* occ_surf = CAST_TO(surfs_to_remove.get(), OCCSurface);
+    if(!occ_surf)
+      continue;
+    if(!surfaces.is_in_list(occ_surf))
+      continue;
+    TopoDS_Face * face = occ_surf->get_TopoDS_Face();
+    face_shapes.Append(*face); 
+  }
+
+  if(face_shapes.IsEmpty())
+  {
+    PRINT_ERROR("The surfaces provided should be from the body to be hollowed.\n");
+    return CUBIT_FAILURE;
+  }
+  
+  double tol = 1.e-3; //hard coded for now, can be changed by application
+  TopoDS_Shape* solid = shape_list.get();
+  BRepOffsetAPI_MakeThickSolid hollower(*solid, face_shapes, depth, tol);
+  TopoDS_Shape new_shape = hollower.Shape();
+  TopoDS_Solid old_solid = TopoDS::Solid(*solid);
+  OCCLump::update_OCC_entity(old_solid , new_shape, &hollower); 
+ 
+  //ok, we're done with all hollowing, construct new Body'
+  DLIList<TopologyBridge*> tbs;
+  tbs += OCCQueryEngine::instance()->populate_topology_bridge(new_shape);
+
+  for (int i = 0; i< tbs.size(); i++)
+  {
+    BodySM* bodysm = CAST_TO(tbs.get_and_step(), BodySM);
+    if (bodysm)
+      new_bodies.append(bodysm);
+  }
+
+  return CUBIT_SUCCESS;
 }
 
 

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-06-19 17:33:03 UTC (rev 1914)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-06-20 18:33:15 UTC (rev 1915)
@@ -2,7 +2,7 @@
 // Filename      : OCCQueryEngine.cpp
 //
 // Purpose       : Implementation of the OCCQueryEngine class.
-//                 This class provides facet-based implementations
+//                 This class provides OCC-based implementations
 //                 of various virtual functions in the GeometryQueryEngine
 //                 hierarchy.
 //
@@ -2310,8 +2310,6 @@
   return status;
 }
 
-const char* fqe_xform_err = "Transform not implemented for OCC geometry.\n";
-
 CubitStatus OCCQueryEngine::restore_transform( BodySM* body )
 {
   return CUBIT_FAILURE;




More information about the cgma-dev mailing list