Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Copyright (c) 2014 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _BSplCLib_Cache_Headerfile
0015 #define _BSplCLib_Cache_Headerfile
0016 
0017 #include <BSplCLib_CacheParams.hxx>
0018 #include <TColStd_HArray2OfReal.hxx>
0019 
0020 //! \brief A cache class for Bezier and B-spline curves.
0021 //!
0022 //! Defines all data, that can be cached on a span of a curve.
0023 //! The data should be recalculated in going from span to span.
0024 class BSplCLib_Cache : public Standard_Transient
0025 {
0026 public:
0027 
0028   //! Constructor, prepares data structures for caching values on a 2d curve.
0029   //! \param theDegree     degree of the curve
0030   //! \param thePeriodic   identify whether the curve is periodic
0031   //! \param theFlatKnots  knots of Bezier/B-spline curve (with repetitions)
0032   //! \param thePoles2d    array of poles of 2D curve
0033   //! \param theWeights    array of weights of corresponding poles
0034   Standard_EXPORT BSplCLib_Cache(const Standard_Integer&        theDegree,
0035                                  const Standard_Boolean&        thePeriodic,
0036                                  const TColStd_Array1OfReal&    theFlatKnots,
0037                                  const TColgp_Array1OfPnt2d&    thePoles2d,
0038                                  const TColStd_Array1OfReal*    theWeights = NULL);
0039 
0040   //! Constructor, prepares data structures for caching values on a 3d curve.
0041   //! \param theDegree     degree of the curve
0042   //! \param thePeriodic   identify whether the curve is periodic
0043   //! \param theFlatKnots  knots of Bezier/B-spline curve (with repetitions)
0044   //! \param thePoles      array of poles of 3D curve
0045   //! \param theWeights    array of weights of corresponding poles
0046   Standard_EXPORT BSplCLib_Cache(const Standard_Integer&        theDegree,
0047                                  const Standard_Boolean&        thePeriodic,
0048                                  const TColStd_Array1OfReal&    theFlatKnots,
0049                                  const TColgp_Array1OfPnt&      thePoles,
0050                                  const TColStd_Array1OfReal*    theWeights = NULL);
0051 
0052   //! Verifies validity of the cache using flat parameter of the point
0053   //! \param theParameter parameter of the point placed in the span
0054   Standard_EXPORT Standard_Boolean IsCacheValid(Standard_Real theParameter) const;
0055 
0056   //! Recomputes the cache data for 2D curves. Does not verify validity of the cache
0057   //! \param theParameter  the value on the knot's axis to identify the span
0058   //! \param theFlatKnots  knots of Bezier/B-spline curve (with repetitions)
0059   //! \param thePoles2d    array of poles of 2D curve
0060   //! \param theWeights    array of weights of corresponding poles
0061   Standard_EXPORT void BuildCache(const Standard_Real&           theParameter,
0062                                   const TColStd_Array1OfReal&    theFlatKnots,
0063                                   const TColgp_Array1OfPnt2d&    thePoles2d,
0064                                   const TColStd_Array1OfReal*    theWeights);
0065 
0066   //! Recomputes the cache data for 3D curves. Does not verify validity of the cache
0067   //! \param theParameter  the value on the knot's axis to identify the span
0068   //! \param theFlatKnots  knots of Bezier/B-spline curve (with repetitions)
0069   //! \param thePoles      array of poles of 3D curve
0070   //! \param theWeights    array of weights of corresponding poles
0071   Standard_EXPORT void BuildCache(const Standard_Real&           theParameter,
0072                                   const TColStd_Array1OfReal&    theFlatKnots,
0073                                   const TColgp_Array1OfPnt&      thePoles,
0074                                   const TColStd_Array1OfReal*    theWeights = NULL);
0075 
0076   //! Calculates the point on the curve in the specified parameter
0077   //! \param[in]  theParameter parameter of calculation of the value
0078   //! \param[out] thePoint     the result of calculation (the point on the curve)
0079   Standard_EXPORT void D0(const Standard_Real& theParameter, gp_Pnt2d& thePoint) const;
0080   Standard_EXPORT void D0(const Standard_Real& theParameter, gp_Pnt&   thePoint) const;
0081 
0082   //! Calculates the point on the curve and its first derivative in the specified parameter
0083   //! \param[in]  theParameter parameter of calculation of the value
0084   //! \param[out] thePoint     the result of calculation (the point on the curve)
0085   //! \param[out] theTangent   tangent vector (first derivatives) for the curve in the calculated point
0086   Standard_EXPORT void D1(const Standard_Real& theParameter, gp_Pnt2d& thePoint, gp_Vec2d& theTangent) const;
0087   Standard_EXPORT void D1(const Standard_Real& theParameter, gp_Pnt&   thePoint, gp_Vec&   theTangent) const;
0088 
0089   //! Calculates the point on the curve and two derivatives in the specified parameter
0090   //! \param[in]  theParameter parameter of calculation of the value
0091   //! \param[out] thePoint     the result of calculation (the point on the curve)
0092   //! \param[out] theTangent   tangent vector (1st derivatives) for the curve in the calculated point
0093   //! \param[out] theCurvature curvature vector (2nd derivatives) for the curve in the calculated point
0094   Standard_EXPORT void D2(const Standard_Real& theParameter, 
0095                                 gp_Pnt2d&      thePoint, 
0096                                 gp_Vec2d&      theTangent, 
0097                                 gp_Vec2d&      theCurvature) const;
0098   Standard_EXPORT void D2(const Standard_Real& theParameter, 
0099                                 gp_Pnt&        thePoint, 
0100                                 gp_Vec&        theTangent, 
0101                                 gp_Vec&        theCurvature) const;
0102 
0103   //! Calculates the point on the curve and three derivatives in the specified parameter
0104   //! \param[in]  theParameter parameter of calculation of the value
0105   //! \param[out] thePoint     the result of calculation (the point on the curve)
0106   //! \param[out] theTangent   tangent vector (1st derivatives) for the curve in the calculated point
0107   //! \param[out] theCurvature curvature vector (2nd derivatives) for the curve in the calculated point
0108   //! \param[out] theTorsion   second curvature vector (3rd derivatives) for the curve in the calculated point
0109   Standard_EXPORT void D3(const Standard_Real& theParameter, 
0110                                 gp_Pnt2d&      thePoint, 
0111                                 gp_Vec2d&      theTangent, 
0112                                 gp_Vec2d&      theCurvature,
0113                                 gp_Vec2d&      theTorsion) const;
0114   Standard_EXPORT void D3(const Standard_Real& theParameter, 
0115                                 gp_Pnt&        thePoint, 
0116                                 gp_Vec&        theTangent, 
0117                                 gp_Vec&        theCurvature,
0118                                 gp_Vec&        theTorsion) const;
0119 
0120 
0121   DEFINE_STANDARD_RTTIEXT(BSplCLib_Cache,Standard_Transient)
0122 
0123 protected:
0124 
0125   //! Fills array of derivatives in the selected point of the curve
0126   //! \param[in]  theParameter  parameter of the calculation
0127   //! \param[in]  theDerivative maximal derivative to be calculated (computes all derivatives lesser than specified)
0128   //! \param[out] theDerivArray result array of derivatives (with size (theDerivative+1)*(PntDim+1), 
0129   //!                           where PntDim = 2 or 3 is a dimension of the curve)
0130   void CalculateDerivative(const Standard_Real&    theParameter, 
0131                            const Standard_Integer& theDerivative, 
0132                                  Standard_Real&    theDerivArray) const;
0133 
0134   // copying is prohibited
0135   BSplCLib_Cache (const BSplCLib_Cache&);
0136   void operator = (const BSplCLib_Cache&);
0137 
0138 private:
0139   Standard_Boolean myIsRational;                //!< identifies the rationality of Bezier/B-spline curve
0140   BSplCLib_CacheParams myParams;                //!< cache parameters
0141   Handle(TColStd_HArray2OfReal) myPolesWeights; //!< array of poles and weights of calculated cache
0142                                                 // the array has following structure:
0143                                                 //       x1 y1 [z1] [w1]
0144                                                 //       x2 y2 [z2] [w2] etc
0145                                                 // for 2D-curves there is no z conponent, for non-rational curves there is no weight
0146 };
0147 
0148 DEFINE_STANDARD_HANDLE(BSplCLib_Cache, Standard_Transient)
0149 
0150 #endif