0026296: Errors in BRepOffsetAPI_MakeOffset: failure because of wrong direction of...
authorjgv <jgv@opencascade.com>
Thu, 2 Jul 2015 10:39:51 +0000 (13:39 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 2 Jul 2015 10:40:52 +0000 (13:40 +0300)
Test cases for issue CR26296

Fix of regressions.

Small correction of test cases for issue CR26296

src/BRepFill/BRepFill_OffsetWire.cxx
src/Bisector/Bisector_BisecAna.cdl
src/Bisector/Bisector_BisecAna.cxx
tests/bugs/modalg_6/bug26296_1 [new file with mode: 0755]
tests/bugs/modalg_6/bug26296_2 [new file with mode: 0755]
tests/bugs/modalg_6/bug26296_3 [new file with mode: 0755]
tests/bugs/modalg_6/bug26296_4 [new file with mode: 0755]
tests/bugs/modalg_6/bug26296_5 [new file with mode: 0755]

index d26c261..a3f62ce 100644 (file)
@@ -1134,7 +1134,8 @@ void BRepFill_OffsetWire::PerformWithBiLo
       TV2->UpdateTolerance( 1.5*dist2 );
   }
 
-  FixHoles();
+  if (!myIsOpenResult)
+    FixHoles();
 
   myIsDone = Standard_True;
 }
@@ -1399,7 +1400,19 @@ void BRepFill_OffsetWire::MakeWires()
     CV  = VF = TopoDS::Vertex(MVE.FindKey(i));
     CE  = TopoDS::Edge(MVE(i).First());
     End = Standard_False;
-    MVE.ChangeFromKey(CV).RemoveFirst(); 
+    MVE.ChangeFromKey(CV).RemoveFirst();
+
+    if (myIsOpenResult && MVE.FindFromKey(CV).IsEmpty())
+    {
+      //MVE.UnBind(CV);
+      TopoDS_Shape LastShape = MVE.FindKey(MVE.Extent());
+      TopTools_ListOfShape LastList;
+      LastList.Append(MVE(MVE.Extent()));
+      MVE.RemoveLast();
+      if (MVE.FindIndex(CV) != 0)
+        MVE.Substitute(MVE.FindIndex(CV), LastShape, LastList);
+    }
+      
 
     //  Modified by Sergey KHROMOV - Thu Mar 14 11:29:59 2002 Begin
     Standard_Boolean isClosed = Standard_False;
@@ -1443,6 +1456,9 @@ void BRepFill_OffsetWire::MakeWires()
           CE = TopoDS::Edge(MVE.FindFromKey(CV).First());
           MVE.ChangeFromKey(CV).RemoveFirst();
         }
+        else if (myIsOpenResult)//CV was a vertex with one edge
+          End = Standard_True;
+        
         if (MVE.FindFromKey(CV).IsEmpty())
         {
           //MVE.UnBind(CV);
index 231e41c..8007c6a 100644 (file)
@@ -124,6 +124,7 @@ is
             Bis   :        Bisec   from GccInt     ;
              V1    :        Vec2d   from gp         ;
              V2    :        Vec2d   from gp         ; 
+            VecRef:        Vec2d   from gp         ;
              Sense :        Real    from Standard   ;
              U     :    out Real    from Standard   ;
             sense :    out Boolean from Standard   ;
index a5c05f0..7255407 100644 (file)
@@ -73,6 +73,7 @@ Standard_Real Bisector_BisecAna::Distance (
    const Handle(GccInt_Bisec)& abisector,
    const gp_Vec2d&             afirstvector ,
    const gp_Vec2d&             asecondvector,
+   const gp_Vec2d&             VecRef,
    const Standard_Real         adirection,
    Standard_Real&              aparameter,
    Standard_Boolean&           asense,
@@ -182,6 +183,14 @@ Standard_Real Bisector_BisecAna::Distance (
           //  Modified by Sergey KHROMOV - Thu Oct 31 14:16:54 2002
         }
       }
+      //jgv: for OCC26185
+      if (VecRef.SquareMagnitude() != 0)
+      {
+        gp_Dir2d DirRef = VecRef;
+        if (tangdir * DirRef < 0.)
+          asense = Standard_False;
+      }
+      ///////////////////
       //  Modified by Sergey KHROMOV - Tue Oct 22 16:35:51 2002 End
     }
   }
@@ -223,8 +232,19 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
   Handle(Geom2d_Curve)  CurveE;
   Handle(GccInt_Bisec)  TheSol;
 
