mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0022939: Make B-Spline internal cache thread-safe to be used in multy-threaded mode
Internal cache in classes implementing b-spline curves and surface in Geom and Geom2d packages is protected from possible concurrency by mutex (added as a class field in each instance).
This commit is contained in:
@@ -129,8 +129,8 @@ uses Array1OfInteger from TColStd,
|
||||
Vec2d from gp,
|
||||
BSplKnotDistribution from GeomAbs,
|
||||
Geometry from Geom2d,
|
||||
Shape from GeomAbs
|
||||
|
||||
Shape from GeomAbs,
|
||||
Mutex from Standard
|
||||
|
||||
raises ConstructionError from Standard,
|
||||
DimensionError from Standard,
|
||||
@@ -1044,4 +1044,7 @@ fields
|
||||
maxderivinv : Real from Standard;
|
||||
maxderivinvok : Boolean from Standard;
|
||||
|
||||
myMutex : Mutex from Standard;
|
||||
-- protected bspline-cache
|
||||
|
||||
end;
|
||||
|
@@ -35,6 +35,7 @@
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <Standard_RangeError.hxx>
|
||||
#include <Standard_Mutex.hxx>
|
||||
|
||||
#define POLES (poles->Array1())
|
||||
#define KNOTS (knots->Array1())
|
||||
@@ -109,14 +110,17 @@ Standard_Integer Geom2d_BSplineCurve::Degree () const
|
||||
void Geom2d_BSplineCurve::D0 ( const Standard_Real U,
|
||||
gp_Pnt2d& P) const
|
||||
{
|
||||
Standard_Real NewU = U ;
|
||||
PeriodicNormalization(NewU) ;
|
||||
if (!IsCacheValid(NewU)) {
|
||||
Geom2d_BSplineCurve * MyCurve = (Geom2d_BSplineCurve *) this ;
|
||||
MyCurve->ValidateCache(NewU) ;
|
||||
}
|
||||
Standard_Real NewU(U);
|
||||
PeriodicNormalization(NewU);
|
||||
|
||||
Geom2d_BSplineCurve* MyCurve = (Geom2d_BSplineCurve *) this;
|
||||
Standard_Mutex::Sentry aSentry(MyCurve->myMutex);
|
||||
|
||||
if (!IsCacheValid(NewU))
|
||||
MyCurve->ValidateCache(NewU);
|
||||
|
||||
if ( rational ) {
|
||||
if(rational)
|
||||
{
|
||||
BSplCLib::CacheD0(NewU,
|
||||
deg,
|
||||
parametercache,
|
||||
@@ -146,14 +150,17 @@ void Geom2d_BSplineCurve::D1 (const Standard_Real U,
|
||||
gp_Pnt2d& P,
|
||||
gp_Vec2d& V1) const
|
||||
{
|
||||
Standard_Real NewU = U ;
|
||||
PeriodicNormalization(NewU) ;
|
||||
if (!IsCacheValid(NewU)) {
|
||||
Geom2d_BSplineCurve * MyCurve = (Geom2d_BSplineCurve *) this ;
|
||||
MyCurve->ValidateCache(NewU) ;
|
||||
}
|
||||
Standard_Real NewU(U);
|
||||
PeriodicNormalization(NewU);
|
||||
|
||||
if ( rational ) {
|
||||
Geom2d_BSplineCurve* MyCurve = (Geom2d_BSplineCurve *) this;
|
||||
Standard_Mutex::Sentry aSentry(MyCurve->myMutex);
|
||||
|
||||
if (!IsCacheValid(NewU))
|
||||
MyCurve->ValidateCache(NewU);
|
||||
|
||||
if(rational)
|
||||
{
|
||||
BSplCLib::CacheD1(NewU,
|
||||
deg,
|
||||
parametercache,
|
||||
@@ -185,14 +192,17 @@ void Geom2d_BSplineCurve::D2 (const Standard_Real U ,
|
||||
gp_Vec2d& V1,
|
||||
gp_Vec2d& V2 ) const
|
||||
{
|
||||
Standard_Real NewU = U ;
|
||||
PeriodicNormalization(NewU) ;
|
||||
if (!IsCacheValid(NewU)) {
|
||||
Geom2d_BSplineCurve * MyCurve = (Geom2d_BSplineCurve *) this ;
|
||||
MyCurve->ValidateCache(NewU) ;
|
||||
}
|
||||
Standard_Real NewU(U);
|
||||
PeriodicNormalization(NewU);
|
||||
|
||||
Geom2d_BSplineCurve* MyCurve = (Geom2d_BSplineCurve *) this;
|
||||
Standard_Mutex::Sentry aSentry(MyCurve->myMutex);
|
||||
|
||||
if (!IsCacheValid(NewU))
|
||||
MyCurve->ValidateCache(NewU);
|
||||
|
||||
if ( rational ) {
|
||||
if(rational)
|
||||
{
|
||||
BSplCLib::CacheD2(NewU,
|
||||
deg,
|
||||
parametercache,
|
||||
@@ -227,14 +237,17 @@ void Geom2d_BSplineCurve::D3 (const Standard_Real U ,
|
||||
gp_Vec2d& V2,
|
||||
gp_Vec2d& V3 ) const
|
||||
{
|
||||
Standard_Real NewU = U ;
|
||||
PeriodicNormalization(NewU) ;
|
||||
if (!IsCacheValid(NewU)) {
|
||||
Geom2d_BSplineCurve * MyCurve = (Geom2d_BSplineCurve *) this ;
|
||||
MyCurve->ValidateCache(NewU) ;
|
||||
}
|
||||
Standard_Real NewU(U);
|
||||
PeriodicNormalization(NewU);
|
||||
|
||||
if ( rational ) {
|
||||
Geom2d_BSplineCurve* MyCurve = (Geom2d_BSplineCurve *) this;
|
||||
Standard_Mutex::Sentry aSentry(MyCurve->myMutex);
|
||||
|
||||
if (!IsCacheValid(NewU))
|
||||
MyCurve->ValidateCache(NewU);
|
||||
|
||||
if(rational)
|
||||
{
|
||||
BSplCLib::CacheD3(NewU,
|
||||
deg,
|
||||
parametercache,
|
||||
|
Reference in New Issue
Block a user