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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Wed Jun 11 14:08:54 CDT 2008


Author: janehu
Date: 2008-06-11 14:08:53 -0500 (Wed, 11 Jun 2008)
New Revision: 1891

Modified:
   cgm/trunk/geom/OCC/OCCCurve.cpp
   cgm/trunk/geom/OCC/OCCCurve.hpp
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
   cgm/trunk/test/modify.cpp
Log:
Test-passed one case of imprint-project-curve. project curvecould return different results, haven't test them all yet.

Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp	2008-06-11 01:14:43 UTC (rev 1890)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp	2008-06-11 19:08:53 UTC (rev 1891)
@@ -969,6 +969,7 @@
 // Date       : 01/08
 //===============================================================================
 Curve* OCCCurve::project_curve(Surface* face_ptr, 
+                               DLIList<Point*>&  normal_proj_points,
                                CubitBoolean closed,
                                const CubitVector* third_point)
 {
@@ -998,35 +999,84 @@
         return (Curve*) NULL;
    }
 
-   TopTools_ListOfShape projections;
-   projections = aProjection.Generated(*edge);
-   int num_projection = projections.Extent();
-   if (num_projection == 0)
+   TopoDS_Shape new_shape = aProjection.Projection();//compound shape
+   int num_projection = 0;
+   if (new_shape.IsNull())
    {
        PRINT_ERROR("Cannot project the curve to the surface.\n");
        return (Curve*) NULL;
    }
 
+   else
+   {
+     //count how many free edges and vertices the new_shape has.
+     TopExp_Explorer Ex;
+     for (Ex.Init(new_shape,TopAbs_EDGE); Ex.More(); Ex.Next())
+       num_projection++;
+     for (Ex.Init(new_shape,TopAbs_VERTEX, TopAbs_EDGE); Ex.More(); Ex.Next())
+       num_projection++;
+   }
+
+   if(num_projection == 0)
+   {
+      PRINT_INFO("No projection on the surface.\n");
+      return (Curve*) NULL;
+   }
+
    else if ( num_projection == 1 )
    {
       if(closed == true)
        PRINT_WARNING("Cannot project the curve to create a closed projection.\n"                 "There is only one projection segment.\n");
 
-      TopoDS_Shape new_shape = aProjection.Projection();//compound shape
-      TopoDS_Edge new_edge = TopoDS::Edge(new_shape);
-      return OCCQueryEngine::instance()->populate_topology_bridge(new_edge);
+      TopExp_Explorer Ex;
+      TopoDS_Edge new_edge;
+      TopoDS_Vertex new_point;
+      for (Ex.Init(new_shape,TopAbs_EDGE); Ex.More(); Ex.Next())
+      {
+        new_edge = TopoDS::Edge(Ex.Current());
+        return OCCQueryEngine::instance()->populate_topology_bridge(new_edge);
+      }
+      for(Ex.Init(new_shape,TopAbs_VERTEX);Ex.More(); Ex.Next())
+      {
+        new_point = TopoDS::Vertex(Ex.Current());
+        normal_proj_points.append(OCCQueryEngine::instance()->populate_topology_bridge(new_point));
+      } 
+      return (Curve*) NULL;
    }
 
    else if (num_projection == 2)
    {
       double d;
       double first, last;
-      TopoDS_Shape shape1 = projections.First();
-      TopoDS_Edge edge1 = TopoDS::Edge(shape1);
+      TopExp_Explorer Ex;
+      TopoDS_Edge edge1, edge2;
+      TopoDS_Vertex point;
 
-      TopoDS_Shape shape2 = projections.Last();
-      TopoDS_Edge edge2 = TopoDS::Edge(shape2);
+      int count = 0;
+      for (Ex.Init(new_shape,TopAbs_EDGE); Ex.More(); Ex.Next())
+      {
+        count++;
+        if(count == 1)
+          edge1 = TopoDS::Edge(Ex.Current());
+        if(count == 2)
+          edge2 = TopoDS::Edge(Ex.Current());
+      }
 
+      for(Ex.Init(new_shape,TopAbs_VERTEX);Ex.More(); Ex.Next())
+      {
+        point = TopoDS::Vertex(Ex.Current());
+        normal_proj_points.append(OCCQueryEngine::instance()->populate_topology_bridge(point));
+      }
+
+      if(edge1.IsNull())
+        return OCCQueryEngine::instance()->populate_topology_bridge(edge2);
+
+      if(edge2.IsNull())
+        return OCCQueryEngine::instance()->populate_topology_bridge(edge1);
+
+      if(edge1.IsNull() && edge2.IsNull())
+        return (Curve*) NULL;
+
       Handle(Geom_Curve) myCurve1 =
                         BRep_Tool::Curve(edge1,first,last);
 
@@ -1055,9 +1105,8 @@
         }
 
         double d2 = projOncurve2.LowerDistance();
-        TopoDS_Shape new_shape =
-                d > d2 ? projections.Last() : projections.First() ;
-        TopoDS_Edge new_edge = TopoDS::Edge(new_shape);
+        TopoDS_Edge new_edge =
+                d > d2 ? edge2 : edge1 ;
         return OCCQueryEngine::instance()->populate_topology_bridge(new_edge);
       }
 

