0025013: ShapeFix_Wire tweaks for better results
authorika <ika@opencascade.com>
Thu, 5 Mar 2015 11:52:06 +0000 (14:52 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 5 Mar 2015 11:53:00 +0000 (14:53 +0300)
Recalculate of tolerance before edge cutting

Test case for issue CR25013

add try to increase tolerance before splitting in singularity during PCurve adding.

Correction of test cases for issue CR25013

20 files changed:
src/ShapeFix/ShapeFix_Wire.cxx
tests/bugs/heal/bug25013_1 [new file with mode: 0755]
tests/bugs/heal/bug25013_2 [new file with mode: 0755]
tests/de/iges_1/J3
tests/de/iges_1/O5
tests/de/iges_2/A1
tests/de/iges_2/A4
tests/de/iges_2/A7
tests/de/iges_2/A8
tests/de/iges_2/B1
tests/de/iges_2/D9
tests/de/iges_2/E3
tests/de/iges_2/G5
tests/de/iges_2/G7
tests/de/iges_2/H9
tests/de/iges_2/I9
tests/de/iges_3/A4
tests/de/step_1/J6
tests/de/step_3/B9
tests/de/step_3/E6

index a6007fb..19fc9ab 100644 (file)
 #include <Geom_OffsetCurve.hxx>
 
 #include <TColStd_HSequenceOfReal.hxx>
+#include <Handle_Geom2dAdaptor_HCurve.hxx>
 #include <Adaptor3d_CurveOnSurface.hxx>
 #include <Geom2dAdaptor_HCurve.hxx>
 #include <GeomAPI_ProjectPointOnCurve.hxx>
@@ -569,66 +570,92 @@ Standard_Boolean ShapeFix_Wire::FixEdgeCurves()
 #ifdef OCCT_DEBUG
            cout << "Edge going over singularity detected; splitted" << endl;
 #endif
-           Standard_Boolean isFwd = ( E.Orientation() == TopAbs_FORWARD );
-           E.Orientation ( TopAbs_FORWARD );
-
-            //if( BRep_Tool::SameParameter(sbwd->Edge(i)) )
-            //  sbe.RemovePCurve ( E, face );
-
-            //10.04.2003 skl for using trimmed lines as pcurves
-           ShapeAnalysis_Edge sae;
-            if( BRep_Tool::SameParameter(sbwd->Edge(i)) )
-              sbe.RemovePCurve ( E, face );
-            else {
-              if(sae.HasPCurve(E,face)) {
-                Handle(Geom2d_Curve) C2d;
-                Standard_Real fp2d,lp2d;
-                if(sae.PCurve(E,face,C2d,fp2d,lp2d)) {
-                  if( !C2d->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve)) )
-                    sbe.RemovePCurve(E,face);
-                }
-              }
+      Standard_Boolean isFwd = ( E.Orientation() == TopAbs_FORWARD );
+      E.Orientation ( TopAbs_FORWARD );
+
+      //if( BRep_Tool::SameParameter(sbwd->Edge(i)) )
+      //  sbe.RemovePCurve ( E, face );
+
+      //10.04.2003 skl for using trimmed lines as pcurves
+      ShapeAnalysis_Edge sae;
+      if( BRep_Tool::SameParameter(sbwd->Edge(i)) )
+        sbe.RemovePCurve ( E, face );
+      else {
+        if(sae.HasPCurve(E,face)) {
+          Handle(Geom2d_Curve) C2d;
+          Standard_Real fp2d,lp2d;
+          if(sae.PCurve(E,face,C2d,fp2d,lp2d)) {
+            if( !C2d->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve)) )
+              sbe.RemovePCurve(E,face);
+          }
+        }
+      }
+
+//    myFixEdge->FixSameParameter ( E ); // to ensure SameRange & SP
+      BRep_Builder B;
+      TopoDS_Vertex V1, V2, V;
+      //ShapeAnalysis_Edge sae;
+      V1 = sae.FirstVertex ( E );
+      V2 = sae.LastVertex ( E );
+        
+      Handle(ShapeExtend_WireData) sw = new ShapeExtend_WireData;
+      for ( Standard_Integer k=0; k <= seq.Length(); k++ )
+      {
+        Standard_Real split = ( k < seq.Length() ? seq(k+1) : b );
+        if ( k < seq.Length() )
+        {
+          B.MakeVertex ( V, C->Value(split), BRep_Tool::Tolerance(E) );
+          //try increase tolerance before splitting
+          Standard_Real aDist = BRep_Tool::Pnt(V1).Distance(BRep_Tool::Pnt(V));
+          if (aDist < BRep_Tool::Tolerance(V1) * 1.01) {
+            B.UpdateVertex(V1, Max(aDist, BRep_Tool::Tolerance(V1)));
+            a = split;
+            V1 = V;
+            continue;
+          }
+          else
+          {
+            aDist = BRep_Tool::Pnt(V2).Distance(BRep_Tool::Pnt(V));
+            if (aDist < BRep_Tool::Tolerance(V2) * 1.01) {
+              B.UpdateVertex(V, Max(aDist, BRep_Tool::Tolerance(V2)));
+              b = split;
+              V2 = V;
+              continue;
             }
+          }
+        }
+        else
+        {
+          V = V2;
+        }
 
-//         myFixEdge->FixSameParameter ( E ); // to ensure SameRange & SP
-           BRep_Builder B;
-           TopoDS_Vertex V1, V2, V;
-           //ShapeAnalysis_Edge sae;
-           V1 = sae.FirstVertex ( E );
-           V2 = sae.LastVertex ( E );
-           Handle(ShapeExtend_WireData) sw = new ShapeExtend_WireData;
-           for ( Standard_Integer k=0; k <= seq.Length(); k++ ) {
-             Standard_Real split = ( k < seq.Length() ? seq(k+1) : b );
-             if ( k < seq.Length() ) 
-               B.MakeVertex ( V, C->Value(split), BRep_Tool::Tolerance(E) );
-             else V = V2;
-             TopoDS_Edge edge = sbe.CopyReplaceVertices ( E, V1, V );
-              if( BRep_Tool::SameParameter(sbwd->Edge(i)) ) {
-                //TopoDS_Edge edge = sbe.CopyReplaceVertices ( E, V1, V );
-                B.Range ( edge, a, split );
-                sw->Add ( edge );
-              }
-              else {
-                //TopoDS_Edge edge = sbe.CopyReplaceVertices(sbwd->Edge(i),V1,V);
-                Handle(ShapeAnalysis_TransferParameters) sftp =
-                  new ShapeAnalysis_TransferParameters(E,face);
-                sftp->TransferRange(edge, a, split, Standard_False);
-                sw->Add(edge);
-              }
-              //sw->Add(edge);
-             a = split;
-             V1 = V;
-           }
-           if ( ! isFwd ) {
-             sw->Reverse();
-             E.Orientation ( TopAbs_REVERSED );
-           }
-           Context()->Replace ( E, sw->Wire() );
-           UpdateWire();
-           nb = sbwd->NbEdges();
-           i--;
-           continue;
-         }
+        TopoDS_Edge edge = sbe.CopyReplaceVertices ( E, V1, V );
+        if( BRep_Tool::SameParameter(sbwd->Edge(i)) ) {
+          //TopoDS_Edge edge = sbe.CopyReplaceVertices ( E, V1, V );
+          B.Range ( edge, a, split );
+          sw->Add ( edge );
+        }
+        else {
+          //TopoDS_Edge edge = sbe.CopyReplaceVertices(sbwd->Edge(i),V1,V);
+          Handle(ShapeAnalysis_TransferParameters) sftp =
+            new ShapeAnalysis_TransferParameters(E,face);
+          sftp->TransferRange(edge, a, split, Standard_False);
+          sw->Add(edge);
+        }
+        //sw->Add(edge);
+        a = split;
+        V1 = V;
+      }
+      if ( ! isFwd ) {
+        sw->Reverse();
+        E.Orientation ( TopAbs_REVERSED );
+      }
+      Context()->Replace ( E, sw->Wire() );
+      UpdateWire();
+      nb = sbwd->NbEdges();
+      i--;
+      continue;
+    }
        }
        
        overdegen = i;
