[cgma-dev] r1572 - cgm/trunk/geom/OCC
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Thu Jan 31 14:39:48 CST 2008
Author: janehu
Date: 2008-01-31 14:39:48 -0600 (Thu, 31 Jan 2008)
New Revision: 1572
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
Log:
studied on how to generate Hyperbola, Parabola, Ellipse using three points, added creating circles
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-01-31 19:56:52 UTC (rev 1571)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-01-31 20:39:48 UTC (rev 1572)
@@ -286,6 +286,19 @@
// Function : make_Curve
// Member Type: PUBLIC
// Description: make a curve
+// For STRAIGHT_CURVE_TYPE:
+// intermediate_point_ptr is not used
+//
+// For PARABOLA_CURVE_TYPE
+// intermediate_point_ptr is the tip of the parabola
+//
+// For ELLIPSE_CURVE_TYPE
+// intermediate_point_ptr is the center of the ellipse
+// sense is used to determine which part of the ellipse is required
+//
+// For ARC_CURVE_TYPE
+// arc passes three points
+//
// Author : Jane Hu
// Date : 01/08
//===============================================================================
@@ -307,7 +320,92 @@
point1_ptr = point2_ptr;
point2_ptr = tmp_point;
}
- return make_Curve(curve_type, point1_ptr, point2_ptr, mid_points);
+
+ if(curve_type == SPLINE_CURVE_TYPE)
+ return make_Curve(curve_type, point1_ptr, point2_ptr, mid_points);
+
+ CubitVector v1(point1_ptr->coordinates());
+ CubitVector v2(point2_ptr->coordinates());
+
+ gp_Pnt pt1(v1.x(),v1.y(), v1.z());
+ gp_Pnt pt2(v2.x(),v2.y(), v2.z());
+
+ CubitVector v3;
+ gp_Pnt pt3;
+ if(intermediate_point_ptr != NULL)
+ {
+ v3 = point1_ptr->coordinates();
+ pt3.SetValue(v3.x(),v3.y(), v3.z());
+ }
+
+ if (curve_type == STRAIGHT_CURVE_TYPE)
+ Handle(Geom_TrimmedCurve) curve_ptr = GC_MakeSegment(pt1,pt2);
+
+ else if (curve_type == ARC_CURVE_TYPE)
+ {
+ assert(intermediate_point_ptr != NULL);
+ Handle(Geom_TrimmedCurve) curve_ptr = GC_MakeArcOfCircle(pt1, pt2, pt3);
+ }
+
+ else if (curve_type == ELLIPSE_CURVE_TYPE)
+ {
+ assert(intermediate_point_ptr != NULL);
+
+ Handle(Geom_TrimmedCurve) curve_ptr = GC_MakeArcOfEllipse(
+ }
+
+ else if(curve_type == PARABOLA_CURVE_TYPE)
+ {
+ assert(intermediate_point_ptr != NULL);
+ //find the directrix and focus of this parabola
+ CubitVector width_vec = v2 - v1;
+ CubitVector midpoint_vec = (v1 + v2)/2.0;
+ CubitVector height_vec = v3 - midpoint_vec;
+
+ // Find the focus of this parabola.
+ // Since for a parabola with its peak at the origin, y = (1/(4*a))*x^2,
+ // and since we have restricted this parabola to be symmetric (per the FastQ
+ // method, see the FastQ file getwt.f), we can use the following relationship
+ // to determine "a", the distance the focus lies from the peak on the line
+ // formed by the peak and the midpoint of the start and end points`
+ }
+
+ else if(curve_type == HYPERBOLA_CURVE_TYPE)
+ {
+ assert(intermediate_point_ptr != NULL);
+ //given two foci and a third point on the curve
+ // if a = 1/2 length major axis, b = 1/2 length minor axis and
+ // c = distance center to focus, then a*a + b*b = c*c
+ CubitVector midpoint_vec = (v1 + v2)/2.0;
+ gp_Pnt center(midpoint_vec.x(), midpoint_vec.y(), midpoint_vec.z());
+
+ //x direction:
+ CubitVector x = v1 - v2;
+ if(x.length() > 0.000001)
+ x.normalize();
+ else
+ {
+ }
+ //main direction:
+ CubitVector N = x * (v3 - v1);
+ if (N.length() > 0.000001)
+ N.normalize();
+ else
+ {
+ }
+ gp_Ax2 axis(center, N, x);
+ double major = x.length()/2.0;
+ double minor = sqrt((center - v1).length() ^ 2 - major ^ 2);
+ gp_Hypr hypt(axis, major, minor);
+
+
+A
+A
+
+ }
+
+ TopoDS_Edge new_edge = BRepBuilderAPI_MakeEdge(curve_ptr);
+ return OCCQueryEngine::instance()->populate_topology_bridge(new_edge);
}
//===============================================================================
More information about the cgma-dev
mailing list