42cf5bc1 |
1 | // Created on: 1993-03-10 |
2 | // Created by: JCV |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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 |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Geom_OffsetSurface_HeaderFile |
18 | #define _Geom_OffsetSurface_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <Standard_Real.hxx> |
24 | #include <Geom_OsculatingSurface.hxx> |
25 | #include <GeomAbs_Shape.hxx> |
26 | #include <Geom_Surface.hxx> |
27 | #include <Standard_Boolean.hxx> |
28 | #include <Standard_Integer.hxx> |
6b84c3f7 |
29 | #include <GeomEvaluator_OffsetSurface.hxx> |
42cf5bc1 |
30 | class Geom_Surface; |
31 | class Standard_ConstructionError; |
32 | class Standard_RangeError; |
33 | class Standard_NoSuchObject; |
34 | class Geom_UndefinedDerivative; |
35 | class Geom_UndefinedValue; |
36 | class Geom_Curve; |
37 | class gp_Pnt; |
38 | class gp_Vec; |
39 | class Geom_BSplineSurface; |
40 | class gp_Trsf; |
41 | class gp_GTrsf2d; |
42 | class Geom_Geometry; |
43 | |
44 | |
45 | class Geom_OffsetSurface; |
46 | DEFINE_STANDARD_HANDLE(Geom_OffsetSurface, Geom_Surface) |
47 | |
48 | //! Describes an offset surface in 3D space. |
49 | //! An offset surface is defined by: |
50 | //! - the basis surface to which it is parallel, and |
51 | //! - the distance between the offset surface and its basis surface. |
52 | //! A point on the offset surface is built by measuring the |
53 | //! offset value along the normal vector at a point on the |
54 | //! basis surface. This normal vector is given by the cross |
55 | //! product D1u^D1v, where D1u and D1v are the |
56 | //! vectors tangential to the basis surface in the u and v |
57 | //! parametric directions at this point. The side of the |
58 | //! basis surface on which the offset is measured |
59 | //! depends on the sign of the offset value. |
60 | //! A Geom_OffsetSurface surface can be |
61 | //! self-intersecting, even if the basis surface does not |
62 | //! self-intersect. The self-intersecting portions are not |
63 | //! deleted at the time of construction. |
64 | //! Warning |
65 | //! There must be only one normal vector defined at any |
66 | //! point on the basis surface. This must be verified by the |
67 | //! user as no check is made at the time of construction |
68 | //! to detect points with multiple possible normal |
69 | //! directions (for example, the top of a conical surface). |
70 | class Geom_OffsetSurface : public Geom_Surface |
71 | { |
72 | |
73 | public: |
74 | |
75 | |
76 | //! Constructs a surface offset from the basis surface |
77 | //! S, where Offset is the distance between the offset |
78 | //! surface and the basis surface at any point. |
79 | //! A point on the offset surface is built by measuring |
80 | //! the offset value along a normal vector at a point on |
81 | //! S. This normal vector is given by the cross product |
82 | //! D1u^D1v, where D1u and D1v are the vectors |
83 | //! tangential to the basis surface in the u and v |
84 | //! parametric directions at this point. The side of S on |
85 | //! which the offset value is measured is indicated by |
86 | //! this normal vector if Offset is positive, or is the |
87 | //! inverse sense if Offset is negative. |
88 | //! If isNotCheckC0 = TRUE checking if basis surface has C0-continuity |
89 | //! is not made. |
90 | //! Warnings : |
91 | //! - The offset surface is built with a copy of the |
92 | //! surface S. Therefore, when S is modified the |
93 | //! offset surface is not modified. |
94 | //! - No check is made at the time of construction to |
95 | //! detect points on S with multiple possible normal directions. |
96 | //! Raised if S is not at least C1. |
97 | //! Warnings : |
98 | //! No check is done to verify that a unique normal direction is |
99 | //! defined at any point of the basis surface S. |
100 | Standard_EXPORT Geom_OffsetSurface(const Handle(Geom_Surface)& S, const Standard_Real Offset, const Standard_Boolean isNotCheckC0 = Standard_False); |
101 | |
102 | //! Raised if S is not at least C1. |
103 | //! Warnings : |
104 | //! No check is done to verify that a unique normal direction is |
105 | //! defined at any point of the basis surface S. |
106 | //! If isNotCheckC0 = TRUE checking if basis surface has C0-continuity |
107 | //! is not made. |
108 | //! Exceptions |
109 | //! Standard_ConstructionError if the surface S is not |
110 | //! at least "C1" continuous. |
111 | Standard_EXPORT void SetBasisSurface (const Handle(Geom_Surface)& S, const Standard_Boolean isNotCheckC0 = Standard_False); |
112 | |
113 | //! Changes this offset surface by assigning D as the offset value. |
114 | Standard_EXPORT void SetOffsetValue (const Standard_Real D); |
115 | |
116 | //! Returns the offset value of this offset surface. |
9f4cd8eb |
117 | inline Standard_Real Offset() const |
118 | { return offsetValue; } |
42cf5bc1 |
119 | |
120 | //! Returns the basis surface of this offset surface. |
121 | //! Note: The basis surface can be an offset surface. |
9f4cd8eb |
122 | inline const Handle(Geom_Surface) & BasisSurface() const |
123 | { return basisSurf; } |
6b84c3f7 |
124 | |
125 | //! Returns osculating surface if base surface is B-spline or Bezier |
126 | inline const Handle(Geom_OsculatingSurface)& OsculatingSurface() const |
127 | { return myOscSurf; } |
42cf5bc1 |
128 | |
129 | //! Changes the orientation of this offset surface in the u |
130 | //! parametric direction. The bounds of the surface |
131 | //! are not changed but the given parametric direction is reversed. |
79104795 |
132 | Standard_EXPORT void UReverse() Standard_OVERRIDE; |
42cf5bc1 |
133 | |
134 | //! Computes the u parameter on the modified |
135 | //! surface, produced by reversing the u |
136 | //! parametric direction of this offset surface, for any |
137 | //! point of u parameter U on this offset surface. |
79104795 |
138 | Standard_EXPORT Standard_Real UReversedParameter (const Standard_Real U) const Standard_OVERRIDE; |
42cf5bc1 |
139 | |
140 | //! Changes the orientation of this offset surface in the v parametric direction. The bounds of the surface |
141 | //! are not changed but the given parametric direction is reversed. |
79104795 |
142 | Standard_EXPORT void VReverse() Standard_OVERRIDE; |
42cf5bc1 |
143 | |
144 | //! Computes the v parameter on the modified |
145 | //! surface, produced by reversing the or v |
146 | //! parametric direction of this offset surface, for any |
147 | //! point of v parameter V on this offset surface. |
79104795 |
148 | Standard_EXPORT Standard_Real VReversedParameter (const Standard_Real V) const Standard_OVERRIDE; |
42cf5bc1 |
149 | |
150 | //! Returns the parametric bounds U1, U2, V1 and V2 of |
151 | //! this offset surface. |
152 | //! If the surface is infinite, this function can return: |
153 | //! - Standard_Real::RealFirst(), or |
154 | //! - Standard_Real::RealLast(). |
79104795 |
155 | Standard_EXPORT void Bounds (Standard_Real& U1, Standard_Real& U2, Standard_Real& V1, Standard_Real& V2) const Standard_OVERRIDE; |
42cf5bc1 |
156 | |
157 | |
158 | //! This method returns the continuity of the basis surface - 1. |
159 | //! Continuity of the Offset surface : |
160 | //! C0 : only geometric continuity, |
161 | //! C1 : continuity of the first derivative all along the Surface, |
162 | //! C2 : continuity of the second derivative all along the Surface, |
163 | //! C3 : continuity of the third derivative all along the Surface, |
164 | //! CN : the order of continuity is infinite. |
165 | //! Example : |
166 | //! If the basis surface is C2 in the V direction and C3 in the U |
167 | //! direction Shape = C1. |
168 | //! Warnings : |
169 | //! If the basis surface has a unique normal direction defined at |
170 | //! any point this method gives the continuity of the offset |
171 | //! surface otherwise the effective continuity can be lower than |
172 | //! the continuity of the basis surface - 1. |
79104795 |
173 | Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE; |
42cf5bc1 |
174 | |
175 | |
176 | //! This method answer True if the continuity of the basis surface |
177 | //! is N + 1 in the U parametric direction. We suppose in this |
178 | //! class that a unique normal is defined at any point on the basis |
179 | //! surface. |
180 | //! Raised if N <0. |
79104795 |
181 | Standard_EXPORT Standard_Boolean IsCNu (const Standard_Integer N) const Standard_OVERRIDE; |
42cf5bc1 |
182 | |
183 | |
184 | //! This method answer True if the continuity of the basis surface |
185 | //! is N + 1 in the V parametric direction. We suppose in this |
186 | //! class that a unique normal is defined at any point on the basis |
187 | //! surface. |
188 | //! Raised if N <0. |
79104795 |
189 | Standard_EXPORT Standard_Boolean IsCNv (const Standard_Integer N) const Standard_OVERRIDE; |
42cf5bc1 |
190 | |
191 | //! Checks whether this offset surface is closed in the u |
192 | //! parametric direction. |
193 | //! Returns true if, taking uFirst and uLast as |
194 | //! the parametric bounds in the u parametric direction, |
195 | //! the distance between the points P(uFirst,v) |
196 | //! and P(uLast,v) is less than or equal to |
197 | //! gp::Resolution() for each value of the parameter v. |
79104795 |
198 | Standard_EXPORT Standard_Boolean IsUClosed() const Standard_OVERRIDE; |
42cf5bc1 |
199 | |
200 | //! Checks whether this offset surface is closed in the u |
201 | //! or v parametric direction. Returns true if taking vFirst and vLast as the |
202 | //! parametric bounds in the v parametric direction, the |
203 | //! distance between the points P(u,vFirst) and |
204 | //! P(u,vLast) is less than or equal to |
205 | //! gp::Resolution() for each value of the parameter u. |
79104795 |
206 | Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE; |
42cf5bc1 |
207 | |
208 | |
209 | //! Returns true if this offset surface is periodic in the u |
210 | //! parametric direction, i.e. if the basis |
211 | //! surface of this offset surface is periodic in this direction. |
79104795 |
212 | Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE; |
42cf5bc1 |
213 | |
214 | //! Returns the period of this offset surface in the u |
215 | //! parametric direction respectively, i.e. the period of the |
216 | //! basis surface of this offset surface in this parametric direction. |
217 | //! raises if the surface is not uperiodic. |
218 | Standard_EXPORT virtual Standard_Real UPeriod() const Standard_OVERRIDE; |
219 | |
220 | |
221 | //! Returns true if this offset surface is periodic in the v |
222 | //! parametric direction, i.e. if the basis |
223 | //! surface of this offset surface is periodic in this direction. |
79104795 |
224 | Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; |
42cf5bc1 |
225 | |
226 | //! Returns the period of this offset surface in the v |
227 | //! parametric direction respectively, i.e. the period of the |
228 | //! basis surface of this offset surface in this parametric direction. |
229 | //! raises if the surface is not vperiodic. |
230 | Standard_EXPORT virtual Standard_Real VPeriod() const Standard_OVERRIDE; |
231 | |
232 | //! Computes the U isoparametric curve. |
79104795 |
233 | Standard_EXPORT Handle(Geom_Curve) UIso (const Standard_Real U) const Standard_OVERRIDE; |
42cf5bc1 |
234 | |
235 | //! Computes the V isoparametric curve. |
236 | //! |
237 | //! Te followings methods compute value and derivatives. |
238 | //! |
239 | //! Warnings |
240 | //! An exception is raised if a unique normal vector is |
241 | //! not defined on the basis surface for the parametric |
242 | //! value (U,V). |
243 | //! No check is done at the creation time and we suppose |
244 | //! in this package that the offset surface can be defined |
245 | //! at any point. |
79104795 |
246 | Standard_EXPORT Handle(Geom_Curve) VIso (const Standard_Real V) const Standard_OVERRIDE; |
42cf5bc1 |
247 | |
248 | |
249 | //! P (U, V) = Pbasis + Offset * Ndir where |
250 | //! Ndir = D1Ubasis ^ D1Vbasis / ||D1Ubasis ^ D1Vbasis|| is the |
251 | //! normal direction of the basis surface. Pbasis, D1Ubasis, |
252 | //! D1Vbasis are the point and the first derivatives on the basis |
253 | //! surface. |
254 | //! If Ndir is undefined this method computes an approched normal |
255 | //! direction using the following limited development : |
256 | //! Ndir = N0 + DNdir/DU + DNdir/DV + Eps with Eps->0 which |
257 | //! requires to compute the second derivatives on the basis surface. |
258 | //! If the normal direction cannot be approximate for this order |
259 | //! of derivation the exception UndefinedValue is raised. |
260 | //! |
261 | //! Raised if the continuity of the basis surface is not C1. |
262 | //! Raised if the order of derivation required to compute the |
263 | //! normal direction is greater than the second order. |
79104795 |
264 | Standard_EXPORT void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const Standard_OVERRIDE; |
42cf5bc1 |
265 | |
266 | |
267 | //! Raised if the continuity of the basis surface is not C2. |
79104795 |
268 | Standard_EXPORT void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const Standard_OVERRIDE; |
42cf5bc1 |
269 | |
270 | //! ---Purpose ; |
271 | //! Raised if the continuity of the basis surface is not C3. |
79104795 |
272 | Standard_EXPORT void D2 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const Standard_OVERRIDE; |
42cf5bc1 |
273 | |
274 | |
275 | //! Raised if the continuity of the basis surface is not C4. |
79104795 |
276 | Standard_EXPORT void D3 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const Standard_OVERRIDE; |
42cf5bc1 |
277 | |
278 | |
279 | //! Computes the derivative of order Nu in the direction u and Nv |
280 | //! in the direction v. |
281 | //! ---Purpose ; |
282 | //! Raised if the continuity of the basis surface is not CNu + 1 |
283 | //! in the U direction and CNv + 1 in the V direction. |
284 | //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0. |
285 | //! |
286 | //! The following methods compute the value and derivatives |
287 | //! on the offset surface and returns the derivatives on the |
288 | //! basis surface too. |
289 | //! The computation of the value and derivatives on the basis |
290 | //! surface are used to evaluate the offset surface. |
291 | //! |
292 | //! Warnings : |
293 | //! The exception UndefinedValue or UndefinedDerivative is |
294 | //! raised if it is not possible to compute a unique offset |
295 | //! direction. |
79104795 |
296 | Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv) const Standard_OVERRIDE; |
42cf5bc1 |
297 | |
298 | //! Applies the transformation T to this offset surface. |
299 | //! Note: the basis surface is also modified. |
79104795 |
300 | Standard_EXPORT void Transform (const gp_Trsf& T) Standard_OVERRIDE; |
42cf5bc1 |
301 | |
302 | //! Computes the parameters on the transformed surface for |
303 | //! the transform of the point of parameters U,V on <me>. |
304 | //! |
305 | //! me->Transformed(T)->Value(U',V') |
306 | //! |
307 | //! is the same point as |
308 | //! |
309 | //! me->Value(U,V).Transformed(T) |
310 | //! |
311 | //! Where U',V' are the new values of U,V after calling |
312 | //! |
313 | //! me->TranformParameters(U,V,T) |
314 | //! This methods calls the basis surface method. |
315 | Standard_EXPORT virtual void TransformParameters (Standard_Real& U, Standard_Real& V, const gp_Trsf& T) const Standard_OVERRIDE; |
316 | |
317 | //! Returns a 2d transformation used to find the new |
318 | //! parameters of a point on the transformed surface. |
319 | //! |
320 | //! me->Transformed(T)->Value(U',V') |
321 | //! |
322 | //! is the same point as |
323 | //! |
324 | //! me->Value(U,V).Transformed(T) |
325 | //! |
326 | //! Where U',V' are obtained by transforming U,V with |
327 | //! th 2d transformation returned by |
328 | //! |
329 | //! me->ParametricTransformation(T) |
330 | //! |
331 | //! This methods calls the basis surface method. |
332 | Standard_EXPORT virtual gp_GTrsf2d ParametricTransformation (const gp_Trsf& T) const Standard_OVERRIDE; |
333 | |
334 | //! Creates a new object which is a copy of this offset surface. |
79104795 |
335 | Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE; |
42cf5bc1 |
336 | |
337 | //! returns an equivalent surface of the offset surface |
338 | //! when the basis surface is a canonic surface or a |
339 | //! rectangular limited surface on canonic surface or if |
340 | //! the offset is null. |
341 | Standard_EXPORT Handle(Geom_Surface) Surface() const; |
342 | |
343 | //! if Standard_True, L is the local osculating surface |
344 | //! along U at the point U,V. It means that DL/DU is |
345 | //! collinear to DS/DU . If IsOpposite == Standard_True |
346 | //! these vectors have opposite direction. |
347 | Standard_EXPORT Standard_Boolean UOsculatingSurface (const Standard_Real U, const Standard_Real V, Standard_Boolean& IsOpposite, Handle(Geom_BSplineSurface)& UOsculSurf) const; |
348 | |
349 | //! if Standard_True, L is the local osculating surface |
350 | //! along V at the point U,V. |
351 | //! It means that DL/DV is |
352 | //! collinear to DS/DV . If IsOpposite == Standard_True |
353 | //! these vectors have opposite direction. |
354 | Standard_EXPORT Standard_Boolean VOsculatingSurface (const Standard_Real U, const Standard_Real V, Standard_Boolean& IsOpposite, Handle(Geom_BSplineSurface)& VOsculSurf) const; |
355 | |
356 | //! Returns continuity of the basis surface. |
9f4cd8eb |
357 | inline GeomAbs_Shape GetBasisSurfContinuity() const |
358 | { return myBasisSurfContinuity; } |
42cf5bc1 |
359 | |
bc73b006 |
360 | //! Dumps the content of me into the stream |
361 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; |
362 | |
92efcf78 |
363 | DEFINE_STANDARD_RTTIEXT(Geom_OffsetSurface,Geom_Surface) |
42cf5bc1 |
364 | |
42cf5bc1 |
365 | private: |
366 | |
42cf5bc1 |
367 | Handle(Geom_Surface) basisSurf; |
368 | Handle(Geom_Surface) equivSurf; |
369 | Standard_Real offsetValue; |
6b84c3f7 |
370 | Handle(Geom_OsculatingSurface) myOscSurf; |
42cf5bc1 |
371 | GeomAbs_Shape myBasisSurfContinuity; |
6b84c3f7 |
372 | Handle(GeomEvaluator_OffsetSurface) myEvaluator; |
42cf5bc1 |
373 | }; |
374 | |
42cf5bc1 |
375 | #endif // _Geom_OffsetSurface_HeaderFile |