0021317: Face cannot be fixed by Shape Healing
authorika <ika@opencascade.com>
Thu, 1 Aug 2013 08:34:52 +0000 (12:34 +0400)
committerika <ika@opencascade.com>
Thu, 1 Aug 2013 08:34:52 +0000 (12:34 +0400)
Fix that face, in which only wire was reordered during shape healing, was not replaced.
Add test case for this fix
Add status for shifted wires in reordering.
Modified test case de/step_1/E3 according to new reference data

src/ShapeAnalysis/ShapeAnalysis_Wire.cxx
src/ShapeAnalysis/ShapeAnalysis_WireOrder.cxx
src/ShapeFix/ShapeFix_Face.cxx
src/ShapeFix/ShapeFix_Wire.cxx
tests/bugs/heal/bug21317 [new file with mode: 0755]
tests/de/step_1/E3

index 060f9dc..02f16eb 100755 (executable)
@@ -594,6 +594,7 @@ Standard_Boolean ShapeAnalysis_Wire::CheckOrder(ShapeAnalysis_WireOrder& sawo,
   case   2: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2); break;
   case  -1: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE3); break;
   case  -2: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE4); break;
+  case   3: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE5); break;//only shifted
   case -10: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL1); break;
   }
   return LastCheckStatus (ShapeExtend_DONE);
index d218e75..5f10726 100755 (executable)
@@ -393,8 +393,32 @@ void ShapeAnalysis_WireOrder::Perform(const Standard_Boolean /*closed*/)
       if(stTmp>=0) stTmp = (mainSeq->Value(i) > 0 ? 1 : -1);
     myOrd->SetValue(i,mainSeq->Value(i));
   }
-  myStat = stTmp;
-  return;
+  if (stTmp == 0) {
+    myStat = stTmp;
+    return;
+  }
+  else {//check if edges were only shifted in reverse or forward, not reordered
+    Standard_Boolean isShiftReverse = Standard_True, isShiftForward = Standard_True;
+    Standard_Integer tmpFirst = 0, tmpSecond = 0, length = mainSeq->Length();
+    for(i = 1; i <= length - 1; i++) {
+      tmpFirst = mainSeq->Value(i);
+      tmpSecond = mainSeq->Value(i+1);
+      if (!(tmpSecond - tmpFirst == 1 || (tmpFirst == length && tmpSecond == 1)))
+        isShiftForward = Standard_False;
+      if (!(tmpFirst - tmpSecond == 1 || (tmpSecond == length && tmpFirst == 1)))
+        isShiftReverse = Standard_False;
+    }
+    tmpFirst = mainSeq->Value(length);
+    tmpSecond = mainSeq->Value(1);
+    if (!(tmpSecond - tmpFirst == 1 || (tmpFirst == length && tmpSecond == 1)))
+      isShiftForward = Standard_False;
+    if (!(tmpFirst - tmpSecond == 1 || (tmpSecond == length && tmpFirst == 1)))
+      isShiftReverse = Standard_False;
+    if (isShiftForward || isShiftReverse)
+      stTmp = 3;
+    myStat = stTmp;
+    return;
+  }
 }
 
 //=======================================================================
index e433ed7..f6f3d75 100755 (executable)
@@ -443,7 +443,7 @@ Standard_Boolean ShapeFix_Face::Perform()
       }
       if ( theAdvFixWire->Perform() ) {
        //fixed = Standard_True; 
-        isfixReorder =  (theAdvFixWire->StatusReorder(ShapeExtend_DONE) || isfixReorder);
+        isfixReorder =  ((theAdvFixWire->StatusReorder(ShapeExtend_DONE) && !theAdvFixWire->StatusReorder(ShapeExtend_DONE5)) || isfixReorder);
         fixed = (theAdvFixWire->StatusSmall(ShapeExtend_DONE) || 
                theAdvFixWire->StatusConnected(ShapeExtend_DONE) ||
                theAdvFixWire->StatusEdgeCurves(ShapeExtend_DONE) ||
@@ -477,11 +477,11 @@ Standard_Boolean ShapeFix_Face::Perform()
       if ( ! Context().IsNull() ) Context()->Replace ( S, tmpFace );
       //myFace = tmpFace;
       isReplaced = Standard_True;
-      myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
-      
     }
-    if(fixed || isfixReorder)
+    if(fixed || isfixReorder) {
       myFace = tmpFace;
+      myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
+    }
   }
   
   myResult = myFace;
