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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Tue Jan 13 14:53:08 CST 2009


Author: janehu
Date: 2009-01-13 14:53:08 -0600 (Tue, 13 Jan 2009)
New Revision: 2535

Modified:
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
Log:
Added tweak_fillet functions; Removed unused webcut functions.

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2009-01-12 20:01:52 UTC (rev 2534)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2009-01-13 20:53:08 UTC (rev 2535)
@@ -45,6 +45,9 @@
 #include "GC_MakeTrimmedCone.hxx"
 #include "GC_MakeTrimmedCylinder.hxx"
 #include "gce_MakeElips.hxx"
+#include "BRepFilletAPI_MakeFillet.hxx"
+#include "BRepFilletAPI_MakeFillet2d.hxx"
+#include "ChFi2d_ConstructionError.hxx"
 #include "Geom_BezierCurve.hxx"
 #include "BndLib_AddSurface.hxx"
 #include "Handle_Geom_Plane.hxx"
@@ -91,6 +94,7 @@
 #include "TopOpeBRep_EdgesIntersector.hxx"
 #include "TopExp_Explorer.hxx"
 #include "TopExp.hxx"
+#include "OCCDrawTool.hpp"
 #include "OCCModifyEngine.hpp"
 #include "OCCQueryEngine.hpp"
 #include "OCCCoFace.hpp"
@@ -139,6 +143,7 @@
 #include "AppUtil.hpp"
 #include "SphereEvaluator.hpp"
 #include "CylinderEvaluator.hpp"
+#include "GfxPreview.hpp"
 #include <vector>
 OCCModifyEngine* OCCModifyEngine::instance_ = 0;
 #define DEBUG
@@ -4551,113 +4556,6 @@
 }
 
 //===============================================================================
-// Function   : webcut_with_sheet
-// Member Type: PUBLIC
-// Description: 
-// Author     : John Fowler
-// Date       : 10/02
-//===============================================================================
-CubitStatus OCCModifyEngine::webcut_with_sheet(DLIList<BodySM*> & /*webcut_body_list*/,
-                                                 BodySM * /*sheet_body*/,
-                                                 DLIList<BodySM*> & /*new_bodies*/,
-                                                 bool /*imprint*/ )
-{
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
-}
-
-//===============================================================================
-// Function   : webcut_with_extended_surf
-// Member Type: PUBLIC
-// Description: 
-// Author     : John Fowler
-// Date       : 10/02
-//===============================================================================
-CubitStatus OCCModifyEngine::webcut_with_extended_surf(DLIList<BodySM*> & /*webcut_body_list*/,
-                                                         Surface * /*extend_from*/,
-                                                         DLIList<BodySM*> & /*new_bodies*/,
-                                                         int & /*num_cut*/,
-                                                         bool /*imprint*/ )
-{
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
-}
-
-//===============================================================================
-// Function   : webcut_with_cylinder
-// Member Type: PUBLIC
-// Description: 
-// Author     : John Fowler
-// Date       : 10/02
-//===============================================================================
-CubitStatus OCCModifyEngine::webcut_with_cylinder(DLIList<BodySM*> &webcut_body_list,
-                                            double radius,
-                                            const CubitVector &axis,
-                                            const CubitVector &center,
-                                            DLIList<BodySM*>& results_list,
-                                            bool imprint )
-{
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
-}
-
-//===============================================================================
-// Function   : webcut_with_brick
-// Member Type: PUBLIC
-// Description: 
-// Author     : John Fowler
-// Date       : 10/02
-//===============================================================================
-CubitStatus OCCModifyEngine::webcut_with_brick( 
-                                      DLIList<BodySM*>& /*webcut_body_list*/, 
-                                      const CubitVector &/*center*/,
-                                      const CubitVector* /*axes[3]*/, 
-                                      const CubitVector &/*extension*/,
-                                      DLIList<BodySM*> &/*results_list*/,
-                                      bool /*imprint*/ )
-{
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
-}
-
-//===============================================================================
-// Function   : webcut_with_planar_sheet
-// Member Type: PUBLIC
-// Description: 
-// Author     : John Fowler
-// Date       : 10/02
-//===============================================================================
-CubitStatus OCCModifyEngine::webcut_with_planar_sheet( 
-                                          DLIList<BodySM*>& /*webcut_body_list*/,
-                                          const CubitVector &/*center*/,
-                                          const CubitVector* /*axes[2]*/,
-                                          double /*width*/, 
-                                          double /*height*/,
-                                          DLIList<BodySM*> &/*results_list*/,
-                                          bool /*imprint*/ )
-{
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
-}
-
-//===============================================================================
-// Function   : webcut_with_curve_loop
-// Member Type: PUBLIC
-// Description: 
-// Author     : John Fowler
-// Date       : 10/02
-//===============================================================================
-CubitStatus OCCModifyEngine::webcut_with_curve_loop(
-                                              DLIList<BodySM*> &/*webcut_body_list*/,
-                                              DLIList<Curve*> &/*ref_edge_list*/,
-                                              DLIList<BodySM*>& /*results_list*/,
-                                              bool /*imprint*/)
-{
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
-}
-
-//===============================================================================
 // Function   : section
 // Member Type: PUBLIC
 // Description: 
