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

jiangtao_ma at yahoo.com jiangtao_ma at yahoo.com
Thu Sep 29 12:21:31 CDT 2011


Author: janehu
Date: 2011-09-29 12:21:31 -0500 (Thu, 29 Sep 2011)
New Revision: 5180

Modified:
   cgm/trunk/geom/OCC/OCCSurface.cpp
Log:
Added code to project point onto one of the surface curves if a point is projected to void space on a surface.

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2011-09-29 17:19:30 UTC (rev 5179)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2011-09-29 17:21:31 UTC (rev 5180)
@@ -48,6 +48,7 @@
 #include "BRep_Builder.hxx"
 #include "LocOpe_SplitShape.hxx"
 #include "TopoDS_Compound.hxx"
+#include "BRepExtrema_DistShapeShape.hxx"
 // ********** END CUBIT INCLUDES           **********
 
 
@@ -319,7 +320,8 @@
 
 //-------------------------------------------------------------------------
 // Purpose       : Computes the closest_point on the trimmed surface to the 
-//                 input location. 
+//                 input location. if the point is not on surface, like in the
+//                 hole of the surface, try to project to one of the curves. 
 //
 // Special Notes : 
 //-------------------------------------------------------------------------
@@ -338,8 +340,45 @@
 			  newP = ext.Point(i).Value();
 		  }
 	  }
+          point_on_surface = CubitVector(newP.X(), newP.Y(), newP.Z());
   }
-  point_on_surface = CubitVector(newP.X(), newP.Y(), newP.Z());
+  else
+    return;
+
+  CubitPointContainment pos = point_containment(point_on_surface);
+  if(pos == CUBIT_PNT_OUTSIDE)
+  {
+    DLIList<OCCCurve*> curves;
+    int num_curve = get_curves(curves);
+    double d_min = 0., d;
+    OCCCurve* the_curve;
+    gp_Pnt pt = gp_Pnt(point_on_surface.x(), point_on_surface.y(), 
+                       point_on_surface.z());
+    TopoDS_Vertex theVertex = BRepBuilderAPI_MakeVertex(pt);
+    CubitVector closest_location;
+    do
+    {
+      for (i = 0; i < curves.size(); i++)
+      {
+        OCCCurve* curve = curves.get_and_step();
+        TopoDS_Edge* theEdge = curve->get_TopoDS_Edge( );
+        BRepExtrema_DistShapeShape distShapeShape(*theEdge, theVertex);
+        d = distShapeShape.Value();


More information about the cgma-dev mailing list