0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[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
0a96e0bb 32#include <BSplCLib_CacheParams.hxx>
33
c8b5b3d8 34//! \brief A cache class for Bezier and B-spline surfaces.
94f71cad 35//!
c8b5b3d8 36//! Defines all data, that can be cached on a span of the surface.
94f71cad 37//! The data should be recalculated in going from span to span.
38class BSplSLib_Cache : public Standard_Transient
39{
40public:
0a96e0bb 41
c8b5b3d8 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
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,
0e14656b 56 const TColStd_Array2OfReal* theWeights = NULL);
94f71cad 57
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;
63
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
c8b5b3d8 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
94f71cad 74 //! \param theWeights array of weights of corresponding poles
0a96e0bb 75 Standard_EXPORT void BuildCache(const Standard_Real& theParameterU,
76 const Standard_Real& theParameterV,
77 const TColStd_Array1OfReal& theFlatKnotsU,
78 const TColStd_Array1OfReal& theFlatKnotsV,
94f71cad 79 const TColgp_Array2OfPnt& thePoles,
0e14656b 80 const TColStd_Array2OfReal* theWeights = NULL);
94f71cad 81
c8b5b3d8 82 //! Calculates the point on the surface for specified parameters
94f71cad 83 //! \param[in] theU first parameter for calculation of the value
84 //! \param[in] theV second parameter for calculation of the value
c8b5b3d8 85 //! \param[out] thePoint the result of calculation (the point on the surface)
94f71cad 86 Standard_EXPORT void D0(const Standard_Real& theU, const Standard_Real& theV, gp_Pnt& thePoint) const;
87
c8b5b3d8 88 //! Calculates the point on the surface and its first derivative
94f71cad 89 //! \param[in] theU first parameter of calculation of the value
90 //! \param[in] theV second parameter of calculation of the value
c8b5b3d8 91 //! \param[out] thePoint the result of calculation (the point on the surface)
94f71cad 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,
96 gp_Pnt& thePoint,
97 gp_Vec& theTangentU,
98 gp_Vec& theTangentV) const;
99
c8b5b3d8 100 //! Calculates the point on the surface and derivatives till second order
94f71cad 101 //! \param[in] theU first parameter of calculation of the value
102 //! \param[in] theV second parameter of calculation of the value
c8b5b3d8 103 //! \param[out] thePoint the result of calculation (the point on the surface)
94f71cad 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,
111 gp_Pnt& thePoint,
112 gp_Vec& theTangentU,
113 gp_Vec& theTangentV,
114 gp_Vec& theCurvatureU,
115 gp_Vec& theCurvatureV,
116 gp_Vec& theCurvatureUV) const;
117
118
92efcf78 119 DEFINE_STANDARD_RTTIEXT(BSplSLib_Cache,Standard_Transient)
94f71cad 120
0a96e0bb 121private:
122 // copying is prohibited
123 BSplSLib_Cache (const BSplSLib_Cache&);
124 void operator = (const BSplSLib_Cache&);
94f71cad 125
126private:
0a96e0bb 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
94f71cad 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
94f71cad 135};
136
137DEFINE_STANDARD_HANDLE(BSplSLib_Cache, Standard_Transient)
138
139#endif