Changeset 2296
- Timestamp:
- 12/02/08 14:11:41 (3 months ago)
- Files:
-
- cgm/trunk/geom/OCC/OCCModifyEngine.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
r2286 r2296 41 41 #include "GC_MakeTrimmedCone.hxx" 42 42 #include "GC_MakeTrimmedCylinder.hxx" 43 #include "gce_MakeElips.hxx" 43 44 #include "Geom_BezierCurve.hxx" 44 45 #include "BndLib_AddSurface.hxx" … … 363 364 // For ELLIPSE_CURVE_TYPE 364 365 // intermediate_point_ptr is the center of the ellipse 365 // the point who is farther away to the center is the vertex of the ellipse366 // the other s point projects to major axis at focus.366 // the two points are vertices, one gives the major radius, 367 // the other point gives the minor radius. 367 368 // sense is used to determine which part of the ellipse is required 368 369 // … … 417 418 assert(intermediate_point_ptr != NULL); 418 419 419 //calculate for the axis 420 double d1 = (v1 - v3).length_squared(); 421 double d2 = (v2 - v3).length_squared(); 422 423 CubitVector x = d1 >= d2 ? v1-v3 : v2-v3; 424 x.normalize(); 425 gp_Dir x_dir(x.x(), x.y(), x.z()); 426 427 CubitVector N = (v1 - v3) * (v2 - v3); 428 if(N.length_squared() < tol * tol) 420 gp_Pnt center(v3.x(), v3.y(), v3.z()); 421 422 gp_Elips ellipse; 423 gce_MakeElips ellipse1(pt1 , pt2 , center); 424 if(ellipse1.IsDone()) 425 ellipse = ellipse1.Value(); 426 else if(!ellipse1.IsDone() && ellipse1.Status() == gce_InvertRadius) 429 427 { 430 PRINT_ERROR("Cannot create an ellipse curve from the given points.\n" 431 "3 points are in the same line.\n"); 432 return (Curve *)NULL; 428 gce_MakeElips ellipse2(pt2, pt1, center); 429 if(ellipse2.IsDone()) 430 ellipse = ellipse2.Value(); 431 else 432 { 433 PRINT_ERROR("Can't create an ellipse from give 3 points.\n"); 434 return (Curve *)NULL; 435 } 436 } 437 else 438 { 439 PRINT_ERROR("Can't create an ellipse from give 3 points.\n"); 440 return (Curve *)NULL; 433 441 } 434 N.normalize();435 if (sense == CUBIT_REVERSED)436 N = -N;437 gp_Dir N_dir(N.x(), N.y(), N.z());438 439 gp_Pnt center(v3.x(), v3.y(), v3.z());440 gp_Ax2 axis(center, N_dir, x_dir);441 442 //calculate for the major and minor radius.443 double major = d1 >= d2 ? sqrt(d1): sqrt(d2);444 double other_d = d1 >= d2 ? sqrt(d2) : sqrt(d1);445 double c = cos((v1 - v3).interior_angle(v2 - v3)) * other_d;446 double minor = sqrt(major * major - c * c);447 448 gp_Elips ellipse(axis, major, minor);449 442 CubitBoolean use_sense = (sense == CUBIT_FORWARD ? CUBIT_TRUE : CUBIT_FALSE); 450 443 curve_ptr = GC_MakeArcOfEllipse(ellipse, pt1, pt2, use_sense);