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).
Vec from gp,
BSplKnotDistribution from GeomAbs,
Geometry from Geom,
- Shape from GeomAbs
+ Shape from GeomAbs,
+ Mutex from Standard
raises ConstructionError from Standard,
maxderivinv : Real from Standard;
maxderivinvok : Boolean from Standard;
+ myMutex : Mutex from Standard;
+ -- protected bspline-cache
end;
#include <Standard_OutOfRange.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_RangeError.hxx>
+#include <Standard_Mutex.hxx>
#define POLES (poles->Array1())
#define KNOTS (knots->Array1())
//purpose :
//=======================================================================
-void Geom_BSplineCurve::D0 ( const Standard_Real U,
- gp_Pnt& P) const
+void Geom_BSplineCurve::D0(const Standard_Real U, gp_Pnt& P) const
{
- Standard_Real NewU = U ;
- PeriodicNormalization(NewU) ;
- if (!IsCacheValid(NewU))
- {
- Geom_BSplineCurve * MyCurve = (Geom_BSplineCurve *) this ;
- MyCurve->ValidateCache(NewU) ;
- }
- if (rational) {
+ Standard_Real NewU(U);
+ PeriodicNormalization(NewU);
+
+ Geom_BSplineCurve* MyCurve = (Geom_BSplineCurve *) this;
+ Standard_Mutex::Sentry aSentry(MyCurve->myMutex);
+ if(!IsCacheValid(NewU))
+ MyCurve->ValidateCache(NewU);
+
+ if(rational)
+ {
BSplCLib::CacheD0(NewU,
- deg,
- parametercache,
- spanlenghtcache,
- (cachepoles->Array1()),
- cacheweights->Array1(),
- P) ;
-
+ deg,
+ parametercache,
+ spanlenghtcache,
+ cachepoles->Array1(),
+ cacheweights->Array1(),
+ P);
}
- else {
-
+ else
+ {
BSplCLib::CacheD0(NewU,
- deg,
- parametercache,
- spanlenghtcache,
- (cachepoles->Array1()),
- *((TColStd_Array1OfReal*) NULL),
- P) ;
+ deg,
+ parametercache,
+ spanlenghtcache,
+ cachepoles->Array1(),
+ *((TColStd_Array1OfReal*) NULL),
+ P);
}
}
gp_Pnt& P,
gp_Vec& V1) const
{
-Standard_Real NewU = U ;
- PeriodicNormalization(NewU) ;
- if (!IsCacheValid(NewU))
- {
- Geom_BSplineCurve * MyCurve = (Geom_BSplineCurve *) this ;
- MyCurve->ValidateCache(NewU) ;
- }
- if (rational) {
+ Standard_Real NewU(U);
+ PeriodicNormalization(NewU);
+
+ Geom_BSplineCurve* MyCurve = (Geom_BSplineCurve *) this;
+ Standard_Mutex::Sentry aSentry(MyCurve->myMutex);
+
+ if(!IsCacheValid(NewU))
+ MyCurve->ValidateCache(NewU);
+
+ if(rational)
+ {
BSplCLib::CacheD1(NewU,
- deg,
- parametercache,
- spanlenghtcache,
- (cachepoles->Array1()),
- cacheweights->Array1(),
- P,
- V1) ;
+ deg,
+ parametercache,
+ spanlenghtcache,
+ cachepoles->Array1(),
+ cacheweights->Array1(),
+ P,
+ V1);
}
- else {
+ else
+ {
BSplCLib::CacheD1(NewU,
- deg,
- parametercache,
- spanlenghtcache,
- (cachepoles->Array1()),
- *((TColStd_Array1OfReal*) NULL),
- P,
- V1) ;
+ deg,
+ parametercache,
+ spanlenghtcache,
+ cachepoles->Array1(),
+ *((TColStd_Array1OfReal*) NULL),
+ P,
+ V1);
}
}
//purpose :
//=======================================================================
-void Geom_BSplineCurve::D2 (const Standard_Real U ,
- gp_Pnt& P ,
- gp_Vec& V1,
- gp_Vec& V2 ) const
+void Geom_BSplineCurve::D2(const Standard_Real U,
+ gp_Pnt& P,
+ gp_Vec& V1,
+ gp_Vec& V2) const
{
-
- Standard_Real NewU = U ;
- PeriodicNormalization(NewU) ;
- if (!IsCacheValid(NewU))
- {
- Geom_BSplineCurve * MyCurve = (Geom_BSplineCurve *) this ;
- MyCurve->ValidateCache(NewU) ;
- }
- if (rational) {
+ Standard_Real NewU(U);
+ PeriodicNormalization(NewU);
+
+ Geom_BSplineCurve* MyCurve = (Geom_BSplineCurve *) this;
+ Standard_Mutex::Sentry aSentry(MyCurve->myMutex);
+
+ if(!IsCacheValid(NewU))
+ MyCurve->ValidateCache(NewU);
+
+ if(rational)
+ {
BSplCLib::CacheD2(NewU,
deg,
parametercache,
cacheweights->Array1(),
P,
V1,
- V2) ;
+ V2);
}
else {
BSplCLib::CacheD2(NewU,
*((TColStd_Array1OfReal*) NULL),
P,
V1,
- V2) ;
+ V2);
}
}
//purpose :
//=======================================================================
-void Geom_BSplineCurve::D3 (const Standard_Real U ,
- gp_Pnt& P ,
- gp_Vec& V1,
- gp_Vec& V2,
- gp_Vec& V3 ) const
+void Geom_BSplineCurve::D3(const Standard_Real U,
+ gp_Pnt& P,
+ gp_Vec& V1,
+ gp_Vec& V2,
+ gp_Vec& V3) const
{
-Standard_Real NewU = U ;
- PeriodicNormalization(NewU) ;
- if (!IsCacheValid(NewU))
- {
- Geom_BSplineCurve * MyCurve = (Geom_BSplineCurve *) this ;
- MyCurve->ValidateCache(NewU) ;
- }
- if (rational) {
+ Standard_Real NewU(U);
+ PeriodicNormalization(NewU);
+
+ Geom_BSplineCurve* MyCurve = (Geom_BSplineCurve *) this;
+ Standard_Mutex::Sentry aSentry(MyCurve->myMutex);
+
+ if(!IsCacheValid(NewU))
+ MyCurve->ValidateCache(NewU);
+
+ if(rational)
+ {
BSplCLib::CacheD3(NewU,
deg,
parametercache,
V2,
V3) ;
}
- else {
+ else
+ {
BSplCLib::CacheD3(NewU,
deg,
parametercache,
spanlenghtcache,
- (cachepoles->Array1()),
+ cachepoles->Array1(),
*((TColStd_Array1OfReal*) NULL),
P,
V1,
BSplKnotDistribution from GeomAbs,
Curve from Geom,
Geometry from Geom,
- Shape from GeomAbs
-
+ Shape from GeomAbs,
+ Mutex from Standard
raises ConstructionError from Standard,
DimensionError from Standard,
vmaxderivinv : Real from Standard;
maxderivinvok : Boolean from Standard;
+ myMutex : Mutex from Standard;
+ -- protected bsplinesurface-cache
+
end;
#include <Standard_DimensionError.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_NotImplemented.hxx>
+#include <Standard_Mutex.hxx>
#define POLES (poles->Array2())
#define WEIGHTS (weights->Array2())
//purpose :
//=======================================================================
-void Geom_BSplineSurface::D0 (const Standard_Real U,
- const Standard_Real V,
- gp_Pnt& P ) const
+void Geom_BSplineSurface::D0(const Standard_Real U,
+ const Standard_Real V,
+ gp_Pnt& P) const
{
- Standard_Real new_u = U,
- new_v = V ;
- PeriodicNormalization(new_u,
- new_v) ;
- if (!IsCacheValid(new_u,
- new_v))
- {
- Geom_BSplineSurface * my_surface = (Geom_BSplineSurface *) this ;
- my_surface->ValidateCache(new_u,
- new_v) ;
- }
+ Standard_Real new_u(U), new_v(V);
+ PeriodicNormalization(new_u, new_v);
+
+ Geom_BSplineSurface* MySurface = (Geom_BSplineSurface *) this;
+ Standard_Mutex::Sentry aSentry(MySurface->myMutex);
+
+ if(!IsCacheValid(new_u, new_v))
+ MySurface->ValidateCache(new_u, new_v);
+
Standard_Real uparameter_11 = (2*ucacheparameter + ucachespanlenght)/2,
uspanlenght_11 = ucachespanlenght/2,
vparameter_11 = (2*vcacheparameter + vcachespanlenght)/2,
//purpose :
//=======================================================================
-void Geom_BSplineSurface::D1 (const Standard_Real U,
- const Standard_Real V,
- gp_Pnt& P,
- gp_Vec& D1U,
- gp_Vec& D1V) const
-{
- Standard_Real new_u = U,
- new_v = V ;
- PeriodicNormalization(new_u,
- new_v) ;
- if (!IsCacheValid(new_u,
- new_v))
- {
- Geom_BSplineSurface * my_surface = (Geom_BSplineSurface *) this ;
- my_surface->ValidateCache(new_u,
- new_v) ;
- }
+void Geom_BSplineSurface::D1(const Standard_Real U,
+ const Standard_Real V,
+ gp_Pnt& P,
+ gp_Vec& D1U,
+ gp_Vec& D1V) const
+{
+ Standard_Real new_u(U), new_v(V);
+ PeriodicNormalization(new_u, new_v);
+
+ Geom_BSplineSurface* MySurface = (Geom_BSplineSurface *) this;
+ Standard_Mutex::Sentry aSentry(MySurface->myMutex);
+
+ if(!IsCacheValid(new_u, new_v))
+ MySurface->ValidateCache(new_u, new_v);
Standard_Real uparameter_11 = (2*ucacheparameter + ucachespanlenght)/2,
uspanlenght_11 = ucachespanlenght/2,
gp_Vec& D2V,
gp_Vec& D2UV) const
{
+ Standard_Real new_u(U), new_v(V);
+ PeriodicNormalization(new_u, new_v);
+
+ Geom_BSplineSurface* MySurface = (Geom_BSplineSurface *) this;
+ Standard_Mutex::Sentry aSentry(MySurface->myMutex);
- Standard_Real new_u = U,
- new_v = V ;
- PeriodicNormalization(new_u,
- new_v) ;
- if (!IsCacheValid(new_u,
- new_v))
- {
- Geom_BSplineSurface * my_surface = (Geom_BSplineSurface *) this ;
- my_surface->ValidateCache(new_u,
- new_v) ;
- }
+ if(!IsCacheValid(new_u, new_v))
+ MySurface->ValidateCache(new_u, new_v);
Standard_Real uparameter_11 = (2*ucacheparameter + ucachespanlenght)/2,
uspanlenght_11 = ucachespanlenght/2,
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,
maxderivinv : Real from Standard;
maxderivinvok : Boolean from Standard;
+ myMutex : Mutex from Standard;
+ -- protected bspline-cache
+
end;
#include <Standard_OutOfRange.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_RangeError.hxx>
+#include <Standard_Mutex.hxx>
#define POLES (poles->Array1())
#define KNOTS (knots->Array1())
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,
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,
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,
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,