@@ -4804,7 +4702,6 @@
 CubitStatus OCCModifyEngine::split_periodic( BodySM * /*body_ptr*/,
                                                BodySM *& /*new_body*/ )
 {
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
   return CUBIT_FAILURE;
 }
 
@@ -5681,17 +5578,55 @@
 // Member Type: PUBLIC
 // Description: Create a round fillet (or blend) at the given curves on solid 
 //              bodies.
-// Author     : 
-// Date       : 
+// Author     : Jane Hu
+// Date       : 01/09
 //=============================================================================
-CubitStatus OCCModifyEngine::tweak_fillet( DLIList<Curve*> & /*curve_list*/, 
-                                             double /*radius*/,
-                                             DLIList<BodySM*> & /*new_bodysm_list*/,
-                                             CubitBoolean /*keep_old_body*/,
-                                             CubitBoolean /*preview*/ ) const
+CubitStatus OCCModifyEngine::tweak_fillet( DLIList<Curve*> & curve_list, 
+                                           double radius,
+                                           DLIList<BodySM*> & new_bodysm_list,
+                                           CubitBoolean keep_old_body,
+                                           CubitBoolean preview ) const
 {
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
+  CubitStatus stat;
+  int count = 0;
+  for(int i = 0; i < curve_list.size(); i++) 
+  {
+    BodySM * new_bodysm_ptr = NULL;
+    stat = tweak_fillet(curve_list.get_and_step(), radius, radius, 
+                        new_bodysm_ptr , keep_old_body, CUBIT_FALSE);
+    if(stat && new_bodysm_ptr)
+    {
+      count++;
+      new_bodysm_list.append(new_bodysm_ptr);
+    }
+  }
+
+  if(count == 0) 
+    return CUBIT_FAILURE;
+ 
+  if(preview)
+  {
+    GfxPreview::clear();
+    for(int i = 0; i < new_bodysm_list.size(); i++)
+    {
+      BodySM* new_bodysm = new_bodysm_list.get_and_step();
+      TopoDS_Shape* modified_shape = 
+          CAST_TO(new_bodysm, OCCBody)->get_TopoDS_Shape();
+      TopExp_Explorer Ex;
+      Ex.Init(*modified_shape, TopAbs_FACE);
+      for( ; Ex.More(); Ex.Next() )
+      {
+        TopoDS_Face face = TopoDS::Face(Ex.Current());
+        // Draw this face
+        OCCDrawTool::instance()->draw_FACE( &face, CUBIT_BLUE, CUBIT_TRUE );
+      }
+    }
+    GfxPreview::flush();
+    OCCQueryEngine::instance()->delete_solid_model_entities(new_bodysm_list);  
+    new_bodysm_list.clean_out();
+  }
+  
+  return CUBIT_SUCCESS;
 }
 
 //=============================================================================
@@ -5700,18 +5635,93 @@
 // Description: Create a round fillet (or blend) at the given curves on a solid 
 //              body.  The fillet has a variable radius from the start to the
 //              end of the curve.
-// Author     : 
-// Date       : 
+// Author     : Jane Hu 
+// Date       : 01/09
 //=============================================================================
