Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:33

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