1 // Created on: 1993-03-10
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Geom_OffsetSurface_HeaderFile
18 #define _Geom_OffsetSurface_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
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>
30 class Standard_ConstructionError;
31 class Standard_RangeError;
32 class Standard_NoSuchObject;
33 class Geom_UndefinedDerivative;
34 class Geom_UndefinedValue;
38 class Geom_BSplineSurface;
44 class Geom_OffsetSurface;
45 DEFINE_STANDARD_HANDLE(Geom_OffsetSurface, Geom_Surface)
47 //! Describes an offset surface in 3D space.
48 //! An offset surface is defined by:
49 //! - the basis surface to which it is parallel, and
50 //! - the distance between the offset surface and its basis surface.
51 //! A point on the offset surface is built by measuring the
52 //! offset value along the normal vector at a point on the
53 //! basis surface. This normal vector is given by the cross
54 //! product D1u^D1v, where D1u and D1v are the
55 //! vectors tangential to the basis surface in the u and v
56 //! parametric directions at this point. The side of the
57 //! basis surface on which the offset is measured
58 //! depends on the sign of the offset value.
59 //! A Geom_OffsetSurface surface can be
60 //! self-intersecting, even if the basis surface does not
61 //! self-intersect. The self-intersecting portions are not
62 //! deleted at the time of construction.
64 //! There must be only one normal vector defined at any
65 //! point on the basis surface. This must be verified by the
66 //! user as no check is made at the time of construction
67 //! to detect points with multiple possible normal
68 //! directions (for example, the top of a conical surface).
69 class Geom_OffsetSurface : public Geom_Surface
75 //! Constructs a surface offset from the basis surface
76 //! S, where Offset is the distance between the offset
77 //! surface and the basis surface at any point.
78 //! A point on the offset surface is built by measuring
79 //! the offset value along a normal vector at a point on
80 //! S. This normal vector is given by the cross product
81 //! D1u^D1v, where D1u and D1v are the vectors
82 //! tangential to the basis surface in the u and v
83 //! parametric directions at this point. The side of S on
84 //! which the offset value is measured is indicated by
85 //! this normal vector if Offset is positive, or is the
86 //! inverse sense if Offset is negative.
87 //! If isNotCheckC0 = TRUE checking if basis surface has C0-continuity
90 //! - The offset surface is built with a copy of the
91 //! surface S. Therefore, when S is modified the
92 //! offset surface is not modified.
93 //! - No check is made at the time of construction to
94 //! detect points on S with multiple possible normal directions.
95 //! Raised if S is not at least C1.
97 //! No check is done to verify that a unique normal direction is
98 //! defined at any point of the basis surface S.
99 Standard_EXPORT Geom_OffsetSurface(const Handle(Geom_Surface)& S, const Standard_Real Offset, const Standard_Boolean isNotCheckC0 = Standard_False);
101 //! Raised if S is not at least C1.
103 //! No check is done to verify that a unique normal direction is
104 //! defined at any point of the basis surface S.
105 //! If isNotCheckC0 = TRUE checking if basis surface has C0-continuity
108 //! Standard_ConstructionError if the surface S is not
109 //! at least "C1" continuous.
110 Standard_EXPORT void SetBasisSurface (const Handle(Geom_Surface)& S, const Standard_Boolean isNotCheckC0 = Standard_False);
112 //! Changes this offset surface by assigning D as the offset value.
113 Standard_EXPORT void SetOffsetValue (const Standard_Real D);
115 //! Returns the offset value of this offset surface.
116 Standard_EXPORT Standard_Real Offset() const;
118 //! Returns the basis surface of this offset surface.
119 //! Note: The basis surface can be an offset surface.
120 Standard_EXPORT Handle(Geom_Surface) BasisSurface() const;
122 //! Changes the orientation of this offset surface in the u
123 //! parametric direction. The bounds of the surface
124 //! are not changed but the given parametric direction is reversed.
125 Standard_EXPORT void UReverse();
127 //! Computes the u parameter on the modified
128 //! surface, produced by reversing the u
129 //! parametric direction of this offset surface, for any
130 //! point of u parameter U on this offset surface.
131 Standard_EXPORT Standard_Real UReversedParameter (const Standard_Real U) const;
133 //! Changes the orientation of this offset surface in the v parametric direction. The bounds of the surface
134 //! are not changed but the given parametric direction is reversed.
135 Standard_EXPORT void VReverse();
137 //! Computes the v parameter on the modified
138 //! surface, produced by reversing the or v
139 //! parametric direction of this offset surface, for any
140 //! point of v parameter V on this offset surface.
141 Standard_EXPORT Standard_Real VReversedParameter (const Standard_Real V) const;
143 //! Returns the parametric bounds U1, U2, V1 and V2 of
144 //! this offset surface.
145 //! If the surface is infinite, this function can return:
146 //! - Standard_Real::RealFirst(), or
147 //! - Standard_Real::RealLast().
148 Standard_EXPORT void Bounds (Standard_Real& U1, Standard_Real& U2, Standard_Real& V1, Standard_Real& V2) const;
151 //! This method returns the continuity of the basis surface - 1.
152 //! Continuity of the Offset surface :
153 //! C0 : only geometric continuity,
154 //! C1 : continuity of the first derivative all along the Surface,
155 //! C2 : continuity of the second derivative all along the Surface,
156 //! C3 : continuity of the third derivative all along the Surface,
157 //! CN : the order of continuity is infinite.
159 //! If the basis surface is C2 in the V direction and C3 in the U
160 //! direction Shape = C1.
162 //! If the basis surface has a unique normal direction defined at
163 //! any point this method gives the continuity of the offset
164 //! surface otherwise the effective continuity can be lower than
165 //! the continuity of the basis surface - 1.
166 Standard_EXPORT GeomAbs_Shape Continuity() const;
169 //! This method answer True if the continuity of the basis surface
170 //! is N + 1 in the U parametric direction. We suppose in this
171 //! class that a unique normal is defined at any point on the basis
174 Standard_EXPORT Standard_Boolean IsCNu (const Standard_Integer N) const;
177 //! This method answer True if the continuity of the basis surface
178 //! is N + 1 in the V parametric direction. We suppose in this
179 //! class that a unique normal is defined at any point on the basis
182 Standard_EXPORT Standard_Boolean IsCNv (const Standard_Integer N) const;
184 //! Checks whether this offset surface is closed in the u
185 //! parametric direction.
186 //! Returns true if, taking uFirst and uLast as
187 //! the parametric bounds in the u parametric direction,
188 //! the distance between the points P(uFirst,v)
189 //! and P(uLast,v) is less than or equal to
190 //! gp::Resolution() for each value of the parameter v.
191 Standard_EXPORT Standard_Boolean IsUClosed() const;
193 //! Checks whether this offset surface is closed in the u
194 //! or v parametric direction. Returns true if taking vFirst and vLast as the
195 //! parametric bounds in the v parametric direction, the
196 //! distance between the points P(u,vFirst) and
197 //! P(u,vLast) is less than or equal to
198 //! gp::Resolution() for each value of the parameter u.
199 Standard_EXPORT Standard_Boolean IsVClosed() const;
202 //! Returns true if this offset surface is periodic in the u
203 //! parametric direction, i.e. if the basis
204 //! surface of this offset surface is periodic in this direction.
205 Standard_EXPORT Standard_Boolean IsUPeriodic() const;
207 //! Returns the period of this offset surface in the u
208 //! parametric direction respectively, i.e. the period of the
209 //! basis surface of this offset surface in this parametric direction.
210 //! raises if the surface is not uperiodic.
211 Standard_EXPORT virtual Standard_Real UPeriod() const Standard_OVERRIDE;
214 //! Returns true if this offset surface is periodic in the v
215 //! parametric direction, i.e. if the basis
216 //! surface of this offset surface is periodic in this direction.
217 Standard_EXPORT Standard_Boolean IsVPeriodic() const;
219 //! Returns the period of this offset surface in the v
220 //! parametric direction respectively, i.e. the period of the
221 //! basis surface of this offset surface in this parametric direction.
222 //! raises if the surface is not vperiodic.
223 Standard_EXPORT virtual Standard_Real VPeriod() const Standard_OVERRIDE;
225 //! Computes the U isoparametric curve.
226 Standard_EXPORT Handle(Geom_Curve) UIso (const Standard_Real U) const;
228 //! Computes the V isoparametric curve.
230 //! Te followings methods compute value and derivatives.
233 //! An exception is raised if a unique normal vector is
234 //! not defined on the basis surface for the parametric
236 //! No check is done at the creation time and we suppose
237 //! in this package that the offset surface can be defined
239 Standard_EXPORT Handle(Geom_Curve) VIso (const Standard_Real V) const;
242 //! P (U, V) = Pbasis + Offset * Ndir where
243 //! Ndir = D1Ubasis ^ D1Vbasis / ||D1Ubasis ^ D1Vbasis|| is the
244 //! normal direction of the basis surface. Pbasis, D1Ubasis,
245 //! D1Vbasis are the point and the first derivatives on the basis
247 //! If Ndir is undefined this method computes an approched normal
248 //! direction using the following limited development :
249 //! Ndir = N0 + DNdir/DU + DNdir/DV + Eps with Eps->0 which
250 //! requires to compute the second derivatives on the basis surface.
251 //! If the normal direction cannot be approximate for this order
252 //! of derivation the exception UndefinedValue is raised.
254 //! Raised if the continuity of the basis surface is not C1.
255 //! Raised if the order of derivation required to compute the
256 //! normal direction is greater than the second order.
257 Standard_EXPORT void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const;
260 //! Raised if the continuity of the basis surface is not C2.
261 Standard_EXPORT void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const;
264 //! Raised if the continuity of the basis surface is not C3.
265 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;
268 //! Raised if the continuity of the basis surface is not C4.
269 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;
272 //! Computes the derivative of order Nu in the direction u and Nv
273 //! in the direction v.
275 //! Raised if the continuity of the basis surface is not CNu + 1
276 //! in the U direction and CNv + 1 in the V direction.
277 //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
279 //! The following methods compute the value and derivatives
280 //! on the offset surface and returns the derivatives on the
281 //! basis surface too.
282 //! The computation of the value and derivatives on the basis
283 //! surface are used to evaluate the offset surface.
286 //! The exception UndefinedValue or UndefinedDerivative is
287 //! raised if it is not possible to compute a unique offset
289 Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv) const;
292 //! P (U, V) = Pbasis + Offset * Ndir where
293 //! Ndir = D1Ubasis ^ D1Vbasis / ||D1Ubasis ^ D1Vbasis|| is
294 //! the normal direction of the surface.
295 //! If Ndir is undefined this method computes an approched normal
296 //! direction using the following limited development :
297 //! Ndir = N0 + DNdir/DU + DNdir/DV + Eps with Eps->0 which
298 //! requires to compute the second derivatives on the basis surface.
299 //! If the normal direction cannot be approximate for this order
300 //! of derivation the exception UndefinedValue is raised.
302 //! Raised if the continuity of the basis surface is not C1.
303 //! Raised if the order of derivation required to compute the normal
304 //! direction is greater than the second order.
305 Standard_EXPORT void Value (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Pnt& Pbasis, gp_Vec& D1Ubasis, gp_Vec& D1Vbasis) const;
308 //! Raised if the continuity of the basis surface is not C2.
309 Standard_EXPORT void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Pnt& Pbasis, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D1Ubasis, gp_Vec& D1Vbasis, gp_Vec& D2Ubasis, gp_Vec& D2Vbasis, gp_Vec& D2UVbasis) const;
312 //! Raised if the continuity of the basis surface is not C3.
313 //! The following private methods
314 //! includes common part of local and global methods
315 //! of derivative evaluations.
316 Standard_EXPORT void D2 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Pnt& Pbasis, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D1Ubasis, gp_Vec& D1Vbasis, gp_Vec& D2Ubasis, gp_Vec& D2Vbasis, gp_Vec& D2UVbasis, gp_Vec& D3Ubasis, gp_Vec& D3Vbasis, gp_Vec& D3UUVbasis, gp_Vec& D3UVVbasis) const;
318 Standard_EXPORT void LocalD0 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer VSide, gp_Pnt& P) const;
320 Standard_EXPORT void LocalD1 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer VSide, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const;
322 Standard_EXPORT void LocalD2 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer VSide, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const;
324 Standard_EXPORT void LocalD3 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer VSide, 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;
326 Standard_EXPORT gp_Vec LocalDN (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer VSide, const Standard_Integer Nu, const Standard_Integer Nv) const;
329 //! Applies the transformation T to this offset surface.
330 //! Note: the basis surface is also modified.
331 Standard_EXPORT void Transform (const gp_Trsf& T);
333 //! Computes the parameters on the transformed surface for
334 //! the transform of the point of parameters U,V on <me>.
336 //! me->Transformed(T)->Value(U',V')
338 //! is the same point as
340 //! me->Value(U,V).Transformed(T)
342 //! Where U',V' are the new values of U,V after calling
344 //! me->TranformParameters(U,V,T)
345 //! This methods calls the basis surface method.
346 Standard_EXPORT virtual void TransformParameters (Standard_Real& U, Standard_Real& V, const gp_Trsf& T) const Standard_OVERRIDE;
348 //! Returns a 2d transformation used to find the new
349 //! parameters of a point on the transformed surface.
351 //! me->Transformed(T)->Value(U',V')
353 //! is the same point as
355 //! me->Value(U,V).Transformed(T)
357 //! Where U',V' are obtained by transforming U,V with
358 //! th 2d transformation returned by
360 //! me->ParametricTransformation(T)
362 //! This methods calls the basis surface method.
363 Standard_EXPORT virtual gp_GTrsf2d ParametricTransformation (const gp_Trsf& T) const Standard_OVERRIDE;
365 //! Creates a new object which is a copy of this offset surface.
366 Standard_EXPORT Handle(Geom_Geometry) Copy() const;
368 //! returns an equivalent surface of the offset surface
369 //! when the basis surface is a canonic surface or a
370 //! rectangular limited surface on canonic surface or if
371 //! the offset is null.
372 Standard_EXPORT Handle(Geom_Surface) Surface() const;
374 //! if Standard_True, L is the local osculating surface
375 //! along U at the point U,V. It means that DL/DU is
376 //! collinear to DS/DU . If IsOpposite == Standard_True
377 //! these vectors have opposite direction.
378 Standard_EXPORT Standard_Boolean UOsculatingSurface (const Standard_Real U, const Standard_Real V, Standard_Boolean& IsOpposite, Handle(Geom_BSplineSurface)& UOsculSurf) const;
380 //! if Standard_True, L is the local osculating surface
381 //! along V at the point U,V.
382 //! It means that DL/DV is
383 //! collinear to DS/DV . If IsOpposite == Standard_True
384 //! these vectors have opposite direction.
385 Standard_EXPORT Standard_Boolean VOsculatingSurface (const Standard_Real U, const Standard_Real V, Standard_Boolean& IsOpposite, Handle(Geom_BSplineSurface)& VOsculSurf) const;
387 //! Returns continuity of the basis surface.
388 Standard_EXPORT GeomAbs_Shape GetBasisSurfContinuity() const;
393 DEFINE_STANDARD_RTTI(Geom_OffsetSurface,Geom_Surface)
403 Standard_EXPORT void SetD0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, const gp_Vec& D1U, const gp_Vec& D1V) const;
405 Standard_EXPORT void SetD1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, const gp_Vec& d2u, const gp_Vec& d2v, const gp_Vec& d2uv) const;
407 Standard_EXPORT void SetD2 (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 gp_Vec& d3u, const gp_Vec& d3v, const gp_Vec& d3uuv, const gp_Vec& d3uvv) const;
409 Standard_EXPORT void SetD3 (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;
411 //! The following functions evaluates the local
412 //! derivatives on surface. Useful to manage discontinuities
414 //! if Side = 1 -> P = S( U+,V )
415 //! if Side = -1 -> P = S( U-,V )
416 //! else P is betveen discontinuities
417 //! can be evaluated using methods of
418 //! global evaluations P = S( U ,V )
419 Standard_EXPORT gp_Vec SetDN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv, const gp_Vec& D1U, const gp_Vec& D1V) const;
421 //! This method locates U,V parameters on basis BSpline surface
422 //! and calls LocalDi or Di methods corresponding an order
423 //! of derivative and position
424 //! of UV-point relatively the surface discontinuities.
425 Standard_EXPORT void LocateSides (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer VSide, const Handle(Geom_BSplineSurface)& BSplS, const Standard_Integer NDir, 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;
427 Handle(Geom_Surface) basisSurf;
428 Handle(Geom_Surface) equivSurf;
429 Standard_Real offsetValue;
430 Geom_OsculatingSurface myOscSurf;
431 GeomAbs_Shape myBasisSurfContinuity;
442 #endif // _Geom_OffsetSurface_HeaderFile