1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0030582: Coding - avoid defining references to properties of NULL objects

Approx_SweepApproximation::Perform() now creates empty arrays.
GeomAdaptor_SurfaceOfRevolution::UTrim() - fixed No_Exception misuse.
StdPrs_ShadedShape - fixed defining an invalid reference to Poly_Triangulation::UVNodes().

BSplCLib::MovePoint() and BSplCLib::MovePointAndTangent() now take optional
weights parameter as pointer consistent to other methods like BSplCLib::BuildEval().
This commit is contained in:
kgv 2019-03-15 18:06:04 +03:00 committed by apn
parent afb3647b34
commit aff73fd598
12 changed files with 296 additions and 583 deletions

View File

@ -163,12 +163,21 @@ void Approx_SweepApproximation::Perform(const Standard_Real First,
myDWeigths = new (TColStd_HArray1OfReal)(1, Num3DSS); myDWeigths = new (TColStd_HArray1OfReal)(1, Num3DSS);
myD2Weigths = new (TColStd_HArray1OfReal)(1, Num3DSS); myD2Weigths = new (TColStd_HArray1OfReal)(1, Num3DSS);
if (Num2DSS>0) { if (Num2DSS>0)
{
myPoles2d = new (TColgp_HArray1OfPnt2d)(1, Num2DSS); myPoles2d = new (TColgp_HArray1OfPnt2d)(1, Num2DSS);
myDPoles2d = new (TColgp_HArray1OfVec2d)(1, Num2DSS); myDPoles2d = new (TColgp_HArray1OfVec2d)(1, Num2DSS);
myD2Poles2d = new (TColgp_HArray1OfVec2d)(1, Num2DSS); myD2Poles2d = new (TColgp_HArray1OfVec2d)(1, Num2DSS);
COnSurfErr = new (TColStd_HArray1OfReal)(1, Num2DSS); COnSurfErr = new (TColStd_HArray1OfReal)(1, Num2DSS);
} }
else
{
myPoles2d = new TColgp_HArray1OfPnt2d();
myDPoles2d = new TColgp_HArray1OfVec2d();
myD2Poles2d = new TColgp_HArray1OfVec2d();
COnSurfErr = new TColStd_HArray1OfReal();
}
// Checks if myFunc->D2 is implemented // Checks if myFunc->D2 is implemented
if (continuity >= GeomAbs_C2) { if (continuity >= GeomAbs_C2) {
Standard_Boolean B; Standard_Boolean B;

View File

@ -1337,7 +1337,7 @@ public:
//! (3, NbPoles-2) -> the ends and the tangency are enforced //! (3, NbPoles-2) -> the ends and the tangency are enforced
//! if Problem in BSplineBasis calculation, no change for the curve //! if Problem in BSplineBasis calculation, no change for the curve
//! and FirstIndex, LastIndex = 0 //! and FirstIndex, LastIndex = 0
Standard_EXPORT static void MovePoint (const Standard_Real U, const gp_Vec2d& Displ, const Standard_Integer Index1, const Standard_Integer Index2, const Standard_Integer Degree, const Standard_Boolean Rational, const TColgp_Array1OfPnt2d& Poles, const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Integer& FirstIndex, Standard_Integer& LastIndex, TColgp_Array1OfPnt2d& NewPoles); Standard_EXPORT static void MovePoint (const Standard_Real U, const gp_Vec2d& Displ, const Standard_Integer Index1, const Standard_Integer Index2, const Standard_Integer Degree, const TColgp_Array1OfPnt2d& Poles, const TColStd_Array1OfReal* Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Integer& FirstIndex, Standard_Integer& LastIndex, TColgp_Array1OfPnt2d& NewPoles);
//! Find the new poles which allows an old point (with a //! Find the new poles which allows an old point (with a
//! given u as parameter) to reach a new position //! given u as parameter) to reach a new position
@ -1348,7 +1348,7 @@ public:
//! (3, NbPoles-2) -> the ends and the tangency are enforced //! (3, NbPoles-2) -> the ends and the tangency are enforced
//! if Problem in BSplineBasis calculation, no change for the curve //! if Problem in BSplineBasis calculation, no change for the curve
//! and FirstIndex, LastIndex = 0 //! and FirstIndex, LastIndex = 0
Standard_EXPORT static void MovePoint (const Standard_Real U, const gp_Vec& Displ, const Standard_Integer Index1, const Standard_Integer Index2, const Standard_Integer Degree, const Standard_Boolean Rational, const TColgp_Array1OfPnt& Poles, const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Integer& FirstIndex, Standard_Integer& LastIndex, TColgp_Array1OfPnt& NewPoles); Standard_EXPORT static void MovePoint (const Standard_Real U, const gp_Vec& Displ, const Standard_Integer Index1, const Standard_Integer Index2, const Standard_Integer Degree, const TColgp_Array1OfPnt& Poles, const TColStd_Array1OfReal* Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Integer& FirstIndex, Standard_Integer& LastIndex, TColgp_Array1OfPnt& NewPoles);
//! This is the dimension free version of the utility //! This is the dimension free version of the utility
//! U is the parameter must be within the first FlatKnots and the //! U is the parameter must be within the first FlatKnots and the
@ -1366,7 +1366,7 @@ public:
//! = ... //! = ...
//! Same holds for EndingCondition //! Same holds for EndingCondition
//! Poles are the poles of the curve //! Poles are the poles of the curve
//! Weights are the weights of the curve if Rational = Standard_True //! Weights are the weights of the curve if not NULL
//! NewPoles are the poles of the deformed curve //! NewPoles are the poles of the deformed curve
//! ErrorStatus will be 0 if no error happened //! ErrorStatus will be 0 if no error happened
//! 1 if there are not enough knots/poles //! 1 if there are not enough knots/poles
@ -1375,7 +1375,7 @@ public:
//! If StartCondition = 1 and EndCondition = 1 then you need at least //! If StartCondition = 1 and EndCondition = 1 then you need at least
//! 4 + 2 = 6 poles so for example to have a C1 cubic you will need //! 4 + 2 = 6 poles so for example to have a C1 cubic you will need
//! have at least 2 internal knots. //! have at least 2 internal knots.
Standard_EXPORT static void MovePointAndTangent (const Standard_Real U, const Standard_Integer ArrayDimension, Standard_Real& Delta, Standard_Real& DeltaDerivative, const Standard_Real Tolerance, const Standard_Integer Degree, const Standard_Boolean Rational, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, Standard_Real& Poles, const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Real& NewPoles, Standard_Integer& ErrorStatus); Standard_EXPORT static void MovePointAndTangent (const Standard_Real U, const Standard_Integer ArrayDimension, Standard_Real& Delta, Standard_Real& DeltaDerivative, const Standard_Real Tolerance, const Standard_Integer Degree, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, Standard_Real& Poles, const TColStd_Array1OfReal* Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Real& NewPoles, Standard_Integer& ErrorStatus);
//! This is the dimension free version of the utility //! This is the dimension free version of the utility
//! U is the parameter must be within the first FlatKnots and the //! U is the parameter must be within the first FlatKnots and the
@ -1393,7 +1393,7 @@ public:
//! = ... //! = ...
//! Same holds for EndingCondition //! Same holds for EndingCondition
//! Poles are the poles of the curve //! Poles are the poles of the curve
//! Weights are the weights of the curve if Rational = Standard_True //! Weights are the weights of the curve if not NULL
//! NewPoles are the poles of the deformed curve //! NewPoles are the poles of the deformed curve
//! ErrorStatus will be 0 if no error happened //! ErrorStatus will be 0 if no error happened
//! 1 if there are not enough knots/poles //! 1 if there are not enough knots/poles
@ -1402,7 +1402,7 @@ public:
//! If StartCondition = 1 and EndCondition = 1 then you need at least //! If StartCondition = 1 and EndCondition = 1 then you need at least
//! 4 + 2 = 6 poles so for example to have a C1 cubic you will need //! 4 + 2 = 6 poles so for example to have a C1 cubic you will need
//! have at least 2 internal knots. //! have at least 2 internal knots.
Standard_EXPORT static void MovePointAndTangent (const Standard_Real U, const gp_Vec& Delta, const gp_Vec& DeltaDerivative, const Standard_Real Tolerance, const Standard_Integer Degree, const Standard_Boolean Rational, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, const TColgp_Array1OfPnt& Poles, const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal& FlatKnots, TColgp_Array1OfPnt& NewPoles, Standard_Integer& ErrorStatus); Standard_EXPORT static void MovePointAndTangent (const Standard_Real U, const gp_Vec& Delta, const gp_Vec& DeltaDerivative, const Standard_Real Tolerance, const Standard_Integer Degree, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, const TColgp_Array1OfPnt& Poles, const TColStd_Array1OfReal* Weights, const TColStd_Array1OfReal& FlatKnots, TColgp_Array1OfPnt& NewPoles, Standard_Integer& ErrorStatus);
//! This is the dimension free version of the utility //! This is the dimension free version of the utility
//! U is the parameter must be within the first FlatKnots and the //! U is the parameter must be within the first FlatKnots and the
@ -1420,7 +1420,7 @@ public:
//! = ... //! = ...
//! Same holds for EndingCondition //! Same holds for EndingCondition
//! Poles are the poles of the curve //! Poles are the poles of the curve
//! Weights are the weights of the curve if Rational = Standard_True //! Weights are the weights of the curve if not NULL
//! NewPoles are the poles of the deformed curve //! NewPoles are the poles of the deformed curve
//! ErrorStatus will be 0 if no error happened //! ErrorStatus will be 0 if no error happened
//! 1 if there are not enough knots/poles //! 1 if there are not enough knots/poles
@ -1429,7 +1429,7 @@ public:
//! If StartCondition = 1 and EndCondition = 1 then you need at least //! If StartCondition = 1 and EndCondition = 1 then you need at least
//! 4 + 2 = 6 poles so for example to have a C1 cubic you will need //! 4 + 2 = 6 poles so for example to have a C1 cubic you will need
//! have at least 2 internal knots. //! have at least 2 internal knots.
Standard_EXPORT static void MovePointAndTangent (const Standard_Real U, const gp_Vec2d& Delta, const gp_Vec2d& DeltaDerivative, const Standard_Real Tolerance, const Standard_Integer Degree, const Standard_Boolean Rational, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, const TColgp_Array1OfPnt2d& Poles, const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal& FlatKnots, TColgp_Array1OfPnt2d& NewPoles, Standard_Integer& ErrorStatus); Standard_EXPORT static void MovePointAndTangent (const Standard_Real U, const gp_Vec2d& Delta, const gp_Vec2d& DeltaDerivative, const Standard_Real Tolerance, const Standard_Integer Degree, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, const TColgp_Array1OfPnt2d& Poles, const TColStd_Array1OfReal* Weights, const TColStd_Array1OfReal& FlatKnots, TColgp_Array1OfPnt2d& NewPoles, Standard_Integer& ErrorStatus);
//! given a tolerance in 3D space returns a //! given a tolerance in 3D space returns a

View File

@ -567,11 +567,10 @@ void BSplCLib::MovePointAndTangent(const Standard_Real U,
Standard_Real &DeltaDerivatives, Standard_Real &DeltaDerivatives,
const Standard_Real Tolerance, const Standard_Real Tolerance,
const Standard_Integer Degree, const Standard_Integer Degree,
const Standard_Boolean Rational,
const Standard_Integer StartingCondition, const Standard_Integer StartingCondition,
const Standard_Integer EndingCondition, const Standard_Integer EndingCondition,
Standard_Real& Poles, Standard_Real& Poles,
const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal* Weights,
const TColStd_Array1OfReal& FlatKnots, const TColStd_Array1OfReal& FlatKnots,
Standard_Real& NewPoles, Standard_Real& NewPoles,
Standard_Integer& ErrorStatus) Standard_Integer& ErrorStatus)
@ -603,8 +602,8 @@ void BSplCLib::MovePointAndTangent(const Standard_Real U,
ErrorStatus = 0 ; ErrorStatus = 0 ;
weights_array = NULL ; weights_array = NULL ;
if (Rational) { if (Weights != NULL) {
weights_array = (Standard_Real *) &Weights(Weights.Lower()) ; weights_array = const_cast<Standard_Real*>(&Weights->First());
} }
poles_array = &Poles ; poles_array = &Poles ;
@ -765,7 +764,7 @@ void BSplCLib::MovePointAndTangent(const Standard_Real U,
extrap_mode[0] = Degree ; extrap_mode[0] = Degree ;
extrap_mode[1] = Degree ; extrap_mode[1] = Degree ;
if (Rational) { if (Weights != NULL) {
// //
// evaluate in homogenised form // evaluate in homogenised form
// //

View File

@ -1218,9 +1218,8 @@ void BSplCLib::MovePoint (const Standard_Real U,
const Standard_Integer Index1, const Standard_Integer Index1,
const Standard_Integer Index2, const Standard_Integer Index2,
const Standard_Integer Degree, const Standard_Integer Degree,
const Standard_Boolean Rational,
const Array1OfPoints& Poles, const Array1OfPoints& Poles,
const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal* Weights,
const TColStd_Array1OfReal& FlatKnots, const TColStd_Array1OfReal& FlatKnots,
Standard_Integer& FirstIndex, Standard_Integer& FirstIndex,
Standard_Integer& LastIndex, Standard_Integer& LastIndex,
@ -1280,8 +1279,8 @@ void BSplCLib::MovePoint (const Standard_Real U,
for (i = 1; i <= Degree+1; i++) { for (i = 1; i <= Degree+1; i++) {
ii = i + FirstNonZeroBsplineIndex - 1; ii = i + FirstNonZeroBsplineIndex - 1;
if (Rational) { if (Weights != NULL) {
hN = Weights(ii)*BSplineBasis(1, i); hN = Weights->Value(ii)*BSplineBasis(1, i);
D2 += hN; D2 += hN;
} }
else { else {
@ -1301,7 +1300,7 @@ void BSplCLib::MovePoint (const Standard_Real U,
} }
} }
if (Rational) { if (Weights != NULL) {
Coef = D2/D1; Coef = D2/D1;
} }
else { else {
@ -1345,11 +1344,10 @@ void BSplCLib::MovePointAndTangent (const Standard_Real U,
const Vector& DeltaDerivatives, const Vector& DeltaDerivatives,
const Standard_Real Tolerance, const Standard_Real Tolerance,
const Standard_Integer Degree, const Standard_Integer Degree,
const Standard_Boolean Rational,
const Standard_Integer StartingCondition, const Standard_Integer StartingCondition,
const Standard_Integer EndingCondition, const Standard_Integer EndingCondition,
const Array1OfPoints& Poles, const Array1OfPoints& Poles,
const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal* Weights,
const TColStd_Array1OfReal& FlatKnots, const TColStd_Array1OfReal& FlatKnots,
Array1OfPoints& NewPoles, Array1OfPoints& NewPoles,
Standard_Integer & ErrorStatus) Standard_Integer & ErrorStatus)
@ -1376,7 +1374,6 @@ void BSplCLib::MovePointAndTangent (const Standard_Real U,
delta_derivative_array[0], delta_derivative_array[0],
Tolerance, Tolerance,
Degree, Degree,
Rational,
StartingCondition, StartingCondition,
EndingCondition, EndingCondition,
poles_array[0], poles_array[0],

View File

@ -257,35 +257,21 @@ void Geom_BSplineCurve::IncreaseDegree (const Standard_Integer Degree)
new TColStd_HArray1OfInteger(1,nbknots); new TColStd_HArray1OfInteger(1,nbknots);
Handle(TColStd_HArray1OfReal) nweights; Handle(TColStd_HArray1OfReal) nweights;
if (IsRational())
if (IsRational()) { {
nweights = new TColStd_HArray1OfReal(1,npoles->Upper()); nweights = new TColStd_HArray1OfReal(1,npoles->Upper());
BSplCLib::IncreaseDegree
(deg,Degree, periodic,
poles->Array1(),&weights->Array1(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(),&nweights->ChangeArray1(),
nknots->ChangeArray1(),nmults->ChangeArray1());
} }
else { BSplCLib::IncreaseDegree (deg, Degree, periodic,
BSplCLib::IncreaseDegree poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
(deg,Degree, periodic, knots->Array1(), mults->Array1(),
poles->Array1(),BSplCLib::NoWeights(), npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(),
BSplCLib::NoWeights(),
nknots->ChangeArray1(),nmults->ChangeArray1()); nknots->ChangeArray1(),nmults->ChangeArray1());
}
deg = Degree; deg = Degree;
poles = npoles; poles = npoles;
weights = nweights; weights = nweights;
knots = nknots; knots = nknots;
mults = nmults; mults = nmults;
UpdateKnots(); UpdateKnots();
} }
//======================================================================= //=======================================================================
@ -385,34 +371,24 @@ void Geom_BSplineCurve::InsertKnots(const TColStd_Array1OfReal& Knots,
nmults = new TColStd_HArray1OfInteger(1,nbknots); nmults = new TColStd_HArray1OfInteger(1,nbknots);
} }
if (rational) { Handle(TColStd_HArray1OfReal) nweights;
Handle(TColStd_HArray1OfReal) nweights = if (rational)
new TColStd_HArray1OfReal(1,nbpoles); {
BSplCLib::InsertKnots(deg,periodic, nweights = new TColStd_HArray1OfReal(1,nbpoles);
poles->Array1(), &weights->Array1(), }
BSplCLib::InsertKnots (deg, periodic,
poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), mults->Array1(), knots->Array1(), mults->Array1(),
Knots, &Mults, Knots, &Mults,
npoles->ChangeArray1(), &nweights->ChangeArray1(), npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(),
nknots->ChangeArray1(), nmults->ChangeArray1(), nknots->ChangeArray1(), nmults->ChangeArray1(),
Epsilon, Add); Epsilon, Add);
weights = nweights; weights = nweights;
}
else {
BSplCLib::InsertKnots(deg,periodic,
poles->Array1(), BSplCLib::NoWeights(),
knots->Array1(), mults->Array1(),
Knots, &Mults,
npoles->ChangeArray1(),
BSplCLib::NoWeights(),
nknots->ChangeArray1(), nmults->ChangeArray1(),
Epsilon, Add);
}
poles = npoles; poles = npoles;
knots = nknots; knots = nknots;
mults = nmults; mults = nmults;
UpdateKnots(); UpdateKnots();
} }
//======================================================================= //=======================================================================
@ -452,31 +428,23 @@ Standard_Boolean Geom_BSplineCurve::RemoveKnot(const Standard_Integer Index,
nmults = new TColStd_HArray1OfInteger(1,knots->Length()-1); nmults = new TColStd_HArray1OfInteger(1,knots->Length()-1);
} }
if (IsRational()) { Handle(TColStd_HArray1OfReal) nweights;
Handle(TColStd_HArray1OfReal) nweights = if (IsRational())
new TColStd_HArray1OfReal(1,npoles->Length()); {
if (!BSplCLib::RemoveKnot nweights = new TColStd_HArray1OfReal(1,npoles->Length());
(Index, M, deg, periodic,
poles->Array1(),&weights->Array1(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(), &nweights->ChangeArray1(),
nknots->ChangeArray1(),nmults->ChangeArray1(),
Tolerance))
return Standard_False;
weights = nweights;
} }
else {
if (!BSplCLib::RemoveKnot if (!BSplCLib::RemoveKnot (Index, M, deg, periodic,
(Index, M, deg, periodic, poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
poles->Array1(), BSplCLib::NoWeights(),
knots->Array1(),mults->Array1(), knots->Array1(),mults->Array1(),
npoles->ChangeArray1(), npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(),
BSplCLib::NoWeights(),
nknots->ChangeArray1(),nmults->ChangeArray1(), nknots->ChangeArray1(),nmults->ChangeArray1(),
Tolerance)) Tolerance))
{
return Standard_False; return Standard_False;
} }
weights = nweights;
poles = npoles; poles = npoles;
knots = nknots; knots = nknots;
mults = nmults; mults = nmults;
@ -932,27 +900,16 @@ void Geom_BSplineCurve::SetNotPeriodic ()
= new TColStd_HArray1OfInteger(1,NbKnots); = new TColStd_HArray1OfInteger(1,NbKnots);
Handle(TColStd_HArray1OfReal) nweights; Handle(TColStd_HArray1OfReal) nweights;
if (IsRational())
if (IsRational()) { {
nweights = new TColStd_HArray1OfReal(1,NbPoles); nweights = new TColStd_HArray1OfReal(1,NbPoles);
BSplCLib::Unperiodize
(deg,mults->Array1(),knots->Array1(),poles->Array1(),
&weights->Array1(),nmults->ChangeArray1(),
nknots->ChangeArray1(),npoles->ChangeArray1(),
&nweights->ChangeArray1());
} }
else {
BSplCLib::Unperiodize BSplCLib::Unperiodize (deg,
(deg,mults->Array1(),knots->Array1(),poles->Array1(), mults->Array1(), knots->Array1(), poles->Array1(),
BSplCLib::NoWeights(),nmults->ChangeArray1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
nknots->ChangeArray1(),npoles->ChangeArray1(), nmults->ChangeArray1(), nknots->ChangeArray1(), npoles->ChangeArray1(),
BSplCLib::NoWeights()); !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights());
}
poles = npoles; poles = npoles;
weights = nweights; weights = nweights;
mults = nmults; mults = nmults;
@ -1046,8 +1003,8 @@ void Geom_BSplineCurve::MovePoint(const Standard_Real U,
gp_Pnt P0; gp_Pnt P0;
D0(U, P0); D0(U, P0);
gp_Vec Displ(P0, P); gp_Vec Displ(P0, P);
BSplCLib::MovePoint(U, Displ, Index1, Index2, deg, rational, poles->Array1(), BSplCLib::MovePoint (U, Displ, Index1, Index2, deg, poles->Array1(),
weights->Array1(), flatknots->Array1(), rational ? &weights->Array1() : BSplCLib::NoWeights(), flatknots->Array1(),
FirstModifiedPole, LastmodifiedPole, npoles); FirstModifiedPole, LastmodifiedPole, npoles);
if (FirstModifiedPole) { if (FirstModifiedPole) {
poles->ChangeArray1() = npoles; poles->ChangeArray1() = npoles;
@ -1091,11 +1048,10 @@ void Geom_BSplineCurve::MovePointAndTangent(const Standard_Real U,
delta_derivative, delta_derivative,
Tolerance, Tolerance,
deg, deg,
rational,
StartingCondition, StartingCondition,
EndingCondition, EndingCondition,
poles->Array1(), poles->Array1(),
weights->Array1(), rational ? &weights->Array1() : BSplCLib::NoWeights(),
flatknots->Array1(), flatknots->Array1(),
new_poles, new_poles,
ErrorStatus) ; ErrorStatus) ;

View File

@ -184,20 +184,11 @@ void Geom_BSplineCurve::D0(const Standard_Real U, gp_Pnt& P) const
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU); BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex)) if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--; aSpanIndex--;
if (rational)
{ BSplCLib::D0 (aNewU, aSpanIndex, deg, periodic, POLES,
BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(),
knots->Array1(), &mults->Array1(), knots->Array1(), &mults->Array1(),
P); P);
}
else
{
BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P);
}
} }
//======================================================================= //=======================================================================
@ -215,20 +206,11 @@ void Geom_BSplineCurve::D1 (const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU); BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex)) if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--; aSpanIndex--;
if (rational)
{ BSplCLib::D1 (aNewU, aSpanIndex, deg, periodic, POLES,
BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(),
knots->Array1(), &mults->Array1(), knots->Array1(), &mults->Array1(),
P, V1); P, V1);
}
else
{
BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1);
}
} }
//======================================================================= //=======================================================================
@ -247,20 +229,11 @@ void Geom_BSplineCurve::D2(const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU); BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex)) if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--; aSpanIndex--;
if (rational)
{ BSplCLib::D2 (aNewU, aSpanIndex, deg, periodic, POLES,
BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(),
knots->Array1(), &mults->Array1(), knots->Array1(), &mults->Array1(),
P, V1, V2); P, V1, V2);
}
else
{
BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1, V2);
}
} }
//======================================================================= //=======================================================================
@ -280,20 +253,11 @@ void Geom_BSplineCurve::D3(const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU); BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex)) if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--; aSpanIndex--;
if (rational)
{ BSplCLib::D3 (aNewU, aSpanIndex, deg, periodic, POLES,
BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(),
knots->Array1(), &mults->Array1(), knots->Array1(), &mults->Array1(),
P, V1, V2, V3); P, V1, V2, V3);
}
else
{
BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1, V2, V3);
}
} }
//======================================================================= //=======================================================================
@ -305,16 +269,9 @@ gp_Vec Geom_BSplineCurve::DN(const Standard_Real U,
const Standard_Integer N) const const Standard_Integer N) const
{ {
gp_Vec V; gp_Vec V;
if (rational) { BSplCLib::DN (U, N, 0, deg, periodic, POLES,
BSplCLib::DN(U,N,0,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(), FKNOTS, FMULTS, V);
FKNOTS,FMULTS,V);
}
else {
BSplCLib::DN(U,N,0,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,V);
}
return V; return V;
} }
@ -466,16 +423,9 @@ void Geom_BSplineCurve::LocalD0
Standard_Integer index = 0; Standard_Integer index = 0;
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic,FromK1,ToK2, index,u); BSplCLib::LocateParameter(deg, FKNOTS, U, periodic,FromK1,ToK2, index,u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if (rational) { BSplCLib::D0 (u, index, deg, periodic, POLES,
BSplCLib::D0(u,index,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(), FKNOTS, FMULTS, P);
FKNOTS,FMULTS,P);
}
else {
BSplCLib::D0(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P);
}
} }
//======================================================================= //=======================================================================
@ -496,16 +446,9 @@ void Geom_BSplineCurve::LocalD1 (const Standard_Real U,
Standard_Integer index = 0; Standard_Integer index = 0;
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u); BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if (rational) { BSplCLib::D1 (u, index, deg, periodic, POLES,
BSplCLib::D1(u,index,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(),
FKNOTS,FMULTS,P,V1); FKNOTS,FMULTS,P,V1);
}
else {
BSplCLib::D1(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P,V1);
}
} }
//======================================================================= //=======================================================================
@ -528,16 +471,9 @@ void Geom_BSplineCurve::LocalD2
Standard_Integer index = 0; Standard_Integer index = 0;
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u); BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if (rational) { BSplCLib::D2 (u, index, deg, periodic, POLES,
BSplCLib::D2(u,index,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(), FKNOTS, FMULTS, P, V1, V2);
FKNOTS,FMULTS,P,V1,V2);
}
else {
BSplCLib::D2(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P,V1,V2);
}
} }
//======================================================================= //=======================================================================
@ -561,16 +497,9 @@ void Geom_BSplineCurve::LocalD3
Standard_Integer index = 0; Standard_Integer index = 0;
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u); BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if (rational) { BSplCLib::D3 (u, index, deg, periodic, POLES,
BSplCLib::D3(u,index,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(), FKNOTS, FMULTS, P, V1, V2, V3);
FKNOTS,FMULTS,P,V1,V2,V3);
}
else {
BSplCLib::D3(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P,V1,V2,V3);
}
} }
//======================================================================= //=======================================================================
@ -593,16 +522,9 @@ gp_Vec Geom_BSplineCurve::LocalDN
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
gp_Vec V; gp_Vec V;
if (rational) { BSplCLib::DN (u, N, index, deg, periodic, POLES,
BSplCLib::DN(u,N,index,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(), FKNOTS, FMULTS, V);
FKNOTS,FMULTS,V);
}
else {
BSplCLib::DN(u,N,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,V);
}
return V; return V;
} }
@ -821,64 +743,45 @@ void Geom_BSplineCurve::LocateU
//purpose : //purpose :
//======================================================================= //=======================================================================
void Geom_BSplineCurve::Resolution(const Standard_Real Tolerance3D, void Geom_BSplineCurve::Resolution (const Standard_Real Tolerance3D,
Standard_Real & UTolerance) Standard_Real& UTolerance)
{ {
Standard_Integer ii; if (!maxderivinvok)
if(!maxderivinvok){ {
if ( periodic) { if (periodic)
{
Standard_Integer NbKnots, NbPoles; Standard_Integer NbKnots, NbPoles;
BSplCLib::PrepareUnperiodize( deg, BSplCLib::PrepareUnperiodize (deg, mults->Array1(), NbKnots, NbPoles);
mults->Array1(), TColgp_Array1OfPnt new_poles (1, NbPoles);
NbKnots, TColStd_Array1OfReal new_weights(1, NbPoles);
NbPoles); for (Standard_Integer ii = 1; ii <= NbPoles; ii++)
TColgp_Array1OfPnt new_poles(1,NbPoles) ; {
TColStd_Array1OfReal new_weights(1,NbPoles) ; new_poles(ii) = poles->Array1()((ii-1) % poles->Length() + 1);
for(ii = 1 ; ii <= NbPoles ; ii++) {
new_poles(ii) = poles->Array1()((ii-1) % poles->Length() + 1) ;
} }
if (rational) { if (rational)
for(ii = 1 ; ii <= NbPoles ; ii++) { {
new_weights(ii) = weights->Array1()((ii-1) % poles->Length() + 1) ; for (Standard_Integer ii = 1; ii <= NbPoles; ii++)
{
new_weights(ii) = weights->Array1()((ii-1) % poles->Length() + 1);
} }
BSplCLib::Resolution(new_poles, }
&new_weights, BSplCLib::Resolution (new_poles,
rational ? &new_weights : BSplCLib::NoWeights(),
new_poles.Length(), new_poles.Length(),
flatknots->Array1(), flatknots->Array1(),
deg, deg,
1., 1.,
maxderivinv) ; maxderivinv);
} }
else { else
BSplCLib::Resolution(new_poles, {
BSplCLib::NoWeights(), BSplCLib::Resolution (poles->Array1(),
new_poles.Length(), rational ? &weights->Array1() : BSplCLib::NoWeights(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
}
else {
if (rational) {
BSplCLib::Resolution(poles->Array1(),
&weights->Array1(),
poles->Length(), poles->Length(),
flatknots->Array1(), flatknots->Array1(),
deg, deg,
1., 1.,
maxderivinv) ; maxderivinv);
}
else {
BSplCLib::Resolution(poles->Array1(),
BSplCLib::NoWeights(),
poles->Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
} }
maxderivinvok = 1; maxderivinvok = 1;
} }

View File

@ -257,27 +257,14 @@ void Geom2d_BSplineCurve::IncreaseDegree
Handle(TColStd_HArray1OfReal) nweights; Handle(TColStd_HArray1OfReal) nweights;
if (IsRational()) { if (IsRational()) {
nweights = new TColStd_HArray1OfReal(1,npoles->Upper()); nweights = new TColStd_HArray1OfReal(1,npoles->Upper());
BSplCLib::IncreaseDegree
(deg,Degree, periodic,
poles->Array1(),&weights->Array1(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(),&nweights->ChangeArray1(),
nknots->ChangeArray1(),nmults->ChangeArray1());
} }
else {
BSplCLib::IncreaseDegree BSplCLib::IncreaseDegree (deg, Degree, periodic,
(deg,Degree, periodic, poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
poles->Array1(), knots->Array1(), mults->Array1(),
BSplCLib::NoWeights(), npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(),
knots->Array1(),mults->Array1(), nknots->ChangeArray1(), nmults->ChangeArray1());
npoles->ChangeArray1(),
BSplCLib::NoWeights(),
nknots->ChangeArray1(),nmults->ChangeArray1());
}
deg = Degree; deg = Degree;
poles = npoles; poles = npoles;
@ -384,35 +371,24 @@ void Geom2d_BSplineCurve::InsertKnots(const TColStd_Array1OfReal& Knots,
nmults = new TColStd_HArray1OfInteger(1,nbknots); nmults = new TColStd_HArray1OfInteger(1,nbknots);
} }
if (rational) { Handle(TColStd_HArray1OfReal) nweights;
Handle(TColStd_HArray1OfReal) nweights = if (rational)
new TColStd_HArray1OfReal(1,nbpoles); {
BSplCLib::InsertKnots(deg,periodic, nweights = new TColStd_HArray1OfReal (1, nbpoles);
poles->Array1(), &weights->Array1(),
knots->Array1(), mults->Array1(),
Knots, &Mults,
npoles->ChangeArray1(), &nweights->ChangeArray1(),
nknots->ChangeArray1(), nmults->ChangeArray1(),
Epsilon,Add);
weights = nweights;
}
else {
BSplCLib::InsertKnots(deg,periodic,
poles->Array1(),
BSplCLib::NoWeights(),
knots->Array1(), mults->Array1(),
Knots, &Mults,
npoles->ChangeArray1(),
BSplCLib::NoWeights(),
nknots->ChangeArray1(), nmults->ChangeArray1(),
Epsilon,Add);
} }
BSplCLib::InsertKnots (deg, periodic,
poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
knots->Array1(), mults->Array1(),
Knots, &Mults,
npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(),
nknots->ChangeArray1(), nmults->ChangeArray1(),
Epsilon, Add);
weights = nweights;
poles = npoles; poles = npoles;
knots = nknots; knots = nknots;
mults = nmults; mults = nmults;
UpdateKnots(); UpdateKnots();
} }
//======================================================================= //=======================================================================
@ -450,32 +426,23 @@ Standard_Boolean Geom2d_BSplineCurve::RemoveKnot
nmults = new TColStd_HArray1OfInteger(1,knots->Length()-1); nmults = new TColStd_HArray1OfInteger(1,knots->Length()-1);
} }
if (IsRational()) { Handle(TColStd_HArray1OfReal) nweights;
Handle(TColStd_HArray1OfReal) nweights = if (IsRational())
new TColStd_HArray1OfReal(1,npoles->Length()); {
if (!BSplCLib::RemoveKnot nweights = new TColStd_HArray1OfReal(1,npoles->Length());
(Index, M, deg, periodic,
poles->Array1(),&weights->Array1(),
knots->Array1(),mults->Array1(),
npoles->ChangeArray1(), &nweights->ChangeArray1(),
nknots->ChangeArray1(),nmults->ChangeArray1(),
Tolerance))
return Standard_False;
weights = nweights;
} }
else {
if (!BSplCLib::RemoveKnot if (!BSplCLib::RemoveKnot (Index, M, deg, periodic,
(Index, M, deg, periodic, poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
poles->Array1(),
BSplCLib::NoWeights(),
knots->Array1(),mults->Array1(), knots->Array1(),mults->Array1(),
npoles->ChangeArray1(), npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(),
BSplCLib::NoWeights(),
nknots->ChangeArray1(),nmults->ChangeArray1(), nknots->ChangeArray1(),nmults->ChangeArray1(),
Tolerance)) Tolerance))
{
return Standard_False; return Standard_False;
} }
weights = nweights;
poles = npoles; poles = npoles;
knots = nknots; knots = nknots;
mults = nmults; mults = nmults;
@ -1047,27 +1014,15 @@ void Geom2d_BSplineCurve::SetNotPeriodic ()
= new TColStd_HArray1OfInteger(1,NbKnots); = new TColStd_HArray1OfInteger(1,NbKnots);
Handle(TColStd_HArray1OfReal) nweights; Handle(TColStd_HArray1OfReal) nweights;
if (IsRational()) { if (IsRational()) {
nweights = new TColStd_HArray1OfReal(1,NbPoles); nweights = new TColStd_HArray1OfReal(1,NbPoles);
BSplCLib::Unperiodize
(deg,mults->Array1(),knots->Array1(),poles->Array1(),
&weights->Array1(),nmults->ChangeArray1(),
nknots->ChangeArray1(),npoles->ChangeArray1(),
&nweights->ChangeArray1());
} }
else {
BSplCLib::Unperiodize BSplCLib::Unperiodize (deg,
(deg,mults->Array1(),knots->Array1(),poles->Array1(), mults->Array1(), knots->Array1(), poles->Array1(),
BSplCLib::NoWeights(),nmults->ChangeArray1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(),
nknots->ChangeArray1(),npoles->ChangeArray1(), nmults->ChangeArray1(), nknots->ChangeArray1(), npoles->ChangeArray1(),
BSplCLib::NoWeights()); !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights());
}
poles = npoles; poles = npoles;
weights = nweights; weights = nweights;
mults = nmults; mults = nmults;
@ -1161,8 +1116,9 @@ void Geom2d_BSplineCurve::MovePoint(const Standard_Real U,
gp_Pnt2d P0; gp_Pnt2d P0;
D0(U, P0); D0(U, P0);
gp_Vec2d Displ(P0, P); gp_Vec2d Displ(P0, P);
BSplCLib::MovePoint(U, Displ, Index1, Index2, deg, rational, poles->Array1(),
weights->Array1(), flatknots->Array1(), BSplCLib::MovePoint (U, Displ, Index1, Index2, deg, poles->Array1(),
rational ? &weights->Array1() : BSplCLib::NoWeights(), flatknots->Array1(),
FirstModifiedPole, LastmodifiedPole, npoles); FirstModifiedPole, LastmodifiedPole, npoles);
if (FirstModifiedPole) { if (FirstModifiedPole) {
poles->ChangeArray1() = npoles; poles->ChangeArray1() = npoles;
@ -1203,19 +1159,19 @@ MovePointAndTangent(const Standard_Real U,
delta_derivative.SetCoord(ii, delta_derivative.SetCoord(ii,
Tangent.Coord(ii)- delta_derivative.Coord(ii)) ; Tangent.Coord(ii)- delta_derivative.Coord(ii)) ;
} }
BSplCLib::MovePointAndTangent(U,
BSplCLib::MovePointAndTangent (U,
delta, delta,
delta_derivative, delta_derivative,
Tolerance, Tolerance,
deg, deg,
rational,
StartingCondition, StartingCondition,
EndingCondition, EndingCondition,
poles->Array1(), poles->Array1(),
weights->Array1(), rational ? &weights->Array1() : BSplCLib::NoWeights(),
flatknots->Array1(), flatknots->Array1(),
new_poles, new_poles,
ErrorStatus) ; ErrorStatus);
if (!ErrorStatus) { if (!ErrorStatus) {
poles->ChangeArray1() = new_poles; poles->ChangeArray1() = new_poles;
maxderivinvok = 0; maxderivinvok = 0;

View File

@ -190,20 +190,11 @@ void Geom2d_BSplineCurve::D0(const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU); BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex)) if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--; aSpanIndex--;
if (rational)
{ BSplCLib::D0 (aNewU, aSpanIndex, deg, periodic, POLES,
BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(),
knots->Array1(), &mults->Array1(), knots->Array1(), &mults->Array1(),
P); P);
}
else
{
BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P);
}
} }
@ -222,20 +213,11 @@ void Geom2d_BSplineCurve::D1(const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU); BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex)) if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--; aSpanIndex--;
if (rational)
{ BSplCLib::D1 (aNewU, aSpanIndex, deg, periodic, POLES,
BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(),
knots->Array1(), &mults->Array1(), knots->Array1(), &mults->Array1(),
P, V1); P, V1);
}
else
{
BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1);
}
} }
//======================================================================= //=======================================================================
@ -254,20 +236,11 @@ void Geom2d_BSplineCurve::D2(const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU); BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex)) if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--; aSpanIndex--;
if (rational)
{ BSplCLib::D2 (aNewU, aSpanIndex, deg, periodic, POLES,
BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(),
knots->Array1(), &mults->Array1(), knots->Array1(), &mults->Array1(),
P, V1, V2); P, V1, V2);
}
else
{
BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1, V2);
}
} }
//======================================================================= //=======================================================================
@ -287,20 +260,11 @@ void Geom2d_BSplineCurve::D3(const Standard_Real U,
BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU); BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU);
if (aNewU < knots->Value(aSpanIndex)) if (aNewU < knots->Value(aSpanIndex))
aSpanIndex--; aSpanIndex--;
if (rational)
{ BSplCLib::D3 (aNewU, aSpanIndex, deg, periodic, POLES,
BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(),
knots->Array1(), &mults->Array1(), knots->Array1(), &mults->Array1(),
P, V1, V2, V3); P, V1, V2, V3);
}
else
{
BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES,
BSplCLib::NoWeights(),
knots->Array1(), &mults->Array1(),
P, V1, V2, V3);
}
} }
//======================================================================= //=======================================================================
@ -312,17 +276,9 @@ gp_Vec2d Geom2d_BSplineCurve::DN(const Standard_Real U,
const Standard_Integer N) const const Standard_Integer N) const
{ {
gp_Vec2d V; gp_Vec2d V;
BSplCLib::DN (U, N, 0, deg, periodic, POLES,
if ( rational ) { rational ? &weights->Array1() : BSplCLib::NoWeights(),
BSplCLib::DN(U,N,0,deg,periodic,POLES, FKNOTS, FMULTS, V);
&weights->Array1(),
FKNOTS,FMULTS, V);
}
else {
BSplCLib::DN(U,N,0,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,V);
}
return V; return V;
} }
@ -475,16 +431,9 @@ void Geom2d_BSplineCurve::LocalD0
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic,FromK1,ToK2, index,u); BSplCLib::LocateParameter(deg, FKNOTS, U, periodic,FromK1,ToK2, index,u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if ( rational ) { BSplCLib::D0 (u, index, deg, periodic, POLES,
BSplCLib::D0(u,index,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(), FKNOTS, FMULTS, P);
FKNOTS,FMULTS,P);
}
else {
BSplCLib::D0(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P);
}
} }
//======================================================================= //=======================================================================
@ -506,16 +455,9 @@ void Geom2d_BSplineCurve::LocalD1 (const Standard_Real U,
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u); BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if (rational) { BSplCLib::D1 (u, index, deg, periodic, POLES,
BSplCLib::D1(u,index,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(), FKNOTS, FMULTS, P, V1);
FKNOTS,FMULTS,P,V1);
}
else {
BSplCLib::D1(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P,V1);
}
} }
//======================================================================= //=======================================================================
@ -539,16 +481,9 @@ void Geom2d_BSplineCurve::LocalD2
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u); BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if ( rational ) { BSplCLib::D2 (u, index, deg, periodic, POLES,
BSplCLib::D2(u,index,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(), FKNOTS, FMULTS, P, V1, V2);
FKNOTS,FMULTS,P,V1,V2);
}
else {
BSplCLib::D2(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P,V1,V2);
}
} }
//======================================================================= //=======================================================================
@ -573,16 +508,9 @@ void Geom2d_BSplineCurve::LocalD3
BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u); BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u);
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
if ( rational ) { BSplCLib::D3 (u, index, deg, periodic, POLES,
BSplCLib::D3(u,index,deg,periodic,POLES, rational ? &weights->Array1() : BSplCLib::NoWeights(),
&weights->Array1(), FKNOTS, FMULTS, P, V1, V2, V3);
FKNOTS,FMULTS,P,V1,V2,V3);
}
else {
BSplCLib::D3(u,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,P,V1,V2,V3);
}
} }
//======================================================================= //=======================================================================
@ -605,17 +533,9 @@ gp_Vec2d Geom2d_BSplineCurve::LocalDN
index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic);
gp_Vec2d V; gp_Vec2d V;
BSplCLib::DN (u, N, index, deg, periodic, POLES,
if ( rational ) { rational ? &weights->Array1() : BSplCLib::NoWeights(),
BSplCLib::DN(u,N,index,deg,periodic,POLES, FKNOTS, FMULTS, V);
&weights->Array1(),
FKNOTS,FMULTS,V);
}
else {
BSplCLib::DN(u,N,index,deg,periodic,POLES,
BSplCLib::NoWeights(),
FKNOTS,FMULTS,V);
}
return V; return V;
} }
@ -832,63 +752,45 @@ void Geom2d_BSplineCurve::LocateU
//purpose : //purpose :
//======================================================================= //=======================================================================
void Geom2d_BSplineCurve::Resolution(const Standard_Real ToleranceUV, void Geom2d_BSplineCurve::Resolution (const Standard_Real ToleranceUV,
Standard_Real & UTolerance) Standard_Real& UTolerance)
{ {
Standard_Integer ii ; if (!maxderivinvok)
if(!maxderivinvok){ {
if ( periodic) { if (periodic)
{
Standard_Integer NbKnots, NbPoles; Standard_Integer NbKnots, NbPoles;
BSplCLib::PrepareUnperiodize( deg, BSplCLib::PrepareUnperiodize (deg, mults->Array1(), NbKnots, NbPoles);
mults->Array1(), TColgp_Array1OfPnt2d new_poles (1, NbPoles);
NbKnots, TColStd_Array1OfReal new_weights (1, NbPoles);
NbPoles); for (Standard_Integer ii = 1; ii <= NbPoles ; ii++)
TColgp_Array1OfPnt2d new_poles(1,NbPoles) ; {
TColStd_Array1OfReal new_weights(1,NbPoles) ; new_poles (ii) = poles->Array1()(((ii-1) % poles->Length()) + 1);
for(ii = 1 ; ii <= NbPoles ; ii++) {
new_poles(ii) = poles->Array1()(((ii-1) % poles->Length()) + 1) ;
} }
if (rational) { if (rational)
for(ii = 1 ; ii <= NbPoles ; ii++) { {
new_weights(ii) = weights->Array1()(((ii-1) % poles->Length()) + 1) ; for (Standard_Integer ii = 1; ii <= NbPoles; ii++)
{
new_weights (ii) = weights->Array1()(((ii-1) % poles->Length()) + 1);
} }
BSplCLib::Resolution(new_poles, }
&new_weights, BSplCLib::Resolution (new_poles,
rational ? &new_weights : BSplCLib::NoWeights(),
new_poles.Length(), new_poles.Length(),
flatknots->Array1(), flatknots->Array1(),
deg, deg,
1., 1.,
maxderivinv) ; maxderivinv);
} }
else { else
BSplCLib::Resolution(new_poles, {
BSplCLib::NoWeights(), BSplCLib::Resolution (poles->Array1(),
new_poles.Length(), rational ? &weights->Array1() : BSplCLib::NoWeights(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
}
else {
if (rational) {
BSplCLib::Resolution(poles->Array1(),
&weights->Array1(),
poles->Length(), poles->Length(),
flatknots->Array1(), flatknots->Array1(),
deg, deg,
1., 1.,
maxderivinv) ; maxderivinv);
}
else {
BSplCLib::Resolution(poles->Array1(),
BSplCLib::NoWeights(),
poles->Length(),
flatknots->Array1(),
deg,
1.,
maxderivinv) ;
}
} }
maxderivinvok = 1; maxderivinvok = 1;
} }

View File

@ -268,21 +268,10 @@ void GeomAdaptor_SurfaceOfRevolution::VIntervals(TColStd_Array1OfReal& T,
//purpose : //purpose :
//======================================================================= //=======================================================================
Handle(Adaptor3d_HSurface) GeomAdaptor_SurfaceOfRevolution::UTrim Handle(Adaptor3d_HSurface) GeomAdaptor_SurfaceOfRevolution::UTrim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const
(const Standard_Real
#ifndef No_Exception
First
#endif
,const Standard_Real
#ifndef No_Exception
Last
#endif
,const Standard_Real
) const
{ {
#ifndef No_Exception const Standard_Real Eps = Precision::PConfusion();
Standard_Real Eps = Precision::PConfusion(); (void )Eps; (void )First; (void )Last; (void )Tol;
#endif
Standard_OutOfRange_Raise_if Standard_OutOfRange_Raise_if
( Abs(First) > Eps || Abs(Last - 2.*M_PI) > Eps, ( Abs(First) > Eps || Abs(Last - 2.*M_PI) > Eps,
"GeomAdaptor_SurfaceOfRevolution : UTrim : Parameters out of range"); "GeomAdaptor_SurfaceOfRevolution : UTrim : Parameters out of range");

View File

@ -1987,20 +1987,19 @@ void Law_BSpline::
&poles->Array1()(1) ; &poles->Array1()(1) ;
new_poles_array = (Standard_Real *) new_poles_array = (Standard_Real *)
&new_poles(1) ; &new_poles(1) ;
BSplCLib::MovePointAndTangent(U, BSplCLib::MovePointAndTangent (U,
dimension, dimension,
delta, delta,
delta_derivative, delta_derivative,
Tolerance, Tolerance,
deg, deg,
rational,
StartingCondition, StartingCondition,
EndingCondition, EndingCondition,
poles_array[0], poles_array[0],
weights->Array1(), rational ? &weights->Array1() : BSplCLib::NoWeights(),
flatknots->Array1(), flatknots->Array1(),
new_poles_array[0], new_poles_array[0],
ErrorStatus) ; ErrorStatus);
if (!ErrorStatus) { if (!ErrorStatus) {
poles->ChangeArray1() = new_poles; poles->ChangeArray1() = new_poles;
} }

View File

@ -29,6 +29,7 @@ class HClassName : public _Array1Type_, public Standard_Transient {
public: \ public: \
DEFINE_STANDARD_ALLOC \ DEFINE_STANDARD_ALLOC \
DEFINE_NCOLLECTION_ALLOC \ DEFINE_NCOLLECTION_ALLOC \
HClassName () : _Array1Type_ () {} \
HClassName (const Standard_Integer theLower, \ HClassName (const Standard_Integer theLower, \
const Standard_Integer theUpper) : \ const Standard_Integer theUpper) : \
_Array1Type_ (theLower,theUpper) {} \ _Array1Type_ (theLower,theUpper) {} \

View File

@ -188,7 +188,9 @@ namespace
// Extracts vertices & normals from nodes // Extracts vertices & normals from nodes
const TColgp_Array1OfPnt& aNodes = aT->Nodes(); const TColgp_Array1OfPnt& aNodes = aT->Nodes();
const TColgp_Array1OfPnt2d& aUVNodes = aT->UVNodes(); const TColgp_Array1OfPnt2d* aUVNodes = theHasTexels && aT->HasUVNodes() && aT->UVNodes().Upper() == aNodes.Upper()
? &aT->UVNodes()
: NULL;
StdPrs_ToolTriangulatedShape::ComputeNormals (aFace, aT); StdPrs_ToolTriangulatedShape::ComputeNormals (aFace, aT);
const TShort_Array1OfShortReal& aNormals = aT->Normals(); const TShort_Array1OfShortReal& aNormals = aT->Normals();
const Standard_ShortReal* aNormArr = &aNormals.First(); const Standard_ShortReal* aNormArr = &aNormals.First();
@ -216,12 +218,12 @@ namespace
aNorm.Transform (aTrsf); aNorm.Transform (aTrsf);
} }
if (theHasTexels && aUVNodes.Upper() == aNodes.Upper()) if (aUVNodes != NULL)
{ {
const gp_Pnt2d aTexel = (dUmax == 0.0 || dVmax == 0.0) const gp_Pnt2d aTexel = (dUmax == 0.0 || dVmax == 0.0)
? aUVNodes (aNodeIter) ? aUVNodes->Value (aNodeIter)
: gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aUVNodes(aNodeIter).X() - aUmin)) / dUmax) / theUVScale.X(), : gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aUVNodes->Value (aNodeIter).X() - aUmin)) / dUmax) / theUVScale.X(),
(-theUVOrigin.Y() + (theUVRepeat.Y() * (aUVNodes(aNodeIter).Y() - aVmin)) / dVmax) / theUVScale.Y()); (-theUVOrigin.Y() + (theUVRepeat.Y() * (aUVNodes->Value (aNodeIter).Y() - aVmin)) / dVmax) / theUVScale.Y());
anArray->AddVertex (aPoint, aNorm, aTexel); anArray->AddVertex (aPoint, aNorm, aTexel);
} }
else else