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

jiangtao_ma at yahoo.com jiangtao_ma at yahoo.com
Thu Aug 18 10:10:29 CDT 2011


Author: janehu
Date: 2011-08-18 10:10:29 -0500 (Thu, 18 Aug 2011)
New Revision: 5105

Modified:
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
Log:
Fix for ilc_13body.stp case with 2 coedges in one loop, provided by Hong-Jun.

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2011-08-15 19:14:18 UTC (rev 5104)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2011-08-18 15:10:29 UTC (rev 5105)
@@ -2080,6 +2080,55 @@
       CubitVector normal;
       occ_surface->get_point_normal(center, normal);
 
+      //number of coedges = 2 case is checked here.
+      //make sure the normal get from the cross product of the two 
+      //coedges are the same as the normal.
+      DLIList<OCCCoEdge*> codeges;
+      occ_surface->get_coedges(codeges);
+      if(codeges.size() == 2 && occ_surface->measure() > 0.000001)
+      {
+        OCCCoEdge* coedge1 = codeges.get_and_step();
+        OCCCoEdge* coedge2 = codeges.get();
+        OCCCurve* curve1 = CAST_TO(coedge1->curve(), OCCCurve);
+        OCCCurve* curve2 = CAST_TO(coedge2->curve(), OCCCurve);
+        double d1 = curve1->measure();
+        double d2 = curve2->measure();
+        double start1 = curve1->start_param();
+        double start2 = curve2->start_param();
+        double u1, u2;
+        if (coedge1->sense() == CUBIT_REVERSED)
+          u1 = curve1->u_from_arc_length(start1, d1*0.05);
+        else
+          u1 =  curve1->u_from_arc_length(start1, d1*0.95);
+        if (coedge2->sense() == CUBIT_REVERSED)
+          u2 = curve2->u_from_arc_length(start2, d2 * 0.95);
+        else
+          u2 =  curve2->u_from_arc_length(start2, d2*0.05);
+        CubitVector v1, v2, v_cross;
+        double d_dot;
+        curve1->position_from_u(u1,v1);
+        curve2->position_from_u(u2,v2);
+        CubitVector tangent1, tangent2;
+        curve1->get_tangent(v1, tangent1);
+        curve2->get_tangent(v2, tangent2);
+        if (coedge1->sense() == CUBIT_REVERSED)
+          tangent1 *= -1;
+        if (coedge2->sense() == CUBIT_REVERSED)
+          tangent2 *= -1;
+        v_cross = tangent1 * tangent2; 
+        if (v_cross.length() > 0.000001)
+        {
+          d_dot = v_cross % normal;
+          if (d_dot < 0) 
+          {
+             //Reverse all coedges' senses.
+             CubitSense sense = (coedge1->sense() == CUBIT_FORWARD ? CUBIT_REVERSED : CUBIT_FORWARD);


More information about the cgma-dev mailing list