@@ -844,13 +871,14 @@ Standard_Boolean ShapeFix_Wire::FixSelfIntersection()
       if(LastFixStatus (ShapeExtend_DONE6))
   myStatusSelfIntersection |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE6 );
 
-      if ( ! myTopoMode || nb < 3 ) {
-       //#86 rln 22.03.99 sim2.igs, entity 4292: After fixing of self-intersecting
-       //BRepCheck finds one more self-intersection not found by ShapeAnalysis
-       //%15 pdn 06.04.99 repeat until fixed CTS18546-2 entity 777
-       //FixIntersectingEdges ( num );
-       if ( LastFixStatus ( ShapeExtend_DONE7 ) ) num--;
-       continue;
+      if ( /*! myTopoMode ||*/ nb < 3 ) {
+        //#86 rln 22.03.99 sim2.igs, entity 4292: After fixing of self-intersecting
+        //BRepCheck finds one more self-intersection not found by ShapeAnalysis
+        //%15 pdn 06.04.99 repeat until fixed CTS18546-2 entity 777
+        
+        // if the tolerance was modified we should recheck the result, if it was enough
+        if ( LastFixStatus ( ShapeExtend_DONE7 ) ) num--;
+        continue;
       }
 
       if ( LastFixStatus ( ShapeExtend_DONE4 ) ) sbwd->Remove ( num );
@@ -868,7 +896,9 @@ Standard_Boolean ShapeFix_Wire::FixSelfIntersection()
        //#86 rln 22.03.99
        //%15 pdn 06.04.99 repeat until fixed CTS18546-2 entity 777
        //FixIntersectingEdges ( num );
-       if ( LastFixStatus ( ShapeExtend_DONE7 ) ) num--;
+       /*if ( LastFixStatus ( ShapeExtend_DONE7 ) )*/
+        // Always revisit the fixed edge
+        num--;
       }
     }
   }
