Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-24 09:16:25

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_OffsetCurve_HeaderFile
0018 #define _Geom_OffsetCurve_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <gp_Dir.hxx>
0024 #include <GeomAbs_Shape.hxx>
0025 #include <Geom_Curve.hxx>
0026 #include <Standard_Integer.hxx>
0027 #include <GeomEvaluator_OffsetCurve.hxx>
0028 
0029 class gp_Pnt;
0030 class gp_Vec;
0031 class gp_Trsf;
0032 class Geom_Geometry;
0033 
0034 class Geom_OffsetCurve;
0035 DEFINE_STANDARD_HANDLE(Geom_OffsetCurve, Geom_Curve)
0036 
0037 //! This class implements the basis services for an offset curve
0038 //! in 3D space. The Offset curve in this package can be a self
0039 //! intersecting curve even if the basis curve does not
0040 //! self-intersect. The self intersecting portions are not deleted
0041 //! at the construction time.
0042 //! An offset curve is a curve at constant distance (Offset) from
0043 //! a basis curve in a reference direction V. The offset curve
0044 //! takes its parametrization from the basis curve.
0045 //! The Offset curve is in the direction of the normal N
0046 //! defined with the cross product  T^V, where the vector T
0047 //! is given by the first derivative on the basis curve with
0048 //! non zero length.
0049 //! The distance offset may be positive or negative to indicate the
0050 //! preferred side of the curve :
0051 //! . distance offset >0 => the curve is in the direction of N
0052 //! . distance offset <0 => the curve is in the direction of - N
0053 //!
0054 //! On the Offset curve :
0055 //! Value (U) = BasisCurve.Value(U) + (Offset * (T ^ V)) / ||T ^ V||
0056 //!
0057 //! At any point the Offset direction V must not be parallel to the
0058 //! vector T and the vector T must not have null length else the
0059 //! offset curve is not defined. So the offset curve has not the
0060 //! same continuity as the basis curve.
0061 //!
0062 //! Warnings :
0063 //!
0064 //! In this package we suppose that the continuity of the offset
0065 //! curve is one degree less than the continuity of the basis
0066 //! curve and we don't check that at any point ||T^V|| != 0.0
0067 //!
0068 //! So to evaluate the curve it is better to check that the offset
0069 //! curve is well defined at any point because an exception could
0070 //! be raised. The check is not done in this package at the creation
0071 //! of the offset curve because the control needs the use of an
0072 //! algorithm which cannot be implemented in this package.
0073 //!
0074 //! The OffsetCurve is closed if the first point and the last point
0075 //! are the same (The distance between these two points is lower or
0076 //! equal to the Resolution sea package gp) . The OffsetCurve can be
0077 //! closed even if the basis curve is not closed.
0078 class Geom_OffsetCurve : public Geom_Curve
0079 {
0080 
0081 public:
0082   //! C is the basis curve, Offset is the distance between <me> and
0083   //! the basis curve at any point. V defines the fixed reference
0084   //! direction (offset direction). If P is a point on the basis
0085   //! curve and T the first derivative with non zero length
0086   //! at this point, the corresponding point on the offset curve is
0087   //! in the direction of the vector-product N = V ^ T   where
0088   //! N is a unitary vector.
0089   //! If isNotCheckC0 = TRUE checking if basis curve has C0-continuity
0090   //! is not made.
0091   //! Warnings :
0092   //! In this package the entities are not shared. The OffsetCurve is
0093   //! built with a copy of the curve C. So when C is modified the
0094   //! OffsetCurve is not modified
0095   //!
0096   //! Raised if the basis curve C is not at least C1.
0097   //! Warnings :
0098   //! No check is done to know if ||V^T|| != 0.0 at any point.
0099   Standard_EXPORT Geom_OffsetCurve(const Handle(Geom_Curve)& C,
0100                                    const Standard_Real       Offset,
0101                                    const gp_Dir&             V,
0102                                    const Standard_Boolean    isNotCheckC0 = Standard_False);
0103 
0104   //! Changes the orientation of this offset curve.
0105   //! As a result:
0106   //! - the basis curve is reversed,
0107   //! - the start point of the initial curve becomes the
0108   //! end point of the reversed curve,
0109   //! - the end point of the initial curve becomes the
0110   //! start point of the reversed curve, and
0111   //! - the first and last parameters are recomputed.
0112   Standard_EXPORT void Reverse() Standard_OVERRIDE;
0113 
0114   //! Computes the parameter on the reversed curve for
0115   //! the point of parameter U on this offset curve.
0116   Standard_EXPORT Standard_Real ReversedParameter(const Standard_Real U) const Standard_OVERRIDE;
0117 
0118   //! Changes this offset curve by assigning C
0119   //! as the basis curve from which it is built.
0120   //! If isNotCheckC0 = TRUE checking if basis curve
0121   //! has C0-continuity is not made.
0122   //! Exceptions
0123   //! Standard_ConstructionError if the curve C is not at least "C1" continuous.
0124   Standard_EXPORT void SetBasisCurve(const Handle(Geom_Curve)& C,
0125                                      const Standard_Boolean    isNotCheckC0 = Standard_False);
0126 
0127   //! Changes this offset curve by assigning V as the
0128   //! reference vector used to compute the offset direction.
0129   Standard_EXPORT void SetDirection(const gp_Dir& V);
0130 
0131   //! Changes this offset curve by assigning D as the offset value.
0132   Standard_EXPORT void SetOffsetValue(const Standard_Real D);
0133 
0134   //! Returns the basis curve of this offset curve.
0135   //! Note: The basis curve can be an offset curve.
0136   Standard_EXPORT Handle(Geom_Curve) BasisCurve() const;
0137 
0138   //! Returns the global continuity of this offset curve as a
0139   //! value of the GeomAbs_Shape enumeration.
0140   //! The degree of continuity of this offset curve is equal
0141   //! to the degree of continuity of the basis curve minus 1.
0142   //! Continuity of the Offset curve :
0143   //! C0 : only geometric continuity,
0144   //! C1 : continuity of the first derivative all along the Curve,
0145   //! C2 : continuity of the second derivative all along the Curve,
0146   //! C3 : continuity of the third derivative all along the Curve,
0147   //! G1 : tangency continuity all along the Curve,
0148   //! G2 : curvature continuity all along the Curve,
0149   //! CN : the order of continuity is infinite.
0150   //! Warnings :
0151   //! Returns the continuity of the basis curve - 1.
0152   //! The offset curve must have a unique offset direction defined
0153   //! at any point.
0154   Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
0155 
0156   //! Returns the reference vector of this offset curve.
0157   //! Value and derivatives
0158   //! Warnings :
0159   //! The exception UndefinedValue or UndefinedDerivative is
0160   //! raised if it is not possible to compute a unique offset
0161   //! direction.
0162   //! If T is the first derivative with not null length and
0163   //! V the offset direction the relation ||T(U) ^ V|| != 0
0164   //! must be satisfied to evaluate the offset curve.
0165   //! No check is done at the creation time and we suppose
0166   //! in this package that the offset curve is well defined.
0167   Standard_EXPORT const gp_Dir& Direction() const;
0168 
0169   //! Warning! this should not be called
0170   //! if the basis curve is not at least C1. Nevertheless
0171   //! if used on portion where the curve is C1, it is OK
0172   Standard_EXPORT void D0(const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
0173 
0174   //! Warning! this should not be called
0175   //! if the continuity of the basis curve is not C2.
0176   //! Nevertheless, it's OK to use it  on portion
0177   //! where the curve is C2
0178   Standard_EXPORT void D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const Standard_OVERRIDE;
0179 
0180   //! Warning! this should not be called
0181   //! if the continuity of the basis curve is not C3.
0182   //! Nevertheless, it's OK to use it  on portion
0183   //! where the curve is C3
0184   Standard_EXPORT void D2(const Standard_Real U,
0185                           gp_Pnt&             P,
0186                           gp_Vec&             V1,
0187                           gp_Vec&             V2) const Standard_OVERRIDE;
0188 
0189   Standard_EXPORT void D3(const Standard_Real U,
0190                           gp_Pnt&             P,
0191                           gp_Vec&             V1,
0192                           gp_Vec&             V2,
0193                           gp_Vec&             V3) const Standard_OVERRIDE;
0194 
0195   //! The returned vector gives the value of the derivative
0196   //! for the order of derivation N.
0197   //!
0198   //! The following functions compute the value and derivatives
0199   //! on the offset curve and returns the derivatives on the
0200   //! basis curve too.
0201   //! The computation of the value and derivatives on the basis
0202   //! curve are used to evaluate the offset curve
0203   //!
0204   //! Warning:
0205   //! The exception UndefinedValue or UndefinedDerivative is
0206   //! raised if it is not possible to compute a unique offset
0207   //! direction.
0208   //! Raised if N < 1.
0209   Standard_EXPORT gp_Vec DN(const Standard_Real    U,
0210                             const Standard_Integer N) const Standard_OVERRIDE;
0211 
0212   //! Returns the value of the first parameter of this
0213   //! offset curve. The first parameter corresponds to the
0214   //! start point of the curve.
0215   //! Note: the first and last parameters of this offset curve
0216   //! are also the ones of its basis curve.
0217   Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
0218 
0219   //! Returns the value of the last parameter of this
0220   //! offset curve. The last parameter
0221   //! corresponds to the end point.
0222   //! Note: the first and last parameters of this offset curve
0223   //! are also the ones of its basis curve.
0224   Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
0225 
0226   //! Returns the offset value of this offset curve.
0227   Standard_EXPORT Standard_Real Offset() const;
0228 
0229   //! Returns True if the distance between the start point
0230   //! and the end point of the curve is lower or equal to
0231   //! Resolution from package gp.
0232   Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
0233 
0234   //! Returns true if the degree of continuity of the basis
0235   //! curve of this offset curve is at least N + 1.
0236   //! This method answer True if the continuity of the basis curve
0237   //! is N + 1.  We suppose in this class that a normal direction
0238   //! to the basis curve (used to compute the offset curve) is
0239   //! defined at any point on the basis curve.
0240   //! Raised if N < 0.
0241   Standard_EXPORT Standard_Boolean IsCN(const Standard_Integer N) const Standard_OVERRIDE;
0242 
0243   //! Returns true if this offset curve is periodic, i.e. if the
0244   //! basis curve of this offset curve is periodic.
0245   Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
0246 
0247   //! Returns the period of this offset curve, i.e. the period
0248   //! of the basis curve of this offset curve.
0249   //! Exceptions
0250   //! Standard_NoSuchObject if the basis curve is not periodic.
0251   Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE;
0252 
0253   //! Applies the transformation T to this offset curve.
0254   //! Note: the basis curve is also modified.
0255   Standard_EXPORT void Transform(const gp_Trsf& T) Standard_OVERRIDE;
0256 
0257   //! Returns the  parameter on the  transformed  curve for
0258   //! the transform of the point of parameter U on <me>.
0259   //! me->Transformed(T)->Value(me->TransformedParameter(U,T))
0260   //! is the same point as
0261   //! me->Value(U).Transformed(T)
0262   //! This methods calls the basis curve method.
0263   Standard_EXPORT virtual Standard_Real TransformedParameter(const Standard_Real U,
0264                                                              const gp_Trsf&      T) const
0265     Standard_OVERRIDE;
0266 
0267   //! Returns a  coefficient to compute the parameter on
0268   //! the transformed  curve  for  the transform  of the
0269   //! point on <me>.
0270   //!
0271   //! Transformed(T)->Value(U * ParametricTransformation(T))
0272   //! is the same point as
0273   //! Value(U).Transformed(T)
0274   //! This methods calls the basis curve method.
0275   Standard_EXPORT virtual Standard_Real ParametricTransformation(const gp_Trsf& T) const
0276     Standard_OVERRIDE;
0277 
0278   //! Creates a new object which is a copy of this offset curve.
0279   Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
0280 
0281   //! Returns continuity of the basis curve.
0282   Standard_EXPORT GeomAbs_Shape GetBasisCurveContinuity() const;
0283 
0284   //! Dumps the content of me into the stream
0285   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0286                                         Standard_Integer  theDepth = -1) const Standard_OVERRIDE;
0287 
0288   DEFINE_STANDARD_RTTIEXT(Geom_OffsetCurve, Geom_Curve)
0289 
0290 protected:
0291 private:
0292   Handle(Geom_Curve)                basisCurve;
0293   gp_Dir                            direction;
0294   Standard_Real                     offsetValue;
0295   GeomAbs_Shape                     myBasisCurveContinuity;
0296   Handle(GeomEvaluator_OffsetCurve) myEvaluator;
0297 };
0298 
0299 #endif // _Geom_OffsetCurve_HeaderFile