0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / BSplSLib / BSplSLib_Cache.hxx
CommitLineData
94f71cad 1// Copyright (c) 2014 OPEN CASCADE SAS
2//
3// This file is part of Open CASCADE Technology software library.
4//
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.
10//
11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
13
14#ifndef _BSplSLib_Cache_Headerfile
15#define _BSplSLib_Cache_Headerfile
16
17#include <Standard.hxx>
18#include <Standard_Macro.hxx>
ec357c5c 19#include <Standard_Type.hxx>
94f71cad 20#include <Standard_Transient.hxx>
21
94f71cad 22#include <gp_Pnt.hxx>
23#include <gp_Vec.hxx>
24
b7c077b9 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>
94f71cad 31
c8b5b3d8 32//! \brief A cache class for Bezier and B-spline surfaces.
94f71cad 33//!
c8b5b3d8 34//! Defines all data, that can be cached on a span of the surface.
94f71cad 35//! The data should be recalculated in going from span to span.
36class BSplSLib_Cache : public Standard_Transient
37{
38public:
39 //! Default constructor
40 Standard_EXPORT BSplSLib_Cache();
c8b5b3d8 41 //! Constructor for caching of the span for the surface
42 //! \param theDegreeU degree along the first parameter (U) of the surface
43 //! \param thePeriodicU identify the surface is periodical along U axis
44 //! \param theFlatKnotsU knots of the surface (with repetition) along U axis
45 //! \param theDegreeV degree alogn the second parameter (V) of the surface
46 //! \param thePeriodicV identify the surface is periodical along V axis
47 //! \param theFlatKnotsV knots of the surface (with repetition) along V axis
48 //! \param thePoles array of poles of the surface
94f71cad 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 TColgp_Array2OfPnt& thePoles,
0e14656b 57 const TColStd_Array2OfReal* theWeights = NULL);
94f71cad 58
59 //! Verifies validity of the cache using parameters of the point
60 //! \param theParameterU first parameter of the point placed in the span
61 //! \param theParameterV second parameter of the point placed in the span
62 Standard_EXPORT Standard_Boolean IsCacheValid(Standard_Real theParameterU,
63 Standard_Real theParameterV) const;
64
65 //! Recomputes the cache data. Does not verify validity of the cache
66 //! \param theParameterU the parametric value on the U axis to identify the span
67 //! \param theParameterV the parametric value on the V axis to identify the span
c8b5b3d8 68 //! \param theDegreeU degree along U axis
69 //! \param thePeriodicU identify whether the surface is periodic along U axis
70 //! \param theFlatKnotsU flat knots of the surface along U axis
71 //! \param theDegreeV degree along V axis
72 //! \param thePeriodicV identify whether the surface is periodic along V axis
73 //! \param theFlatKnotsV flat knots of the surface along V axis
74 //! \param thePoles array of poles of the surface
94f71cad 75 //! \param theWeights array of weights of corresponding poles
76 Standard_EXPORT void BuildCache(const Standard_Real& theParameterU,
77 const Standard_Real& theParameterV,
78 const Standard_Integer& theDegreeU,
79 const Standard_Boolean& thePeriodicU,
80 const TColStd_Array1OfReal& theFlatKnotsU,
81 const Standard_Integer& theDegreeV,
82 const Standard_Boolean& thePeriodicV,
83 const TColStd_Array1OfReal& theFlatKnotsV,
84 const TColgp_Array2OfPnt& thePoles,
0e14656b 85 const TColStd_Array2OfReal* theWeights = NULL);
94f71cad 86
c8b5b3d8 87 //! Calculates the point on the surface for specified parameters
94f71cad 88 //! \param[in] theU first parameter for calculation of the value
89 //! \param[in] theV second parameter for calculation of the value
c8b5b3d8 90 //! \param[out] thePoint the result of calculation (the point on the surface)
94f71cad 91 Standard_EXPORT void D0(const Standard_Real& theU, const Standard_Real& theV, gp_Pnt& thePoint) const;
92
c8b5b3d8 93 //! Calculates the point on the surface and its first derivative
94f71cad 94 //! \param[in] theU first parameter of calculation of the value
95 //! \param[in] theV second parameter of calculation of the value
c8b5b3d8 96 //! \param[out] thePoint the result of calculation (the point on the surface)
94f71cad 97 //! \param[out] theTangentU tangent vector along U axis in the calculated point
98 //! \param[out] theTangentV tangent vector along V axis in the calculated point
99 Standard_EXPORT void D1(const Standard_Real& theU,
100 const Standard_Real& theV,
101 gp_Pnt& thePoint,
102 gp_Vec& theTangentU,
103 gp_Vec& theTangentV) const;
104
c8b5b3d8 105 //! Calculates the point on the surface and derivatives till second order
94f71cad 106 //! \param[in] theU first parameter of calculation of the value
107 //! \param[in] theV second parameter of calculation of the value
c8b5b3d8 108 //! \param[out] thePoint the result of calculation (the point on the surface)
94f71cad 109 //! \param[out] theTangentU tangent vector along U axis in the calculated point
110 //! \param[out] theTangentV tangent vector along V axis in the calculated point
111 //! \param[out] theCurvatureU curvature vector (2nd derivative on U) along U axis
112 //! \param[out] theCurvatureV curvature vector (2nd derivative on V) along V axis
113 //! \param[out] theCurvatureUV 2nd mixed derivative on U anv V
114 Standard_EXPORT void D2(const Standard_Real& theU,
115 const Standard_Real& theV,
116 gp_Pnt& thePoint,
117 gp_Vec& theTangentU,
118 gp_Vec& theTangentV,
119 gp_Vec& theCurvatureU,
120 gp_Vec& theCurvatureV,
121 gp_Vec& theCurvatureUV) const;
122
123
92efcf78 124 DEFINE_STANDARD_RTTIEXT(BSplSLib_Cache,Standard_Transient)
94f71cad 125
126protected:
c8b5b3d8 127 //! Normalizes the parameter for periodical surfaces
128 //! \param[in] theDegree degree along selected direction
94f71cad 129 //! \param[in] theFlatKnots knots with repetitions along selected direction
130 //! \param[in,out] theParameter the value to be normalized into the knots array
131 void PeriodicNormalization(const Standard_Integer& theDegree,
132 const TColStd_Array1OfReal& theFlatKnots,
133 Standard_Real& theParameter) const;
134
135private:
136 Handle(TColStd_HArray2OfReal) myPolesWeights; ///< array of poles and weights of calculated cache
137 // the array has following structure:
138 // x11 y11 z11 [w11] x12 y12 z12 [w12] ...
139 // x21 y21 z21 [w21] x22 y22 z22 [w22] etc
140 // for non-rational surfaces there is no weight;
141 // size of array: (max(myDegree)+1) * A*(min(myDegree)+1), where A = 4 or 3
142
c8b5b3d8 143 Standard_Boolean myIsRational; ///< identifies the rationality of Bezier/B-spline surface
94f71cad 144 Standard_Real mySpanStart[2]; ///< parameters (u, v) for the frst point of the span
145 Standard_Real mySpanLength[2]; ///< lengths of the span along corresponding parameter
c8b5b3d8 146 Standard_Integer mySpanIndex[2]; ///< indexes of the span on Bezier/B-spline surface
f3a1c0cb 147 Standard_Integer mySpanIndexMin[2]; ///< minimal indexes of span
94f71cad 148 Standard_Integer mySpanIndexMax[2]; ///< maximal indexes of span
c8b5b3d8 149 Standard_Integer myDegree[2]; ///< degrees of Bezier/B-spline for each parameter
150 Handle(TColStd_HArray1OfReal) myFlatKnots[2]; ///< arrays of knots of Bezier/B-spline
94f71cad 151 // (used for periodic normalization of parameters, Null for non-periodical splines)
152};
153
154DEFINE_STANDARD_HANDLE(BSplSLib_Cache, Standard_Transient)
155
156#endif