mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0027234: Code duplication: Convert_CompBezierCurvesToBSplineCurve* in ShapeConstruct
Classes from ShapeConstruct duplicating the ones from Convert package are removed. Protection against joining segments when degree is 1 is introduced in Convert classes. Optimization previously made in Convert_CompBezierCurvesToBSplineCurve class (within #25256) is applied to 2d equivalent. Data for automatic upgrade procedure are extended to replace removed classes by their duplicates from Convert. // cout disabled unless OCCT_DEBUG is defined
This commit is contained in:
@@ -162,7 +162,7 @@ void Convert_CompBezierCurves2dToBSplineCurve2d::Perform()
|
||||
myDegree = Max( myDegree, (mySequence(i))->Length() -1);
|
||||
}
|
||||
|
||||
Standard_Real D1, D2, Lambda, Det=0;
|
||||
Standard_Real Det=0;
|
||||
gp_Pnt2d P1, P2, P3;
|
||||
Standard_Integer Deg, Inc, MaxDegree = myDegree;
|
||||
TColgp_Array1OfPnt2d Points(1, myDegree+1);
|
||||
@@ -196,31 +196,25 @@ void Convert_CompBezierCurves2dToBSplineCurve2d::Perform()
|
||||
P2 = Points(1);
|
||||
P3 = Points(2);
|
||||
gp_Vec2d V1(P1, P2), V2(P2, P3);
|
||||
D1 = P1.SquareDistance(P2);
|
||||
D2 = P3.SquareDistance(P2);
|
||||
Lambda = Sqrt(D2/D1);
|
||||
|
||||
|
||||
// Processing of the tangency between the Bezier and the previous.
|
||||
// This allows guaranteeing at least continuity C1 if the tangents are coherent.
|
||||
|
||||
|
||||
// Test of angle at myAngular
|
||||
|
||||
if (V1.Magnitude() > gp::Resolution() &&
|
||||
V2.Magnitude() > gp::Resolution() &&
|
||||
V1.IsParallel(V2, myAngular )) {
|
||||
KnotsMultiplicities.Append(MaxDegree-1);
|
||||
CurveKnVals(i) = CurveKnVals(i-1) * Lambda;
|
||||
Det += CurveKnVals(i);
|
||||
|
||||
Standard_Real D1 = V1.SquareMagnitude();
|
||||
Standard_Real D2 = V2.SquareMagnitude();
|
||||
if (MaxDegree > 1 && //rln 20.06.99 work-around
|
||||
D1 > gp::Resolution() && D2 > gp::Resolution() && V1.IsParallel(V2, myAngular ))
|
||||
{
|
||||
Standard_Real Lambda = Sqrt(D2/D1);
|
||||
KnotsMultiplicities.Append(MaxDegree - 1);
|
||||
CurveKnVals(i) = CurveKnVals(i - 1) * Lambda;
|
||||
}
|
||||
else {
|
||||
CurveKnVals(i) = 1.0e0 ;
|
||||
Det += CurveKnVals(i) ;
|
||||
CurvePoles.Append(Points(1));
|
||||
KnotsMultiplicities.Append(MaxDegree);
|
||||
CurvePoles.Append(Points(1));
|
||||
KnotsMultiplicities.Append(MaxDegree);
|
||||
CurveKnVals(i) = 1.0;
|
||||
}
|
||||
Det += CurveKnVals(i);
|
||||
|
||||
// Store poles.
|
||||
for (Standard_Integer j = 2 ; j <= MaxDegree ; j++) {
|
||||
|
@@ -51,9 +51,10 @@ void Convert_CompBezierCurvesToBSplineCurve::AddCurve
|
||||
P1 = mySequence.Last()->Value(mySequence.Last()->Upper());
|
||||
P2 = Poles(Poles.Lower());
|
||||
|
||||
// NYI
|
||||
if ( !P1.IsEqual(P2,Precision::Confusion()))
|
||||
cout << "Convert_CompBezierCurvesToBSplineCurve::Addcurve" << endl;;
|
||||
#ifdef OCCT_DEBUG
|
||||
if (!P1.IsEqual(P2, Precision::Confusion()))
|
||||
cout << "Convert_CompBezierCurvesToBSplineCurve::Addcurve" << endl;
|
||||
#endif
|
||||
}
|
||||
myDone = Standard_False;
|
||||
Handle(TColgp_HArray1OfPnt) HPoles =
|
||||
@@ -199,26 +200,26 @@ void Convert_CompBezierCurvesToBSplineCurve::Perform()
|
||||
|
||||
Standard_Real D1 = V1.SquareMagnitude();
|
||||
Standard_Real D2 = V2.SquareMagnitude();
|
||||
if (D1 > gp::Resolution() && D2 > gp::Resolution() && V1.IsParallel(V2, myAngular )) {
|
||||
if (MaxDegree > 1 && //rln 20.06.99 work-around
|
||||
D1 > gp::Resolution() && D2 > gp::Resolution() && V1.IsParallel(V2, myAngular ))
|
||||
{
|
||||
Standard_Real Lambda = Sqrt(D2/D1);
|
||||
if(CurveKnVals(i-1) * Lambda > 10. * Epsilon(Det)) {
|
||||
KnotsMultiplicities.Append(MaxDegree-1);
|
||||
CurveKnVals(i) = CurveKnVals(i-1) * Lambda;
|
||||
Det += CurveKnVals(i);
|
||||
}
|
||||
else {
|
||||
CurvePoles.Append(Points(1));
|
||||
KnotsMultiplicities.Append(MaxDegree);
|
||||
CurveKnVals(i) = 1.0 ;
|
||||
Det += CurveKnVals(i) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
CurvePoles.Append(Points(1));
|
||||
KnotsMultiplicities.Append(MaxDegree);
|
||||
CurveKnVals(i) = 1.0 ;
|
||||
Det += CurveKnVals(i) ;
|
||||
}
|
||||
Det += CurveKnVals(i);
|
||||
|
||||
// Store the poles.
|
||||
for (Standard_Integer j = 2 ; j <= MaxDegree ; j++) {
|
||||
|
Reference in New Issue
Block a user