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