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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Fri Jan 2 12:29:36 CST 2009


Author: janehu
Date: 2009-01-02 12:29:35 -0600 (Fri, 02 Jan 2009)
New Revision: 2503

Modified:
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
Log:
Modify creat_arc_three from curves to use tangent points instead of using intersection points of bi-section line and curve to create circle.

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-12-30 19:54:22 UTC (rev 2502)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2009-01-02 18:29:35 UTC (rev 2503)
@@ -4990,7 +4990,7 @@
   OCCQueryEngine::instance()->get_intersections(curve3, curve1, intscts,none,none);
   vt3 = *intscts.get();
 
-  double u, u11, u12, u21, u22, u31, u32;
+  double u11, u12, u21, u22, u31, u32;
   occ_crv1->get_param_range(u11, u12);
   occ_crv2->get_param_range(u21, u22);
   occ_crv3->get_param_range(u31, u32);
@@ -5064,214 +5064,56 @@
   t_curve32.normalize();
   CubitVector p32 = vt3 + t_curve32;
 
-  //3. find the intersection of each of the bisection curve with the third curve
-  //Error out if there's multiple solutions,urge user to shorten the curves to 
-  //make the intention clear.
-
-  CubitVector int_pt11, int_pt12, int_pt21, int_pt22, int_pt31, int_pt32;
-  intscts.clean_out();
-  OCCQueryEngine::instance()->get_intersections(curve3, vt1, p11, intscts,none,none);
-  CubitVector int_pt = *intscts.pop(); 
-  u = occ_crv3->u_from_position (int_pt);
-  CubitBoolean found[6] = {CUBIT_FALSE, CUBIT_FALSE, CUBIT_FALSE, CUBIT_FALSE,
-                           CUBIT_FALSE, CUBIT_FALSE};
-
-  if(u >= u31-tol && u <= u32+tol) //found intersection point
-  {
-    int_pt11 = int_pt;
-    found[0] = CUBIT_TRUE;
-  }
-
-  OCCQueryEngine::instance()->get_intersections(curve3, vt1, p12, intscts,none,none);
-  int_pt = *intscts.pop();
-  u = occ_crv3->u_from_position (int_pt);
-  if(u >= u31-tol && u <= u32+tol)
-  {
-    if(found[0])
-    {
-      found[1] = CUBIT_TRUE;
-      int_pt12 = int_pt;
-    }
-    else
-    {
-      int_pt11 = int_pt;
-      found[0] = CUBIT_TRUE;
-    }
-  }
-  if(!found[0] ) 
-  {
-     PRINT_ERROR("Can't find the intesection point to create circle.\n");
-     return (Curve*) NULL;
-  }
-
-  OCCQueryEngine::instance()->get_intersections(curve1, vt2, p21, intscts,none,none);
-  int_pt = *intscts.pop();
-  u = occ_crv1->u_from_position (int_pt);
-  if(u >= u11-tol && u <= u12+tol) //found intersection point
-  {
-    found[2] = CUBIT_TRUE;
-    int_pt21 = int_pt;
-  }
-
-  OCCQueryEngine::instance()->get_intersections(curve1, vt2, p22, intscts,none,none);
-  int_pt = *intscts.pop();
-  u = occ_crv1->u_from_position (int_pt);
-  if(u >= u11-tol && u <= u12+tol)
-  {
-    if(found[2])
-    {
-      int_pt22 = int_pt;
-      found[3] = CUBIT_TRUE;
-    }
-    else
-    {
-      found[2] = CUBIT_TRUE;
-      int_pt21 = int_pt;
-    }
-  }
-  if(!found[2] )
-  {
-     PRINT_ERROR("Can't find the intesection point to create circle.\n");
-     return (Curve*) NULL;
-  }
-
-  OCCQueryEngine::instance()->get_intersections(curve2, vt3, p31, intscts,none,none);
-  int_pt = *intscts.pop();
-  u = occ_crv2->u_from_position (int_pt);
-  if(u >= u21-tol && u <= u22+tol) //found intersection point
-  {
-    found[4] = CUBIT_TRUE;
-    int_pt31 = int_pt;
-  }
-
-  OCCQueryEngine::instance()->get_intersections(curve2, vt3, p32, intscts,none,none);
-  int_pt = *intscts.pop();
-  u = occ_crv2->u_from_position (int_pt);
-  if(u >= u21-tol && u <= u22+tol)
-  {
-    if(found[4])
-    {
-      int_pt32 = int_pt;
-      found[5] = CUBIT_TRUE;
-    }
-    else
-    {
-      found[4] = CUBIT_TRUE;
-      int_pt31 = int_pt;
-    }
-  }
-  if(!found[4] )
-  {
-     PRINT_ERROR("Can't find the intesection point to create circle.\n");
-     return (Curve*) NULL;
-  }
-
-  //find the three intersection points which when connected with the vertices,
+  //3. find the three intersection points which when connected with the vertices,
   //intersect at same point.
