From aff73fd5982f248ec430867ff9a18b7a8b482391 Mon Sep 17 00:00:00 2001 From: kgv Date: Fri, 15 Mar 2019 18:06:04 +0300 Subject: [PATCH] 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(). --- src/Approx/Approx_SweepApproximation.cxx | 11 +- src/BSplCLib/BSplCLib.hxx | 16 +- src/BSplCLib/BSplCLib_2.cxx | 9 +- src/BSplCLib/BSplCLib_CurveComputation.gxx | 13 +- src/Geom/Geom_BSplineCurve.cxx | 136 ++++------ src/Geom/Geom_BSplineCurve_1.cxx | 241 ++++++----------- src/Geom2d/Geom2d_BSplineCurve.cxx | 154 ++++------- src/Geom2d/Geom2d_BSplineCurve_1.cxx | 242 ++++++------------ .../GeomAdaptor_SurfaceOfRevolution.cxx | 17 +- src/Law/Law_BSpline.cxx | 27 +- src/NCollection/NCollection_DefineHArray1.hxx | 1 + src/StdPrs/StdPrs_ShadedShape.cxx | 12 +- 12 files changed, 296 insertions(+), 583 deletions(-) diff --git a/src/Approx/Approx_SweepApproximation.cxx b/src/Approx/Approx_SweepApproximation.cxx index 590e713af0..c252c31322 100644 --- a/src/Approx/Approx_SweepApproximation.cxx +++ b/src/Approx/Approx_SweepApproximation.cxx @@ -163,12 +163,21 @@ void Approx_SweepApproximation::Perform(const Standard_Real First, myDWeigths = new (TColStd_HArray1OfReal)(1, Num3DSS); myD2Weigths = new (TColStd_HArray1OfReal)(1, Num3DSS); - if (Num2DSS>0) { + if (Num2DSS>0) + { myPoles2d = new (TColgp_HArray1OfPnt2d)(1, Num2DSS); myDPoles2d = new (TColgp_HArray1OfVec2d)(1, Num2DSS); myD2Poles2d = new (TColgp_HArray1OfVec2d)(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 if (continuity >= GeomAbs_C2) { Standard_Boolean B; diff --git a/src/BSplCLib/BSplCLib.hxx b/src/BSplCLib/BSplCLib.hxx index 946ac3ca43..7d7ef6a84e 100644 --- a/src/BSplCLib/BSplCLib.hxx +++ b/src/BSplCLib/BSplCLib.hxx @@ -1337,7 +1337,7 @@ public: //! (3, NbPoles-2) -> the ends and the tangency are enforced //! if Problem in BSplineBasis calculation, no change for the curve //! 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 //! given u as parameter) to reach a new position @@ -1348,7 +1348,7 @@ public: //! (3, NbPoles-2) -> the ends and the tangency are enforced //! if Problem in BSplineBasis calculation, no change for the curve //! 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 //! U is the parameter must be within the first FlatKnots and the @@ -1366,7 +1366,7 @@ public: //! = ... //! Same holds for EndingCondition //! 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 //! ErrorStatus will be 0 if no error happened //! 1 if there are not enough knots/poles @@ -1375,7 +1375,7 @@ public: //! 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 //! 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 //! U is the parameter must be within the first FlatKnots and the @@ -1393,7 +1393,7 @@ public: //! = ... //! Same holds for EndingCondition //! 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 //! ErrorStatus will be 0 if no error happened //! 1 if there are not enough knots/poles @@ -1402,7 +1402,7 @@ public: //! 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 //! 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 //! U is the parameter must be within the first FlatKnots and the @@ -1420,7 +1420,7 @@ public: //! = ... //! Same holds for EndingCondition //! 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 //! ErrorStatus will be 0 if no error happened //! 1 if there are not enough knots/poles @@ -1429,7 +1429,7 @@ public: //! 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 //! 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 diff --git a/src/BSplCLib/BSplCLib_2.cxx b/src/BSplCLib/BSplCLib_2.cxx index bbdfebef51..54e114d92f 100644 --- a/src/BSplCLib/BSplCLib_2.cxx +++ b/src/BSplCLib/BSplCLib_2.cxx @@ -567,11 +567,10 @@ void BSplCLib::MovePointAndTangent(const Standard_Real U, Standard_Real &DeltaDerivatives, 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* Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Real& NewPoles, Standard_Integer& ErrorStatus) @@ -603,8 +602,8 @@ void BSplCLib::MovePointAndTangent(const Standard_Real U, ErrorStatus = 0 ; weights_array = NULL ; - if (Rational) { - weights_array = (Standard_Real *) &Weights(Weights.Lower()) ; + if (Weights != NULL) { + weights_array = const_cast(&Weights->First()); } poles_array = &Poles ; @@ -765,7 +764,7 @@ void BSplCLib::MovePointAndTangent(const Standard_Real U, extrap_mode[0] = Degree ; extrap_mode[1] = Degree ; - if (Rational) { + if (Weights != NULL) { // // evaluate in homogenised form // diff --git a/src/BSplCLib/BSplCLib_CurveComputation.gxx b/src/BSplCLib/BSplCLib_CurveComputation.gxx index 584b8d63d9..1ebee54a48 100644 --- a/src/BSplCLib/BSplCLib_CurveComputation.gxx +++ b/src/BSplCLib/BSplCLib_CurveComputation.gxx @@ -1218,9 +1218,8 @@ void BSplCLib::MovePoint (const Standard_Real U, const Standard_Integer Index1, const Standard_Integer Index2, const Standard_Integer Degree, - const Standard_Boolean Rational, const Array1OfPoints& Poles, - const TColStd_Array1OfReal& Weights, + const TColStd_Array1OfReal* Weights, const TColStd_Array1OfReal& FlatKnots, Standard_Integer& FirstIndex, Standard_Integer& LastIndex, @@ -1280,8 +1279,8 @@ void BSplCLib::MovePoint (const Standard_Real U, for (i = 1; i <= Degree+1; i++) { ii = i + FirstNonZeroBsplineIndex - 1; - if (Rational) { - hN = Weights(ii)*BSplineBasis(1, i); + if (Weights != NULL) { + hN = Weights->Value(ii)*BSplineBasis(1, i); D2 += hN; } else { @@ -1301,7 +1300,7 @@ void BSplCLib::MovePoint (const Standard_Real U, } } - if (Rational) { + if (Weights != NULL) { Coef = D2/D1; } else { @@ -1345,11 +1344,10 @@ void BSplCLib::MovePointAndTangent (const Standard_Real U, const Vector& DeltaDerivatives, const Standard_Real Tolerance, const Standard_Integer Degree, - const Standard_Boolean Rational, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, const Array1OfPoints& Poles, - const TColStd_Array1OfReal& Weights, + const TColStd_Array1OfReal* Weights, const TColStd_Array1OfReal& FlatKnots, Array1OfPoints& NewPoles, Standard_Integer & ErrorStatus) @@ -1376,7 +1374,6 @@ void BSplCLib::MovePointAndTangent (const Standard_Real U, delta_derivative_array[0], Tolerance, Degree, - Rational, StartingCondition, EndingCondition, poles_array[0], diff --git a/src/Geom/Geom_BSplineCurve.cxx b/src/Geom/Geom_BSplineCurve.cxx index c2c07e7bcc..7792defa11 100644 --- a/src/Geom/Geom_BSplineCurve.cxx +++ b/src/Geom/Geom_BSplineCurve.cxx @@ -257,35 +257,21 @@ void Geom_BSplineCurve::IncreaseDegree (const Standard_Integer Degree) new TColStd_HArray1OfInteger(1,nbknots); Handle(TColStd_HArray1OfReal) nweights; - - if (IsRational()) { - + if (IsRational()) + { 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, - poles->Array1(),BSplCLib::NoWeights(), - knots->Array1(),mults->Array1(), - npoles->ChangeArray1(), - BSplCLib::NoWeights(), - nknots->ChangeArray1(),nmults->ChangeArray1()); - } - + BSplCLib::IncreaseDegree (deg, Degree, periodic, + poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(), + knots->Array1(), mults->Array1(), + npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(), + nknots->ChangeArray1(),nmults->ChangeArray1()); deg = Degree; poles = npoles; weights = nweights; knots = nknots; mults = nmults; UpdateKnots(); - } //======================================================================= @@ -385,34 +371,24 @@ void Geom_BSplineCurve::InsertKnots(const TColStd_Array1OfReal& Knots, nmults = new TColStd_HArray1OfInteger(1,nbknots); } - if (rational) { - Handle(TColStd_HArray1OfReal) nweights = - new TColStd_HArray1OfReal(1,nbpoles); - BSplCLib::InsertKnots(deg,periodic, - 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); + Handle(TColStd_HArray1OfReal) nweights; + if (rational) + { + nweights = new TColStd_HArray1OfReal(1,nbpoles); } + 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; knots = nknots; mults = nmults; UpdateKnots(); - } //======================================================================= @@ -452,31 +428,23 @@ Standard_Boolean Geom_BSplineCurve::RemoveKnot(const Standard_Integer Index, nmults = new TColStd_HArray1OfInteger(1,knots->Length()-1); } - if (IsRational()) { - Handle(TColStd_HArray1OfReal) nweights = - new TColStd_HArray1OfReal(1,npoles->Length()); - if (!BSplCLib::RemoveKnot - (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; + Handle(TColStd_HArray1OfReal) nweights; + if (IsRational()) + { + nweights = new TColStd_HArray1OfReal(1,npoles->Length()); } - else { - if (!BSplCLib::RemoveKnot - (Index, M, deg, periodic, - poles->Array1(), BSplCLib::NoWeights(), - knots->Array1(),mults->Array1(), - npoles->ChangeArray1(), - BSplCLib::NoWeights(), - nknots->ChangeArray1(),nmults->ChangeArray1(), - Tolerance)) - return Standard_False; + + if (!BSplCLib::RemoveKnot (Index, M, deg, periodic, + poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(), + knots->Array1(),mults->Array1(), + npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(), + nknots->ChangeArray1(),nmults->ChangeArray1(), + Tolerance)) + { + return Standard_False; } - + + weights = nweights; poles = npoles; knots = nknots; mults = nmults; @@ -932,27 +900,16 @@ void Geom_BSplineCurve::SetNotPeriodic () = new TColStd_HArray1OfInteger(1,NbKnots); Handle(TColStd_HArray1OfReal) nweights; - - if (IsRational()) { - + if (IsRational()) + { 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 - (deg,mults->Array1(),knots->Array1(),poles->Array1(), - BSplCLib::NoWeights(),nmults->ChangeArray1(), - nknots->ChangeArray1(),npoles->ChangeArray1(), - BSplCLib::NoWeights()); - } + + BSplCLib::Unperiodize (deg, + mults->Array1(), knots->Array1(), poles->Array1(), + !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(), + nmults->ChangeArray1(), nknots->ChangeArray1(), npoles->ChangeArray1(), + !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights()); poles = npoles; weights = nweights; mults = nmults; @@ -1046,9 +1003,9 @@ void Geom_BSplineCurve::MovePoint(const Standard_Real U, gp_Pnt P0; D0(U, P0); gp_Vec Displ(P0, P); - BSplCLib::MovePoint(U, Displ, Index1, Index2, deg, rational, poles->Array1(), - weights->Array1(), flatknots->Array1(), - FirstModifiedPole, LastmodifiedPole, npoles); + BSplCLib::MovePoint (U, Displ, Index1, Index2, deg, poles->Array1(), + rational ? &weights->Array1() : BSplCLib::NoWeights(), flatknots->Array1(), + FirstModifiedPole, LastmodifiedPole, npoles); if (FirstModifiedPole) { poles->ChangeArray1() = npoles; maxderivinvok = 0; @@ -1091,11 +1048,10 @@ void Geom_BSplineCurve::MovePointAndTangent(const Standard_Real U, delta_derivative, Tolerance, deg, - rational, StartingCondition, EndingCondition, poles->Array1(), - weights->Array1(), + rational ? &weights->Array1() : BSplCLib::NoWeights(), flatknots->Array1(), new_poles, ErrorStatus) ; diff --git a/src/Geom/Geom_BSplineCurve_1.cxx b/src/Geom/Geom_BSplineCurve_1.cxx index 303374e934..d9bc85afae 100644 --- a/src/Geom/Geom_BSplineCurve_1.cxx +++ b/src/Geom/Geom_BSplineCurve_1.cxx @@ -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); if (aNewU < knots->Value(aSpanIndex)) aSpanIndex--; - if (rational) - { - BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES, - &weights->Array1(), - knots->Array1(), &mults->Array1(), - P); - } - else - { - BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES, - BSplCLib::NoWeights(), - knots->Array1(), &mults->Array1(), - P); - } + + BSplCLib::D0 (aNewU, aSpanIndex, deg, periodic, POLES, + rational ? &weights->Array1() : 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); if (aNewU < knots->Value(aSpanIndex)) aSpanIndex--; - if (rational) - { - BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES, - &weights->Array1(), - knots->Array1(), &mults->Array1(), - P, V1); - } - else - { - BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES, - BSplCLib::NoWeights(), - knots->Array1(), &mults->Array1(), - P, V1); - } + + BSplCLib::D1 (aNewU, aSpanIndex, deg, periodic, POLES, + rational ? &weights->Array1() : 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); if (aNewU < knots->Value(aSpanIndex)) aSpanIndex--; - if (rational) - { - BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES, - &weights->Array1(), - knots->Array1(), &mults->Array1(), - P, V1, V2); - } - else - { - BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES, - BSplCLib::NoWeights(), - knots->Array1(), &mults->Array1(), - P, V1, V2); - } + + BSplCLib::D2 (aNewU, aSpanIndex, deg, periodic, POLES, + rational ? &weights->Array1() : 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); if (aNewU < knots->Value(aSpanIndex)) aSpanIndex--; - if (rational) - { - BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES, - &weights->Array1(), - knots->Array1(), &mults->Array1(), - P, V1, V2, V3); - } - else - { - BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES, - BSplCLib::NoWeights(), - knots->Array1(), &mults->Array1(), - P, V1, V2, V3); - } + + BSplCLib::D3 (aNewU, aSpanIndex, deg, periodic, POLES, + rational ? &weights->Array1() : 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 { gp_Vec V; - if (rational) { - BSplCLib::DN(U,N,0,deg,periodic,POLES, - &weights->Array1(), - FKNOTS,FMULTS,V); - } - else { - BSplCLib::DN(U,N,0,deg,periodic,POLES, - BSplCLib::NoWeights(), - FKNOTS,FMULTS,V); - } + BSplCLib::DN (U, N, 0, deg, periodic, POLES, + rational ? &weights->Array1() : BSplCLib::NoWeights(), + FKNOTS, FMULTS, V); return V; } @@ -466,16 +423,9 @@ void Geom_BSplineCurve::LocalD0 Standard_Integer index = 0; BSplCLib::LocateParameter(deg, FKNOTS, U, periodic,FromK1,ToK2, index,u); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); - if (rational) { - BSplCLib::D0(u,index,deg,periodic,POLES, - &weights->Array1(), - FKNOTS,FMULTS,P); - } - else { - BSplCLib::D0(u,index,deg,periodic,POLES, - BSplCLib::NoWeights(), - FKNOTS,FMULTS,P); - } + BSplCLib::D0 (u, index, deg, periodic, POLES, + rational ? &weights->Array1() : BSplCLib::NoWeights(), + FKNOTS, FMULTS, P); } //======================================================================= @@ -496,16 +446,9 @@ void Geom_BSplineCurve::LocalD1 (const Standard_Real U, Standard_Integer index = 0; BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); - if (rational) { - BSplCLib::D1(u,index,deg,periodic,POLES, - &weights->Array1(), - FKNOTS,FMULTS,P,V1); - } - else { - BSplCLib::D1(u,index,deg,periodic,POLES, - BSplCLib::NoWeights(), - FKNOTS,FMULTS,P,V1); - } + BSplCLib::D1 (u, index, deg, periodic, POLES, + rational ? &weights->Array1() : BSplCLib::NoWeights(), + FKNOTS,FMULTS,P,V1); } //======================================================================= @@ -528,16 +471,9 @@ void Geom_BSplineCurve::LocalD2 Standard_Integer index = 0; BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); - if (rational) { - BSplCLib::D2(u,index,deg,periodic,POLES, - &weights->Array1(), - FKNOTS,FMULTS,P,V1,V2); - } - else { - BSplCLib::D2(u,index,deg,periodic,POLES, - BSplCLib::NoWeights(), - FKNOTS,FMULTS,P,V1,V2); - } + BSplCLib::D2 (u, index, deg, periodic, POLES, + rational ? &weights->Array1() : BSplCLib::NoWeights(), + FKNOTS, FMULTS, P, V1, V2); } //======================================================================= @@ -561,16 +497,9 @@ void Geom_BSplineCurve::LocalD3 Standard_Integer index = 0; BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); - if (rational) { - BSplCLib::D3(u,index,deg,periodic,POLES, - &weights->Array1(), - FKNOTS,FMULTS,P,V1,V2,V3); - } - else { - BSplCLib::D3(u,index,deg,periodic,POLES, - BSplCLib::NoWeights(), - FKNOTS,FMULTS,P,V1,V2,V3); - } + BSplCLib::D3 (u, index, deg, periodic, POLES, + rational ? &weights->Array1() : 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); gp_Vec V; - if (rational) { - BSplCLib::DN(u,N,index,deg,periodic,POLES, - &weights->Array1(), - FKNOTS,FMULTS,V); - } - else { - BSplCLib::DN(u,N,index,deg,periodic,POLES, - BSplCLib::NoWeights(), - FKNOTS,FMULTS,V); - } + BSplCLib::DN (u, N, index, deg, periodic, POLES, + rational ? &weights->Array1() : BSplCLib::NoWeights(), + FKNOTS, FMULTS, V); return V; } @@ -821,64 +743,45 @@ void Geom_BSplineCurve::LocateU //purpose : //======================================================================= -void Geom_BSplineCurve::Resolution(const Standard_Real Tolerance3D, - Standard_Real & UTolerance) +void Geom_BSplineCurve::Resolution (const Standard_Real Tolerance3D, + Standard_Real& UTolerance) { - Standard_Integer ii; - if(!maxderivinvok){ - if ( periodic) { + if (!maxderivinvok) + { + if (periodic) + { Standard_Integer NbKnots, NbPoles; - BSplCLib::PrepareUnperiodize( deg, - mults->Array1(), - NbKnots, - NbPoles); - TColgp_Array1OfPnt new_poles(1,NbPoles) ; - TColStd_Array1OfReal new_weights(1,NbPoles) ; - for(ii = 1 ; ii <= NbPoles ; ii++) { - new_poles(ii) = poles->Array1()((ii-1) % poles->Length() + 1) ; + BSplCLib::PrepareUnperiodize (deg, mults->Array1(), NbKnots, NbPoles); + TColgp_Array1OfPnt new_poles (1, NbPoles); + TColStd_Array1OfReal new_weights(1, NbPoles); + for (Standard_Integer ii = 1; ii <= NbPoles; ii++) + { + new_poles(ii) = poles->Array1()((ii-1) % poles->Length() + 1); } - if (rational) { - for(ii = 1 ; ii <= NbPoles ; ii++) { - new_weights(ii) = weights->Array1()((ii-1) % poles->Length() + 1) ; - } - BSplCLib::Resolution(new_poles, - &new_weights, - new_poles.Length(), - flatknots->Array1(), - deg, - 1., - maxderivinv) ; + if (rational) + { + for (Standard_Integer ii = 1; ii <= NbPoles; ii++) + { + new_weights(ii) = weights->Array1()((ii-1) % poles->Length() + 1); + } } - else { - BSplCLib::Resolution(new_poles, - BSplCLib::NoWeights(), - new_poles.Length(), - flatknots->Array1(), - deg, - 1., - maxderivinv) ; - } - + BSplCLib::Resolution (new_poles, + rational ? &new_weights : BSplCLib::NoWeights(), + new_poles.Length(), + flatknots->Array1(), + deg, + 1., + maxderivinv); } - else { - if (rational) { - BSplCLib::Resolution(poles->Array1(), - &weights->Array1(), - poles->Length(), - flatknots->Array1(), - deg, - 1., - maxderivinv) ; - } - else { - BSplCLib::Resolution(poles->Array1(), - BSplCLib::NoWeights(), - poles->Length(), - flatknots->Array1(), - deg, - 1., - maxderivinv) ; - } + else + { + BSplCLib::Resolution (poles->Array1(), + rational ? &weights->Array1() : BSplCLib::NoWeights(), + poles->Length(), + flatknots->Array1(), + deg, + 1., + maxderivinv); } maxderivinvok = 1; } diff --git a/src/Geom2d/Geom2d_BSplineCurve.cxx b/src/Geom2d/Geom2d_BSplineCurve.cxx index b4cc7df96e..9ab6e279fb 100644 --- a/src/Geom2d/Geom2d_BSplineCurve.cxx +++ b/src/Geom2d/Geom2d_BSplineCurve.cxx @@ -257,27 +257,14 @@ void Geom2d_BSplineCurve::IncreaseDegree Handle(TColStd_HArray1OfReal) nweights; if (IsRational()) { - 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, - poles->Array1(), - BSplCLib::NoWeights(), - knots->Array1(),mults->Array1(), - npoles->ChangeArray1(), - BSplCLib::NoWeights(), - nknots->ChangeArray1(),nmults->ChangeArray1()); - } + BSplCLib::IncreaseDegree (deg, Degree, periodic, + poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(), + knots->Array1(), mults->Array1(), + npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(), + nknots->ChangeArray1(), nmults->ChangeArray1()); deg = Degree; poles = npoles; @@ -384,35 +371,24 @@ void Geom2d_BSplineCurve::InsertKnots(const TColStd_Array1OfReal& Knots, nmults = new TColStd_HArray1OfInteger(1,nbknots); } - if (rational) { - Handle(TColStd_HArray1OfReal) nweights = - new TColStd_HArray1OfReal(1,nbpoles); - BSplCLib::InsertKnots(deg,periodic, - 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); + Handle(TColStd_HArray1OfReal) nweights; + if (rational) + { + nweights = new TColStd_HArray1OfReal (1, nbpoles); } + 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; knots = nknots; mults = nmults; UpdateKnots(); - } //======================================================================= @@ -450,32 +426,23 @@ Standard_Boolean Geom2d_BSplineCurve::RemoveKnot nmults = new TColStd_HArray1OfInteger(1,knots->Length()-1); } - if (IsRational()) { - Handle(TColStd_HArray1OfReal) nweights = - new TColStd_HArray1OfReal(1,npoles->Length()); - if (!BSplCLib::RemoveKnot - (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; + Handle(TColStd_HArray1OfReal) nweights; + if (IsRational()) + { + nweights = new TColStd_HArray1OfReal(1,npoles->Length()); } - else { - if (!BSplCLib::RemoveKnot - (Index, M, deg, periodic, - poles->Array1(), - BSplCLib::NoWeights(), - knots->Array1(),mults->Array1(), - npoles->ChangeArray1(), - BSplCLib::NoWeights(), - nknots->ChangeArray1(),nmults->ChangeArray1(), - Tolerance)) - return Standard_False; + + if (!BSplCLib::RemoveKnot (Index, M, deg, periodic, + poles->Array1(), !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(), + knots->Array1(),mults->Array1(), + npoles->ChangeArray1(), !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights(), + nknots->ChangeArray1(),nmults->ChangeArray1(), + Tolerance)) + { + return Standard_False; } - + + weights = nweights; poles = npoles; knots = nknots; mults = nmults; @@ -1047,27 +1014,15 @@ void Geom2d_BSplineCurve::SetNotPeriodic () = new TColStd_HArray1OfInteger(1,NbKnots); Handle(TColStd_HArray1OfReal) nweights; - if (IsRational()) { - 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 - (deg,mults->Array1(),knots->Array1(),poles->Array1(), - BSplCLib::NoWeights(),nmults->ChangeArray1(), - nknots->ChangeArray1(),npoles->ChangeArray1(), - BSplCLib::NoWeights()); - } + + BSplCLib::Unperiodize (deg, + mults->Array1(), knots->Array1(), poles->Array1(), + !nweights.IsNull() ? &weights->Array1() : BSplCLib::NoWeights(), + nmults->ChangeArray1(), nknots->ChangeArray1(), npoles->ChangeArray1(), + !nweights.IsNull() ? &nweights->ChangeArray1() : BSplCLib::NoWeights()); poles = npoles; weights = nweights; mults = nmults; @@ -1161,9 +1116,10 @@ void Geom2d_BSplineCurve::MovePoint(const Standard_Real U, gp_Pnt2d P0; D0(U, P0); gp_Vec2d Displ(P0, P); - BSplCLib::MovePoint(U, Displ, Index1, Index2, deg, rational, poles->Array1(), - weights->Array1(), flatknots->Array1(), - FirstModifiedPole, LastmodifiedPole, npoles); + + BSplCLib::MovePoint (U, Displ, Index1, Index2, deg, poles->Array1(), + rational ? &weights->Array1() : BSplCLib::NoWeights(), flatknots->Array1(), + FirstModifiedPole, LastmodifiedPole, npoles); if (FirstModifiedPole) { poles->ChangeArray1() = npoles; maxderivinvok = 0; @@ -1203,19 +1159,19 @@ MovePointAndTangent(const Standard_Real U, delta_derivative.SetCoord(ii, Tangent.Coord(ii)- delta_derivative.Coord(ii)) ; } - BSplCLib::MovePointAndTangent(U, - delta, - delta_derivative, - Tolerance, - deg, - rational, - StartingCondition, - EndingCondition, - poles->Array1(), - weights->Array1(), - flatknots->Array1(), - new_poles, - ErrorStatus) ; + + BSplCLib::MovePointAndTangent (U, + delta, + delta_derivative, + Tolerance, + deg, + StartingCondition, + EndingCondition, + poles->Array1(), + rational ? &weights->Array1() : BSplCLib::NoWeights(), + flatknots->Array1(), + new_poles, + ErrorStatus); if (!ErrorStatus) { poles->ChangeArray1() = new_poles; maxderivinvok = 0; diff --git a/src/Geom2d/Geom2d_BSplineCurve_1.cxx b/src/Geom2d/Geom2d_BSplineCurve_1.cxx index d6b231ec17..d390e8ddaf 100644 --- a/src/Geom2d/Geom2d_BSplineCurve_1.cxx +++ b/src/Geom2d/Geom2d_BSplineCurve_1.cxx @@ -190,20 +190,11 @@ void Geom2d_BSplineCurve::D0(const Standard_Real U, BSplCLib::LocateParameter(deg, knots->Array1(), &mults->Array1(), U, periodic, aSpanIndex, aNewU); if (aNewU < knots->Value(aSpanIndex)) aSpanIndex--; - if (rational) - { - BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES, - &weights->Array1(), - knots->Array1(), &mults->Array1(), - P); - } - else - { - BSplCLib::D0(aNewU,aSpanIndex,deg,periodic,POLES, - BSplCLib::NoWeights(), - knots->Array1(), &mults->Array1(), - P); - } + + BSplCLib::D0 (aNewU, aSpanIndex, deg, periodic, POLES, + rational ? &weights->Array1() : 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); if (aNewU < knots->Value(aSpanIndex)) aSpanIndex--; - if (rational) - { - BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES, - &weights->Array1(), - knots->Array1(), &mults->Array1(), - P, V1); - } - else - { - BSplCLib::D1(aNewU,aSpanIndex,deg,periodic,POLES, - BSplCLib::NoWeights(), - knots->Array1(), &mults->Array1(), - P, V1); - } + + BSplCLib::D1 (aNewU, aSpanIndex, deg, periodic, POLES, + rational ? &weights->Array1() : 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); if (aNewU < knots->Value(aSpanIndex)) aSpanIndex--; - if (rational) - { - BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES, - &weights->Array1(), - knots->Array1(), &mults->Array1(), - P, V1, V2); - } - else - { - BSplCLib::D2(aNewU,aSpanIndex,deg,periodic,POLES, - BSplCLib::NoWeights(), - knots->Array1(), &mults->Array1(), - P, V1, V2); - } + + BSplCLib::D2 (aNewU, aSpanIndex, deg, periodic, POLES, + rational ? &weights->Array1() : 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); if (aNewU < knots->Value(aSpanIndex)) aSpanIndex--; - if (rational) - { - BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES, - &weights->Array1(), - knots->Array1(), &mults->Array1(), - P, V1, V2, V3); - } - else - { - BSplCLib::D3(aNewU,aSpanIndex,deg,periodic,POLES, - BSplCLib::NoWeights(), - knots->Array1(), &mults->Array1(), - P, V1, V2, V3); - } + + BSplCLib::D3 (aNewU, aSpanIndex, deg, periodic, POLES, + rational ? &weights->Array1() : 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 { gp_Vec2d V; - - if ( rational ) { - BSplCLib::DN(U,N,0,deg,periodic,POLES, - &weights->Array1(), - FKNOTS,FMULTS, V); - } - else { - BSplCLib::DN(U,N,0,deg,periodic,POLES, - BSplCLib::NoWeights(), - FKNOTS,FMULTS,V); - } + BSplCLib::DN (U, N, 0, deg, periodic, POLES, + rational ? &weights->Array1() : BSplCLib::NoWeights(), + FKNOTS, FMULTS, V); return V; } @@ -475,16 +431,9 @@ void Geom2d_BSplineCurve::LocalD0 BSplCLib::LocateParameter(deg, FKNOTS, U, periodic,FromK1,ToK2, index,u); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); - if ( rational ) { - BSplCLib::D0(u,index,deg,periodic,POLES, - &weights->Array1(), - FKNOTS,FMULTS,P); - } - else { - BSplCLib::D0(u,index,deg,periodic,POLES, - BSplCLib::NoWeights(), - FKNOTS,FMULTS,P); - } + BSplCLib::D0 (u, index, deg, periodic, POLES, + rational ? &weights->Array1() : 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); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); - if (rational) { - BSplCLib::D1(u,index,deg,periodic,POLES, - &weights->Array1(), - FKNOTS,FMULTS,P,V1); - } - else { - BSplCLib::D1(u,index,deg,periodic,POLES, - BSplCLib::NoWeights(), - FKNOTS,FMULTS,P,V1); - } + BSplCLib::D1 (u, index, deg, periodic, POLES, + rational ? &weights->Array1() : BSplCLib::NoWeights(), + FKNOTS, FMULTS, P, V1); } //======================================================================= @@ -539,16 +481,9 @@ void Geom2d_BSplineCurve::LocalD2 BSplCLib::LocateParameter(deg, FKNOTS, U, periodic, FromK1,ToK2, index, u); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); - if ( rational ) { - BSplCLib::D2(u,index,deg,periodic,POLES, - &weights->Array1(), - FKNOTS,FMULTS,P,V1,V2); - } - else { - BSplCLib::D2(u,index,deg,periodic,POLES, - BSplCLib::NoWeights(), - FKNOTS,FMULTS,P,V1,V2); - } + BSplCLib::D2 (u, index, deg, periodic, POLES, + rational ? &weights->Array1() : 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); index = BSplCLib::FlatIndex(deg,index,mults->Array1(),periodic); - if ( rational ) { - BSplCLib::D3(u,index,deg,periodic,POLES, - &weights->Array1(), - FKNOTS,FMULTS,P,V1,V2,V3); - } - else { - BSplCLib::D3(u,index,deg,periodic,POLES, - BSplCLib::NoWeights(), - FKNOTS,FMULTS,P,V1,V2,V3); - } + BSplCLib::D3 (u, index, deg, periodic, POLES, + rational ? &weights->Array1() : 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); gp_Vec2d V; - - if ( rational ) { - BSplCLib::DN(u,N,index,deg,periodic,POLES, - &weights->Array1(), - FKNOTS,FMULTS,V); - } - else { - BSplCLib::DN(u,N,index,deg,periodic,POLES, - BSplCLib::NoWeights(), - FKNOTS,FMULTS,V); - } + BSplCLib::DN (u, N, index, deg, periodic, POLES, + rational ? &weights->Array1() : BSplCLib::NoWeights(), + FKNOTS, FMULTS, V); return V; } @@ -832,63 +752,45 @@ void Geom2d_BSplineCurve::LocateU //purpose : //======================================================================= -void Geom2d_BSplineCurve::Resolution(const Standard_Real ToleranceUV, - Standard_Real & UTolerance) +void Geom2d_BSplineCurve::Resolution (const Standard_Real ToleranceUV, + Standard_Real& UTolerance) { - Standard_Integer ii ; - if(!maxderivinvok){ - if ( periodic) { + if (!maxderivinvok) + { + if (periodic) + { Standard_Integer NbKnots, NbPoles; - BSplCLib::PrepareUnperiodize( deg, - mults->Array1(), - NbKnots, - NbPoles); - TColgp_Array1OfPnt2d new_poles(1,NbPoles) ; - TColStd_Array1OfReal new_weights(1,NbPoles) ; - for(ii = 1 ; ii <= NbPoles ; ii++) { - new_poles(ii) = poles->Array1()(((ii-1) % poles->Length()) + 1) ; + BSplCLib::PrepareUnperiodize (deg, mults->Array1(), NbKnots, NbPoles); + TColgp_Array1OfPnt2d new_poles (1, NbPoles); + TColStd_Array1OfReal new_weights (1, NbPoles); + for (Standard_Integer ii = 1; ii <= NbPoles ; ii++) + { + new_poles (ii) = poles->Array1()(((ii-1) % poles->Length()) + 1); } - if (rational) { - for(ii = 1 ; ii <= NbPoles ; ii++) { - new_weights(ii) = weights->Array1()(((ii-1) % poles->Length()) + 1) ; - } - BSplCLib::Resolution(new_poles, - &new_weights, - new_poles.Length(), - flatknots->Array1(), - deg, - 1., - maxderivinv) ; - } - else { - BSplCLib::Resolution(new_poles, - BSplCLib::NoWeights(), - new_poles.Length(), - flatknots->Array1(), - deg, - 1., - maxderivinv) ; + if (rational) + { + for (Standard_Integer ii = 1; ii <= NbPoles; ii++) + { + new_weights (ii) = weights->Array1()(((ii-1) % poles->Length()) + 1); + } } + BSplCLib::Resolution (new_poles, + rational ? &new_weights : BSplCLib::NoWeights(), + new_poles.Length(), + flatknots->Array1(), + deg, + 1., + maxderivinv); } - else { - if (rational) { - BSplCLib::Resolution(poles->Array1(), - &weights->Array1(), - poles->Length(), - flatknots->Array1(), - deg, - 1., - maxderivinv) ; - } - else { - BSplCLib::Resolution(poles->Array1(), - BSplCLib::NoWeights(), - poles->Length(), - flatknots->Array1(), - deg, - 1., - maxderivinv) ; - } + else + { + BSplCLib::Resolution (poles->Array1(), + rational ? &weights->Array1() : BSplCLib::NoWeights(), + poles->Length(), + flatknots->Array1(), + deg, + 1., + maxderivinv); } maxderivinvok = 1; } diff --git a/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx index d8fdd70710..ccbf50aceb 100644 --- a/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx +++ b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx @@ -268,21 +268,10 @@ void GeomAdaptor_SurfaceOfRevolution::VIntervals(TColStd_Array1OfReal& T, //purpose : //======================================================================= -Handle(Adaptor3d_HSurface) GeomAdaptor_SurfaceOfRevolution::UTrim -(const Standard_Real -#ifndef No_Exception - First -#endif - ,const Standard_Real -#ifndef No_Exception - Last -#endif - ,const Standard_Real - ) const +Handle(Adaptor3d_HSurface) GeomAdaptor_SurfaceOfRevolution::UTrim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const { -#ifndef No_Exception - Standard_Real Eps = Precision::PConfusion(); -#endif + const Standard_Real Eps = Precision::PConfusion(); + (void )Eps; (void )First; (void )Last; (void )Tol; Standard_OutOfRange_Raise_if ( Abs(First) > Eps || Abs(Last - 2.*M_PI) > Eps, "GeomAdaptor_SurfaceOfRevolution : UTrim : Parameters out of range"); diff --git a/src/Law/Law_BSpline.cxx b/src/Law/Law_BSpline.cxx index c4eaeb3e3b..0f245a42b0 100644 --- a/src/Law/Law_BSpline.cxx +++ b/src/Law/Law_BSpline.cxx @@ -1987,20 +1987,19 @@ void Law_BSpline:: &poles->Array1()(1) ; new_poles_array = (Standard_Real *) &new_poles(1) ; - BSplCLib::MovePointAndTangent(U, - dimension, - delta, - delta_derivative, - Tolerance, - deg, - rational, - StartingCondition, - EndingCondition, - poles_array[0], - weights->Array1(), - flatknots->Array1(), - new_poles_array[0], - ErrorStatus) ; + BSplCLib::MovePointAndTangent (U, + dimension, + delta, + delta_derivative, + Tolerance, + deg, + StartingCondition, + EndingCondition, + poles_array[0], + rational ? &weights->Array1() : BSplCLib::NoWeights(), + flatknots->Array1(), + new_poles_array[0], + ErrorStatus); if (!ErrorStatus) { poles->ChangeArray1() = new_poles; } diff --git a/src/NCollection/NCollection_DefineHArray1.hxx b/src/NCollection/NCollection_DefineHArray1.hxx index 5304a3876d..d1da5ee2f8 100644 --- a/src/NCollection/NCollection_DefineHArray1.hxx +++ b/src/NCollection/NCollection_DefineHArray1.hxx @@ -29,6 +29,7 @@ class HClassName : public _Array1Type_, public Standard_Transient { public: \ DEFINE_STANDARD_ALLOC \ DEFINE_NCOLLECTION_ALLOC \ + HClassName () : _Array1Type_ () {} \ HClassName (const Standard_Integer theLower, \ const Standard_Integer theUpper) : \ _Array1Type_ (theLower,theUpper) {} \ diff --git a/src/StdPrs/StdPrs_ShadedShape.cxx b/src/StdPrs/StdPrs_ShadedShape.cxx index c39b366f12..60c41a1286 100644 --- a/src/StdPrs/StdPrs_ShadedShape.cxx +++ b/src/StdPrs/StdPrs_ShadedShape.cxx @@ -188,7 +188,9 @@ namespace // Extracts vertices & normals from 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); const TShort_Array1OfShortReal& aNormals = aT->Normals(); const Standard_ShortReal* aNormArr = &aNormals.First(); @@ -216,12 +218,12 @@ namespace aNorm.Transform (aTrsf); } - if (theHasTexels && aUVNodes.Upper() == aNodes.Upper()) + if (aUVNodes != NULL) { const gp_Pnt2d aTexel = (dUmax == 0.0 || dVmax == 0.0) - ? aUVNodes (aNodeIter) - : gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aUVNodes(aNodeIter).X() - aUmin)) / dUmax) / theUVScale.X(), - (-theUVOrigin.Y() + (theUVRepeat.Y() * (aUVNodes(aNodeIter).Y() - aVmin)) / dVmax) / theUVScale.Y()); + ? aUVNodes->Value (aNodeIter) + : gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aUVNodes->Value (aNodeIter).X() - aUmin)) / dUmax) / theUVScale.X(), + (-theUVOrigin.Y() + (theUVRepeat.Y() * (aUVNodes->Value (aNodeIter).Y() - aVmin)) / dVmax) / theUVScale.Y()); anArray->AddVertex (aPoint, aNorm, aTexel); } else