@@ -1331,8 +1361,13 @@ Standard_Boolean ShapeFix_Wire::FixShifted()
     TopoDS_Edge E1 = sbwd->Edge ( n1 );
     TopoDS_Edge E2 = sbwd->Edge ( n2 );
 
-    if ( BRep_Tool::Degenerated(E1) || BRep_Tool::Degenerated(E2) ) {
-      if ( ! degstop ) { stop = n2; degstop = Standard_True; }
+    if ( BRep_Tool::Degenerated(E1) || BRep_Tool::Degenerated(E2) )
+    {
+      if ( ! degstop )
+      {
+        stop = n2;
+        degstop = Standard_True;
+      }
       continue;
     }
 
@@ -1376,82 +1411,100 @@ Standard_Boolean ShapeFix_Wire::FixShifted()
       }
     }
 
-    if ( isDeg ) {
-      if ( ! degstop ) { stop = n2; degstop = Standard_True; }
-      if ( ! degn2 ) { degn2 = n2; pdeg = p; }
-      else if ( pdeg.SquareDistance(p) < Precision()*Precision() ) {
-        degn2 = n2;    
-//     if ( stop < n2 ) { stop = n2; degstop = Standard_True; }
+    if ( isDeg )
+    {
+      if ( ! degstop )
+      {
+        stop = n2;
+        degstop = Standard_True;
       }
-      else {
-       Standard_Real ax1 = 0., bx1 = 0., ax2 = 0., bx2 = 0.;
-       Handle(Geom2d_Curve) cx1, cx2;
-       if ( ( c2d1.IsNull() && ! sae.PCurve ( E1, Face(), c2d1, a1, b1, Standard_True ) ) ||
-            ( c2d2.IsNull() && ! sae.PCurve ( E2, Face(), c2d2, a2, b2, Standard_True ) ) ||
-            ! sae.PCurve ( sbwd->Edge ( degn2 >1 ? degn2-1 : nb ), Face(), cx1, ax1, bx1, Standard_True ) ||
-            ! sae.PCurve ( sbwd->Edge ( degn2 ), Face(), cx2, ax2, bx2, Standard_True ) ) {
-         myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 );
-         continue;
-       }
-       gp_Pnt2d pd1 = cx1->Value ( bx1 );
-       gp_Pnt2d pd2 = cx2->Value ( ax2 );
-       gp_Pnt2d pn1 = c2d1->Value ( b1 );
-       gp_Pnt2d pn2 = c2d2->Value ( a2 );
-       gp_Vec2d x(0.,0.); // shift vector
-       Standard_Real period;
-       if ( uclosed ) { x.SetX ( 1. ); period = URange; }
-       else { x.SetY ( 1. ); period = VRange; }
-       Standard_Real rot1 = ( pn1.XY() - pd2.XY() ) ^ x.XY();
-       Standard_Real rot2 = ( pd1.XY() - pn2.XY() ) ^ x.XY();
-       Standard_Real scld = ( pd2.XY() - pd1.XY() ) * x.XY();
-       Standard_Real scln = ( pn2.XY() - pn1.XY() ) * x.XY();
-       if ( rot1 * rot2 < -::Precision::PConfusion() && 
-            scld * scln < -::Precision::PConfusion() && 
-            Abs ( scln ) > 0.1 * period && Abs ( scld ) > 0.1 * period && 
-            rot1 * scld > ::Precision::PConfusion() && 
-            rot2 * scln > ::Precision::PConfusion() ) {
-         // abv 02 Mar 00: trying more sophisticated analysis (ie_exhaust-A.stp #37520)
-         Standard_Real sign = ( rot2 >0 ? 1. : -1. );
-         Standard_Real deep1 = Min ( sign * ( pn2.XY() * x.XY() ),
-                               Min ( sign * ( pd1.XY() * x.XY() ),
-                               Min ( sign * ( c2d2->Value(b2 ).XY() * x.XY() ),
-                               Min ( sign * (  cx1->Value(ax1).XY() * x.XY() ),
-                               Min ( sign * ( c2d2->Value(0.5*(a2 +b2 )).XY() * x.XY() ),
-                                     sign * (  cx1->Value(0.5*(ax1+bx1)).XY() * x.XY() ) ) ) ) ) );
-         Standard_Real deep2 = Max ( sign * ( pn1.XY() * x.XY() ),
-                               Max ( sign * ( pd2.XY() * x.XY() ),
-                               Max ( sign * ( c2d1->Value(a1 ).XY() * x.XY() ),
-                               Max ( sign * (  cx2->Value(bx2).XY() * x.XY() ),
-                               Max ( sign * ( c2d1->Value(0.5*(a1 +b1 )).XY() * x.XY() ),
-                                     sign * (  cx2->Value(0.5*(ax2+bx2)).XY() * x.XY() ) ) ) ) ) );
-         Standard_Real deep = deep2 - deep1; // estimated current size of wire by x
-         // pdn 30 Oct 00: trying correct period [0,period] (trj5_k1-tc-203.stp #4698)
-         Standard_Real dx = ShapeAnalysis::AdjustToPeriod ( deep, ::Precision::PConfusion(), period+::Precision::PConfusion()); 
-         x *= ( scld >0 ? -dx : dx );
-//       x *= ( Abs(scld-scln) > 1.5 * period ? 2. : 1. ) *
-//            ( scld >0 ? -period : period );
-         gp_Trsf2d Shift;
-         Shift.SetTranslation ( x );
-         for ( Standard_Integer k=degn2; ; k++ ) {
-           if ( k > nb ) k = 1;
-           if ( k == n2 ) break;
-           TopoDS_Edge edge = sbwd->Edge ( k );
-           if ( ! sae.PCurve ( edge, Face(), cx1, ax1, bx1, Standard_True ) ) continue;
-           //cx1->Transform ( Shift );
-            // skl 15.05.2002 for OCC208 (if few edges have reference to one pcurve)
-            Handle(Geom2d_Curve) cx1new = Handle(Geom2d_Curve)::DownCast(cx1->Transformed(Shift));
-            sbe.ReplacePCurve(edge,cx1new,Face());
-           UpdateEdgeUVPoints ( edge, Face() );
-         }
-         myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
+
+      if ( ! degn2 )
+      {
+        degn2 = n2;
+        pdeg = p;
+      }
+      else
+      {
+        if ( pdeg.SquareDistance(p) < Precision() * Precision() )
+        {
+          degn2 = n2;
+          //if ( stop < n2 ) { stop = n2; degstop = Standard_True; }
+        }
+        else
+        {
+          Standard_Real ax1 = 0., bx1 = 0., ax2 = 0., bx2 = 0.;
+          Handle(Geom2d_Curve) cx1, cx2;
+          if (  ( c2d1.IsNull() && ! sae.PCurve ( E1, Face(), c2d1, a1, b1, Standard_True ) ) ||
+                ( c2d2.IsNull() && ! sae.PCurve ( E2, Face(), c2d2, a2, b2, Standard_True ) ) ||
+                ! sae.PCurve ( sbwd->Edge ( degn2 >1 ? degn2-1 : nb ), Face(), cx1, ax1, bx1, Standard_True ) ||
+                ! sae.PCurve ( sbwd->Edge ( degn2 ), Face(), cx2, ax2, bx2, Standard_True ) )
+          {
+            myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 );
+            continue;
+          }
+          gp_Pnt2d pd1 = cx1->Value ( bx1 );
+          gp_Pnt2d pd2 = cx2->Value ( ax2 );
+          gp_Pnt2d pn1 = c2d1->Value ( b1 );
+          gp_Pnt2d pn2 = c2d2->Value ( a2 );
+          gp_Vec2d x(0.,0.); // shift vector
+          Standard_Real period;
+          if ( uclosed ) { x.SetX ( 1. ); period = URange; }
+          else { x.SetY ( 1. ); period = VRange; }
+          Standard_Real rot1 = ( pn1.XY() - pd2.XY() ) ^ x.XY();
+          Standard_Real rot2 = ( pd1.XY() - pn2.XY() ) ^ x.XY();
+          Standard_Real scld = ( pd2.XY() - pd1.XY() ) * x.XY();
+          Standard_Real scln = ( pn2.XY() - pn1.XY() ) * x.XY();
+          if (  rot1 * rot2 < -::Precision::PConfusion() && 
+                scld * scln < -::Precision::PConfusion() && 
+                Abs ( scln ) > 0.1 * period && Abs ( scld ) > 0.1 * period && 
+                rot1 * scld > ::Precision::PConfusion() && 
+                rot2 * scln > ::Precision::PConfusion() )
+          {
+            // abv 02 Mar 00: trying more sophisticated analysis (ie_exhaust-A.stp #37520)
+            Standard_Real sign = ( rot2 >0 ? 1. : -1. );
+            Standard_Real deep1 = Min ( sign * ( pn2.XY() * x.XY() ),
+                                  Min ( sign * ( pd1.XY() * x.XY() ),
+                                  Min ( sign * ( c2d2->Value(b2 ).XY() * x.XY() ),
+                                  Min ( sign * (  cx1->Value(ax1).XY() * x.XY() ),
+                                  Min ( sign * ( c2d2->Value(0.5*(a2 +b2 )).XY() * x.XY() ),
+                                        sign * (  cx1->Value(0.5*(ax1+bx1)).XY() * x.XY() ) ) ) ) ) );
+            Standard_Real deep2 = Max ( sign * ( pn1.XY() * x.XY() ),
+                                  Max ( sign * ( pd2.XY() * x.XY() ),
+                                  Max ( sign * ( c2d1->Value(a1 ).XY() * x.XY() ),
+                                  Max ( sign * (  cx2->Value(bx2).XY() * x.XY() ),
+                                  Max ( sign * ( c2d1->Value(0.5*(a1 +b1 )).XY() * x.XY() ),
+                                        sign * (  cx2->Value(0.5*(ax2+bx2)).XY() * x.XY() ) ) ) ) ) );
+            Standard_Real deep = deep2 - deep1; // estimated current size of wire by x
+            // pdn 30 Oct 00: trying correct period [0,period] (trj5_k1-tc-203.stp #4698)
+            Standard_Real dx = ShapeAnalysis::AdjustToPeriod ( deep, ::Precision::PConfusion(), period+::Precision::PConfusion()); 
+            x *= ( scld >0 ? -dx : dx );
+            //x *= ( Abs(scld-scln) > 1.5 * period ? 2. : 1. ) *
+            //     ( scld >0 ? -period : period );
+            gp_Trsf2d Shift;
+            Shift.SetTranslation ( x );
+            for ( Standard_Integer k=degn2; ; k++ )
+            {
+              if ( k > nb ) k = 1;
+              if ( k == n2 ) break;
+              TopoDS_Edge edge = sbwd->Edge ( k );
+              if ( ! sae.PCurve ( edge, Face(), cx1, ax1, bx1, Standard_True ) ) continue;
+              //cx1->Transform ( Shift );
+              // skl 15.05.2002 for OCC208 (if few edges have reference to one pcurve)
+              Handle(Geom2d_Curve) cx1new = Handle(Geom2d_Curve)::DownCast(cx1->Transformed(Shift));
+              sbe.ReplacePCurve(edge,cx1new,Face());
+              UpdateEdgeUVPoints ( edge, Face() );
+            }
+            myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
 #ifdef OCCT_DEBUG
-         cout << "Info: ShapeFix_Wire::FixShifted(): bi - meridian case fixed" << endl;
+            cout << "Info: ShapeFix_Wire::FixShifted(): bi - meridian case fixed" << endl;
 #endif
-          continue;
-       }
-//     degn2 = n2; pdeg = p; // ie_exhaust-A.stp #37520
+            continue;
+          }
+          //degn2 = n2; pdeg = p; // ie_exhaust-A.stp #37520
+        }
       }
-/*     
+/*
       // pdn to fix half sphere
       TopoDS_Vertex VE = sae.LastVertex ( E2 );
       gp_Pnt pe = BRep_Tool::Pnt ( VE );
@@ -2333,77 +2386,100 @@ Standard_Boolean ShapeFix_Wire::FixIntersectingEdges (const Standard_Integer num
     Standard_Real rad = errors.Value(i);
     Standard_Real newtol = 1.0001 * ( pnt.Distance ( pint ) + rad );
 
-//    GeomAdaptor_Surface& Ads = myAnalyzer->Surface()->Adaptor3d()->ChangeSurface();
+    //GeomAdaptor_Surface& Ads = myAnalyzer->Surface()->Adaptor3d()->ChangeSurface();
 
     //:r8 abv 12 Apr 99: try increasing tolerance of edge
-    if ( ! myTopoMode && newtol > tol ) {
+
+    Standard_Boolean locMayEdit = myTopoMode;
+    // Always try to modify the tolerance firstly as a better solution
+    if ( /*! myTopoMode &&*/ newtol > tol ) {
       Standard_Real te1 = rad + ComputeLocalDeviation (E1, pint, pnt,
-                                                param1, ( isForward1 ? b1 : a1 ), Face() );
+        param1, ( isForward1 ? b1 : a1 ), Face() );
       Standard_Real te2 = rad + ComputeLocalDeviation (E2, pint, pnt, 
-                                                ( isForward2 ? a2 : b2 ), param2, Face() );
+        ( isForward2 ? a2 : b2 ), param2, Face() );
       Standard_Real maxte = Max ( te1, te2 );
       if ( maxte < MaxTolerance() && maxte < newtol ) {
-       if ( BRep_Tool::Tolerance(E1) < te1 || BRep_Tool::Tolerance(E2) < te2 ) {
-         B.UpdateEdge ( E1, 1.000001 * te1 );
-         B.UpdateVertex ( sae.FirstVertex ( E1 ), 1.000001 * te1 );
-         B.UpdateVertex ( sae.LastVertex  ( E1 ), 1.000001 * te1 );
-         B.UpdateEdge ( E2, 1.000001 * te2 );
-         B.UpdateVertex ( sae.FirstVertex ( E2 ), 1.000001 * te2 );
-         B.UpdateVertex ( sae.LastVertex  ( E2 ), 1.000001 * te2 );
-         myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE6 );
-       }
-       newtol = 1.000001 * maxte;
+        if ( BRep_Tool::Tolerance(E1) < te1 || BRep_Tool::Tolerance(E2) < te2 ) {
+#ifdef OCCT_DEBUG
+          cout << "Warning: ShapeFix_Wire::FixIE: edges tolerance increased: (" <<
+            te1 << ", " << te2 << ") / " << newtol << endl;
+#endif
+          B.UpdateEdge ( E1, 1.000001 * te1 );
+          B.UpdateVertex ( sae.FirstVertex ( E1 ), 1.000001 * te1 );
+          B.UpdateVertex ( sae.LastVertex  ( E1 ), 1.000001 * te1 );
+          B.UpdateEdge ( E2, 1.000001 * te2 );
+          B.UpdateVertex ( sae.FirstVertex ( E2 ), 1.000001 * te2 );
+          B.UpdateVertex ( sae.LastVertex  ( E2 ), 1.000001 * te2 );
+
+          myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE6 );
+          locMayEdit = Standard_False;
+        }
+        newtol = 1.000001 * maxte;
       }
     }
     
