[cgma-dev] r2174 - in cgm/trunk: geom geom/OCC test

janehu at mcs.anl.gov janehu at mcs.anl.gov
Fri Oct 24 15:04:49 CDT 2008


Author: janehu
Date: 2008-10-24 15:04:49 -0500 (Fri, 24 Oct 2008)
New Revision: 2174

Modified:
   cgm/trunk/geom/GeometryModifyTool.cpp
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/test/modify.cpp
Log:
sweep_rotational passed surface rotational-swept, closed-curve rotational-swept with make-solid either 0 or 1, open-curve meet negative testrequirement for erroring out if intersect in the middle of the curve, but failed to do end points on axis rotational for both make or not make solid option. Investigating. Acis can do this case.

Modified: cgm/trunk/geom/GeometryModifyTool.cpp
===================================================================
--- cgm/trunk/geom/GeometryModifyTool.cpp	2008-10-23 15:42:41 UTC (rev 2173)
+++ cgm/trunk/geom/GeometryModifyTool.cpp	2008-10-24 20:04:49 UTC (rev 2174)
@@ -2874,6 +2874,14 @@
   if (!sweep_finish("rotational", body_list, result_list, change_newids))
     status = CUBIT_FAILURE;
 
+  body_list.clean_out();
+  for(int i = 0; i < result_list.size(); i++)
+  {
+    Body* body = CAST_TO(result_list.get_and_step()->topology_entity(),Body );
+    if(body)
+      body_list.append(body);
+  }
+  CAST_LIST( body_list, ref_ent_list, RefEntity);
   return status;
 }
 

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-10-23 15:42:41 UTC (rev 2173)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-10-24 20:04:49 UTC (rev 2174)
@@ -3969,6 +3969,7 @@
   }
   TopoDS_Edge *edge = curve->get_TopoDS_Edge( );
   toposhape = BRepBuilderAPI_MakeWire(*edge);
