From: anv Date: Mon, 27 May 2019 13:41:16 +0000 (+0300) Subject: 0030747: Modeling Algorithms - 2d Curves concatenator doesn't properly process closed... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FCR30747;p=occt-copy.git 0030747: Modeling Algorithms - 2d Curves concatenator doesn't properly process closed contours. - Correct processing of closed curves was added to method Geom2dConvert_CompCurveToBSplineCurve::Add; - Default value of After changed to true as it's is a more expected behavior. --- diff --git a/src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.cxx b/src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.cxx index f68c1f4ddc..ff05b30148 100644 --- a/src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.cxx +++ b/src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.cxx @@ -83,60 +83,41 @@ Add(const Handle(Geom2d_BoundedCurve)& NewCurve, return Standard_True; } - myTol = Tolerance; + Standard_Real aSqTol = Tolerance * Tolerance; Standard_Integer LBs = Bs->NbPoles(), LCb = myCurve->NbPoles(); - - // myCurve est elle fermee ? - if (myCurve->Pole(LCb).Distance(myCurve->Pole(1)) < myTol){ - if(After){ - // Ajout Apres ? - Standard_Real d1 = myCurve->Pole(LCb).Distance(Bs->Pole(1)); - Standard_Real d2 = myCurve->Pole(LCb).Distance(Bs->Pole(LBs)); - if (d2 < d1) { - Bs->Reverse(); - d1 = d2; - } - if (d1 < myTol) { - Add(myCurve, Bs, Standard_True); - return Standard_True; - } - } - else{ - // Ajout avant ? - Standard_Real d1 = myCurve->Pole(1).Distance(Bs->Pole(1)); - Standard_Real d2 = myCurve->Pole(1).Distance(Bs->Pole(LBs)); - if (d1 < d2) { - Bs->Reverse(); - d2 = d1; - } - if (d2 < myTol) { - Add(Bs, myCurve, Standard_False); - return Standard_True; - } - } + + Standard_Boolean isBeforeReversed = myCurve->Pole(1).SquareDistance(Bs->Pole(1)) < aSqTol; + Standard_Boolean isBefore = (myCurve->Pole(1).SquareDistance(Bs->Pole(LBs)) < aSqTol) || isBeforeReversed; + Standard_Boolean isAfterReversed = myCurve->Pole(LCb).SquareDistance(Bs->Pole(LBs)) < aSqTol; + Standard_Boolean isAfter = (myCurve->Pole(LCb).SquareDistance(Bs->Pole(1)) < aSqTol) || isAfterReversed; + + // myCurve and NewCurve together form a closed curve + if (isBefore && isAfter) + { + if (After) isBefore = Standard_False; + else isAfter = Standard_False; } - // Ajout Apres ? - else { - Standard_Real d1 = myCurve->Pole(LCb).Distance(Bs->Pole(1)); - Standard_Real d2 = myCurve->Pole(LCb).Distance(Bs->Pole(LBs)); - if (( d1 < myTol) || ( d2 < myTol)) { - if (d2 < d1) {Bs->Reverse();} - Add(myCurve, Bs, Standard_True); - return Standard_True; + if (isAfter) + { + if (isAfterReversed) + { + Bs->Reverse(); } - // Ajout avant ? - else { - d1 = myCurve->Pole(1).Distance(Bs->Pole(1)); - d2 = myCurve->Pole(1).Distance(Bs->Pole(LBs)); - if ( (d1 < myTol) || (d2 < myTol)) { - if (d1 < d2) {Bs->Reverse();} - Add(Bs, myCurve, Standard_False ); - return Standard_True; - } + Add(myCurve, Bs, Standard_True); + return Standard_True; + } + else if (isBefore) + { + if (isBeforeReversed) + { + Bs->Reverse(); } - } + Add(Bs, myCurve, Standard_False); + return Standard_True; + } + return Standard_False; } diff --git a/src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.hxx b/src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.hxx index 78842835a1..d732b5a856 100644 --- a/src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.hxx +++ b/src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.hxx @@ -49,7 +49,7 @@ public: //! Tolerance is used to check continuity and decrease //! Multiplicty at the common Knot //! After is usefull if BasisCurve is a closed curve . - Standard_EXPORT Standard_Boolean Add (const Handle(Geom2d_BoundedCurve)& NewCurve, const Standard_Real Tolerance, const Standard_Boolean After = Standard_False); + Standard_EXPORT Standard_Boolean Add (const Handle(Geom2d_BoundedCurve)& NewCurve, const Standard_Real Tolerance, const Standard_Boolean After = Standard_True); Standard_EXPORT Handle(Geom2d_BSplineCurve) BSplineCurve() const;