-    if ( myTopoMode || newtol <= MaxTolerance() ) {
+    if ( locMayEdit || newtol <= MaxTolerance() )
+    {
       prevRange1 = newRange1; 
       prevRange2 = newRange2;
-      Standard_Boolean locMayEdit = myTopoMode;
-      if ( myTopoMode ) { //:j6 abv 7 Dec 98: ProSTEP TR10 r0601_id.stp #57676 & #58586: do not cut edges because of influence on adjacent faces
+      if ( locMayEdit )
+      {
+        newtol = 1.0001 * ( pnt.Distance ( pint ) + rad );
+        //:j6 abv 7 Dec 98: ProSTEP TR10 r0601_id.stp #57676 & #58586: do not cut edges because of influence on adjacent faces
         ShapeFix_SplitTool aTool;
-        //if ( ! ShapeFix::CutEdge ( E1, ( isForward1 ? a1 : b1 ), param1, Face(), IsCutLine ) ) {
-       if ( ! aTool.CutEdge ( E1, ( isForward1 ? a1 : b1 ), param1, Face(), IsCutLine ) ) {
-         if ( V1.IsSame ( Vp ) )
-           myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE3 );
-         else locMayEdit = Standard_False;
-       }
-       else cutEdge1 = Standard_True; //:h4
-       //if ( ! ShapeFix::CutEdge ( E2, ( isForward2 ? b2 : a2 ), param2, Face(), IsCutLine ) ) {
-       if ( ! aTool.CutEdge ( E2, ( isForward2 ? b2 : a2 ), param2, Face(), IsCutLine ) ) {
-         if ( V2.IsSame ( Vn ) ) 
-           myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE4 );
-         else locMayEdit = Standard_False;
-       }
-       else cutEdge2 = Standard_True; //:h4
-      }
-      if ( locMayEdit &&
-          newRange1 <= prevRange1 && newRange2 <= prevRange2 && //rln 09/01/98
-          BRep_Tool::SameParameter ( E1 ) &&
-          BRep_Tool::SameParameter ( E2 ) ) {
-       myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE2 );
-       pnt = pint;
-       if ( tol <= rad ) {
-         myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
-         tol = 1.001 * rad;
-       }
+        
+        if ( ! aTool.CutEdge ( E1, ( isForward1 ? a1 : b1 ), param1, Face(), IsCutLine ) ) {
+          if ( V1.IsSame ( Vp ) )
+            myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE3 );
+          else locMayEdit = Standard_False;
+        }
+        else cutEdge1 = Standard_True; //:h4
+        
+        if ( ! aTool.CutEdge ( E2, ( isForward2 ? b2 : a2 ), param2, Face(), IsCutLine ) ) {
+          if ( V2.IsSame ( Vn ) ) 
+            myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE4 );
+          else locMayEdit = Standard_False;
+        }
+        else cutEdge2 = Standard_True; //:h4
       }