Modified: cgm/trunk/geom/OCC/OCCCurve.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.hpp	2008-06-11 01:14:43 UTC (rev 1890)
+++ cgm/trunk/geom/OCC/OCCCurve.hpp	2008-06-11 19:08:53 UTC (rev 1891)
@@ -327,6 +327,7 @@
                           BRepAlgoAPI_BooleanOperation *op = NULL );
  
   Curve* project_curve(Surface* face_ptr,
+                       DLIList<Point*>&  normal_proj_points,
                        CubitBoolean closed,
                        const CubitVector* third_point);
 protected: 

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-06-11 01:14:43 UTC (rev 1890)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-06-11 19:08:53 UTC (rev 1891)
@@ -239,8 +239,9 @@
   if(face_ptr == NULL)
     return curve;
  
+  DLIList<Point*> points;
   new_curve = 
-	CAST_TO(curve, OCCCurve)->project_curve(face_ptr, closed, third_point); 
+	CAST_TO(curve, OCCCurve)->project_curve(face_ptr, points, closed, third_point); 
 
   delete curve;
   return new_curve;
@@ -2913,6 +2914,7 @@
         TopExp_Explorer Ex;
         TopoDS_Face the_face;
         TopoDS_Shape ashape = *(body->get_TopoDS_Shape());
+        M.Clear();
         TopExp::MapShapesAndAncestors(ashape, TopAbs_FACE, TopAbs_COMPSOLID, M);
         if(!M.Contains(*topo_face))
           continue;
@@ -3248,6 +3250,7 @@
 {
   CubitVector* v = NULL;
   Curve* projected_curve = NULL;
+  DLIList<Point*> points;
   //project curves onto surfaces.
   for(int i = 0; i < ref_edge_list.size(); i++)
   {
@@ -3267,11 +3270,13 @@
       }
       
       projected_curve = NULL;
-      projected_curve = curve->project_curve(surface, CUBIT_FALSE, v);
+      projected_curve = curve->project_curve(surface, points, CUBIT_FALSE, v);
       if(projected_curve)
-        projected_curves.append(projected_curve);
+        projected_curves.append_unique(projected_curve);
     }
   }
+  while(points.size() > 0)
+    delete points.pop();
   return CUBIT_SUCCESS;
 }
 

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-06-11 01:14:43 UTC (rev 1890)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-06-11 19:08:53 UTC (rev 1891)
@@ -1582,9 +1582,9 @@
   {
     delete occ_shell->my_body();
     delete occ_shell->my_lump();
-    CubitStatus stat = unhook_ShellSM_from_OCC(occ_shell);
     DLIList<TopologyBridge*> tb_surfaces;
     occ_shell->get_children_virt(tb_surfaces);
+    CubitStatus stat = unhook_ShellSM_from_OCC(occ_shell);
     for(int k = 0; k < tb_surfaces.size(); k++)
       delete_solid_model_entities(CAST_TO(tb_surfaces.get_and_step(), Surface));
     delete occ_shell;

Modified: cgm/trunk/test/modify.cpp
===================================================================
--- cgm/trunk/test/modify.cpp	2008-06-11 01:14:43 UTC (rev 1890)
+++ cgm/trunk/test/modify.cpp	2008-06-11 19:08:53 UTC (rev 1891)
@@ -343,7 +343,7 @@
 
   n = new_bodies.get()->num_ref_edges();//n = 17
 
-  OCCBody* check_body = CAST_TO(face_list.get()->body()->get_body_sm_ptr(), OCCBody);
+  new_bodies.clean_out();
   stat = gmti->imprint(face_list, ref_edges, new_bodies, CUBIT_FALSE);
 
   //test for multi-cut imprint for subtract.
@@ -403,14 +403,9 @@
   tool_body  = gmti->brick(4, 4, 4);
   CubitVector v_move3(0,1,0);
   gti->translate(tool_body,v_move3);
-  BodySM* copy_bodysm = ome->copy_body(tool_body->get_body_sm_ptr());
   Body* copy_tool_body = gmti->copy_body(tool_body);
   Body* copy_tool_body2 = gmti->copy_body(tool_body);
 
-  //test shell body imprint
-  //TopoDS_Shape* tool_shape = CAST_TO(copy_bodysm,OCCBody)->get_TopoDS_Shape();  
-  //TopoDS_Shape* from_shape = CAST_TO(bodysm,OCCBody)->shell()->get_TopoDS_Shell();
-  //ome->imprint_toposhapes(tool_shape, from_shape);
   from_bodies.clean_out();
   new_bodies.clean_out();
   from_bodies.append(copy_tool_body);
@@ -456,6 +451,31 @@
   from_bodies.append(tool_body);
   stat =  gmti->imprint(from_bodies, new_bodies, CUBIT_FALSE);
   
+  //test imprint projected edges
+  bodies.clean_out();
+  gti->bodies(bodies);
+  //delete all entities
+  gti->delete_Body(bodies);
+
+  free_entities.clean_out();
+  gti->get_free_ref_entities(free_entities);  
+  
+  OCCQueryEngine* oqe = OCCQueryEngine::instance();
+  DLIList <OCCBody* > *occ_bodies = oqe->BodyList;
+
+  from_body  = gmti->brick(4, 4, 4);
+  CubitVector v_move9(0,3,0);
+  gti->translate(from_body,v_move9); 
+  ref_faces.clean_out();
+  from_body->ref_faces(ref_faces);
+  tool_body = gmti->brick(11, 1, 1);  
+  ref_edges.clean_out();
+  tool_body->ref_edges(ref_edges);
+  new_bodies.clean_out();
+  gmti->imprint_projected_edges(ref_faces,ref_edges, new_bodies, CUBIT_TRUE,
+       CUBIT_FALSE); 
+  if(new_bodies.size())
+    n = new_bodies.get()->num_ref_faces();
   return CUBIT_SUCCESS;
 
 }




More information about the cgma-dev mailing list