diff --git a/src/Geom/Geom_BSplineCurve.cdl b/src/Geom/Geom_BSplineCurve.cdl index e75a5f0abc..83711c391f 100755 --- a/src/Geom/Geom_BSplineCurve.cdl +++ b/src/Geom/Geom_BSplineCurve.cdl @@ -124,7 +124,8 @@ uses Array1OfInteger from TColStd, Vec from gp, BSplKnotDistribution from GeomAbs, Geometry from Geom, - Shape from GeomAbs + Shape from GeomAbs, + Mutex from Standard raises ConstructionError from Standard, @@ -1035,4 +1036,6 @@ fields maxderivinv : Real from Standard; maxderivinvok : Boolean from Standard; + myMutex : Mutex from Standard; + -- protected bspline-cache end; diff --git a/src/Geom/Geom_BSplineCurve_1.cxx b/src/Geom/Geom_BSplineCurve_1.cxx index 740e30b665..bdd16cc365 100755 --- a/src/Geom/Geom_BSplineCurve_1.cxx +++ b/src/Geom/Geom_BSplineCurve_1.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #define POLES (poles->Array1()) #define KNOTS (knots->Array1()) @@ -105,36 +106,36 @@ Standard_Integer Geom_BSplineCurve::Degree () const //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); } } @@ -147,32 +148,36 @@ void Geom_BSplineCurve::D1 (const Standard_Real U, 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); } } @@ -181,20 +186,22 @@ Standard_Real NewU = U ; //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, @@ -203,7 +210,7 @@ void Geom_BSplineCurve::D2 (const Standard_Real U , cacheweights->Array1(), P, V1, - V2) ; + V2); } else { BSplCLib::CacheD2(NewU, @@ -214,7 +221,7 @@ void Geom_BSplineCurve::D2 (const Standard_Real U , *((TColStd_Array1OfReal*) NULL), P, V1, - V2) ; + V2); } } @@ -223,21 +230,24 @@ void Geom_BSplineCurve::D2 (const Standard_Real U , //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, @@ -249,12 +259,13 @@ Standard_Real NewU = U ; V2, V3) ; } - else { + else + { BSplCLib::CacheD3(NewU, deg, parametercache, spanlenghtcache, - (cachepoles->Array1()), + cachepoles->Array1(), *((TColStd_Array1OfReal*) NULL), P, V1, diff --git a/src/Geom/Geom_BSplineSurface.cdl b/src/Geom/Geom_BSplineSurface.cdl index d3c9149d0a..102802f366 100755 --- a/src/Geom/Geom_BSplineSurface.cdl +++ b/src/Geom/Geom_BSplineSurface.cdl @@ -153,8 +153,8 @@ uses Array1OfInteger from TColStd, 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, @@ -1487,4 +1487,7 @@ fields vmaxderivinv : Real from Standard; maxderivinvok : Boolean from Standard; + myMutex : Mutex from Standard; + -- protected bsplinesurface-cache + end; diff --git a/src/Geom/Geom_BSplineSurface_1.cxx b/src/Geom/Geom_BSplineSurface_1.cxx index e36e06563a..9ffc3a17d8 100755 --- a/src/Geom/Geom_BSplineSurface_1.cxx +++ b/src/Geom/Geom_BSplineSurface_1.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #define POLES (poles->Array2()) #define WEIGHTS (weights->Array2()) @@ -111,21 +112,19 @@ Standard_Boolean Geom_BSplineSurface::IsCNv //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, @@ -164,23 +163,20 @@ void Geom_BSplineSurface::D0 (const Standard_Real U, //purpose : //======================================================================= -void Geom_BSplineSurface::D1 (const Standard_Real U, - const Standard_Real V, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V) const +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) ; - } + 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, @@ -235,18 +231,14 @@ void Geom_BSplineSurface::D2 (const Standard_Real U, gp_Vec& D2V, gp_Vec& D2UV) const { + Standard_Real new_u(U), new_v(V); + PeriodicNormalization(new_u, new_v); - 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) ; - } + 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, diff --git a/src/Geom2d/Geom2d_BSplineCurve.cdl b/src/Geom2d/Geom2d_BSplineCurve.cdl index 530840b352..33545954f6 100755 --- a/src/Geom2d/Geom2d_BSplineCurve.cdl +++ b/src/Geom2d/Geom2d_BSplineCurve.cdl @@ -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; diff --git a/src/Geom2d/Geom2d_BSplineCurve_1.cxx b/src/Geom2d/Geom2d_BSplineCurve_1.cxx index f1c0f0a7ff..7122ccdd0e 100755 --- a/src/Geom2d/Geom2d_BSplineCurve_1.cxx +++ b/src/Geom2d/Geom2d_BSplineCurve_1.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #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,