-      else if(IsCutLine) {
-       myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE2 );
-       pnt = pint;
-       if ( tol <= rad ) {
-         myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
-         tol = 1.001 * rad;
-       }
+
+      if (  locMayEdit &&
+            newRange1 <= prevRange1 && newRange2 <= prevRange2 && //rln 09/01/98
+            BRep_Tool::SameParameter ( E1 ) &&
+            BRep_Tool::SameParameter ( E2 ) )
+      {
+        myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE2 );
+        pnt = pint;
+        if ( tol <= rad ) {
+          myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
+          tol = 1.001 * rad;
+        }
       }
-      else { // else increase tolerance
-       if (tol < newtol) { //rln 07.04.99 CCI60005-brep.igs
-         myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
-         tol = newtol;
-       }
+      else
+      {
+        if(IsCutLine)
+        {
+          myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE2 );
+          pnt = pint;
+          if ( tol <= rad ) {
+            myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
+            tol = 1.001 * rad;
+          }
+        }
+        else
+        { // else increase tolerance
+          if (tol < newtol)
+          { //rln 07.04.99 CCI60005-brep.igs
+            myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
+            tol = newtol;
+          }
+        }
       }
     }
-    else myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL2 );
+    else
+    {
+      myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL2 );
+    }
   }
 
   if ( ! LastFixStatus ( ShapeExtend_DONE ) ) return Standard_False;
