From 2dad173d8bde34994c0560e96a1833e19845b9cf Mon Sep 17 00:00:00 2001 From: ifv Date: Thu, 26 Jan 2017 12:51:09 +0300 Subject: [PATCH] 0028230: Convert C0 2d curve to C1 raises exception The treatment of small curves (length of curves is less then tolerance used for checking G1) is added in Geom2dConvert_CompCurveToBSplineCurve.cxx --- src/Geom2dConvert/Geom2dConvert.cxx | 2 +- .../Geom2dConvert_CompCurveToBSplineCurve.cxx | 20 ++++++++++++++----- tests/bugs/moddata_3/bug28230 | 11 ++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 tests/bugs/moddata_3/bug28230 diff --git a/src/Geom2dConvert/Geom2dConvert.cxx b/src/Geom2dConvert/Geom2dConvert.cxx index 9190434bc3..87902519d2 100644 --- a/src/Geom2dConvert/Geom2dConvert.cxx +++ b/src/Geom2dConvert/Geom2dConvert.cxx @@ -1480,7 +1480,7 @@ void Geom2dConvert::C0BSplineToC1BSplineCurve(Handle(Geom2d_BSplineCurve)& BS, Geom2dConvert_CompCurveToBSplineCurve C(ArrayOfConcatenated->Value(0)); if (ArrayOfConcatenated->Length()>=2){ for (i=1;iLength();i++){ - fusion=C.Add(ArrayOfConcatenated->Value(i),tolerance); + fusion=C.Add(ArrayOfConcatenated->Value(i),tolerance, Standard_True); if (fusion==Standard_False) Standard_ConstructionError::Raise("Geom2dConvert Concatenation Error") ; } diff --git a/src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.cxx b/src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.cxx index c4ecd1ee60..f68c1f4ddc 100644 --- a/src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.cxx +++ b/src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.cxx @@ -88,19 +88,29 @@ Add(const Handle(Geom2d_BoundedCurve)& NewCurve, Standard_Integer LBs = Bs->NbPoles(), LCb = myCurve->NbPoles(); // myCurve est elle fermee ? - if (myCurve->Pole(LCb).Distance(myCurve->Pole(1))< myTol){ + if (myCurve->Pole(LCb).Distance(myCurve->Pole(1)) < myTol){ if(After){ // Ajout Apres ? - if (myCurve->Pole(LCb).Distance(Bs->Pole(LBs)) < myTol) {Bs->Reverse();} - if (myCurve->Pole(LCb).Distance(Bs->Pole(1)) < myTol) { + 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 ? - if (myCurve->Pole(1).Distance(Bs->Pole(1)) < myTol) {Bs->Reverse();} - if (myCurve->Pole(1).Distance(Bs->Pole(LBs)) < myTol) { + 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; } diff --git a/tests/bugs/moddata_3/bug28230 b/tests/bugs/moddata_3/bug28230 new file mode 100644 index 0000000000..6c67c77ae7 --- /dev/null +++ b/tests/bugs/moddata_3/bug28230 @@ -0,0 +1,11 @@ +puts "============" +puts "CR28230" +puts "===========" +puts "" +############################################################################### +# Convert C0 2d curve to C1 raises exception +############################################################################### + +restore [locate_data_file bug28230_edge.brep] e +mk2dcurve pc e 2 +splitc12d pc 0