-CubitStatus OCCModifyEngine::tweak_fillet( Curve * /*curve_ptr*/, 
-                                             double /*start_radius*/,
-                                             double /*end_radius*/,
-                                             BodySM *& /*new_bodysm_ptr*/,
-                                             CubitBoolean /*keep_old_body*/,
-                                             CubitBoolean /*preview*/ ) const
+CubitStatus OCCModifyEngine::tweak_fillet( Curve * curve_ptr, 
+                                           double start_radius,
+                                           double end_radius,
+                                           BodySM *& new_bodysm_ptr,
+                                           CubitBoolean keep_old_body,
+                                           CubitBoolean preview ) const
 {
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
+  OCCCurve *occ_curve = CAST_TO(curve_ptr, OCCCurve);
+  TopoDS_Edge* topo_edge = occ_curve->get_TopoDS_Edge();
+
+  OCCQueryEngine* oqe = OCCQueryEngine::instance();
+  DLIList <OCCBody* > *bodies = oqe->BodyList;
+  TopTools_IndexedDataMapOfShapeListOfShape M;
+  DLIList<TopoDS_CompSolid*> shape_list;
+  OCCBody * body = NULL;
+  for(int j = 0; j <  bodies->size(); j++)
+  {
+    body = bodies->get_and_step();
+    TopExp_Explorer Ex;
+    TopoDS_Shape ashape = *(body->get_TopoDS_Shape());
+    M.Clear();
+    TopExp::MapShapesAndAncestors(ashape, TopAbs_EDGE, TopAbs_COMPSOLID, M);
+    if(!M.Contains(*topo_edge))
+      continue;
+    DLIList<Lump*> lumps = body->lumps();
+    if(lumps.size() > 1)
+    {
+      PRINT_ERROR("Fillets must be created on single-lump solids.\n");
+      return CUBIT_FAILURE;
+    }
+    shape_list.append_unique(body->get_TopoDS_Shape());
+  }
+  if(shape_list.size() != 1)
+  {
+    PRINT_ERROR("Fillets must be created on solids.\n");
+    return CUBIT_FAILURE;
+  }
+
+  TopoDS_Shape newShape;
+  TopoDS_CompSolid* shape = shape_list.get();
+  if(keep_old_body)
+  {
+    BRepBuilderAPI_Copy api_copy(*shape);
+    newShape = api_copy.ModifiedShape(*shape);
+  }
+  else
+    newShape = *shape;
+  BRepFilletAPI_MakeFillet fillet(newShape);
+  fillet.Add(start_radius, end_radius, *topo_edge);
+  fillet.Build();
+
+  if(!fillet.IsDone())
+  {
+    PRINT_ERROR("Can't create fillet on given curve.\n");
+    return CUBIT_FAILURE;
+  } 
+  TopoDS_Shape modified_shape = fillet.Shape();
+
+  if( !preview )
+  {
+    TopExp_Explorer Ex;
+    Ex.Init(newShape, TopAbs_SOLID);
+    TopoDS_Solid old_solid = TopoDS::Solid(Ex.Current());
+    OCCLump::update_OCC_entity(old_solid , modified_shape, &fillet);     
+    DLIList<TopologyBridge*> tbs = OCCQueryEngine::instance()->populate_topology_bridge(modified_shape);
+    new_bodysm_ptr = CAST_TO(tbs.get(), BodySM);  
+    return CUBIT_SUCCESS;
+  }
+  else
+  {
+    GfxPreview::clear();
+
+    TopExp_Explorer Ex;
+    Ex.Init(modified_shape, TopAbs_FACE); 
+    for( ; Ex.More(); Ex.Next() )
+    {
+      TopoDS_Face face = TopoDS::Face(Ex.Current());
+      // Draw this face
+      OCCDrawTool::instance()->draw_FACE( &face, CUBIT_BLUE, CUBIT_TRUE );
+    }
+
+    GfxPreview::flush();
+    return CUBIT_SUCCESS;
+  }
 }
 
 //=============================================================================
@@ -5719,18 +5729,92 @@
 // Member Type: PUBLIC
 // Description: Create a round fillet (or blend) at the given vertices on sheet
 //              bodies.
-// Author     : 
-// Date       : 
+// Author     : Jane Hu
+// Date       : 01/09 
 //=============================================================================
 CubitStatus