@@ -2679,6 +2755,8 @@ static Standard_Boolean TryBendingPCurve (const TopoDS_Edge &E, const TopoDS_Fac
       else return Standard_False;
     }
     c2d = bs;
+
+    if ( ! TryNewPCurve ( E, face, c2d, first, last, tol ) ) return Standard_False;
   }
   catch ( Standard_Failure ) {
 #ifdef OCCT_DEBUG
@@ -2687,8 +2765,7 @@ static Standard_Boolean TryBendingPCurve (const TopoDS_Edge &E, const TopoDS_Fac
     return Standard_False;
   }
   }
-  
-  if ( ! TryNewPCurve ( E, face, c2d, first, last, tol ) ) return Standard_False;
+
   return Standard_True;
 }
 
diff --git a/tests/bugs/heal/bug25013_1 b/tests/bugs/heal/bug25013_1
new file mode 100755 (executable)
index 0000000..2c4177d
--- /dev/null
@@ -0,0 +1,14 @@
+puts "========="
+puts " OCC25013"
+puts "========="
+puts ""
+##################################################
+# ShapeFix_Wire tweaks for better results
+##################################################
+
+stepread [locate_data_file bug25013_25013faces.stp] a *
+
+tpcompound result
+checkshape result
+
+set 2dviewer 1
diff --git a/tests/bugs/heal/bug25013_2 b/tests/bugs/heal/bug25013_2
new file mode 100755 (executable)
index 0000000..4474aea
--- /dev/null
@@ -0,0 +1,14 @@
+puts "========="
+puts " OCC25013"
+puts "========="
+puts ""
+##################################################
+# ShapeFix_Wire tweaks for better results
+##################################################
+
+stepread [locate_data_file bug25013_25013face.stp] a *
+
+tpcompound result
+checkshape result
+
+set 2dviewer 1
index 39f8472..a928687 100644 (file)
@@ -1,6 +1,6 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 puts "TODO CR23096 ALL: LABELS : Faulty" 
-
+puts "TODO CR25013 ALL: Error : 1 differences with reference data found" 
 
 set filename CTS18546-2.igs
 
