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:
parent
d780e37a83
commit
0d1b4a2271
@ -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);
|
||||||
@ -182,7 +182,7 @@ void Convert_CompBezierCurvesToBSplineCurve::Perform()
|
|||||||
if (i == LowerI) {
|
if (i == LowerI) {
|
||||||
// Processing of the initial node of the BSpline.
|
// Processing of the initial node of the BSpline.
|
||||||
for (Standard_Integer j = 1 ; j <= MaxDegree ; j++) {
|
for (Standard_Integer j = 1 ; j <= MaxDegree ; j++) {
|
||||||
CurvePoles.Append(Points(j));
|
CurvePoles.Append(Points(j));
|
||||||
}
|
}
|
||||||
CurveKnVals(1) = 1.; // To begin the series.
|
CurveKnVals(1) = 1.; // To begin the series.
|
||||||
KnotsMultiplicities.Append(MaxDegree+1);
|
KnotsMultiplicities.Append(MaxDegree+1);
|
||||||
@ -194,40 +194,37 @@ 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 )) {
|
||||||
if(CurveKnVals(i-1) * Lambda > 10. * Epsilon(Det)) {
|
Standard_Real Lambda = Sqrt(D2/D1);
|
||||||
KnotsMultiplicities.Append(MaxDegree-1);
|
if(CurveKnVals(i-1) * Lambda > 10. * Epsilon(Det)) {
|
||||||
CurveKnVals(i) = CurveKnVals(i-1) * Lambda;
|
KnotsMultiplicities.Append(MaxDegree-1);
|
||||||
Det += CurveKnVals(i);
|
CurveKnVals(i) = CurveKnVals(i-1) * Lambda;
|
||||||
}
|
Det += CurveKnVals(i);
|
||||||
else {
|
}
|
||||||
CurvePoles.Append(Points(1));
|
else {
|
||||||
KnotsMultiplicities.Append(MaxDegree);
|
CurvePoles.Append(Points(1));
|
||||||
CurveKnVals(i) = 1.0 ;
|
KnotsMultiplicities.Append(MaxDegree);
|
||||||
Det += CurveKnVals(i) ;
|
CurveKnVals(i) = 1.0 ;
|
||||||
}
|
Det += CurveKnVals(i) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CurvePoles.Append(Points(1));
|
CurvePoles.Append(Points(1));
|
||||||
KnotsMultiplicities.Append(MaxDegree);
|
KnotsMultiplicities.Append(MaxDegree);
|
||||||
CurveKnVals(i) = 1.0 ;
|
CurveKnVals(i) = 1.0 ;
|
||||||
Det += CurveKnVals(i) ;
|
Det += CurveKnVals(i) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the poles.
|
// Store the poles.
|
||||||
for (Standard_Integer j = 2 ; j <= MaxDegree ; j++) {
|
for (Standard_Integer j = 2 ; j <= MaxDegree ; j++) {
|
||||||
CurvePoles.Append(Points(j));
|
CurvePoles.Append(Points(j));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user