Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 09:17:33

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_Curve_HeaderFile
0018 #define _Geom_Curve_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Geom_Geometry.hxx>
0024 #include <gp_Pnt.hxx>
0025 #include <gp_Vec.hxx>
0026 #include <GeomAbs_Shape.hxx>
0027 #include <Geom_UndefinedDerivative.hxx>
0028 #include <Geom_UndefinedValue.hxx>
0029 
0030 class gp_Trsf;
0031 
0032 //! The abstract class Curve describes the common
0033 //! behavior of curves in 3D space. The Geom package
0034 //! provides numerous concrete classes of derived
0035 //! curves, including lines, circles, conics, Bezier or
0036 //! BSpline curves, etc.
0037 //! The main characteristic of these curves is that they
0038 //! are parameterized. The Geom_Curve class shows:
0039 //! - how to work with the parametric equation of a curve
0040 //! in order to calculate the point of parameter u,
0041 //! together with the vector tangent and the derivative
0042 //! vectors of order 2, 3,..., N at this point;
0043 //! - how to obtain general information about the curve
0044 //! (for example, level of continuity, closed
0045 //! characteristics, periodicity, bounds of the parameter field);
0046 //! - how the parameter changes when a geometric
0047 //! transformation is applied to the curve or when the
0048 //! orientation of the curve is inverted.
0049 //! All curves must have a geometric continuity: a curve is
0050 //! at least "C0". Generally, this property is checked at
0051 //! the time of construction or when the curve is edited.
0052 //! Where this is not the case, the documentation states so explicitly.
0053 //! Warning
0054 //! The Geom package does not prevent the
0055 //! construction of curves with null length or curves which
0056 //! self-intersect.
0057 class Geom_Curve : public Geom_Geometry
0058 {
0059 
0060 public:
0061   //! Result of D1 evaluation: point and first derivative.
0062   struct ResD1
0063   {
0064     gp_Pnt Point;
0065     gp_Vec D1;
0066   };
0067 
0068   //! Result of D2 evaluation: point and first two derivatives.
0069   struct ResD2
0070   {
0071     gp_Pnt Point;
0072     gp_Vec D1;
0073     gp_Vec D2;
0074   };
0075 
0076   //! Result of D3 evaluation: point and first three derivatives.
0077   struct ResD3
0078   {
0079     gp_Pnt Point;
0080     gp_Vec D1;
0081     gp_Vec D2;
0082     gp_Vec D3;
0083   };
0084 
0085   //! Changes the direction of parametrization of <me>.
0086   //! The "FirstParameter" and the "LastParameter" are not changed
0087   //! but the orientation of the curve is modified. If the curve
0088   //! is bounded the StartPoint of the initial curve becomes the
0089   //! EndPoint of the reversed curve and the EndPoint of the initial
0090   //! curve becomes the StartPoint of the reversed curve.
0091   Standard_EXPORT virtual void Reverse() = 0;
0092 
0093   //! Returns the parameter on the reversed curve for
0094   //! the point of parameter U on <me>.
0095   //!
0096   //! me->Reversed()->Value(me->ReversedParameter(U))
0097   //!
0098   //! is the same point as
0099   //!
0100   //! me->Value(U)
0101   Standard_EXPORT virtual double ReversedParameter(const double U) const = 0;
0102 
0103   //! Returns the parameter on the transformed curve for
0104   //! the transform of the point of parameter U on <me>.
0105   //!
0106   //! me->Transformed(T)->Value(me->TransformedParameter(U,T))
0107   //!
0108   //! is the same point as
0109   //!
0110   //! me->Value(U).Transformed(T)
0111   //!
0112   //! This methods returns <U>
0113   //!
0114   //! It can be redefined. For example on the Line.
0115   Standard_EXPORT virtual double TransformedParameter(const double U, const gp_Trsf& T) const;
0116 
0117   //! Returns a coefficient to compute the parameter on
0118   //! the transformed curve for the transform of the
0119   //! point on <me>.
0120   //!
0121   //! Transformed(T)->Value(U * ParametricTransformation(T))
0122   //!
0123   //! is the same point as
0124   //!
0125   //! Value(U).Transformed(T)
0126   //!
0127   //! This methods returns 1.
0128   //!
0129   //! It can be redefined. For example on the Line.
0130   Standard_EXPORT virtual double ParametricTransformation(const gp_Trsf& T) const;
0131 
0132   //! Returns a copy of <me> reversed.
0133   [[nodiscard]] Standard_EXPORT occ::handle<Geom_Curve> Reversed() const;
0134 
0135   //! Returns the value of the first parameter.
0136   //! Warnings :
0137   //! It can be RealFirst from package Standard
0138   //! if the curve is infinite
0139   Standard_EXPORT virtual double FirstParameter() const = 0;
0140 
0141   //! Returns the value of the last parameter.
0142   //! Warnings :
0143   //! It can be RealLast from package Standard
0144   //! if the curve is infinite
0145   Standard_EXPORT virtual double LastParameter() const = 0;
0146 
0147   //! Returns true if the curve is closed.
0148   //! Some curves such as circle are always closed, others such as line
0149   //! are never closed (by definition).
0150   //! Some Curves such as OffsetCurve can be closed or not. These curves
0151   //! are considered as closed if the distance between the first point
0152   //! and the last point of the curve is lower or equal to the Resolution
0153   //! from package gp which is a fixed criterion independent of the
0154   //! application.
0155   Standard_EXPORT virtual bool IsClosed() const = 0;
0156 
0157   //! Is the parametrization of the curve periodic ?
0158   //! It is possible only if the curve is closed and if the
0159   //! following relation is satisfied :
0160   //! for each parametric value U the distance between the point
0161   //! P(u) and the point P (u + T) is lower or equal to Resolution
0162   //! from package gp, T is the period and must be a constant.
0163   //! There are three possibilities :
0164   //! . the curve is never periodic by definition (SegmentLine)
0165   //! . the curve is always periodic by definition (Circle)
0166   //! . the curve can be defined as periodic (BSpline). In this case
0167   //! a function SetPeriodic allows you to give the shape of the
0168   //! curve. The general rule for this case is : if a curve can be
0169   //! periodic or not the default periodicity set is non periodic
0170   //! and you have to turn (explicitly) the curve into a periodic
0171   //! curve if you want the curve to be periodic.
0172   Standard_EXPORT virtual bool IsPeriodic() const = 0;
0173 
0174   //! Returns the period of this curve.
0175   //! Exceptions Standard_NoSuchObject if this curve is not periodic.
0176   Standard_EXPORT virtual double Period() const;
0177 
0178   //! It is the global continuity of the curve
0179   //! C0 : only geometric continuity,
0180   //! C1 : continuity of the first derivative all along the Curve,
0181   //! C2 : continuity of the second derivative all along the Curve,
0182   //! C3 : continuity of the third derivative all along the Curve,
0183   //! G1 : tangency continuity all along the Curve,
0184   //! G2 : curvature continuity all along the Curve,
0185   //! CN : the order of continuity is infinite.
0186   Standard_EXPORT virtual GeomAbs_Shape Continuity() const = 0;
0187 
0188   //! Returns true if the degree of continuity of this curve is at least N.
0189   //! Exceptions - Standard_RangeError if N is less than 0.
0190   Standard_EXPORT virtual bool IsCN(const int N) const = 0;
0191 
0192   //! Computes the point of parameter U.
0193   //! Raises an exception on failure (e.g. OffsetCurve at singular point).
0194   [[nodiscard]] Standard_EXPORT virtual gp_Pnt EvalD0(const double U) const = 0;
0195 
0196   //! Computes the point and first derivative at parameter U.
0197   //! Raises an exception if the curve continuity is not C1.
0198   [[nodiscard]] Standard_EXPORT virtual ResD1 EvalD1(const double U) const = 0;
0199 
0200   //! Computes the point and first two derivatives at parameter U.
0201   //! Raises an exception if the curve continuity is not C2.
0202   [[nodiscard]] Standard_EXPORT virtual ResD2 EvalD2(const double U) const = 0;
0203 
0204   //! Computes the point and first three derivatives at parameter U.
0205   //! Raises an exception if the curve continuity is not C3.
0206   [[nodiscard]] Standard_EXPORT virtual ResD3 EvalD3(const double U) const = 0;
0207 
0208   //! Computes the Nth derivative at parameter U.
0209   //! Raises an exception if the curve continuity is not CN, or N < 1.
0210   [[nodiscard]] Standard_EXPORT virtual gp_Vec EvalDN(const double U, const int N) const = 0;
0211 
0212   //! Returns in P the point of parameter U.
0213   inline void D0(const double U, gp_Pnt& P) const { P = EvalD0(U); }
0214 
0215   //! Returns the point P of parameter U and the first derivative V1.
0216   inline void D1(const double U, gp_Pnt& P, gp_Vec& V1) const
0217   {
0218     const ResD1 aR = EvalD1(U);
0219     P              = aR.Point;
0220     V1             = aR.D1;
0221   }
0222 
0223   //! Returns the point P of parameter U, the first and second derivatives V1 and V2.
0224   inline void D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const
0225   {
0226     const ResD2 aR = EvalD2(U);
0227     P              = aR.Point;
0228     V1             = aR.D1;
0229     V2             = aR.D2;
0230   }
0231 
0232   //! Returns the point P of parameter U, the first, the second and the third derivative.
0233   inline void D3(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const
0234   {
0235     const ResD3 aR = EvalD3(U);
0236     P              = aR.Point;
0237     V1             = aR.D1;
0238     V2             = aR.D2;
0239     V3             = aR.D3;
0240   }
0241 
0242   //! The returned vector gives the value of the derivative for the order of derivation N.
0243   inline gp_Vec DN(const double U, const int N) const { return EvalDN(U, N); }
0244 
0245   //! Computes the point of parameter U on <me>.
0246   gp_Pnt Value(const double U) const { return EvalD0(U); }
0247 
0248   //! Dumps the content of me into the stream
0249   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override;
0250 
0251   DEFINE_STANDARD_RTTIEXT(Geom_Curve, Geom_Geometry)
0252 };
0253 
0254 #endif // _Geom_Curve_HeaderFile