index aeeb063..b17d699 100755 (executable)
@@ -441,6 +441,8 @@ Standard_Boolean ShapeFix_Wire::FixReorder()
     myStatusReorder |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE2 );
   if ( sawo.Status() <0 ) 
     myStatusReorder |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE3 );
+  if ( sawo.Status() == 3)
+    myStatusReorder |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE5 );//only shifted
   return Standard_True;
 }
 
diff --git a/tests/bugs/heal/bug21317 b/tests/bugs/heal/bug21317
new file mode 100755 (executable)
index 0000000..84e75c5
--- /dev/null
@@ -0,0 +1,25 @@
+puts "================"
+puts "OCC21317"
+puts "================"
+puts ""
+######################################################################################
+# Face cannot be fixed by Shape Healing
+######################################################################################
+
+set BugNumber OCC21317
+
+catch {pload XDE}
+
+restore [locate_data_file bug21317_faulty.brep] a 
+fixshape result a
+set info [checkshape result]
+
+# Resume
+puts ""
+if { [regexp {This shape seems to be valid} $info] } {
+   puts "OK ${BugNumber}"
+} else {
+   puts "Faulty ${BugNumber}"
+}
+
+set 2dviewer 0
index 429937a..5e961c4 100644 (file)
@@ -12,9 +12,9 @@ set ref_data {
 DATA        : Faulties = 0  ( 0 )  Warnings = 0  ( 0 )  Summary  = 0  ( 0 )
 TPSTAT      : Faulties = 0  ( 0 )  Warnings = 21  ( 12 )  Summary  = 21  ( 12 )
 CHECKSHAPE  : Wires    = 2  ( 0 )  Faces    = 2  ( 0 )  Shells   = 0  ( 0 )   Solids   = 0 ( 0 )
-NBSHAPES    : Solid    = 3  ( 4 )  Shell    = 4  ( 4 )  Face     = 35  ( 35 )   Summary  = 292  ( 266 )
-STATSHAPE   : Solid    = 3  ( 4 )  Shell    = 4  ( 4 )  Face     = 35  ( 35 )   FreeWire = 0  ( 0 )   FreeEdge  = 24 ( 24 )   SharedEdge = 105  ( 103 )
-TOLERANCE   : MaxTol   = 6.104502198e-06  (          1e-05 )  AvgTol   =  9.694977451e-07  (  2.91037487e-06 )
+NBSHAPES    : Solid    = 4  ( 4 )  Shell    = 4  ( 4 )  Face     = 35  ( 35 )   Summary  = 289  ( 266 )
+STATSHAPE   : Solid    = 4  ( 4 )  Shell    = 4  ( 4 )  Face     = 35  ( 35 )   FreeWire = 0  ( 0 )   FreeEdge  = 24 ( 24 )   SharedEdge = 103  ( 103 )
+TOLERANCE   : MaxTol   = 6.104502198e-06  (          1e-05 )  AvgTol   =  9.682983037e-07  (  2.91037487e-06 )
 LABELS      : N0Labels = 4  ( 4 )  N1Labels = 31  ( 31 )  N2Labels = 0  ( 0 )   TotalLabels = 35  ( 35 )   NameLabels = 7  ( 7 )   ColorLabels = 0  ( 0 )   LayerLabels = 28  ( 28 )
 PROPS       : Centroid = 0  ( 0 )  Volume   = 0  ( 0 )  Area     = 0  ( 0 )
 NCOLORS     : NColors  = 0  ( 0 )