mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-18 14:27:39 +03:00
0023620: Follow up of 0022939 - make Bezier curve/surface evaluation thread-safe
1. Remove cache from Geom_BezierCurve, Geom2d_BezierCurve and Geom_BezierSurface 2. Add cache for Bezier curves into GeomAdaptor_Curve, Geom2dAdaptor_Curve and GeomAdaptor_Surface 3. Update comments in corresponding cache classes 4. Avoid frequent down-casting to B-splines in adaptors
This commit is contained in:
@@ -31,9 +31,9 @@
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
|
||||
//! \brief A cache class for B-spline curves.
|
||||
//! \brief A cache class for Bezier and B-spline curves.
|
||||
//!
|
||||
//! Defines all data, that can be cached on a span of B-spline curve.
|
||||
//! Defines all data, that can be cached on a span of a curve.
|
||||
//! The data should be recalculated in going from span to span.
|
||||
class BSplCLib_Cache : public Standard_Transient
|
||||
{
|
||||
@@ -41,10 +41,10 @@ public:
|
||||
//! Default constructor
|
||||
Standard_EXPORT BSplCLib_Cache();
|
||||
//! Constructor for caching of 2D curves
|
||||
//! \param theDegree degree of the B-spline
|
||||
//! \param thePeriodic identify the B-spline is periodic
|
||||
//! \param theFlatKnots knots of B-spline curve (with repetitions)
|
||||
//! \param thePoles2d array of poles of 2D B-spline
|
||||
//! \param theDegree degree of the curve
|
||||
//! \param thePeriodic identify the curve is periodic
|
||||
//! \param theFlatKnots knots of Bezier/B-spline curve (with repetitions)
|
||||
//! \param thePoles2d array of poles of 2D curve
|
||||
//! \param theWeights array of weights of corresponding poles
|
||||
Standard_EXPORT BSplCLib_Cache(const Standard_Integer& theDegree,
|
||||
const Standard_Boolean& thePeriodic,
|
||||
@@ -52,10 +52,10 @@ public:
|
||||
const TColgp_Array1OfPnt2d& thePoles2d,
|
||||
const TColStd_Array1OfReal* theWeights = NULL);
|
||||
//! Constructor for caching of 3D curves
|
||||
//! \param theDegree degree of the B-spline
|
||||
//! \param thePeriodic identify the B-spline is periodic
|
||||
//! \param theFlatKnots knots of B-spline curve (with repetitions)
|
||||
//! \param thePoles array of poles of 3D B-spline
|
||||
//! \param theDegree degree of the curve
|
||||
//! \param thePeriodic identify the curve is periodic
|
||||
//! \param theFlatKnots knots of Bezier/B-spline curve (with repetitions)
|
||||
//! \param thePoles array of poles of 3D curve
|
||||
//! \param theWeights array of weights of corresponding poles
|
||||
Standard_EXPORT BSplCLib_Cache(const Standard_Integer& theDegree,
|
||||
const Standard_Boolean& thePeriodic,
|
||||
@@ -69,10 +69,10 @@ public:
|
||||
|
||||
//! Recomputes the cache data for 2D curves. Does not verify validity of the cache
|
||||
//! \param theParameter the value on the knot's axis to identify the span
|
||||
//! \param theDegree degree of the B-spline
|
||||
//! \param thePeriodic identify the B-spline is periodic
|
||||
//! \param theFlatKnots knots of B-spline curve (with repetitions)
|
||||
//! \param thePoles2d array of poles of 2D B-spline
|
||||
//! \param theDegree degree of the curve
|
||||
//! \param thePeriodic identify the curve is periodic
|
||||
//! \param theFlatKnots knots of Bezier/B-spline curve (with repetitions)
|
||||
//! \param thePoles2d array of poles of 2D curve
|
||||
//! \param theWeights array of weights of corresponding poles
|
||||
Standard_EXPORT void BuildCache(const Standard_Real& theParameter,
|
||||
const Standard_Integer& theDegree,
|
||||
@@ -82,10 +82,10 @@ public:
|
||||
const TColStd_Array1OfReal* theWeights = NULL);
|
||||
//! Recomputes the cache data for 3D curves. Does not verify validity of the cache
|
||||
//! \param theParameter the value on the knot's axis to identify the span
|
||||
//! \param theDegree degree of the B-spline
|
||||
//! \param thePeriodic identify the B-spline is periodic
|
||||
//! \param theFlatKnots knots of B-spline curve (with repetitions)
|
||||
//! \param thePoles array of poles of 3D B-spline
|
||||
//! \param theDegree degree of the curve
|
||||
//! \param thePeriodic identify the curve is periodic
|
||||
//! \param theFlatKnots knots of Bezier/B-spline curve (with repetitions)
|
||||
//! \param thePoles array of poles of 3D curve
|
||||
//! \param theWeights array of weights of corresponding poles
|
||||
Standard_EXPORT void BuildCache(const Standard_Real& theParameter,
|
||||
const Standard_Integer& theDegree,
|
||||
@@ -94,24 +94,24 @@ public:
|
||||
const TColgp_Array1OfPnt& thePoles,
|
||||
const TColStd_Array1OfReal* theWeights = NULL);
|
||||
|
||||
//! Calculates the point on B-spline in the selected point
|
||||
//! Calculates the point on the curve in the specified parameter
|
||||
//! \param[in] theParameter parameter of calculation of the value
|
||||
//! \param[out] thePoint the result of calculation (the point on B-spline)
|
||||
//! \param[out] thePoint the result of calculation (the point on the curve)
|
||||
Standard_EXPORT void D0(const Standard_Real& theParameter, gp_Pnt2d& thePoint) const;
|
||||
Standard_EXPORT void D0(const Standard_Real& theParameter, gp_Pnt& thePoint) const;
|
||||
|
||||
//! Calculates the point on B-spline and its first derivative in the selected point
|
||||
//! Calculates the point on the curve and its first derivative in the specified parameter
|
||||
//! \param[in] theParameter parameter of calculation of the value
|
||||
//! \param[out] thePoint the result of calculation (the point on B-spline)
|
||||
//! \param[out] theTangent tangent vector (first derivatives) for B-spline in the calculated point
|
||||
//! \param[out] thePoint the result of calculation (the point on the curve)
|
||||
//! \param[out] theTangent tangent vector (first derivatives) for the curve in the calculated point
|
||||
Standard_EXPORT void D1(const Standard_Real& theParameter, gp_Pnt2d& thePoint, gp_Vec2d& theTangent) const;
|
||||
Standard_EXPORT void D1(const Standard_Real& theParameter, gp_Pnt& thePoint, gp_Vec& theTangent) const;
|
||||
|
||||
//! Calculates the point on B-spline and two derivatives in the selected point
|
||||
//! Calculates the point on the curve and two derivatives in the specified parameter
|
||||
//! \param[in] theParameter parameter of calculation of the value
|
||||
//! \param[out] thePoint the result of calculation (the point on B-spline)
|
||||
//! \param[out] theTangent tangent vector (1st derivatives) for B-spline in the calculated point
|
||||
//! \param[out] theCurvature curvature vector (2nd derivatives) for B-spline in the calculated point
|
||||
//! \param[out] thePoint the result of calculation (the point on the curve)
|
||||
//! \param[out] theTangent tangent vector (1st derivatives) for the curve in the calculated point
|
||||
//! \param[out] theCurvature curvature vector (2nd derivatives) for the curve in the calculated point
|
||||
Standard_EXPORT void D2(const Standard_Real& theParameter,
|
||||
gp_Pnt2d& thePoint,
|
||||
gp_Vec2d& theTangent,
|
||||
@@ -121,12 +121,12 @@ public:
|
||||
gp_Vec& theTangent,
|
||||
gp_Vec& theCurvature) const;
|
||||
|
||||
//! Calculates the point on B-spline and three derivatives in the selected point
|
||||
//! Calculates the point on the curve and three derivatives in the specified parameter
|
||||
//! \param[in] theParameter parameter of calculation of the value
|
||||
//! \param[out] thePoint the result of calculation (the point on B-spline)
|
||||
//! \param[out] theTangent tangent vector (1st derivatives) for B-spline in the calculated point
|
||||
//! \param[out] theCurvature curvature vector (2nd derivatives) for B-spline in the calculated point
|
||||
//! \param[out] theTorsion second curvature vector (3rd derivatives) for B-spline in the calculated point
|
||||
//! \param[out] thePoint the result of calculation (the point on the curve)
|
||||
//! \param[out] theTangent tangent vector (1st derivatives) for the curve in the calculated point
|
||||
//! \param[out] theCurvature curvature vector (2nd derivatives) for the curve in the calculated point
|
||||
//! \param[out] theTorsion second curvature vector (3rd derivatives) for the curve in the calculated point
|
||||
Standard_EXPORT void D3(const Standard_Real& theParameter,
|
||||
gp_Pnt2d& thePoint,
|
||||
gp_Vec2d& theTangent,
|
||||
@@ -142,16 +142,16 @@ public:
|
||||
DEFINE_STANDARD_RTTI(BSplCLib_Cache, Standard_Transient)
|
||||
|
||||
protected:
|
||||
//! Normalizes the parameter for periodical B-splines
|
||||
//! Normalizes the parameter for periodical curves
|
||||
//! \param theFlatKnots knots with repetitions
|
||||
//! \param theParameter the value to be normalized into the knots array
|
||||
void PeriodicNormalization(const TColStd_Array1OfReal& theFlatKnots, Standard_Real& theParameter) const;
|
||||
|
||||
//! Fills array of derivatives in the selected point of the B-spline
|
||||
//! Fills array of derivatives in the selected point of the curve
|
||||
//! \param[in] theParameter parameter of the calculation
|
||||
//! \param[in] theDerivative maximal derivative to be calculated (computes all derivatives lesser than specified)
|
||||
//! \param[out] theDerivArray result array of derivatives (with size (theDerivative+1)*(PntDim+1),
|
||||
//! where PntDim = 2 or 3 is a dimension of B-spline curve)
|
||||
//! where PntDim = 2 or 3 is a dimension of the curve)
|
||||
void CalculateDerivative(const Standard_Real& theParameter,
|
||||
const Standard_Integer& theDerivative,
|
||||
Standard_Real& theDerivArray) const;
|
||||
@@ -163,13 +163,13 @@ private:
|
||||
// x2 y2 [z2] [w2] etc
|
||||
// for 2D-curves there is no z conponent, for non-rational curves there is no weight
|
||||
|
||||
Standard_Boolean myIsRational; ///< identifies the rationality of B-spline
|
||||
Standard_Boolean myIsRational; ///< identifies the rationality of Bezier/B-spline curve
|
||||
Standard_Real mySpanStart; ///< parameter for the first point of the span
|
||||
Standard_Real mySpanLength; ///< length of the span
|
||||
Standard_Integer mySpanIndex; ///< index of the span on B-spline curve
|
||||
Standard_Integer mySpanIndexMax; ///< maximal number of spans on B-spline curve
|
||||
Standard_Integer myDegree; ///< degree of B-spline
|
||||
Handle(TColStd_HArray1OfReal) myFlatKnots; ///< knots of B-spline (used for periodic normalization of parameters, exists only for periodical splines)
|
||||
Standard_Integer mySpanIndex; ///< index of the span on Bezier/B-spline curve
|
||||
Standard_Integer mySpanIndexMax; ///< maximal number of spans on Bezier/B-spline curve
|
||||
Standard_Integer myDegree; ///< degree of Bezier/B-spline
|
||||
Handle(TColStd_HArray1OfReal) myFlatKnots; ///< knots of Bezier/B-spline (used for periodic normalization of parameters, exists only for periodical splines)
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(BSplCLib_Cache, Standard_Transient)
|
||||
|
Reference in New Issue
Block a user