1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

0024682: Move out B-spline cache from curves and surfaces to dedicated classes BSplCLib_Cache and BSplSLib_Cache

1. B-spline cache was moved into separated classes: BSplCLib_Cache for 2D and 3D curves and BSplSLib_Cache for surfaces.

2. The cache is used now in corresponding adaptor classes (Geom2dAdaptor_Curve, GeomAdaptor_Curve and GeomAdaptor_Surface) when the curve or surface is a B-spline.

3. Algorithms were changed to use adaptors for B-spline calculations instead of curves or surfaces.

4. Precised calculation of derivatives of surface of revolution is implemented for the points of surface placed on the axis of revolution (Geom_SurfaceOfRevolution.cxx)

5. Small modifications are made to adjust algorithms to new behavior of B-spline calculation.

6. Test cases were modified according to the modern behavior.

7. Changes in BOPAlgo_WireSplitter, BOPTools_AlgoTools, BRepLib_CheckCurveOnSurface and ShapeAnalysis_Wire to use adaptors instead of geometric entities

8. Allow Geom2dAdaptor and GeomAdaptor in case of offset curve to use corresponding adaptor for basis curve

Modification of test-cases according to the new behavior.
This commit is contained in:
azv
2015-05-28 13:36:57 +03:00
committed by bugmaster
parent 9176540c64
commit 94f71cad33
137 changed files with 4104 additions and 2503 deletions

View File

