1 // Copyright (c) 2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _BSplSLib_Cache_Headerfile
15 #define _BSplSLib_Cache_Headerfile
17 #include <Standard.hxx>
18 #include <Standard_Macro.hxx>
19 #include <Standard_Type.hxx>
20 #include <Standard_Transient.hxx>
25 #include <TColgp_Array2OfPnt.hxx>
26 #include <TColStd_Array1OfInteger.hxx>
27 #include <TColStd_HArray2OfReal.hxx>
28 #include <TColStd_HArray1OfReal.hxx>
29 #include <TColStd_Array1OfReal.hxx>
30 #include <TColStd_Array2OfReal.hxx>
32 #include <BSplCLib_CacheParams.hxx>
34 //! \brief A cache class for Bezier and B-spline surfaces.
36 //! Defines all data, that can be cached on a span of the surface.
37 //! The data should be recalculated in going from span to span.
38 class BSplSLib_Cache : public Standard_Transient
42 //! Constructor for caching of the span for the surface
43 //! \param theDegreeU degree along the first parameter (U) of the surface
44 //! \param thePeriodicU identify the surface is periodical along U axis
45 //! \param theFlatKnotsU knots of the surface (with repetition) along U axis
46 //! \param theDegreeV degree alogn the second parameter (V) of the surface
47 //! \param thePeriodicV identify the surface is periodical along V axis
48 //! \param theFlatKnotsV knots of the surface (with repetition) along V axis
49 //! \param theWeights array of weights of corresponding poles
50 Standard_EXPORT BSplSLib_Cache(const Standard_Integer& theDegreeU,
51 const Standard_Boolean& thePeriodicU,
52 const TColStd_Array1OfReal& theFlatKnotsU,
53 const Standard_Integer& theDegreeV,
54 const Standard_Boolean& thePeriodicV,
55 const TColStd_Array1OfReal& theFlatKnotsV,
56 const TColStd_Array2OfReal* theWeights = NULL);
58 //! Verifies validity of the cache using parameters of the point
59 //! \param theParameterU first parameter of the point placed in the span
60 //! \param theParameterV second parameter of the point placed in the span
61 Standard_EXPORT Standard_Boolean IsCacheValid(Standard_Real theParameterU,
62 Standard_Real theParameterV) const;
64 //! Recomputes the cache data. Does not verify validity of the cache
65 //! \param theParameterU the parametric value on the U axis to identify the span
66 //! \param theParameterV the parametric value on the V axis to identify the span
67 //! \param theDegreeU degree along U axis
68 //! \param thePeriodicU identify whether the surface is periodic along U axis
69 //! \param theFlatKnotsU flat knots of the surface along U axis
70 //! \param theDegreeV degree along V axis
71 //! \param thePeriodicV identify whether the surface is periodic along V axis
72 //! \param theFlatKnotsV flat knots of the surface along V axis
73 //! \param thePoles array of poles of the surface
74 //! \param theWeights array of weights of corresponding poles
75 Standard_EXPORT void BuildCache(const Standard_Real& theParameterU,
76 const Standard_Real& theParameterV,
77 const TColStd_Array1OfReal& theFlatKnotsU,
78 const TColStd_Array1OfReal& theFlatKnotsV,
79 const TColgp_Array2OfPnt& thePoles,
80 const TColStd_Array2OfReal* theWeights = NULL);
82 //! Calculates the point on the surface for specified parameters
83 //! \param[in] theU first parameter for calculation of the value
84 //! \param[in] theV second parameter for calculation of the value
85 //! \param[out] thePoint the result of calculation (the point on the surface)
86 Standard_EXPORT void D0(const Standard_Real& theU, const Standard_Real& theV, gp_Pnt& thePoint) const;
88 //! Calculates the point on the surface and its first derivative
89 //! \param[in] theU first parameter of calculation of the value
90 //! \param[in] theV second parameter of calculation of the value
91 //! \param[out] thePoint the result of calculation (the point on the surface)
92 //! \param[out] theTangentU tangent vector along U axis in the calculated point
93 //! \param[out] theTangentV tangent vector along V axis in the calculated point
94 Standard_EXPORT void D1(const Standard_Real& theU,
95 const Standard_Real& theV,
98 gp_Vec& theTangentV) const;
100 //! Calculates the point on the surface and derivatives till second order
101 //! \param[in] theU first parameter of calculation of the value
102 //! \param[in] theV second parameter of calculation of the value
103 //! \param[out] thePoint the result of calculation (the point on the surface)
104 //! \param[out] theTangentU tangent vector along U axis in the calculated point
105 //! \param[out] theTangentV tangent vector along V axis in the calculated point
106 //! \param[out] theCurvatureU curvature vector (2nd derivative on U) along U axis
107 //! \param[out] theCurvatureV curvature vector (2nd derivative on V) along V axis
108 //! \param[out] theCurvatureUV 2nd mixed derivative on U anv V
109 Standard_EXPORT void D2(const Standard_Real& theU,
110 const Standard_Real& theV,
114 gp_Vec& theCurvatureU,
115 gp_Vec& theCurvatureV,
116 gp_Vec& theCurvatureUV) const;
119 DEFINE_STANDARD_RTTIEXT(BSplSLib_Cache,Standard_Transient)
122 // copying is prohibited
123 BSplSLib_Cache (const BSplSLib_Cache&);
124 void operator = (const BSplSLib_Cache&);
127 Standard_Boolean myIsRational; //!< identifies the rationality of Bezier/B-spline surface
128 BSplCLib_CacheParams myParamsU, myParamsV; //!< cach parameters by U and V directions
129 Handle(TColStd_HArray2OfReal) myPolesWeights; //!< array of poles and weights of calculated cache
130 // the array has following structure:
131 // x11 y11 z11 [w11] x12 y12 z12 [w12] ...
132 // x21 y21 z21 [w21] x22 y22 z22 [w22] etc
133 // for non-rational surfaces there is no weight;
134 // size of array: (max(myDegree)+1) * A*(min(myDegree)+1), where A = 4 or 3
137 DEFINE_STANDARD_HANDLE(BSplSLib_Cache, Standard_Transient)