index d9b250f..d1e0c36 100755 (executable)
@@ -1,4 +1,5 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
+puts "TODO CR25013 ALL: Error : 2 differences with reference data found" 
 
 set filename lh93wsddr3370z2.igs
 
index a9495b3..71b00be 100644 (file)
@@ -1,5 +1,6 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 puts "TODO CR23096 ALL: STATSHAPE : Faulty" 
+puts "TODO CR25013 ALL: Error : 3 differences with reference data found" 
 
 
 set filename CCI60011.igs
index dc1bc93..e72114a 100644 (file)
@@ -1,5 +1,6 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 puts "TODO CR23096 ALL: LABELS : Faulty" 
+puts "TODO CR25013 ALL: Error : 1 differences with reference data found" 
 
 set LinuxDiff 1
 set filename pro5101.igs
index 1c3c8b7..71415e4 100644 (file)
@@ -3,6 +3,7 @@ puts "TODO CR23096 ALL: CHECKSHAPE : Faulty"
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 puts "TODO CR23096 ALL: COLORS : Faulty" 
 puts "TODO CR23096 ALL: NBSHAPES : Faulty"
+puts "TODO CR25013 ALL: Error : 1 differences with reference data found" 
 
 set LinuxDiff 2
 set LinuxFaulties {NBSHAPES}
