b311480e |
1 | -- Created on: 1993-07-07 |
2 | -- Created by: Jean Claude VAUTHIER |
3 | -- Copyright (c) 1993-1999 Matra Datavision |
4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | -- |
6 | -- The content of this file is subject to the Open CASCADE Technology Public |
7 | -- License Version 6.5 (the "License"). You may not use the content of this file |
8 | -- except in compliance with the License. Please obtain a copy of the License |
9 | -- at http://www.opencascade.org and read it completely before using this file. |
10 | -- |
11 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | -- |
14 | -- The Original Code and all software distributed under the License is |
15 | -- distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | -- Initial Developer hereby disclaims all such warranties, including without |
17 | -- limitation, any warranties of merchantability, fitness for a particular |
18 | -- purpose or non-infringement. Please see the License for the specific terms |
19 | -- and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | -- jct : modified 15-Apr-97 : added method ExtendSurfByLength |
22 | |
23 | |
24 | package GeomLib |
25 | |
26 | ---Purpose: Geom Library. This package provides an |
27 | -- implementation of functions for basic computation |
28 | -- on geometric entity from packages Geom and Geom2d. |
29 | |
30 | |
31 | uses |
32 | TCollection, |
33 | TColStd, |
34 | TColgp, |
35 | TColGeom, |
36 | TColGeom2d, |
37 | Adaptor3d, |
38 | AdvApprox, |
39 | Geom, |
40 | Geom2d, |
41 | GeomAbs, |
42 | math, |
43 | gp, |
44 | StdFail |
45 | |
46 | is |
47 | |
48 | enumeration InterpolationErrors is |
49 | ---Purpose: in case the interpolation errors out, this |
50 | -- tells what happened |
51 | NoError, |
52 | NotEnoughtPoints, |
53 | DegreeSmallerThan3, |
54 | InversionProblem |
55 | |
56 | end InterpolationErrors; |
57 | |
58 | -- -- --------------- -- |
59 | -- C L A S S E S -- |
60 | -- --------------- -- |
61 | |
62 | class Array1OfMat instantiates |
63 | Array1 from TCollection (Mat from gp); |
64 | |
65 | class MakeCurvefromApprox; |
66 | ---Purpose: This class is used to create the curves ( 2d or |
67 | -- 3d) rational or not created by the class |
68 | -- ApproxAFunction from AdvApprox. |
69 | |
70 | |
71 | |
72 | class Interpolate ; |
73 | ---Purpose: this class compute the poles of a curve given some |
74 | -- parameters, points to interpolate and boundary conditions |
75 | -- in 3d |
76 | class DenominatorMultiplier ; |
77 | ---Purpose: this defines an evaluator for a function of 2 variables |
78 | -- that will be used by CancelDenominatorDerivative in one |
79 | -- direction. |
80 | |
81 | |
82 | class CheckBSplineCurve ; |
83 | ---Purpose: Checks for the end tangents : wether or not those |
84 | -- are reversed regarding the third or n-3rd control |
85 | -- |
86 | -- |
87 | class Check2dBSplineCurve ; |
88 | |
89 | ---Purpose: Checks for the end tangents : wether or not those |
90 | -- are reversed |
91 | |
92 | class IsPlanarSurface; |
93 | |
94 | class Tool; |
95 | ---Purpose: provides various methods with Geom2d and Geom curves |
96 | --- and surfaces. |
97 | |
98 | private class PolyFunc; |
99 | |
100 | private class LogSample; |
101 | |
102 | pointer DenominatorMultiplierPtr to DenominatorMultiplier from GeomLib ; |
103 | ------------------------- |
104 | -- M E T H O D E S -- |
105 | -- ----------------- -- |
106 | |
107 | To3d (Position : in Ax2 from gp; |
108 | Curve2d : in Curve from Geom2d) |
109 | returns Curve from Geom; |
110 | ---Purpose: Computes the curve 3d from package Geom |
111 | -- corresponding to curve 2d from package Geom2d, on |
112 | -- the plan defined with the local coordinate system |
113 | -- Position. |
114 | |
115 | |
116 | GTransform( Curve : in Curve from Geom2d; |
117 | GTrsf : in GTrsf2d from gp) |
118 | returns Curve from Geom2d; |
119 | ---Purpose: Computes the curve 3d from package Geom |
120 | -- corresponding to the curve 3d from package Geom, |
121 | -- transformed with the transformation <GTrsf> |
122 | -- WARNING : this method may return a null Handle if |
123 | -- it's impossible to compute the transformation of |
124 | -- a curve. It's not implemented when : |
125 | -- 1) the curve is an infinite parabola or hyperbola |
126 | -- 2) the curve is an offsetcurve |
127 | |
128 | SameRange(Tolerance : in Real from Standard ; |
129 | Curve2dPtr : in Curve from Geom2d ; |
130 | First : in Real from Standard ; |
131 | Last : in Real from Standard ; |
132 | RequestedFirst : in Real from Standard ; |
133 | RequestedLast : in Real from Standard ; |
134 | NewCurve2dPtr : out Curve from Geom2d) ; |
135 | |
136 | ---Purpose: Make the curve Curve2dPtr have the imposed |
137 | -- range First to List the most economic way, |
138 | -- that is if it can change the range without |
139 | -- changing the nature of the curve it will try |
140 | -- to do that. Otherwise it will produce a Bspline |
141 | -- curve that has the required range |
142 | BuildCurve3d(Tolerance : in Real from Standard ; |
143 | CurvePtr : in out CurveOnSurface from Adaptor3d ; |
144 | FirstParameter : in Real from Standard ; |
145 | LastParameter : in Real from Standard ; |
146 | NewCurvePtr : out Curve from Geom ; |
147 | MaxDeviation : out Real from Standard ; |
148 | AverageDeviation : out Real from Standard ; |
149 | Continuity : Shape from GeomAbs = GeomAbs_C1; |
150 | MaxDegree : Integer = 14; |
151 | MaxSegment : Integer = 30); |
152 | |
153 | AdjustExtremity(Curve : in out BoundedCurve from Geom; |
154 | P1, P2 : Pnt from gp; |
155 | T1, T2 : Vec from gp); |
156 | |
157 | ExtendCurveToPoint(Curve : in out BoundedCurve from Geom; |
158 | Point : Pnt from gp; |
159 | Cont : Integer from Standard; |
160 | After : Boolean from Standard); |
161 | ---Purpose: Extends the bounded curve Curve to the point Point. |
162 | -- The extension is built: |
163 | -- - at the end of the curve if After equals true, or |
164 | -- - at the beginning of the curve if After equals false. |
165 | -- The extension is performed according to a degree of |
166 | -- continuity equal to Cont, which in its turn must be equal to 1, 2 or 3. |
167 | -- This function converts the bounded curve Curve into a BSpline curve. |
168 | -- Warning |
169 | -- - Nothing is done, and Curve is not modified if Cont is |
170 | -- not equal to 1, 2 or 3. |
171 | -- - It is recommended that the extension should not be |
172 | -- too large with respect to the size of the bounded |
173 | -- curve Curve: Point must not be located too far from |
174 | -- one of the extremities of Curve. |
175 | |
176 | |
177 | ExtendSurfByLength(Surf : in out BoundedSurface from Geom; |
178 | Length : Real from Standard; |
179 | Cont : Integer from Standard; |
180 | InU : Boolean from Standard; |
181 | After : Boolean from Standard); |
182 | ---Purpose: |
183 | -- Extends the bounded surface Surf along one of its |
184 | -- boundaries. The chord length of the extension is equal to Length. |
185 | -- The direction of the extension is given as: |
186 | -- - the u parametric direction of Surf, if InU equals true, or |
187 | -- - the v parametric direction of Surf, if InU equals false. |
188 | -- In this parametric direction, the extension is built on the side of: |
189 | -- - the last parameter of Surf, if After equals true, or |
190 | -- - the first parameter of Surf, if After equals false. |
191 | -- The extension is performed according to a degree of |
192 | -- continuity equal to Cont, which in its turn must be equal to 1, 2 or 3. |
193 | -- This function converts the bounded surface Surf into a BSpline surface. |
194 | -- Warning |
195 | -- - Nothing is done, and Surf is not modified if Cont is |
196 | -- not equal to 1, 2 or 3. |
197 | -- - It is recommended that Length, the size of the |
198 | -- extension should not be too large with respect to the |
199 | -- size of the bounded surface Surf. |
200 | -- - Surf must not be a periodic BSpline surface in the |
201 | -- parametric direction corresponding to the direction of extension. |
202 | |
203 | |
204 | |
205 | AxeOfInertia(Points : Array1OfPnt from TColgp; |
206 | Axe : out Ax2 from gp; |
207 | IsSingular : out Boolean; |
208 | Tol : Real = 1.0e-7); |
209 | ---Purpose: Compute axes of inertia, of some points -- -- -- |
210 | -- <Axe>.Location() is the BaryCentre -- -- -- -- -- |
211 | -- <Axe>.XDirection is the axe of upper inertia -- -- -- |
212 | -- -- <Axe>.Direction is the Normal to the average plane |
213 | -- -- -- -- IsSingular is True if points are on line -- |
214 | -- Tol is used to determine singular cases. |
215 | |
216 | Inertia(Points : Array1OfPnt from TColgp; |
217 | Bary : out Pnt from gp; |
218 | XDir,YDir : out Dir from gp; |
219 | Xgap,YGap,ZGap : out Real); |
220 | ---Level: Advanced |
221 | ---Purpose: Compute principale axes of inertia, and dispertion |
222 | -- value of some points. |
223 | |
224 | |
225 | RemovePointsFromArray(NumPoints : Integer from Standard ; |
226 | InParameters : Array1OfReal from TColStd ; |
227 | OutParameters : in out HArray1OfReal from TColStd) ; |
228 | ---Purpose: Warning! This assume that the InParameter is an increasing sequence |
229 | -- of real number and it will not check for that : Unpredictable |
230 | -- result can happen if this is not satisfied. It is the caller |
231 | -- responsability to check for that property. |
232 | -- |
233 | -- This method makes uniform NumPoints segments S1,...SNumPoints out |
234 | -- of the segment defined by the first parameter and the |
235 | -- last parameter ofthe InParameter ; keeps only one |
236 | -- point of the InParameters set of parameter in each of |
237 | -- the uniform segments taking care of the first and the |
238 | -- last parameters. For the ith segment the element of |
239 | -- the InParameter is the one that is the first to exceed |
240 | -- the midpoint of the segment and to fall before the |
241 | -- midpoint of the next segment |
242 | -- There will be at the end at most NumPoints + 1 if |
243 | -- NumPoints > 2 in the OutParameters Array |
244 | |
245 | |
246 | DensifyArray1OfReal(MinNumPoints : Integer from Standard ; |
247 | InParameters : Array1OfReal from TColStd ; |
248 | OutParameters : in out HArray1OfReal from TColStd) ; |
249 | ---Purpose: this makes sure that there is at least MinNumPoints |
250 | -- in OutParameters taking into account the parameters in |
251 | -- the InParameters array provided those are in order, |
252 | -- that is the sequence of real in the InParameter is strictly |
253 | -- non decreasing |
254 | -- |
255 | |
256 | FuseIntervals(Interval1, Interval2 : Array1OfReal from TColStd; |
257 | Fusion : out SequenceOfReal from TColStd; |
258 | Confusion : Real = 1.0e-9); |
259 | |
260 | EvalMaxParametricDistance(Curve : Curve from Adaptor3d ; |
261 | AReferenceCurve : Curve from Adaptor3d ; |
262 | Tolerance : Real from Standard ; |
263 | Parameters : Array1OfReal from TColStd ; |
264 | MaxDistance : out Real from Standard) ; |
265 | |
266 | ---Purpose: this will compute the maximum distance at the |
267 | -- parameters given in the Parameters array by |
268 | -- evaluating each parameter the two curves and taking |
269 | -- the maximum of the evaluated distance |
270 | |
271 | EvalMaxDistanceAlongParameter(Curve : Curve from Adaptor3d ; |
272 | AReferenceCurve : Curve from Adaptor3d ; |
273 | Tolerance : Real from Standard ; |
274 | Parameters : Array1OfReal from TColStd ; |
275 | MaxDistance : out Real from Standard) ; |
276 | ---Purpose: this will compute the maximum distancef at the parameters |
277 | -- given in the Parameters array by projecting from the Curve |
278 | -- to the reference curve and taking the minimum distance |
279 | -- Than the maximum will be taken on those minimas. |
280 | |
281 | CancelDenominatorDerivative(BSurf : in out BSplineSurface from Geom ; |
282 | UDirection : in Boolean from Standard ; |
283 | VDirection : in Boolean from Standard) ; |
284 | ---Purpose: Cancel,on the boudaries,the denominator first derivative |
285 | -- in the directions wished by the user and set its value to 1. |
286 | |
287 | |
288 | -- TensorialProduct(S : in out BSplineSurface from Geom; |
289 | -- Poles : Array1OfMat from GeomLib; |
290 | -- TPoles : Array1OfPnt from TColgp; |
291 | -- Knots : Array1OfReal from TColStd; |
292 | -- Mults : Array1OfInteger from TColStd); |
293 | -- Purpose: Compute the Tensorial product beetween an |
294 | -- BSplineSurface <S>(U,V) and an Transformation Law M(v) |
295 | -- given by NUBS form (<Poles>, <Knots>, <Mults>). The result |
296 | -- Surface is R(U,V) = M(V)*S(U,V)+T(V). |
297 | |
298 | NormEstim(S : Surface from Geom; |
299 | UV : Pnt2d from gp; |
300 | Tol : Real from Standard; |
301 | N : in out Dir from gp) |
302 | |
303 | returns Integer from Standard; |
304 | -- Purpose: Computes normal of surface S in UV point UV |
305 | -- for regular point N = DU^DV |
306 | -- if |DU| < Tol or |DV| < Tol special treatment is used: |
307 | -- N is computed on base of normal of corresponding isoline |
308 | -- of S |
309 | -- returns 0 for regular point, |
310 | -- 1 for quasysingular (ex.: sphere pole) |
311 | -- 2 for conical singular point |
312 | -- 3 if computation impossible (for ex. DU||DV - tangent isolines) |
313 | |
314 | |
315 | end GeomLib; |
316 | |
317 | |