0028230: Convert C0 2d curve to C1 raises exception
authorifv <ifv@opencascade.com>
Thu, 26 Jan 2017 09:51:09 +0000 (12:51 +0300)
committerapn <apn@opencascade.com>
Thu, 26 Jan 2017 09:51:31 +0000 (12:51 +0300)
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
src/Geom2dConvert/Geom2dConvert_CompCurveToBSplineCurve.cxx
tests/bugs/moddata_3/bug28230 [new file with mode: 0644]

index 9190434..8790251 100644 (file)
@@ -1480,7 +1480,7 @@ void Geom2dConvert::C0BSplineToC1BSplineCurve(Handle(Geom2d_BSplineCurve)& BS,
    Geom2dConvert_CompCurveToBSplineCurve C(ArrayOfConcatenated->Value(0));
    if (ArrayOfConcatenated->Length()>=2){
      for (i=1;i<ArrayOfConcatenated->Length();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") ;
      }
index c4ecd1e..f68c1f4 100644 (file)
@@ -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 (file)
index 0000000..6c67c77
--- /dev/null
@@ -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