index 1d42875..f15eaa5 100644 (file)
@@ -1,6 +1,7 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 puts "TODO CR23096 ALL: COLORS : Faulty" 
+puts "TODO CR25013 ALL: Error : 2 differences with reference data found" 
 
 
 set filename kegel.igs
index 68dda4c..e3c6b4d 100755 (executable)
@@ -2,7 +2,7 @@
 puts "TODO CR23096 ALL: NBSHAPES : Faulty" 
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 puts "TODO CR23096 ALL: LAYERS : Faulty" 
-
+puts "TODO CR25013 ALL: Error : 3 differences with reference data found" 
 
 
 set filename CATIA01.igs
index bcfcc27..f765bd0 100644 (file)
@@ -1,6 +1,7 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 puts "TODO CR23096 ALL: TOLERANCE : Faulty" 
 puts "TODO CR23096 ALL: LABELS : Faulty" 
+puts "TODO CR25013 ALL: Error : 2 differences with reference data found" 
 
 
 set filename bmarkmdl.igs
index dfa481d..89a7b73 100644 (file)
@@ -1,6 +1,7 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 puts "TODO CR23096 ALL: COLORS : Faulty" 
+puts "TODO CR25013 ALL: Error : 1 differences with reference data found" 
 
 
 set filename cts17801.igs
index 6a9f87d..feab40b 100644 (file)
@@ -1,7 +1,7 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
-puts "TODO CR23096 ALL: CHECKSHAPE : Faulty" 
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 puts "TODO CR23096 ALL: COLORS : Faulty" 
+puts "TODO CR25013 ALL: Error : 4 differences with reference data found" 
 
 set LinuxDiff 4
 set filename PRO11641.igs
index 82c912d..3308375 100644 (file)
@@ -3,6 +3,7 @@ puts "TODO CR23096 ALL: CHECKSHAPE : Faulty"
 puts "TODO CR23096 ALL: NBSHAPES : Faulty" 
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 puts "TODO CR23096 ALL: COLORS : Faulty" 
+puts "TODO CR25013 ALL: Error : 3 differences with reference data found" 
 
 
 set filename PRO18777-3.igs
index 6edda92..b11adb9 100755 (executable)
@@ -2,6 +2,7 @@
 puts "TODO CR23096 ALL: NBSHAPES : Faulty" 
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 puts "TODO CR23096 ALL: COLORS : Faulty" 
+puts "TODO CR25013 ALL: Error : 3 differences with reference data found" 
 
 set LinuxDiff 4
 set LinuxFaulties {STATSHAPE}
index 211256a..bde71ca 100644 (file)
@@ -4,6 +4,7 @@ puts "TODO CR23096 ALL: NBSHAPES : Faulty"
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 puts "TODO CR23096 ALL: COLORS : Faulty" 
 puts "TODO CR23096 ALL: LAYERS : Faulty" 
+puts "TODO CR25013 ALL: Error : 1 differences with reference data found" 
 
 
 set filename BUC60215.igs
index 17bc8df..4597216 100755 (executable)
@@ -5,6 +5,7 @@ puts "TODO CR23096 ALL: STATSHAPE : Faulty"
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 puts "TODO CR23096 ALL: COLORS : Faulty" 
 puts "TODO CR23096 ALL: LAYERS : Faulty" 
+puts "TODO CR25013 ALL: Error : 3 differences with reference data found" 
 
 
 set filename BUC40132.igs
index 73c5ac7..6c718bf 100755 (executable)
@@ -1,4 +1,6 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
+puts "TODO CR25013 ALL: Error : 3 differences with reference data found" 
+puts "TODO CR25013 ALL: NBSHAPES : Faulty" 
 
 set LinuxDiff 2
 set LinuxFaulties {STATSHAPE}
index 82276ed..4ea8125 100644 (file)
@@ -1,5 +1,6 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 puts "TODO CR23096 ALL: STATSHAPE : Faulty" 
+puts "TODO CR25013 ALL: Error : 1 differences with reference data found" 
 
 set LinuxDiff 2
 set filename wgehaeuse_surface.stp
index 97795a7..6eb4756 100755 (executable)
@@ -2,6 +2,7 @@
 puts "TODO CR23096 ALL: TPSTAT : Faulty" 
 puts "TODO CR23096 ALL: CHECKSHAPE : Faulty" 
 puts "TODO CR23096 ALL: STATSHAPE : Faulty" 
+puts "TODO CR25013 ALL: Error : 4 differences with reference data found" 
 
 set LinuxDiff 3
 set filename Z8M6SAT.stp