mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0022550: Fixing data races
This commit is contained in:
@@ -18,11 +18,9 @@
|
||||
// in TangExtendToConstraint; Continuity can be equal to 0
|
||||
//
|
||||
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
|
||||
#include <BSplCLib.ixx>
|
||||
#include <PLib.hxx>
|
||||
#include <PLib_LocalArray.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
|
||||
@@ -40,51 +38,22 @@ typedef TColStd_Array1OfInteger Array1OfInteger;
|
||||
|
||||
class BSplCLib_LocalMatrix : public math_Matrix
|
||||
{
|
||||
public:
|
||||
public:
|
||||
BSplCLib_LocalMatrix (Standard_Integer DerivativeRequest, Standard_Integer Order)
|
||||
: math_Matrix (myBuffer, 1, DerivativeRequest + 1, 1, Order)
|
||||
{
|
||||
if ( DerivativeRequest > BSplCLib::MaxDegree() ||
|
||||
Order > BSplCLib::MaxDegree()+1 ||
|
||||
BSplCLib::MaxDegree() > 25 )
|
||||
Standard_OutOfRange::Raise ("BSplCLib: bspline degree is greater than maximum supported");
|
||||
Standard_OutOfRange_Raise_if (DerivativeRequest > BSplCLib::MaxDegree() ||
|
||||
Order > BSplCLib::MaxDegree()+1 || BSplCLib::MaxDegree() > 25,
|
||||
"BSplCLib: bspline degree is greater than maximum supported");
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
// local buffer, to be sufficient for addressing by index [Degree+1][Degree+1]
|
||||
// (see math_Matrix implementation)
|
||||
Standard_Real myBuffer[27*27];
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
//class : BSplCLib_LocalArray
|
||||
//purpose: Auxiliary class optimizing creation of array buffer for
|
||||
// evaluation of bspline (using stack allocation for small arrays)
|
||||
//=======================================================================
|
||||
|
||||
#define LOCARRAY_BUFFER 1024
|
||||
class BSplCLib_LocalArray
|
||||
{
|
||||
public:
|
||||
BSplCLib_LocalArray (Standard_Integer Size)
|
||||
: myPtr(myBuffer)
|
||||
{
|
||||
if ( Size > LOCARRAY_BUFFER )
|
||||
myPtr = (Standard_Real*)Standard::Allocate (Size * sizeof(Standard_Real));
|
||||
}
|
||||
|
||||
~BSplCLib_LocalArray ()
|
||||
{
|
||||
if ( myPtr != myBuffer )
|
||||
Standard::Free (*(Standard_Address*)&myPtr);
|
||||
}
|
||||
|
||||
Standard_Real& operator [] (int i) { return myPtr[i]; }
|
||||
|
||||
private:
|
||||
Standard_Real myBuffer[LOCARRAY_BUFFER];
|
||||
Standard_Real* myPtr;
|
||||
};
|
||||
typedef PLib_LocalArray BSplCLib_LocalArray;
|
||||
|
||||
//=======================================================================
|
||||
//function : Hunt
|
||||
@@ -4172,13 +4141,13 @@ void BSplCLib::Resolution( Standard_Real& Poles,
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
|
||||
// array of flat knots for bezier curve of maximum 25 degree
|
||||
static const Standard_Real knots[52] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||
const Standard_Real& BSplCLib::FlatBezierKnots (const Standard_Integer Degree)
|
||||
{
|
||||
if ( Degree < 1 || Degree > MaxDegree() || MaxDegree() != 25 )
|
||||
Standard_OutOfRange::Raise ("Bezier curve degree greater than maximal supported");
|
||||
|
||||
// array of flat knots for bezier curve of maximum 25 degree
|
||||
static Standard_Real knots[52] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||
Standard_OutOfRange_Raise_if (Degree < 1 || Degree > MaxDegree() || MaxDegree() != 25,
|
||||
"Bezier curve degree greater than maximal supported");
|
||||
|
||||
return knots[25-Degree];
|
||||
}
|
||||
|
@@ -4,9 +4,6 @@
|
||||
// BSpline Curve in 2d space
|
||||
// **************************
|
||||
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
|
||||
#define Dimension_gen 2
|
||||
|
||||
#define Array1OfPoints TColgp_Array1OfPnt2d
|
||||
@@ -38,4 +35,3 @@
|
||||
#define BSplCLib_DataContainer BSplCLib_DataContainer_2d
|
||||
|
||||
#include <BSplCLib_CurveComputation.gxx>
|
||||
|
||||
|
@@ -6,9 +6,6 @@
|
||||
// EvalBsplineBasis,
|
||||
// EvalPolynomial : Horners method
|
||||
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
|
||||
#include <Standard_Stream.hxx>
|
||||
|
||||
#include <BSplCLib.hxx>
|
||||
@@ -30,10 +27,11 @@
|
||||
|
||||
struct BSplCLib_DataContainer
|
||||
{
|
||||
BSplCLib_DataContainer(Standard_Integer Degree)
|
||||
BSplCLib_DataContainer(Standard_Integer Degree)
|
||||
{
|
||||
if ( Degree > BSplCLib::MaxDegree() || BSplCLib::MaxDegree() > 25 )
|
||||
Standard_OutOfRange::Raise ("BSplCLib: bspline degree is greater than maximum supported");
|
||||
Standard_OutOfRange_Raise_if (Degree > BSplCLib::MaxDegree() ||
|
||||
BSplCLib::MaxDegree() > 25,
|
||||
"BSplCLib: bspline degree is greater than maximum supported");
|
||||
}
|
||||
|
||||
Standard_Real poles[2*(25+1)];
|
||||
@@ -918,11 +916,11 @@ void BSplCLib::FunctionMultiply
|
||||
|
||||
for (ii = 1 ; ii <= num_new_poles ; ii++) {
|
||||
contact_order_array(ii) = 0 ;
|
||||
(*FunctionPtr)(contact_order_array(ii),
|
||||
FunctionPtr.Evaluate (contact_order_array(ii),
|
||||
start_end,
|
||||
parameters(ii),
|
||||
result,
|
||||
error_code) ;
|
||||
error_code);
|
||||
if (error_code) {
|
||||
Status = 1 ;
|
||||
goto FINISH ;
|
||||
@@ -1008,11 +1006,11 @@ void BSplCLib::FunctionReparameterise
|
||||
|
||||
for (ii = 1 ; ii <= num_new_poles ; ii++) {
|
||||
contact_order_array(ii) = 0 ;
|
||||
(*FunctionPtr)(contact_order_array(ii),
|
||||
FunctionPtr.Evaluate (contact_order_array(ii),
|
||||
start_end,
|
||||
parameters(ii),
|
||||
result,
|
||||
error_code) ;
|
||||
error_code);
|
||||
if (error_code) {
|
||||
Status = 1 ;
|
||||
goto FINISH ;
|
||||
|
@@ -9,9 +9,6 @@
|
||||
// BSpline Curve in 3d space
|
||||
// ***************************
|
||||
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
|
||||
#define Dimension_gen 3
|
||||
|
||||
#define Array1OfPoints TColgp_Array1OfPnt
|
||||
@@ -47,4 +44,3 @@
|
||||
#define BSplCLib_DataContainer BSplCLib_DataContainer_3d
|
||||
|
||||
#include <BSplCLib_CurveComputation.gxx>
|
||||
|
||||
|
@@ -11,9 +11,6 @@
|
||||
#include <PLib.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
|
||||
#define No_Standard_RangeError
|
||||
#define No_Standard_OutOfRange
|
||||
|
||||
//=======================================================================
|
||||
//struct : BSplCLib_DataContainer
|
||||
//purpose: Auxiliary structure providing buffers for poles and knots used in
|
||||
@@ -24,8 +21,9 @@ struct BSplCLib_DataContainer
|
||||
{
|
||||
BSplCLib_DataContainer(Standard_Integer Degree)
|
||||
{
|
||||
if ( Degree > BSplCLib::MaxDegree() || BSplCLib::MaxDegree() > 25 )
|
||||
Standard_OutOfRange::Raise ("BSplCLib: bspline degree is greater than maximum supported");
|
||||
Standard_OutOfRange_Raise_if (Degree > BSplCLib::MaxDegree() ||
|
||||
BSplCLib::MaxDegree() > 25,
|
||||
"BSplCLib: bspline degree is greater than maximum supported");
|
||||
}
|
||||
|
||||
Standard_Real poles[(25+1)*(Dimension_gen+1)];
|
||||
@@ -1412,4 +1410,3 @@ void BSplCLib::FunctionReparameterise
|
||||
array_of_new_poles[0],
|
||||
Status) ;
|
||||
}
|
||||
|
||||
|
@@ -3,16 +3,9 @@
|
||||
// Author: Xavier BENVENISTE
|
||||
// <xab@zozox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#ifndef _BSplCLib_EvaluatorFunction_HeaderFile
|
||||
#define _BSplCLib_EvaluatorFunction_HeaderFile
|
||||
|
||||
|
||||
// File: AdvApprox_EvaluatorFunction.hxx
|
||||
// Created: Mon May 29 17:04:50 1995
|
||||
// Author: Xavier BENVENISTE
|
||||
// <xab@nonox>
|
||||
|
||||
#ifndef _Standard_Integer_HeaderFile
|
||||
#include <Standard_Integer.hxx>
|
||||
#endif
|
||||
@@ -22,18 +15,43 @@
|
||||
#ifndef _Standard_PrimitiveTypes_HeaderFile
|
||||
#include <Standard_PrimitiveTypes.hxx>
|
||||
#endif
|
||||
typedef void (* BSplCLib_EvaluatorFunction) (const Standard_Integer ,
|
||||
// Derivative Request
|
||||
const Standard_Real *,
|
||||
// StartEnd[2]
|
||||
const Standard_Real ,
|
||||
// Parameter
|
||||
Standard_Real &,
|
||||
// Result
|
||||
Standard_Integer & ) ;
|
||||
// Error Code
|
||||
|
||||
// History - C function pointer converted to a virtual class
|
||||
// in order to get rid of usage of static functions and static data
|
||||
class BSplCLib_EvaluatorFunction
|
||||
{
|
||||
public:
|
||||
|
||||
//! Empty constructor
|
||||
BSplCLib_EvaluatorFunction () {}
|
||||
|
||||
//! Destructor should be declared as virtual
|
||||
virtual ~BSplCLib_EvaluatorFunction () {}
|
||||
|
||||
//! Function evaluation method to be defined by descendant
|
||||
virtual void Evaluate (const Standard_Integer theDerivativeRequest,
|
||||
const Standard_Real* theStartEnd,
|
||||
const Standard_Real theParameter,
|
||||
Standard_Real& theResult,
|
||||
Standard_Integer& theErrorCode) const = 0;
|
||||
|
||||
//! Shortcut for function-call style usage
|
||||
void operator () (const Standard_Integer theDerivativeRequest,
|
||||
const Standard_Real* theStartEnd,
|
||||
const Standard_Real theParameter,
|
||||
Standard_Real& theResult,
|
||||
Standard_Integer& theErrorCode) const
|
||||
{
|
||||
Evaluate (theDerivativeRequest, theStartEnd, theParameter, theResult, theErrorCode);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Copy constructor is declared private to forbid copying
|
||||
BSplCLib_EvaluatorFunction (const BSplCLib_EvaluatorFunction&) {}
|
||||
|
||||
//! Assignment operator is declared private to forbid copying
|
||||
void operator = (const BSplCLib_EvaluatorFunction&) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user