From 673693f1cf72fc6bbdd32f2089eadde145caacf1 Mon Sep 17 00:00:00 2001 From: ika Date: Thu, 1 Aug 2013 12:34:52 +0400 Subject: [PATCH] 0021317: Face cannot be fixed by Shape Healing 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 | 1 + src/ShapeAnalysis/ShapeAnalysis_WireOrder.cxx | 28 +++++++++++++++++-- src/ShapeFix/ShapeFix_Face.cxx | 8 +++--- src/ShapeFix/ShapeFix_Wire.cxx | 2 ++ tests/bugs/heal/bug21317 | 25 +++++++++++++++++ tests/de/step_1/E3 | 6 ++-- 6 files changed, 61 insertions(+), 9 deletions(-) create mode 100755 tests/bugs/heal/bug21317 diff --git a/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx b/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx index 060f9dc9bc..02f16eb7d6 100755 --- a/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx +++ b/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx @@ -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); diff --git a/src/ShapeAnalysis/ShapeAnalysis_WireOrder.cxx b/src/ShapeAnalysis/ShapeAnalysis_WireOrder.cxx index d218e75354..5f107268c9 100755 --- a/src/ShapeAnalysis/ShapeAnalysis_WireOrder.cxx +++ b/src/ShapeAnalysis/ShapeAnalysis_WireOrder.cxx @@ -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; + } } //======================================================================= diff --git a/src/ShapeFix/ShapeFix_Face.cxx b/src/ShapeFix/ShapeFix_Face.cxx index e433ed746c..f6f3d754ac 100755 --- a/src/ShapeFix/ShapeFix_Face.cxx +++ b/src/ShapeFix/ShapeFix_Face.cxx @@ -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; diff --git a/src/ShapeFix/ShapeFix_Wire.cxx b/src/ShapeFix/ShapeFix_Wire.cxx index aeeb063d4f..b17d699248 100755 --- a/src/ShapeFix/ShapeFix_Wire.cxx +++ b/src/ShapeFix/ShapeFix_Wire.cxx @@ -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 index 0000000000..84e75c51bc --- /dev/null +++ b/tests/bugs/heal/bug21317 @@ -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 diff --git a/tests/de/step_1/E3 b/tests/de/step_1/E3 index 429937a74a..5e961c4536 100644 --- a/tests/de/step_1/E3 +++ b/tests/de/step_1/E3 @@ -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 )