1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-07 18:30:55 +03:00

0025256: Small optimization in Convert comp bezier to BSpline

Optimization and code cleaning of CompBezierCurvesToBSplineCurve::Perform
This commit is contained in:
pdn 2014-09-22 19:25:14 +04:00 committed by bugmaster
parent d780e37a83
commit 0d1b4a2271

View File

@ -160,7 +160,7 @@ void Convert_CompBezierCurvesToBSplineCurve::Perform()
myDegree = Max( myDegree, (mySequence(i))->Length() -1); myDegree = Max( myDegree, (mySequence(i))->Length() -1);
} }
Standard_Real D1, D2, Lambda, Det=0; Standard_Real Det=0;
gp_Pnt P1, P2, P3; gp_Pnt P1, P2, P3;
Standard_Integer Deg, Inc, MaxDegree = myDegree; Standard_Integer Deg, Inc, MaxDegree = myDegree;
TColgp_Array1OfPnt Points(1, myDegree+1); TColgp_Array1OfPnt Points(1, myDegree+1);
@ -194,18 +194,15 @@ void Convert_CompBezierCurvesToBSplineCurve::Perform()
P2 = Points(1); P2 = Points(1);
P3 = Points(2); P3 = Points(2);
gp_Vec V1(P1, P2), V2(P2, P3); gp_Vec V1(P1, P2), V2(P2, P3);
D1 = P1.SquareDistance(P2);
D2 = P3.SquareDistance(P2);
Lambda = Sqrt(D2/D1);
// cout << "D1, D2, Lambda : " << D1 << " " << D2 << " " << Lambda << endl;
// Processing of the tangency between Bezier and the previous. // Processing of the tangency between Bezier and the previous.
// This allows to guarantee at least a C1 continuity if the tangents are // This allows to guarantee at least a C1 continuity if the tangents are
// coherent. // coherent.
if (V1.Magnitude() > gp::Resolution() && Standard_Real D1 = V1.SquareMagnitude();
V2.Magnitude() > gp::Resolution() && Standard_Real D2 = V2.SquareMagnitude();
V1.IsParallel(V2, myAngular )) { if (D1 > gp::Resolution() && D2 > gp::Resolution() && V1.IsParallel(V2, myAngular )) {
Standard_Real Lambda = Sqrt(D2/D1);
if(CurveKnVals(i-1) * Lambda > 10. * Epsilon(Det)) { if(CurveKnVals(i-1) * Lambda > 10. * Epsilon(Det)) {
KnotsMultiplicities.Append(MaxDegree-1); KnotsMultiplicities.Append(MaxDegree-1);
CurveKnVals(i) = CurveKnVals(i-1) * Lambda; CurveKnVals(i) = CurveKnVals(i-1) * Lambda;