Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 2015-09-21
0002 // Copyright (c) 2015 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _GeomEvaluator_OffsetCurve_HeaderFile
0016 #define _GeomEvaluator_OffsetCurve_HeaderFile
0017 
0018 #include <GeomAdaptor_Curve.hxx>
0019 #include <GeomEvaluator_Curve.hxx>
0020 #include <gp_Dir.hxx>
0021 
0022 //! Allows to calculate values and derivatives for offset curves in 3D
0023 class GeomEvaluator_OffsetCurve : public GeomEvaluator_Curve
0024 {
0025 public:
0026   //! Initialize evaluator by curve
0027   Standard_EXPORT GeomEvaluator_OffsetCurve(
0028       const Handle(Geom_Curve)& theBase,
0029       const Standard_Real theOffset,
0030       const gp_Dir& theDirection);
0031   //! Initialize evaluator by curve adaptor
0032   Standard_EXPORT GeomEvaluator_OffsetCurve(
0033       const Handle(GeomAdaptor_Curve)& theBase,
0034       const Standard_Real theOffset,
0035       const gp_Dir& theDirection);
0036 
0037   //! Change the offset value
0038   void SetOffsetValue(Standard_Real theOffset)
0039   { myOffset = theOffset; }
0040 
0041   void SetOffsetDirection(const gp_Dir& theDirection)
0042   { myOffsetDir = theDirection; }
0043 
0044   //! Value of curve
0045   Standard_EXPORT void D0(const Standard_Real theU,
0046                           gp_Pnt& theValue) const Standard_OVERRIDE;
0047   //! Value and first derivatives of curve
0048   Standard_EXPORT void D1(const Standard_Real theU,
0049                           gp_Pnt& theValue, gp_Vec& theD1) const Standard_OVERRIDE;
0050   //! Value, first and second derivatives of curve
0051   Standard_EXPORT void D2(const Standard_Real theU,
0052                           gp_Pnt& theValue, gp_Vec& theD1, gp_Vec& theD2) const Standard_OVERRIDE;
0053   //! Value, first, second and third derivatives of curve
0054   Standard_EXPORT void D3(const Standard_Real theU,
0055                           gp_Pnt& theValue, gp_Vec& theD1,
0056                           gp_Vec& theD2, gp_Vec& theD3) const Standard_OVERRIDE;
0057   //! Calculates N-th derivatives of curve, where N = theDeriv. Raises if N < 1
0058   Standard_EXPORT gp_Vec DN(const Standard_Real theU,
0059                             const Standard_Integer theDeriv) const Standard_OVERRIDE;
0060 
0061   Standard_EXPORT virtual Handle(GeomEvaluator_Curve) ShallowCopy() const Standard_OVERRIDE;
0062 
0063   DEFINE_STANDARD_RTTIEXT(GeomEvaluator_OffsetCurve,GeomEvaluator_Curve)
0064 
0065 private:
0066   //! Recalculate D1 values of base curve into D0 value of offset curve
0067   void CalculateD0(      gp_Pnt& theValue,
0068                    const gp_Vec& theD1) const;
0069   //! Recalculate D2 values of base curve into D1 values of offset curve
0070   void CalculateD1(      gp_Pnt& theValue,
0071                          gp_Vec& theD1,
0072                    const gp_Vec& theD2) const;
0073   //! Recalculate D3 values of base curve into D2 values of offset curve
0074   void CalculateD2(      gp_Pnt& theValue,
0075                          gp_Vec& theD1,
0076                          gp_Vec& theD2,
0077                    const gp_Vec& theD3,
0078                    const Standard_Boolean theIsDirChange) const;
0079   //! Recalculate D3 values of base curve into D3 values of offset curve
0080   void CalculateD3(      gp_Pnt& theValue,
0081                          gp_Vec& theD1,
0082                          gp_Vec& theD2,
0083                          gp_Vec& theD3,
0084                    const gp_Vec& theD4,
0085                    const Standard_Boolean theIsDirChange) const;
0086 
0087   //! Calculate value of base curve/adaptor
0088   void BaseD0(const Standard_Real theU, gp_Pnt& theValue) const;
0089   //! Calculate value and first derivatives of base curve/adaptor
0090   void BaseD1(const Standard_Real theU,
0091               gp_Pnt& theValue, gp_Vec& theD1) const;
0092   //! Calculate value, first and second derivatives of base curve/adaptor
0093   void BaseD2(const Standard_Real theU,
0094               gp_Pnt& theValue, gp_Vec& theD1, gp_Vec& theD2) const;
0095   //! Calculate value, first, second and third derivatives of base curve/adaptor
0096   void BaseD3(const Standard_Real theU,
0097               gp_Pnt& theValue, gp_Vec& theD1, gp_Vec& theD2, gp_Vec& theD3) const;
0098   //! Calculate value and derivatives till 4th of base curve/adaptor
0099   void BaseD4(const Standard_Real theU,
0100               gp_Pnt& theValue, gp_Vec& theD1, gp_Vec& theD2, gp_Vec& theD3, gp_Vec& theD4) const;
0101   //! Calculate N-th derivative of base curve/adaptor
0102   gp_Vec BaseDN(const Standard_Real theU, const Standard_Integer theDeriv) const;
0103 
0104   // Recalculate derivatives in the singular point
0105   // Returns true if the direction of derivatives is changed
0106   Standard_Boolean AdjustDerivative(const Standard_Integer theMaxDerivative,
0107                                     const Standard_Real theU,
0108                                           gp_Vec& theD1,
0109                                           gp_Vec& theD2,
0110                                           gp_Vec& theD3,
0111                                           gp_Vec& theD4) const;
0112 
0113 private:
0114   Handle(Geom_Curve)         myBaseCurve;
0115   Handle(GeomAdaptor_Curve) myBaseAdaptor;
0116 
0117   Standard_Real myOffset;    ///< offset value
0118   gp_Dir        myOffsetDir; ///< offset direction
0119 };
0120 
0121 DEFINE_STANDARD_HANDLE(GeomEvaluator_OffsetCurve, GeomEvaluator_Curve)
0122 
0123 
0124 #endif // _GeomEvaluator_OffsetCurve_HeaderFile