-  CubitVector c_p11, c_p12, c_p21, c_p22, c_p31, c_p32, c_p;
+  CubitVector line_p[4], c_p[4], c_ptemp;
   double sc, tc;
-  CubitVector int_pt1, int_pt2, int_pt3;
-  CubitBoolean find = CUBIT_FALSE;
 
   IntersectionTool int_tool;
-  for(int i = 0; i < 8 ; i++)
+  for(int i = 0; i < 4; i++)
   {
-    int_tool.closest_points_on_segments(vt1, int_pt11, vt2, int_pt21, c_p11, c_p12, sc, tc);
-    if(c_p11.distance_between(c_p12) < tol) //intersect 
-      c_p = c_p11;
-    else  
-      assert(0); 
-      
-    int_tool.closest_points_on_segments(vt1, int_pt11, vt3, int_pt31, c_p11, c_p12, sc, tc);
-    if(c_p11.distance_between(c_p12) < tol ) //intersect
+    if( i == 0)
     {
-      if(c_p.distance_between(c_p12) < tol) //three line intersects at same point
-      {
-        find = CUBIT_TRUE;
-        break;
-      }
+      line_p[0] = vt1;
+      line_p[1] = p11;
+      line_p[2] = vt2;
+      line_p[3] = p21;
     } 
-    else //not interscting at same points or parallel
+    else if(i == 1)
+      line_p[3] = p22;
+    else if(i == 2)
+      line_p[1] = p12;
+    else
+      line_p[3] = p21;  
+    int_tool.closest_points_on_segments(line_p[0], line_p[1], line_p[2],
+                    line_p[3], c_ptemp, c_p[i], sc, tc);
+        
+    //check if the closeset point from c_p[i] to three curves are on three curves
+    CubitVector closest1, closest2, closest3;
+    occ_crv1->closest_point(c_p[i], closest1);
+    double u = occ_crv1->u_from_position(closest1);
+    if(u > u11-tol && u < u12 + tol)
     {
-      if(i == 0)
+      occ_crv2->closest_point(c_p[i], closest2);
+      u = occ_crv2->u_from_position(closest2);
+      if(u > u21 - tol && u < u22 + tol)
       {
-        if(found[1])
+        occ_crv3->closest_point(c_p[i], closest3);
+        u = occ_crv3->u_from_position(closest3);
+        if(u > u31 - tol && u < u32 + tol)
         {
-          int_pt1 = int_pt11;
-          int_pt11 = int_pt12;
-        }
-        else
-          i++;
+        //4. use the 3 intersection points to find the arc or circle.
+          OCCPoint occ_p1(closest1);
+          OCCPoint occ_p2(closest2);     
+          OCCPoint occ_p3(closest3);
+          return create_arc_three(&occ_p1, &occ_p2, &occ_p3, full);
+        } 
       }
-      if(i == 1)
-      {
-        if(found[1])
-          int_pt11 = int_pt1;
-        if(found[3])
-        {
-          int_pt2 = int_pt21;
-          int_pt21 = int_pt22;
-        }
-        else
-          i += 2;
-      }
-      if(i == 2)
-      {
-        if(found[1] && found[3])
-          int_pt11 = int_pt12;
-        else 
-          assert(0);
-      }
-      if(i == 3)
-      {
-        if(found[1])
-          int_pt11 = int_pt1;
-        if(found[3])
-          int_pt21 = int_pt2;
-        if(found[5])
-        {
-          int_pt3 = int_pt31;
-          int_pt31 = int_pt32;
-        }
-        else
-          break;
-      }
-      if(i == 4)
-      {
-        if(found[1] && found[5])
-          int_pt11 = int_pt12; 
-        else
-          continue;
-      }
-      if(i == 5)
-      {
-        if(found[1])
-          int_pt11 = int_pt1;
-        if(found[3] && found[5])
-          int_pt21 = int_pt22;
-        else
-          continue;
-      }
-      if(i == 6)
-      {  
-        if(found[1] && found[3] && found[5])
-          int_pt11 = int_pt12;
-        else
-          continue;
-      }
     }
   }
-  if(!find)
-  {
-    PRINT_ERROR("Can't find the intesection point to create circle.\n");
-    return (Curve*) NULL;
-  } 
-  //4. use the 3 intersection points to find the arc or circle.
-  OCCPoint occ_p1(int_pt11);
-  OCCPoint occ_p2(int_pt21);      
-  OCCPoint occ_p3(int_pt31);
-  return create_arc_three(&occ_p1, &occ_p2, &occ_p3, full); 
-}
+  PRINT_ERROR("Can't find the tangent points to create circle.\n");
+  return (Curve*) NULL;
+} 
 
 //===============================================================================
 // Function   : create_arc_center_edge




More information about the cgma-dev mailing list