-  gp_Vec2d tan1 = afirstcurve->DN(afirstcurve->LastParameter (),1);
-  gp_Vec2d tan2 = asecondcurve->DN(asecondcurve->FirstParameter(),1);
+  //jgv: for OCC26296
+  gp_Vec2d LineBisVec(0.,0.);
+  gp_Vec2d tan1, tan2;
+  gp_Pnt2d Pnt1, Pnt2;
+  afirstcurve->D1(afirstcurve->LastParameter(),  Pnt1, tan1);
+  asecondcurve->D1(asecondcurve->FirstParameter(), Pnt2, tan2);
+  if (!oncurve)
+  {
+    LineBisVec = gp_Vec2d(Pnt1, Pnt2);
+    LineBisVec.Rotate(M_PI/2.);
+  }
+  ///////////////////
+  
   tan1.Reverse();
 
   if (type1 == STANDARD_TYPE(Geom2d_TrimmedCurve))
@@ -337,11 +357,11 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
 //                            adirection,parameter,sense,ok);
       if (oncurve)
        distanceptsol = Distance(apoint,solution,
-                                tan2,tan1,
+                                tan2,tan1,LineBisVec,
                                 adirection,parameter,sense,ok);
       else
        distanceptsol = Distance(apoint,solution,
-                                afirstvector,asecondvector,
+                                afirstvector,asecondvector,LineBisVec,
                                 adirection,parameter,sense,ok);
 //  Modified by skv - Tue Feb 15 17:51:29 2005 Integration End
       Handle(Geom2d_Curve) bisectorcurve = new Geom2d_Line(line);
@@ -410,7 +430,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
        sense = Standard_True;
        if (oncurve) {
          distanceptsol = Distance(apoint,solution,
-                                  tan1,tan2,
+                                  tan1,tan2,LineBisVec,
                                   adirection,parameter,sense,ok);
        }
        else {ok = Standard_True;}
