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>
29 #include <GeomEvaluator_OffsetSurface.hxx>
31 class Standard_ConstructionError;
32 class Standard_RangeError;
33 class Standard_NoSuchObject;
34 class Geom_UndefinedDerivative;
35 class Geom_UndefinedValue;
39 class Geom_BSplineSurface;
45 class Geom_OffsetSurface;
46 DEFINE_STANDARD_HANDLE(Geom_OffsetSurface, Geom_Surface)
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.
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
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
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.
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);
102 //! Raised if S is not at least C1.
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
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);
113 //! Changes this offset surface by assigning D as the offset value.
114 Standard_EXPORT void SetOffsetValue (const Standard_Real D);
116 //! Returns the offset value of this offset surface.
117 inline Standard_Real Offset() const
118 { return offsetValue; }
120 //! Returns the basis surface of this offset surface.
121 //! Note: The basis surface can be an offset surface.
122 inline const Handle(Geom_Surface) & BasisSurface() const
123 { return basisSurf; }
125 //! Returns osculating surface if base surface is B-spline or Bezier
126 inline const Handle(Geom_OsculatingSurface)& OsculatingSurface() const
127 { return myOscSurf; }
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.
132 Standard_EXPORT void UReverse() Standard_OVERRIDE;
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.
138 Standard_EXPORT Standard_Real UReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
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.
142 Standard_EXPORT void VReverse() Standard_OVERRIDE;
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.
148 Standard_EXPORT Standard_Real VReversedParameter (const Standard_Real V) const Standard_OVERRIDE;
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().
155 Standard_EXPORT void Bounds (Standard_Real& U1, Standard_Real& U2, Standard_Real& V1, Standard_Real& V2) const Standard_OVERRIDE;
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.
166 //! If the basis surface is C2 in the V direction and C3 in the U
167 //! direction Shape = C1.
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.
173 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
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
181 Standard_EXPORT Standard_Boolean IsCNu (const Standard_Integer N) const Standard_OVERRIDE;
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
189 Standard_EXPORT Standard_Boolean IsCNv (const Standard_Integer N) const Standard_OVERRIDE;
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.
198 Standard_EXPORT Standard_Boolean IsUClosed() const Standard_OVERRIDE;
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.
206 Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE;
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.
212 Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE;
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;
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.
224 Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE;
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;
232 //! Computes the U isoparametric curve.
233 Standard_EXPORT Handle(Geom_Curve) UIso (const Standard_Real U) const Standard_OVERRIDE;
235 //! Computes the V isoparametric curve.
237 //! Te followings methods compute value and derivatives.
240 //! An exception is raised if a unique normal vector is
241 //! not defined on the basis surface for the parametric
243 //! No check is done at the creation time and we suppose
244 //! in this package that the offset surface can be defined
246 Standard_EXPORT Handle(Geom_Curve) VIso (const Standard_Real V) const Standard_OVERRIDE;
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
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.
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.
264 Standard_EXPORT void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const Standard_OVERRIDE;
267 //! Raised if the continuity of the basis surface is not C2.
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;
271 //! Raised if the continuity of the basis surface is not C3.
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;
275 //! Raised if the continuity of the basis surface is not C4.
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;
279 //! Computes the derivative of order Nu in the direction u and Nv
280 //! in the direction v.
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.
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.
293 //! The exception UndefinedValue or UndefinedDerivative is
294 //! raised if it is not possible to compute a unique offset
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;
298 //! Applies the transformation T to this offset surface.
299 //! Note: the basis surface is also modified.
300 Standard_EXPORT void Transform (const gp_Trsf& T) Standard_OVERRIDE;
302 //! Computes the parameters on the transformed surface for
303 //! the transform of the point of parameters U,V on <me>.
305 //! me->Transformed(T)->Value(U',V')
307 //! is the same point as
309 //! me->Value(U,V).Transformed(T)
311 //! Where U',V' are the new values of U,V after calling
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;
317 //! Returns a 2d transformation used to find the new
318 //! parameters of a point on the transformed surface.
320 //! me->Transformed(T)->Value(U',V')
322 //! is the same point as
324 //! me->Value(U,V).Transformed(T)
326 //! Where U',V' are obtained by transforming U,V with
327 //! th 2d transformation returned by
329 //! me->ParametricTransformation(T)
331 //! This methods calls the basis surface method.
332 Standard_EXPORT virtual gp_GTrsf2d ParametricTransformation (const gp_Trsf& T) const Standard_OVERRIDE;
334 //! Creates a new object which is a copy of this offset surface.
335 Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
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;
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;
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;
356 //! Returns continuity of the basis surface.
357 inline GeomAbs_Shape GetBasisSurfContinuity() const
358 { return myBasisSurfContinuity; }
360 DEFINE_STANDARD_RTTIEXT(Geom_OffsetSurface,Geom_Surface)
364 Handle(Geom_Surface) basisSurf;
365 Handle(Geom_Surface) equivSurf;
366 Standard_Real offsetValue;
367 Handle(Geom_OsculatingSurface) myOscSurf;
368 GeomAbs_Shape myBasisSurfContinuity;
369 Handle(GeomEvaluator_OffsetSurface) myEvaluator;
372 #endif // _Geom_OffsetSurface_HeaderFile