+  return CUBIT_SUCCESS;
 }
 
 CubitStatus OCCModifyEngine::get_sweepable_toposhape(OCCSurface*& surface,
@@ -4118,10 +4119,18 @@
   gp_Pnt pt = gp_Pnt( point.x(), point.y(), point.z());
   gp_Ax1 axis = gp_Ax1(pt, adir);
 
+  gp_Lin line = gp_Lin(axis);
+  TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(line);
+  OCCCurve* acurve = new OCCCurve(&edge);
+  assert(acurve);
+
+  CubitVector start;
+  CubitVector end;
+
   for (int i = ref_ent_list.size(); i > 0; i--)
   {
     GeometryEntity *ref_ent = ref_ent_list.get_and_step();
-    //Make copy of the surface for later to build solid.
+    //Make copy of the surface or curve for later to build solid.
     OCCSurface* surface = CAST_TO(ref_ent, OCCSurface);
     OCCCurve* curve = CAST_TO(ref_ent, OCCCurve);
     TopoDS_Shape toposhape ;
@@ -4130,12 +4139,64 @@
       CubitStatus stat = get_sweepable_toposhape(surface, (CubitVector*)NULL, toposhape);
       if(!stat)
         continue;
+      //only non-intersecting of surface and axis can be swept.
+      DLIList<CubitVector*> intersect_pts;
+      OCCQueryEngine::instance()->get_intersections(acurve, surface,
+                                    intersect_pts, CUBIT_TRUE);
+      if(intersect_pts.size() > 0)
+      { 
+        PRINT_ERROR("Only surfaces with no intersection point with the axis can be revolve-swept.\n");
+        continue;
+      } 
     }
     else if(curve != NULL)
     {
       CubitStatus stat = get_sweepable_toposhape(curve, toposhape);
       if(!stat)
         continue;
+      //closed curve can't intersect with the axis, while open curve can only
+      //intersect the axis at the end points. 
+      //only curve not intersecting with axis in curve's middle locations
+      //can be revolved
+      DLIList<CubitVector*> intersect_pts;
+      OCCQueryEngine::instance()->get_intersections(curve, acurve,
+                                  intersect_pts, CUBIT_TRUE, CUBIT_TRUE);
+      if(!toposhape.Closed())
+      {
+        //get start and end points
+        DLIList<OCCPoint*> point_list;
+        curve->get_points(point_list);
+        assert(2 == point_list.size());
+        start = point_list.get_and_step()->coordinates();
+        end = point_list.get()->coordinates();
+
+        if(intersect_pts.size() > 0)
+        {
+          CubitBoolean non_int = CUBIT_FALSE;
+          double tol = OCCQueryEngine::instance()->get_sme_resabs_tolerance();
+          for(int i = 0; i < intersect_pts.size(); i++)
+          {
+             CubitVector prt = *(intersect_pts.get_and_step());
+             if(prt.distance_between(start) > tol &&
+                prt.distance_between(end) > tol)
+             {
+                non_int = CUBIT_TRUE;
+                PRINT_ERROR("Only curves with no intersection point with the axis can be revolve-swept.\n");
+                break;
+              }
+          }
+          if(non_int)
+            continue;
+        }
+      }
+      else
+      {
+        if(intersect_pts.size() > 0)
+        {
+          PRINT_ERROR("Only curves with no intersection point with the axis can be revolve-swept.\n");
+          continue;
+        }  
+      }
     } 
     else
     {
@@ -4150,17 +4211,6 @@
       if(!toposhape.Closed())
       {
         //project the start and end points onto the axis
-        gp_Lin line = gp_Lin(axis);
-        TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(line);
-        OCCCurve* acurve = new OCCCurve(&edge);
-        assert(acurve);
-      
-        //get start and end points
-        DLIList<OCCPoint*> point_list;
-        curve->get_points(point_list);
-        assert(2 == point_list.size());
-        CubitVector start = point_list.get_and_step()->coordinates();
-        CubitVector end = point_list.get()->coordinates();
         CubitBoolean start_closed = CUBIT_FALSE;
         CubitBoolean end_closed = CUBIT_FALSE;
         if(acurve->point_containment(start) != CUBIT_PNT_OFF)
@@ -4199,7 +4249,7 @@
         
         gp_Pnt pt1 = gp_Pnt( end_proj.x(), end_proj.y(), end_proj.z());
         gp_Pnt pt2 = gp_Pnt( start_proj.x(), start_proj.y(), start_proj.z());
-        TopoDS_Edge edge3 = BRepBuilderAPI_MakeEdge(pt1, pt2);
+        TopoDS_Edge edge3 = BRepBuilderAPI_MakeEdge(pt2, pt1);
         m_wire.Add(edge3);
       
         TopoDS_Wire wire = m_wire.Wire();

Modified: cgm/trunk/test/modify.cpp
===================================================================
--- cgm/trunk/test/modify.cpp	2008-10-23 15:42:41 UTC (rev 2173)
+++ cgm/trunk/test/modify.cpp	2008-10-24 20:04:49 UTC (rev 2174)
@@ -730,6 +730,8 @@
   refentities.append(sweep_face);
   RefFace* draft_face = gmti->make_RefFace(sweep_face);
   RefFace* perp_face = gmti->make_RefFace(sweep_face);
+  RefFace* rotate_face = gmti->make_RefFace(sweep_face);
+  RefFace* rotate_face2 = gmti->make_RefFace(sweep_face);
   gmti->sweep_translational(refentities, v_move8, 0, 1, CUBIT_FALSE, CUBIT_FALSE);  
   body = CAST_TO(refentities.get(), Body);
   d = body->measure();
@@ -755,5 +757,75 @@
   d = body->measure();
   //d = 66.3676  theoretical calculation is 66.7833, error 0.62%
   
+  //Testing for sweep_rotational function
+  //1. Negative testing: surface rotates along an intersection axis, fails.
+  refentities.clean_out();
+  refentities.append(rotate_face); 
+  DLIList<RefEdge*> rotate_edges;
+  rotate_face->ref_edges(rotate_edges);
+  CubitVector sweep_axis(1,0,0);   
+  CubitVector point(0, 2, 15);
+  double angle = 1.57;
+  gmti->sweep_rotational(refentities, center, sweep_axis, angle, 0, 0, 1,
+                         CUBIT_FALSE, CUBIT_TRUE, CUBIT_FALSE);
+
+  //2. surface rotates along a non-intersection axis
+  refentities.append(rotate_face);
+  gmti->sweep_rotational(refentities, point, sweep_axis, angle, 0, 0, 1,
+                         CUBIT_FALSE, CUBIT_TRUE, CUBIT_FALSE);
+  body = CAST_TO(refentities.get(), Body);
+  d = body->measure();
+  //d = 9.8646
+
+  //3. closed curve rotates along an intersecting axis, fails
+  refentities.clean_out();
+  refentities.append(rotate_edges.get());
+  gmti->sweep_rotational(refentities, center, sweep_axis, angle, 0, 0, 1,
+                         CUBIT_FALSE, CUBIT_TRUE, CUBIT_FALSE); 
+
+  //4. closed curve rotates along a non-intersecting axis with make_solid
+  //   option set to be true.
+  refentities.append(rotate_edges.get());
+  gmti->sweep_rotational(refentities, point, sweep_axis, angle, 0, 0, 1,
+                         CUBIT_FALSE, CUBIT_TRUE, CUBIT_FALSE);
+  body = CAST_TO(refentities.get(), Body);
+  d = body->measure();
+  //d = 9.8646
+
+  //5. closed curve rotates along a non-intersecting axis with make_solid
+  //   option set to be false.
+  refentities.clean_out();
+  refentities.append(rotate_edges.get());
+  gmti->sweep_rotational(refentities, point, sweep_axis, -angle, 0, 0, 1,
+                         CUBIT_FALSE, CUBIT_FALSE, CUBIT_FALSE);
+  body = CAST_TO(refentities.get(), Body);
+  d = body->measure();
+  //d = 19.7292
+
+  //6. open curve rotates along an intersecting axis with make_solid
+  //   option set to be true. Failed
+  CubitVector pt1(0,1,15);
+  CubitVector pt2(0,-1,15);
+  CubitVector pt3(-1,0,15);
+  RefVertex* vt1 = gmti->make_RefVertex(pt1);
+  RefVertex* vt2 = gmti->make_RefVertex(pt2);
+  RefVertex* vt3 = gmti->make_RefVertex(pt3);
+  RefEdge* edge1 = gmti->make_RefEdge(vt1, vt2, rotate_face, vt3);
+  CubitVector apoint(0,-0.5,15);
+  refentities.clean_out();
+  refentities.append(edge1);
+  gmti->sweep_rotational(refentities, apoint, sweep_axis, angle, 0, 0, 1,
+                         CUBIT_FALSE, CUBIT_TRUE, CUBIT_FALSE);
+
+  //7. open curve rotates along an intersecting axis at end points with 
+  //   make_solid option set to be true.
+  refentities.append(edge1);
+  CubitVector rotate_axis(0, 1, 0);
+  //  gmti->sweep_rotational(refentities, center, rotate_axis, angle, 0, 0, 1,
+                         CUBIT_FALSE, CUBIT_TRUE, CUBIT_FALSE);
+    //body = CAST_TO(refentities.get(), Body);
+    //d = body->measure();
+  //d = 19.7292
+
   return CUBIT_SUCCESS;
 }




More information about the cgma-dev mailing list