-OCCModifyEngine::tweak_fillet( DLIList<Point*> & /*ref_vertex_list*/, 
-                                 double /*radius*/,
-                                 DLIList<BodySM*> & /*new_bodysm_list*/,
-                                 CubitBoolean /*keep_old_body*/,
-                                 CubitBoolean /*preview*/ ) const
+OCCModifyEngine::tweak_fillet( DLIList<Point*> & ref_vertex_list, 
+                               double radius,
+                               DLIList<BodySM*> & new_bodysm_list,
+                               CubitBoolean keep_old_body,
+                               CubitBoolean preview ) const
 {
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
+  OCCQueryEngine* oqe = OCCQueryEngine::instance();
+  DLIList <OCCSurface* > *faces = oqe->SurfaceList;
+  TopTools_IndexedDataMapOfShapeListOfShape M;
+  DLIList<TopoDS_Face*> shape_list;
+
+  for(int i = 0; i < ref_vertex_list.size(); i ++)
+  {
+    Point* pnt = ref_vertex_list.get_and_step();
+    OCCPoint* occ_pnt = CAST_TO(pnt, OCCPoint);
+    TopoDS_Vertex* vertex = occ_pnt->get_TopoDS_Vertex();
+
+    OCCSurface* face = NULL;
+    shape_list.clean_out();
+    for(int j = 0; j <  faces->size(); j++)
+    {
+      face = faces->get_and_step();
+      TopExp_Explorer Ex;
+      TopoDS_Face ashape = *(face->get_TopoDS_Face());
+      M.Clear();
+      TopExp::MapShapesAndAncestors(ashape, TopAbs_VERTEX, TopAbs_FACE, M);
+      if(!M.Contains(*vertex))
+        continue;
+      
+      shape_list.append_unique(face->get_TopoDS_Face());
+    }  
+    if(shape_list.size() != 1)
+    {
+      PRINT_ERROR("Can't create fillet on given vertex.\n");
+      return CUBIT_FAILURE;
+    }      
+    TopoDS_Face *shape = shape_list.get();
+    TopoDS_Face newShape;
+    if(keep_old_body)
+    {
+      BRepBuilderAPI_Copy api_copy(*shape);
+      newShape = TopoDS::Face(api_copy.ModifiedShape(*shape));
+    }
+    else
+      newShape = *shape;
+
+    BRepFilletAPI_MakeFillet2d fillet(newShape);
+    TopoDS_Edge fillet_edge = fillet.AddFillet(*vertex, radius);
+
+    if(fillet.Status() != ChFi2d_IsDone)
+    {
+      PRINT_ERROR("Can't create fillet on given curve.\n");
+      return CUBIT_FAILURE;
+    }
+    TopoDS_Shape modified_shape = fillet.Shape();
+
+    TopExp_Explorer Ex;
+    OCCSurface::update_OCC_entity(newShape , modified_shape, &fillet);
+    TopoDS_Face modified_face = TopoDS::Face(modified_shape);
+    Surface* surf = OCCQueryEngine::instance()->populate_topology_bridge(modified_face, CUBIT_TRUE);
+    BodySM* new_bodysm_ptr = CAST_TO(surf,OCCSurface)->my_body();
+    new_bodysm_list.append(new_bodysm_ptr);
+  }
+
+  if(!preview )
+    return CUBIT_SUCCESS;
+
+  GfxPreview::clear();
+
+  for(int i = 0; i < new_bodysm_list.size(); i++)
+  {
+     BodySM* new_bodysm = new_bodysm_list.get_and_step();
+     OCCSurface* surf = CAST_TO(new_bodysm, OCCBody)->my_sheet_surface();
+     TopoDS_Face* modified_shape = surf->get_TopoDS_Face();
+     // Draw this face
+     OCCDrawTool::instance()->draw_FACE( modified_shape, CUBIT_BLUE, CUBIT_TRUE );
+  }
+  GfxPreview::flush();
+  OCCQueryEngine::instance()->delete_solid_model_entities(new_bodysm_list);
+  new_bodysm_list.clean_out();
+
+  return CUBIT_SUCCESS;
 }
 
 //=============================================================================
@@ -6118,66 +6202,6 @@
    return CUBIT_FAILURE;
 }
 
-CubitStatus OCCModifyEngine::webcut_with_sweep_surfaces(
-                                 DLIList<BodySM*> &blank_bodies,
-                                 DLIList<Surface*> &surfaces,
-                                 const CubitVector& sweep_vector,
-                                 bool sweep_perp, 
-                                 bool through_all,
-                                 bool outward,
-                                 bool up_to_next, 
-                                 Surface *stop_surf, 
-                                 Curve *curve_to_sweep_along, 
-                                 DLIList<BodySM*> &results_list,
-                                 CubitBoolean imprint)
-{
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
-}
-
-CubitStatus OCCModifyEngine::webcut_with_sweep_curves(
-                                 DLIList<BodySM*> &blank_bodies,
-                                 DLIList<Curve*> &curves,
-                                 const CubitVector& sweep_vector,
-                                 bool through_all, 
-                                 Surface *stop_surf, 
-                                 Curve *curve_to_sweep_along, 
-                                 DLIList<BodySM*> &results_list,
-                                 CubitBoolean imprint)
-{
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
-}
-
-CubitStatus OCCModifyEngine::webcut_with_sweep_surfaces_rotated(
-                                 DLIList<BodySM*> &blank_bodies,
-                                 DLIList<Surface*> &surfaces,
-                                 const CubitVector &point, 
-                                 const CubitVector &sweep_axis, 
-                                 double angle, 
-                                 Surface *stop_surf, 
-                                 bool up_to_next, 
-                                 DLIList<BodySM*> &results_list,
-                                 CubitBoolean imprint)
-{
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
-}
-
-CubitStatus OCCModifyEngine::webcut_with_sweep_curves_rotated(
-                                 DLIList<BodySM*> &blank_bodies,
-                                 DLIList<Curve*> &curves,
-                                 const CubitVector &point, 
-                                 const CubitVector &sweep_axis, 
-                                 double angle, 
-                                 Surface *stop_surf, 
-                                 DLIList<BodySM*> &results_list,
-                                 CubitBoolean imprint)
-{
-  PRINT_ERROR("Option not supported for mesh based geometry.\n");
-  return CUBIT_FAILURE;
-}
-
 CubitStatus OCCModifyEngine::scale( BodySM *&body, const CubitVector& factors )
 {
   return OCCQueryEngine::instance()->scale( body, factors );




More information about the cgma-dev mailing list