b311480e |
1 | -- Created on: 1991-10-10 |
2 | -- Created by: Jean Claude VAUTHIER |
3 | -- Copyright (c) 1991-1999 Matra Datavision |
973c2be1 |
4 | -- Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | -- |
973c2be1 |
6 | -- This file is part of Open CASCADE Technology software library. |
b311480e |
7 | -- |
d5f74e42 |
8 | -- This library is free software; you can redistribute it and/or modify it under |
9 | -- the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | -- by the Free Software Foundation, with special exception defined in the file |
11 | -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | -- distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | -- |
973c2be1 |
14 | -- Alternatively, this file may be used under the terms of Open CASCADE |
15 | -- commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | package Convert |
18 | |
ff8178ef |
19 | --- Purpose: |
7fd59977 |
20 | --The Convert package provides algorithms to convert the following into a BSpline curve or surface: |
21 | -- - a bounded curve based on an elementary 2D curve (line, circle or conic) from the gp package, |
22 | -- - a bounded surface based on an elementary surface (cylinder, cone, sphere or torus) from the gp package, |
23 | -- - a series of adjacent 2D or 3D Bezier curves defined by their poles. |
24 | -- These algorithms compute the data needed to define the resulting BSpline curve or surface. |
25 | -- This elementary data (degrees, periodic characteristics, poles and weights, knots and |
26 | -- multiplicities) may then be used directly in an algorithm, or can be used to construct the curve |
27 | -- or the surface by calling the appropriate constructor provided by the classes |
28 | -- Geom2d_BSplineCurve, Geom_BSplineCurve or Geom_BSplineSurface. |
29 | |
ff8178ef |
30 | uses TColStd, |
7fd59977 |
31 | TColgp, |
32 | StdFail, |
33 | gp, |
34 | GeomAbs, |
35 | TCollection |
36 | |
37 | is |
38 | |
39 | enumeration ParameterisationType is |
40 | TgtThetaOver2, |
41 | TgtThetaOver2_1, |
42 | TgtThetaOver2_2, |
43 | TgtThetaOver2_3, |
44 | TgtThetaOver2_4, |
45 | ---Purpose: |
46 | -- Identifies a type of parameterization of a circle or ellipse represented as a BSpline curve. |
47 | -- For a circle with a center C and a radius R (for example a Geom2d_Circle or a Geom_Circle), |
48 | -- the natural parameterization is angular. It uses the angle Theta made by the vector CM with |
49 | -- the 'X Axis' of the circle's local coordinate system as parameter for the current point M. The |
50 | -- coordinates of the point M are as follows: |
51 | -- X = R *cos ( Theta ) |
52 | -- y = R * sin ( Theta ) |
53 | -- Similarly, for an ellipse with a center C, a major radius R and a minor radius r, the circle Circ |
54 | -- with center C and radius R (and located in the same plane as the ellipse) lends its natural |
55 | -- angular parameterization to the ellipse. This is achieved by an affine transformation in the plane |
56 | -- of the ellipse, in the ratio r / R, about the 'X Axis' of its local coordinate system. The |
57 | -- coordinates of the current point M are as follows: |
58 | -- X = R * cos ( Theta ) |
59 | -- y = r * sin ( Theta ) |
60 | -- The process of converting a circle or an ellipse into a rational or non-rational BSpline curve |
61 | -- transforms the Theta angular parameter into a parameter t. This ensures the rational or |
62 | -- polynomial parameterization of the resulting BSpline curve. Several types of parametric |
63 | -- transformations are available. |
64 | -- TgtThetaOver2 |
65 | -- The most usual method is Convert_TgtThetaOver2 where the parameter t on the BSpline |
66 | -- curve is obtained by means of transformation of the following type: |
67 | -- t = tan ( Theta / 2 ) |
68 | -- The result of this definition is: |
69 | -- cos ( Theta ) = ( 1. - t**2 ) / ( 1. + t**2 ) |
70 | -- sin ( Theta ) = 2. * t / ( 1. + t**2 ) |
71 | -- which ensures the rational parameterization of the circle or the ellipse. However, this is not the |
72 | -- most suitable parameterization method where the arc of the circle or ellipse has a large opening |
73 | -- angle. In such cases, the curve will be represented by a BSpline with intermediate knots. Each |
74 | -- span, i.e. each portion of curve between two different knot values, will use parameterization of |
75 | -- this type. |
76 | -- The number of spans is calculated using the following rule: |
77 | -- ( 1.2 * Delta / Pi ) + 1 |
78 | -- where Delta is equal to the opening angle (in radians) of the arc of the circle (Delta is |
79 | -- equal to 2.* Pi in the case of a complete circle). |
80 | -- The resulting BSpline curve is "exact", i.e. computing any point of parameter t on the BSpline |
81 | -- curve gives an exact point on the circle or the ellipse. |
82 | -- TgtThetaOver2_N |
83 | -- Where N is equal to 1, 2, 3 or 4, this ensures the same type of parameterization as |
84 | -- Convert_TgtThetaOver2 but sets the number of spans in the resulting BSpline curve to N |
85 | -- rather than allowing the algorithm to make this calculation. |
86 | -- However, the opening angle Delta (parametric angle, given in radians) of the arc of the circle |
87 | -- (or of the ellipse) must comply with the following: |
88 | -- - Delta <= 0.9999 * Pi for the Convert_TgtThetaOver2_1 method, or |
89 | -- - Delta <= 1.9999 * Pi for the Convert_TgtThetaOver2_2 method. |
90 | -- QuasiAngular |
91 | -- The Convert_QuasiAngular method of parameterization uses a different type of rational |
92 | -- parameterization. This method ensures that the parameter t along the resulting BSpline curve is |
93 | -- very close to the natural parameterization angle Theta of the circle or ellipse (i.e. which uses |
94 | -- the functions sin ( Theta ) and cos ( Theta ). |
95 | -- The resulting BSpline curve is "exact", i.e. computing any point of parameter t on the BSpline |
96 | -- curve gives an exact point on the circle or the ellipse. |
97 | -- RationalC1 |
98 | -- The Convert_RationalC1 method of parameterization uses a further type of rational |
99 | -- parameterization. This method ensures that the equation relating to the resulting BSpline curve |
100 | -- has a "C1" continuous denominator, which is not the case with the above methods. RationalC1 |
101 | -- enhances the degree of continuity at the junction point of the different spans of the curve. |
102 | -- The resulting BSpline curve is "exact", i.e. computing any point of parameter t on the BSpline |
103 | -- curve gives an exact point on the circle or the ellipse. |
104 | -- Polynomial |
105 | -- The Convert_Polynomial method is used to produce polynomial (i.e. non-rational) |
106 | -- parameterization of the resulting BSpline curve with 8 poles (i.e. a polynomial degree equal to 7). |
107 | -- However, the result is an approximation of the circle or ellipse (i.e. computing the point of |
108 | -- parameter t on the BSpline curve does not give an exact point on the circle or the ellipse). |
109 | QuasiAngular, |
110 | RationalC1, |
111 | Polynomial; |
ff8178ef |
112 | |
7fd59977 |
113 | |
114 | |
115 | imported CosAndSinEvalFunction ; |
116 | -- typedef void *CosAndSinEvalFunction(Standard_Real, |
117 | -- const Standard_Integer, |
118 | -- const TColgp_Array1OfPnt2d& |
119 | -- const TColStd_Array1OfReal& |
120 | -- const TColStd_Array1OfInteger& |
121 | -- Standard_Real Result[2] |
ff8178ef |
122 | -- |
123 | |
7fd59977 |
124 | |
125 | deferred class ConicToBSplineCurve; |
7fd59977 |
126 | class CircleToBSplineCurve; |
7fd59977 |
127 | class EllipseToBSplineCurve; |
7fd59977 |
128 | class HyperbolaToBSplineCurve; |
7fd59977 |
129 | class ParabolaToBSplineCurve; |
7fd59977 |
130 | |
7fd59977 |
131 | deferred class ElementarySurfaceToBSplineSurface; |
7fd59977 |
132 | class CylinderToBSplineSurface; |
7fd59977 |
133 | class ConeToBSplineSurface; |
7fd59977 |
134 | class TorusToBSplineSurface; |
7fd59977 |
135 | class SphereToBSplineSurface; |
7fd59977 |
136 | |
7fd59977 |
137 | class SequenceOfArray1OfPoles |
138 | instantiates Sequence from TCollection( HArray1OfPnt from TColgp); |
ff8178ef |
139 | |
7fd59977 |
140 | class CompBezierCurvesToBSplineCurve; |
ff8178ef |
141 | |
7fd59977 |
142 | alias SequenceOfArray1OfPoles2d is SequenceOfArray1OfPnt2d from TColgp; |
ff8178ef |
143 | |
7fd59977 |
144 | class CompBezierCurves2dToBSplineCurve2d; |
7fd59977 |
145 | |
146 | class CompPolynomialToPoles; |
ff8178ef |
147 | |
7fd59977 |
148 | class GridPolynomialToPoles; |
ff8178ef |
149 | |
7fd59977 |
150 | end Convert; |