@@ -30,7 +30,7 @@
#include <Standard_OutOfRange.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_Mutex.hxx>
#include <Precision.hxx>
#define POLES (poles->Array1())
#define KNOTS (knots->Array1())
@@ -183,36 +183,28 @@ Standard_Integer Geom2d_BSplineCurve::Degree () const
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::D0 ( const Standard_Real U,
gp_Pnt2d& P) const
void Geom2d_BSplineCurve::D0(const Standard_Real U,
gp_Pnt2d& P) const
{
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)
Standard_Integer aSpanIndex = 0;
Standard_Real aNewU(U);
PeriodicNormalization(aNewU);
BSplCLib::LocateParameter(deg, knots->Array1(), mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--;
if (rational)
{
BSplCLib::CacheD0(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
cacheweights->Array1(),
P) ;
BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES,
weights->Array1(),
knots->Array1(), mults->Array1(),
P);
}
else {
BSplCLib::CacheD0(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
BSplCLib::NoWeights(),
P) ;
else
{
BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES,
*((TColStd_Array1OfReal*) NULL),
knots->Array1(), mults->Array1(),
P);
}
}
@@ -222,39 +214,29 @@ void Geom2d_BSplineCurve::D0 ( const Standard_Real U,
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::D1 (const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V1) const
void Geom2d_BSplineCurve::D1(const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V1) const
{
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)
Standard_Integer aSpanIndex = 0;
Standard_Real aNewU(U);
PeriodicNormalization(aNewU);
BSplCLib::LocateParameter(deg, knots->Array1(), mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--;
if (rational)
{
BSplCLib::CacheD1(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
cacheweights->Array1(),
P,
V1) ;
BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES,
weights->Array1(),
knots->Array1(), mults->Array1(),
P, V1);
}
else {
BSplCLib::CacheD1(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
BSplCLib::NoWeights(),
P,
V1) ;
else
{
BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES,
*((TColStd_Array1OfReal*) NULL),
knots->Array1(), mults->Array1(),
P, V1);
}
}
@@ -263,42 +245,30 @@ void Geom2d_BSplineCurve::D1 (const Standard_Real U,
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::D2 (const Standard_Real U ,
gp_Pnt2d& P ,
gp_Vec2d& V1,
gp_Vec2d& V2 ) const
void Geom2d_BSplineCurve::D2(const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2) const
{
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)
Standard_Integer aSpanIndex = 0;
Standard_Real aNewU(U);
PeriodicNormalization(aNewU);
BSplCLib::LocateParameter(deg, knots->Array1(), mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--;
if (rational)
{
BSplCLib::CacheD2(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
cacheweights->Array1(),
P,
V1,
V2) ;
BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES,
weights->Array1(),
knots->Array1(), mults->Array1(),
P, V1, V2);
}
else {
BSplCLib::CacheD2(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
BSplCLib::NoWeights(),
P,
V1,
V2) ;
else
{
BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES,
*((TColStd_Array1OfReal*) NULL),
knots->Array1(), mults->Array1(),
P, V1, V2);
}
}
@@ -307,45 +277,31 @@ void Geom2d_BSplineCurve::D2 (const Standard_Real U ,
//purpose :
//=======================================================================
void Geom2d_BSplineCurve::D3 (const Standard_Real U ,
gp_Pnt2d& P ,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3 ) const
void Geom2d_BSplineCurve::D3(const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3) const
{
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)
Standard_Integer aSpanIndex = 0;
Standard_Real aNewU(U);
PeriodicNormalization(aNewU);
BSplCLib::LocateParameter(deg, knots->Array1(), mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--;
if (rational)
{
BSplCLib::CacheD3(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
cacheweights->Array1(),
P,
V1,
V2,
V3) ;
BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES,
weights->Array1(),
knots->Array1(), mults->Array1(),
P, V1, V2, V3);
}
else {
BSplCLib::CacheD3(NewU,
deg,
parametercache,
spanlenghtcache,
(cachepoles->Array1()),
BSplCLib::NoWeights(),
P,
V1,
V2,
V3) ;
else
{
BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES,
*((TColStd_Array1OfReal*) NULL),
knots->Array1(), mults->Array1(),
P, V1, V2, V3);
}
}
@@ -354,20 +310,20 @@ void Geom2d_BSplineCurve::D3 (const Standard_Real U ,
//purpose :
//=======================================================================
gp_Vec2d Geom2d_BSplineCurve::DN (const Standard_Real U,
const Standard_Integer N ) const
gp_Vec2d Geom2d_BSplineCurve::DN(const Standard_Real U,
const Standard_Integer N) const
{
gp_Vec2d V;
if ( rational ) {
BSplCLib::DN(U,N,0,deg,periodic,POLES,
weights->Array1(),
FKNOTS,FMULTS,V);
weights->Array1(),
FKNOTS,FMULTS,V);
}
else {
else {
BSplCLib::DN(U,N,0,deg,periodic,POLES,
*((TColStd_Array1OfReal*) NULL),
FKNOTS,FMULTS,V);
*((TColStd_Array1OfReal*) NULL),
FKNOTS,FMULTS,V);
}
return V;
}
@@ -440,6 +396,11 @@ void Geom2d_BSplineCurve::Knots (TColStd_Array1OfReal& K) const
K = knots->Array1();
}
const TColStd_Array1OfReal& Geom2d_BSplineCurve::Knots() const
{
return knots->Array1();
}
//=======================================================================
//function : KnotSequence
//purpose :
@@ -452,6 +413,11 @@ void Geom2d_BSplineCurve::KnotSequence (TColStd_Array1OfReal& K) const
K = flatknots->Array1();
}
const TColStd_Array1OfReal& Geom2d_BSplineCurve::KnotSequence() const
{
return flatknots->Array1();
}
//=======================================================================
//function : LastUKnotIndex
//purpose :
@@ -676,6 +642,11 @@ void Geom2d_BSplineCurve::Multiplicities (TColStd_Array1OfInteger& M) const
M = mults->Array1();
}
const TColStd_Array1OfInteger& Geom2d_BSplineCurve::Multiplicities() const
{
return mults->Array1();
}
//=======================================================================
//function : NbKnots
//purpose :
@@ -716,6 +687,11 @@ void Geom2d_BSplineCurve::Poles (TColgp_Array1OfPnt2d& P) const
P = poles->Array1();
}
const TColgp_Array1OfPnt2d& Geom2d_BSplineCurve::Poles() const
{
return poles->Array1();
}
//=======================================================================
//function : StartPoint
//purpose :
@@ -764,6 +740,13 @@ void Geom2d_BSplineCurve::Weights
}
}
const TColStd_Array1OfReal& Geom2d_BSplineCurve::Weights() const
{
if (IsRational())
return weights->Array1();
return BSplCLib::NoWeights();
}
//=======================================================================
//function : IsRational
//purpose :
@@ -786,7 +769,6 @@ void Geom2d_BSplineCurve::Transform
for (Standard_Integer I = 1; I <= CPoles.Length(); I++)
CPoles (I).Transform (T);
InvalidateCache();
// maxderivinvok = 0;
}