@@ -423,11 +443,11 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
 //                            adirection,parameter,sense,ok);
          if (oncurve)
            distanceptsol = Distance(apoint,solution,
-                                    tan2,tan1,
+                                    tan2,tan1,LineBisVec,
                                     adirection,parameter,sense,ok);
          else
            distanceptsol = Distance(apoint,solution,
-                                    afirstvector,asecondvector,
+                                    afirstvector,asecondvector,LineBisVec,
                                     adirection,parameter,sense,ok);
 //  Modified by skv - Tue Feb 15 17:51:29 2005 Integration End
          if (distanceptsol <= distancemini) {
@@ -565,7 +585,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
        Handle(GccInt_Bisec) solution = Bisector.ThisSolution(i);
        Degenerate(solution,tolerance);
        sense = Standard_True;
-       distanceptsol = Distance(apoint,solution,tan1,tan2,
+       distanceptsol = Distance(apoint,solution,tan1,tan2,LineBisVec,
                                 adirection,parameter,sense,ok);
        if (ok || !oncurve) {
          sense = Standard_False;
@@ -575,11 +595,11 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
 //                            adirection,parameter,sense,ok);
          if (oncurve)
            distanceptsol = Distance(apoint,solution,
-                                    tan2,tan1,
+                                    tan2,tan1,LineBisVec,
                                     adirection,parameter,sense,ok);
          else
            distanceptsol = Distance(apoint,solution,
-                                    afirstvector,asecondvector,
+                                    afirstvector,asecondvector,LineBisVec,
                                     adirection,parameter,sense,ok);
 //  Modified by skv - Tue Feb 15 17:51:29 2005 Integration End
          if (distanceptsol <= distancemini) {
@@ -633,12 +653,16 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
        }
        else if (type == GccInt_Par) {
          bisectorcurve = new Geom2d_Parabola(TheSol->Parabola());
-          Standard_Real FocalLength = ((Handle(Geom2d_Parabola)&)bisectorcurve)->Focal();
+          gp_Pnt2d apex = bisectorcurve->Value(0.);
+          gp_Pnt2d firstpnt = bisectorcurve->Value(firstparameter);
+          Standard_Real ChordLen = apex.Distance(firstpnt);
+          const Standard_Real TolPar = 1.e-5;
           Standard_Real secondparameter = Precision::Infinite();
          if (!thesense)
           {
             if (ajointype == GeomAbs_Intersection &&
-                4.*FocalLength < firstparameter) //first parameter is too far from peak of parabola
+                TolPar < firstparameter &&
+                ChordLen >= circle1.Radius()) //first parameter is too far from peak of parabola
               secondparameter = 0.;
            thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
                                                  firstparameter,
@@ -647,7 +671,8 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
          else
           {
             if (ajointype == GeomAbs_Intersection &&
-                firstparameter < -4.*FocalLength) //first parameter is too far from peak of parabola
+                firstparameter < -TolPar &&
+                ChordLen >= circle1.Radius()) //first parameter is too far from peak of parabola
               secondparameter = 0.;
            thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
                                                  firstparameter,
@@ -695,11 +720,11 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
 //                            adirection,parameter,sense,ok);
       if (oncurve)
        distanceptsol = Distance(apoint,solution,
-                                tan2,tan1,
+                                tan2,tan1,LineBisVec,
                                 adirection,parameter,sense,ok);
       else
        distanceptsol = Distance(apoint,solution,
-                                afirstvector,asecondvector,
+                                afirstvector,asecondvector,LineBisVec,
                                 adirection,parameter,sense,ok);
 //  Modified by skv - Tue Feb 15 17:51:29 2005 Integration End
 //     if (distanceptsol <= distancemini) {
@@ -729,11 +754,11 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
 //                            adirection,parameter,sense,ok);
       if (oncurve)
        distanceptsol = Distance(apoint,solution,
-                                tan2,tan1,
+                                tan2,tan1,LineBisVec,
                                 adirection,parameter,sense,ok);
       else
        distanceptsol = Distance(apoint,solution,
-                                afirstvector,asecondvector,
+                                afirstvector,asecondvector,LineBisVec,
                                 adirection,parameter,sense,ok, Standard_True);
 //  Modified by skv - Tue Feb 15 17:51:29 2005 Integration End
       if (ok || !oncurve) {
@@ -784,6 +809,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve  ,
   Standard_Boolean ok;
   Standard_Boolean thesense = Standard_False,sense;
   Standard_Real    distanceptsol,parameter,firstparameter =0.,secondparameter;
+  gp_Vec2d VecRef(0.,0.);
   Handle(Geom2d_Curve) curve;
   Handle(GccInt_Bisec) TheSol;
 
@@ -837,7 +863,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve  ,
          Degenerate(solution,tolerance);
          sense = Standard_False;
          distanceptsol = Distance(apoint,solution,
-                                  afirstvector,asecondvector,
+                                  afirstvector,asecondvector,VecRef,
                                   adirection,parameter,sense,ok);
 
          if (distanceptsol <= distancemini) {
@@ -953,7 +979,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve  ,
       }
       sense = Standard_False;
       distanceptsol = Distance(apoint,solution,
-                              afirstvector,asecondvector,
+                              afirstvector,asecondvector,VecRef,
                               adirection,parameter,sense,ok);
 
       if (ok || !oncurve) {
@@ -1040,6 +1066,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Point)& afirstpoint  ,
 {
   Standard_Boolean sense,ok;
   Standard_Real parameter;
+  gp_Vec2d VecRef(0.,0.);
 
   GccAna_Pnt2dBisec bisector(afirstpoint->Pnt2d(),asecondpoint->Pnt2d());
   gp_Lin2d line = bisector.ThisSolution();
@@ -1047,8 +1074,8 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Point)& afirstpoint  ,
 
   sense = Standard_False;
   Distance(apoint,solution,
-                          afirstvector,asecondvector,
-                          adirection,parameter,sense,ok);
+           afirstvector,asecondvector,VecRef,
+           adirection,parameter,sense,ok);
   if (ok || !oncurve) {
     Handle(Geom2d_Curve) bisectorcurve = new Geom2d_Line(line);
     if (!sense)
diff --git a/tests/bugs/modalg_6/bug26296_1 b/tests/bugs/modalg_6/bug26296_1
new file mode 100755 (executable)
index 0000000..a85971e
--- /dev/null
@@ -0,0 +1,40 @@
+puts "============"
+puts "OCC26296"
+puts "============"
+puts ""
+#######################################################################
+# Errors in BRepOffsetAPI_MakeOffset: failure because of wrong direction of bisector.
+#######################################################################
+
+restore [locate_data_file bug26296_wrong1_face.brep] a
+
+smallview
+display a
+fit
+
+if [catch { mkoffset resoffset a 1 5. i } ] {
+  puts "Error : mkoffset is wrong"
+} else {
+  renamevar resoffset_1 result
+
+  set length 559.215
+
+  set nbshapes_expected "
+Number of shapes in shape
+ VERTEX    : 5
+ EDGE      : 5
+ WIRE      : 1
+ FACE      : 0
+ SHELL     : 0
+ SOLID     : 0
+ COMPSOLID : 0
+ COMPOUND  : 0
+ SHAPE     : 11
+"
+  checknbshapes result -ref ${nbshapes_expected} -t -m "Offset"
+
+  display result
+  fit
+}
+
+set only_screen_axo 1
diff --git a/tests/bugs/modalg_6/bug26296_2 b/tests/bugs/modalg_6/bug26296_2
new file mode 100755 (executable)
index 0000000..d211ec8
--- /dev/null
@@ -0,0 +1,40 @@
+puts "============"
+puts "OCC26296"
+puts "============"
+puts ""
+#######################################################################
+# Errors in BRepOffsetAPI_MakeOffset: failure because of wrong direction of bisector.
+#######################################################################
+
+restore [locate_data_file bug26296_wrong1_face.brep] a
+
+smallview
+display a
+fit
+
+if [catch { mkoffset resoffset a 1 -5. i } ] {
+  puts "Error : mkoffset is wrong"
+} else {
+  renamevar resoffset_1 result
+
+  set length 467.541
+
+  set nbshapes_expected "
+Number of shapes in shape
+ VERTEX    : 5
+ EDGE      : 5
+ WIRE      : 1
+ FACE      : 0
+ SHELL     : 0
+ SOLID     : 0
+ COMPSOLID : 0
+ COMPOUND  : 0
+ SHAPE     : 11
+"
+  checknbshapes result -ref ${nbshapes_expected} -t -m "Offset"
+
+  display result
+  fit
+}
+
+set only_screen_axo 1
diff --git a/tests/bugs/modalg_6/bug26296_3 b/tests/bugs/modalg_6/bug26296_3
new file mode 100755 (executable)
index 0000000..089e9fb
--- /dev/null
@@ -0,0 +1,40 @@
+puts "============"
+puts "OCC26296"
+puts "============"
+puts ""
+#######################################################################
+# Errors in BRepOffsetAPI_MakeOffset: failure because of wrong direction of bisector.
+#######################################################################
+
+restore [locate_data_file bug26296_v6_linearc_face.brep] a
+
+smallview
+display a
+fit
+
+if [catch { mkoffset resoffset a 1 5. i } ] {
+  puts "Error : mkoffset is wrong"
+} else {
+  renamevar resoffset_1 result
+
+  set length 622.764
+
+  set nbshapes_expected "
+Number of shapes in shape
+ VERTEX    : 5
+ EDGE      : 5
+ WIRE      : 1
+ FACE      : 0
+ SHELL     : 0
+ SOLID     : 0
+ COMPSOLID : 0
+ COMPOUND  : 0
+ SHAPE     : 11
+"
+  checknbshapes result -ref ${nbshapes_expected} -t -m "Offset"
+
+  display result
+  fit
+}
+
+set only_screen_axo 1
diff --git a/tests/bugs/modalg_6/bug26296_4 b/tests/bugs/modalg_6/bug26296_4
new file mode 100755 (executable)
index 0000000..d28932a
--- /dev/null
@@ -0,0 +1,40 @@
+puts "============"
+puts "OCC26296"
+puts "============"
+puts ""
+#######################################################################
+# Errors in BRepOffsetAPI_MakeOffset: failure because of wrong direction of bisector.
+#######################################################################
+
+restore [locate_data_file bug26296_v6_linearc_face.brep] a
+
+smallview
+display a
+fit
+
+if [catch { mkoffset resoffset a 1 -5. i } ] {
+  puts "Error : mkoffset is wrong"
+} else {
+  renamevar resoffset_1 result
+
+  set length 443.273
+
+  set nbshapes_expected "
+Number of shapes in shape
+ VERTEX    : 5
+ EDGE      : 5
+ WIRE      : 1
+ FACE      : 0
+ SHELL     : 0
+ SOLID     : 0
+ COMPSOLID : 0
+ COMPOUND  : 0
+ SHAPE     : 11
+"
+  checknbshapes result -ref ${nbshapes_expected} -t -m "Offset"
+
+  display result
+  fit
+}
+
+set only_screen_axo 1
diff --git a/tests/bugs/modalg_6/bug26296_5 b/tests/bugs/modalg_6/bug26296_5
new file mode 100755 (executable)
index 0000000..8705494
--- /dev/null
@@ -0,0 +1,40 @@
+puts "============"
+puts "OCC26296"
+puts "============"
+puts ""
+#######################################################################
+# Errors in BRepOffsetAPI_MakeOffset: failure because of wrong direction of bisector.
+#######################################################################
+
+restore [locate_data_file bug26296_linesarc.brep] a
+
+smallview
+display a
+fit
+
+if [catch { openoffset resoffset a 1 6. i } ] {
+  puts "Error : openoffset is wrong"
+} else {
+  renamevar resoffset_1 result
+
+  set length 242.849
+
+  set nbshapes_expected "
+Number of shapes in shape
+ VERTEX    : 4
+ EDGE      : 3
+ WIRE      : 1
+ FACE      : 0
+ SHELL     : 0
+ SOLID     : 0
+ COMPSOLID : 0
+ COMPOUND  : 0
+ SHAPE     : 8
+"
+  checknbshapes result -ref ${nbshapes_expected} -t -m "Offset"
+
+  display result
+  fit
+}
+
+set only_screen_axo 1