Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-30 09:13:35

0001 // Created on: 1993-03-10
0002 // Created by: JCV
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Geom_OffsetSurface_HeaderFile
0018 #define _Geom_OffsetSurface_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <GeomAbs_Shape.hxx>
0024 #include <Geom_Surface.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <GeomEvaluator_OffsetSurface.hxx>
0027 class Geom_Curve;
0028 class gp_Pnt;
0029 class gp_Vec;
0030 class Geom_BSplineSurface;
0031 class gp_Trsf;
0032 class gp_GTrsf2d;
0033 class Geom_Geometry;
0034 
0035 class Geom_OffsetSurface;
0036 DEFINE_STANDARD_HANDLE(Geom_OffsetSurface, Geom_Surface)
0037 
0038 //! Describes an offset surface in 3D space.
0039 //! An offset surface is defined by:
0040 //! - the basis surface to which it is parallel, and
0041 //! - the distance between the offset surface and its basis surface.
0042 //! A point on the offset surface is built by measuring the
0043 //! offset value along the normal vector at a point on the
0044 //! basis surface. This normal vector is given by the cross
0045 //! product D1u^D1v, where D1u and D1v are the
0046 //! vectors tangential to the basis surface in the u and v
0047 //! parametric directions at this point. The side of the
0048 //! basis surface on which the offset is measured
0049 //! depends on the sign of the offset value.
0050 //! A Geom_OffsetSurface surface can be
0051 //! self-intersecting, even if the basis surface does not
0052 //! self-intersect. The self-intersecting portions are not
0053 //! deleted at the time of construction.
0054 //! Warning
0055 //! There must be only one normal vector defined at any
0056 //! point on the basis surface. This must be verified by the
0057 //! user as no check is made at the time of construction
0058 //! to detect points with multiple possible normal
0059 //! directions (for example, the top of a conical surface).
0060 class Geom_OffsetSurface : public Geom_Surface
0061 {
0062 
0063 public:
0064   //! Constructs a surface offset from the basis surface
0065   //! S, where Offset is the distance between the offset
0066   //! surface and the basis surface at any point.
0067   //! A point on the offset surface is built by measuring
0068   //! the offset value along a normal vector at a point on
0069   //! S. This normal vector is given by the cross product
0070   //! D1u^D1v, where D1u and D1v are the vectors
0071   //! tangential to the basis surface in the u and v
0072   //! parametric directions at this point. The side of S on
0073   //! which the offset value is measured is indicated by
0074   //! this normal vector if Offset is positive, or is the
0075   //! inverse sense if Offset is negative.
0076   //! If isNotCheckC0 = TRUE checking if basis surface has C0-continuity
0077   //! is not made.
0078   //! Warnings :
0079   //! - The offset surface is built with a copy of the
0080   //! surface S. Therefore, when S is modified the
0081   //! offset surface is not modified.
0082   //! - No check is made at the time of construction to
0083   //! detect points on S with multiple possible normal directions.
0084   //! Raised if S is not at least C1.
0085   //! Warnings :
0086   //! No check is done to verify that a unique normal direction is
0087   //! defined at any point of the basis surface S.
0088   Standard_EXPORT Geom_OffsetSurface(const Handle(Geom_Surface)& S,
0089                                      const Standard_Real         Offset,
0090                                      const Standard_Boolean      isNotCheckC0 = Standard_False);
0091 
0092   //! Raised if S is not at least C1.
0093   //! Warnings :
0094   //! No check is done to verify that a unique normal direction is
0095   //! defined at any point of the basis surface S.
0096   //! If isNotCheckC0 = TRUE checking if basis surface has C0-continuity
0097   //! is not made.
0098   //! Exceptions
0099   //! Standard_ConstructionError if the surface S is not
0100   //! at least "C1" continuous.
0101   Standard_EXPORT void SetBasisSurface(const Handle(Geom_Surface)& S,
0102                                        const Standard_Boolean      isNotCheckC0 = Standard_False);
0103 
0104   //! Changes this offset surface by assigning D as the offset value.
0105   Standard_EXPORT void SetOffsetValue(const Standard_Real D);
0106 
0107   //! Returns the offset value of this offset surface.
0108   inline Standard_Real Offset() const { return offsetValue; }
0109 
0110   //! Returns the basis surface of this offset surface.
0111   //! Note: The basis surface can be an offset surface.
0112   inline const Handle(Geom_Surface)& BasisSurface() const { return basisSurf; }
0113 
0114   //! Returns osculating surface if base surface is B-spline or Bezier
0115   inline const Handle(Geom_OsculatingSurface)& OsculatingSurface() const { return myOscSurf; }
0116 
0117   //! Changes the orientation of this offset surface in the u
0118   //! parametric direction. The bounds of the surface
0119   //! are not changed but the given parametric direction is reversed.
0120   Standard_EXPORT void UReverse() Standard_OVERRIDE;
0121 
0122   //! Computes the u  parameter on the modified
0123   //! surface, produced by reversing the u
0124   //! parametric direction of this offset surface, for any
0125   //! point of u parameter U  on this offset surface.
0126   Standard_EXPORT Standard_Real UReversedParameter(const Standard_Real U) const Standard_OVERRIDE;
0127 
0128   //! Changes the orientation of this offset surface in the v parametric direction. The bounds of
0129   //! the surface are not changed but the given parametric direction is reversed.
0130   Standard_EXPORT void VReverse() Standard_OVERRIDE;
0131 
0132   //! Computes the  v parameter on the modified
0133   //! surface, produced by reversing the or v
0134   //! parametric direction of this offset surface, for any
0135   //! point of  v parameter V on this offset surface.
0136   Standard_EXPORT Standard_Real VReversedParameter(const Standard_Real V) const Standard_OVERRIDE;
0137 
0138   //! Returns the parametric bounds U1, U2, V1 and V2 of
0139   //! this offset surface.
0140   //! If the surface is infinite, this function can return:
0141   //! - Standard_Real::RealFirst(), or
0142   //! - Standard_Real::RealLast().
0143   Standard_EXPORT void Bounds(Standard_Real& U1,
0144                               Standard_Real& U2,
0145                               Standard_Real& V1,
0146                               Standard_Real& V2) const Standard_OVERRIDE;
0147 
0148   //! This method returns the continuity of the basis surface - 1.
0149   //! Continuity of the Offset surface :
0150   //! C0 : only geometric continuity,
0151   //! C1 : continuity of the first derivative all along the Surface,
0152   //! C2 : continuity of the second derivative all along the Surface,
0153   //! C3 : continuity of the third derivative all along the Surface,
0154   //! CN : the order of continuity is infinite.
0155   //! Example :
0156   //! If the basis surface is C2 in the V direction and C3 in the U
0157   //! direction Shape = C1.
0158   //! Warnings :
0159   //! If the basis surface has a unique normal direction defined at
0160   //! any point this method gives the continuity of the offset
0161   //! surface otherwise the effective continuity can be lower than
0162   //! the continuity of the basis surface - 1.
0163   Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
0164 
0165   //! This method answer True if the continuity of the basis surface
0166   //! is N + 1 in the U parametric direction. We suppose in this
0167   //! class that a unique normal is defined at any point on the basis
0168   //! surface.
0169   //! Raised if N <0.
0170   Standard_EXPORT Standard_Boolean IsCNu(const Standard_Integer N) const Standard_OVERRIDE;
0171 
0172   //! This method answer True if the continuity of the basis surface
0173   //! is N + 1 in the V parametric direction. We suppose in this
0174   //! class that a unique normal is defined at any point on the basis
0175   //! surface.
0176   //! Raised if N <0.
0177   Standard_EXPORT Standard_Boolean IsCNv(const Standard_Integer N) const Standard_OVERRIDE;
0178 
0179   //! Checks whether this offset surface is closed in the u
0180   //! parametric direction.
0181   //! Returns true if, taking uFirst and uLast as
0182   //! the parametric bounds in the u parametric direction,
0183   //! the distance between the points P(uFirst,v)
0184   //! and P(uLast,v) is less than or equal to
0185   //! gp::Resolution() for each value of the   parameter v.
0186   Standard_EXPORT Standard_Boolean IsUClosed() const Standard_OVERRIDE;
0187 
0188   //! Checks whether this offset surface is closed in the u
0189   //! or v parametric direction. Returns true if taking vFirst and vLast as the
0190   //! parametric bounds in the v parametric direction, the
0191   //! distance between the points P(u,vFirst) and
0192   //! P(u,vLast) is less than or equal to
0193   //! gp::Resolution() for each value of the parameter u.
0194   Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE;
0195 
0196   //! Returns true if this offset surface is periodic in the u
0197   //! parametric direction, i.e. if the basis
0198   //! surface of this offset surface is periodic in this direction.
0199   Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE;
0200 
0201   //! Returns the period of this offset surface in the u
0202   //! parametric direction respectively, i.e. the period of the
0203   //! basis surface of this offset surface in this parametric direction.
0204   //! raises if the surface is not uperiodic.
0205   Standard_EXPORT virtual Standard_Real UPeriod() const Standard_OVERRIDE;
0206 
0207   //! Returns true if this offset surface is periodic in the v
0208   //! parametric direction, i.e. if the basis
0209   //! surface of this offset surface is periodic in this direction.
0210   Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE;
0211 
0212   //! Returns the period of this offset surface in the v
0213   //! parametric direction respectively, i.e. the period of the
0214   //! basis surface of this offset surface in this parametric direction.
0215   //! raises if the surface is not vperiodic.
0216   Standard_EXPORT virtual Standard_Real VPeriod() const Standard_OVERRIDE;
0217 
0218   //! Computes the U isoparametric curve.
0219   Standard_EXPORT Handle(Geom_Curve) UIso(const Standard_Real U) const Standard_OVERRIDE;
0220 
0221   //! Computes the V isoparametric curve.
0222   //!
0223   //! The following methods compute value and derivatives.
0224   //!
0225   //! Warnings
0226   //! An exception is raised if a unique normal vector is
0227   //! not defined on the basis surface for the parametric value (U,V).
0228   //! No check is done at the creation time and we suppose
0229   //! in this package that the offset surface can be defined at any point.
0230   Standard_EXPORT Handle(Geom_Curve) VIso(const Standard_Real V) const Standard_OVERRIDE;
0231 
0232   //! @code
0233   //!   P (U, V) = Pbasis + Offset * Ndir
0234   //! @endcode
0235   //! where
0236   //! @code
0237   //!   Ndir = D1Ubasis ^ D1Vbasis / ||D1Ubasis ^ D1Vbasis||
0238   //! @endcode
0239   //! is the normal direction of the basis surface.
0240   //! Pbasis, D1Ubasis, D1Vbasis are the point and the first derivatives on the basis surface.
0241   //! If Ndir is undefined this method computes an approached normal
0242   //! direction using the following limited development:
0243   //! @code
0244   //! Ndir = N0 + DNdir/DU + DNdir/DV + Eps
0245   //! @endcode
0246   //! with Eps->0 which requires to compute the second derivatives on the basis surface.
0247   //! If the normal direction cannot be approximate for this order
0248   //! of derivation the exception UndefinedValue is raised.
0249   //!
0250   //! Raised if the continuity of the basis surface is not C1.
0251   //! Raised if the order of derivation required to compute the
0252   //! normal direction is greater than the second order.
0253   Standard_EXPORT void D0(const Standard_Real U,
0254                           const Standard_Real V,
0255                           gp_Pnt&             P) const Standard_OVERRIDE;
0256 
0257   //! Raised if the continuity of the basis surface is not C2.
0258   Standard_EXPORT void D1(const Standard_Real U,
0259                           const Standard_Real V,
0260                           gp_Pnt&             P,
0261                           gp_Vec&             D1U,
0262                           gp_Vec&             D1V) const Standard_OVERRIDE;
0263 
0264   //! Raised if the continuity of the basis surface is not C3.
0265   Standard_EXPORT void D2(const Standard_Real U,
0266                           const Standard_Real V,
0267                           gp_Pnt&             P,
0268                           gp_Vec&             D1U,
0269                           gp_Vec&             D1V,
0270                           gp_Vec&             D2U,
0271                           gp_Vec&             D2V,
0272                           gp_Vec&             D2UV) const Standard_OVERRIDE;
0273 
0274   //! Raised if the continuity of the basis surface is not C4.
0275   Standard_EXPORT void D3(const Standard_Real U,
0276                           const Standard_Real V,
0277                           gp_Pnt&             P,
0278                           gp_Vec&             D1U,
0279                           gp_Vec&             D1V,
0280                           gp_Vec&             D2U,
0281                           gp_Vec&             D2V,
0282                           gp_Vec&             D2UV,
0283                           gp_Vec&             D3U,
0284                           gp_Vec&             D3V,
0285                           gp_Vec&             D3UUV,
0286                           gp_Vec&             D3UVV) const Standard_OVERRIDE;
0287 
0288   //! Computes the derivative of order Nu in the direction u and Nv in the direction v.
0289   //!
0290   //! Raised if the continuity of the basis surface is not CNu + 1
0291   //! in the U direction and CNv + 1 in the V direction.
0292   //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
0293   //!
0294   //! The following methods compute the value and derivatives
0295   //! on the offset surface and returns the derivatives on the
0296   //! basis surface too.
0297   //! The computation of the value and derivatives on the basis
0298   //! surface are used to evaluate the offset surface.
0299   //!
0300   //! Warnings:
0301   //! The exception UndefinedValue or UndefinedDerivative is
0302   //! raised if it is not possible to compute a unique offset direction.
0303   Standard_EXPORT gp_Vec DN(const Standard_Real    U,
0304                             const Standard_Real    V,
0305                             const Standard_Integer Nu,
0306                             const Standard_Integer Nv) const Standard_OVERRIDE;
0307 
0308   //! Applies the transformation T to this offset surface.
0309   //! Note: the basis surface is also modified.
0310   Standard_EXPORT void Transform(const gp_Trsf& T) Standard_OVERRIDE;
0311 
0312   //! Computes the parameters on the transformed surface for
0313   //! the transform of the point of parameters U,V on <me>.
0314   //! @code
0315   //!   me->Transformed(T)->Value(U',V')
0316   //! @endcode
0317   //! is the same point as
0318   //! @code
0319   //! me->Value(U,V).Transformed(T)
0320   //! @endcode
0321   //! Where U',V' are the new values of U,V after calling
0322   //! @code
0323   //! me->TransformParameters(U,V,T)
0324   //! @endcode
0325   //! This method calls the basis surface method.
0326   Standard_EXPORT virtual void TransformParameters(Standard_Real& U,
0327                                                    Standard_Real& V,
0328                                                    const gp_Trsf& T) const Standard_OVERRIDE;
0329 
0330   //! Returns a 2d transformation used to find the new
0331   //! parameters of a point on the transformed surface.
0332   //! @code
0333   //!   me->Transformed(T)->Value(U',V')
0334   //! @endcode
0335   //! is the same point as
0336   //! @code
0337   //!   me->Value(U,V).Transformed(T)
0338   //! @endcode
0339   //! Where U',V' are obtained by transforming U,V with the 2d transformation returned by
0340   //! @code
0341   //! me->ParametricTransformation(T)
0342   //! @endcode
0343   //! This method calls the basis surface method.
0344   Standard_EXPORT virtual gp_GTrsf2d ParametricTransformation(const gp_Trsf& T) const
0345     Standard_OVERRIDE;
0346 
0347   //! Creates a new object which is a copy of this offset surface.
0348   Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
0349 
0350   //! returns an  equivalent surface of the offset surface
0351   //! when  the basis surface   is a canonic  surface or a
0352   //! rectangular  limited surface on canonic surface or if
0353   //! the offset is null.
0354   Standard_EXPORT Handle(Geom_Surface) Surface() const;
0355 
0356   //! if Standard_True, L is  the local osculating surface
0357   //! along U at  the point U,V.   It means that  DL/DU is
0358   //! collinear to DS/DU .  If IsOpposite == Standard_True
0359   //! these vectors have opposite direction.
0360   Standard_EXPORT Standard_Boolean
0361     UOsculatingSurface(const Standard_Real          U,
0362                        const Standard_Real          V,
0363                        Standard_Boolean&            IsOpposite,
0364                        Handle(Geom_BSplineSurface)& UOsculSurf) const;
0365 
0366   //! if Standard_True, L is the local osculating surface
0367   //! along V at the point U,V.
0368   //! It means that  DL/DV is
0369   //! collinear to DS/DV .  If IsOpposite == Standard_True
0370   //! these vectors have opposite direction.
0371   Standard_EXPORT Standard_Boolean
0372     VOsculatingSurface(const Standard_Real          U,
0373                        const Standard_Real          V,
0374                        Standard_Boolean&            IsOpposite,
0375                        Handle(Geom_BSplineSurface)& VOsculSurf) const;
0376 
0377   //! Returns continuity of the basis surface.
0378   inline GeomAbs_Shape GetBasisSurfContinuity() const { return myBasisSurfContinuity; }
0379 
0380   //! Dumps the content of me into the stream
0381   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0382                                         Standard_Integer  theDepth = -1) const Standard_OVERRIDE;
0383 
0384   DEFINE_STANDARD_RTTIEXT(Geom_OffsetSurface, Geom_Surface)
0385 
0386 private:
0387   Handle(Geom_Surface)                basisSurf;
0388   Handle(Geom_Surface)                equivSurf;
0389   Standard_Real                       offsetValue;
0390   Handle(Geom_OsculatingSurface)      myOscSurf;
0391   GeomAbs_Shape                       myBasisSurfContinuity;
0392   Handle(GeomEvaluator_OffsetSurface) myEvaluator;
0393 };
0394 
0395 #endif // _Geom_OffsetSurface_HeaderFile