From: gka Date: Thu, 10 Sep 2015 14:42:22 +0000 (+0300) Subject: 0025553: ShapeFix_Face::FixMissingSeam() fails to correct a face X-Git-Tag: V7_0_0_beta~279 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=0d3d226ed332b118f67091041643f03ee5dbc16f 0025553: ShapeFix_Face::FixMissingSeam() fails to correct a face Modification to support case when edges on face have incorrect orientation was added. Modification to support case when wires have intersecting segment was added Test cases for issue 25553 added; other affected tests corrected (improvements) Corrected test case --- diff --git a/src/ShapeFix/ShapeFix_Face.cxx b/src/ShapeFix/ShapeFix_Face.cxx index 5a9684f31f..2c59f3f3a9 100644 --- a/src/ShapeFix/ShapeFix_Face.cxx +++ b/src/ShapeFix/ShapeFix_Face.cxx @@ -1654,52 +1654,73 @@ Standard_Boolean ShapeFix_Face::FixMissingSeam() ws.Append ( w2 ); } + // Check consistency of orientations of the two wires that need to be connected by a seam + Standard_Real uf=SUF, vf=SVF; + Standard_Integer coord = ( ismodeu ? 1 : 0 ); + Standard_Integer isneg = ( ismodeu ? ismodeu : -ismodev ); + Standard_Real period = ( ismodeu ? URange : VRange ); + TopoDS_Shape S; + Standard_Real m1[2][2], m2[2][2]; + S = myFace.EmptyCopied(); + B.Add ( S, w1 ); + ShapeAnalysis::GetFaceUVBounds (TopoDS::Face(S), m1[0][0], m1[0][1], m1[1][0], m1[1][1]); + S = myFace.EmptyCopied(); + B.Add ( S, w2 ); + ShapeAnalysis::GetFaceUVBounds (TopoDS::Face(S), m2[0][0], m2[0][1], m2[1][0], m2[1][1]); + + // For the case when surface is closed only in one direction it is necesary to check + // validity of orientation of the open wires in parametric space. + // In case of U closed surface wire with minimal V coordinate should be directed in positive direction by U + // In case of V closed surface wire with minimal U coordinate should be directed in negative direction by V + if (!vclosed || !uclosed) + { + Standard_Real deltaOther = 0.5 * (m2[coord][0] + m2[coord][1]) - 0.5 * (m1[coord][0] + m1[coord][1]); + if (deltaOther * isneg < 0) + { + w1.Reverse(); + w2.Reverse(); + } + } + // sort original wires Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire; sfw->SetFace ( myFace ); sfw->SetPrecision ( Precision() ); - Handle(ShapeExtend_WireData) wd1 = new ShapeExtend_WireData ( w1 ); Handle(ShapeExtend_WireData) wd2 = new ShapeExtend_WireData ( w2 ); - - // sorting -// Standard_Boolean degenerated = ( secondDeg != firstDeg ); -// if ( ! degenerated ) { - sfw->Load ( wd1 ); - sfw->FixReorder(); -// } + sfw->Load ( wd1 ); + sfw->FixReorder(); sfw->Load ( wd2 ); sfw->FixReorder(); - + TopoDS_Wire w11 = wd1->Wire(); + TopoDS_Wire w21 = wd2->Wire(); + //:abv 29.08.01: reconstruct face taking into account reversing TopoDS_Shape dummy = myFace.EmptyCopied(); TopoDS_Face tmpF = TopoDS::Face ( dummy ); tmpF.Orientation ( TopAbs_FORWARD ); for ( i=1; i <= ws.Length(); i++ ) { TopoDS_Wire wire = TopoDS::Wire ( ws.Value(i) ); - if ( wire.IsSame ( w1 ) ) wire = w1; - else if ( wire.IsSame ( w2 ) ) wire = w2; + if ( wire.IsSame ( w1 ) ) wire = w11; + else if ( wire.IsSame ( w2 ) ) wire = w21; + else + { + // other wires (not boundary) are considered as holes; make sure to have them oriented accordingly + TopoDS_Shape curface = tmpF.EmptyCopied(); + B.Add(curface,wire); + curface.Orientation ( myFace.Orientation() ); + if( ShapeAnalysis::IsOuterBound(TopoDS::Face(curface))) + wire.Reverse(); + } B.Add ( tmpF, wire ); } + tmpF.Orientation ( myFace.Orientation() ); - - Standard_Real uf=SUF, vf=SVF; - + // A special kind of FixShifted is necessary for torus-like // surfaces to adjust wires by period ALONG the missing SEAM direction // tr9_r0501-ug.stp #187640 if ( uclosed && vclosed ) { - Standard_Integer coord = ( ismodeu ? 1 : 0 ); - Standard_Integer isneg = ( ismodeu ? ismodeu : -ismodev ); - Standard_Real period = ( ismodeu ? URange : VRange ); - TopoDS_Shape S; - Standard_Real m1[2][2], m2[2][2]; - S = tmpF.EmptyCopied(); - B.Add ( S, w1 ); - ShapeAnalysis::GetFaceUVBounds (TopoDS::Face(S), m1[0][0], m1[0][1], m1[1][0], m1[1][1]); - S = tmpF.EmptyCopied(); - B.Add ( S, w2 ); - ShapeAnalysis::GetFaceUVBounds (TopoDS::Face(S), m2[0][0], m2[0][1], m2[1][0], m2[1][1]); Standard_Real shiftw2 = ShapeAnalysis::AdjustByPeriod ( 0.5 * ( m2[coord][0] + m2[coord][1] ), 0.5 * ( m1[coord][0] + m1[coord][1] + @@ -1711,9 +1732,10 @@ Standard_Boolean ShapeFix_Face::FixMissingSeam() if(it.Value().ShapeType() != TopAbs_WIRE) continue; TopoDS_Wire w = TopoDS::Wire ( it.Value() ); - if ( w == w1 ) continue; + if ( w == w11 ) continue; Standard_Real shift; - if ( w == w2 ) shift = shiftw2; + if ( w == w21 ) shift = shiftw2; + else { S = tmpF.EmptyCopied(); B.Add ( S, w ); diff --git a/src/ShapeFix/ShapeFix_IntersectionTool.cxx b/src/ShapeFix/ShapeFix_IntersectionTool.cxx index 6825955197..2e5f70f9ee 100644 --- a/src/ShapeFix/ShapeFix_IntersectionTool.cxx +++ b/src/ShapeFix/ShapeFix_IntersectionTool.cxx @@ -223,6 +223,7 @@ Standard_Boolean ShapeFix_IntersectionTool::CutEdge(const TopoDS_Edge &edge, return Standard_True; } + } return Standard_False; } @@ -1651,7 +1652,11 @@ Standard_Boolean ShapeFix_IntersectionTool::FixIntersectingWires if(Abs(pend-p11)>Abs(pend-p12)) cut=p12; else cut=p11; Standard_Boolean IsCutLine; - CutEdge(edge1, pend, cut, face, IsCutLine); + if(!CutEdge(edge1, pend, cut, face, IsCutLine)) + { + IsModified1 = Standard_False; + continue; + } if(newtol>BRep_Tool::Tolerance(NewV)) { B.UpdateVertex(NewV,newtol*1.00001); } @@ -1698,14 +1703,20 @@ Standard_Boolean ShapeFix_IntersectionTool::FixIntersectingWires if(Abs(pend-p21)>Abs(pend-p22)) cut=p22; else cut=p21; Standard_Boolean IsCutLine; - CutEdge(edge2, pend, cut, face, IsCutLine); + if(!CutEdge(edge2, pend, cut, face, IsCutLine)) + { + IsModified2 = Standard_False; + continue; + + } if(newtol>BRep_Tool::Tolerance(NewV)) { B.UpdateVertex(NewV,newtol*1.00001); } } if( IsModified1 || IsModified2 ) { - //num2--; + //necessary to make intersect with the same pair of the edges once again with modified ranges + num2--; hasModifWire = Standard_True; //gka 06.09.04 continue; } diff --git a/tests/bugs/heal/bug25553_1 b/tests/bugs/heal/bug25553_1 new file mode 100644 index 0000000000..3b7fa6fa6c --- /dev/null +++ b/tests/bugs/heal/bug25553_1 @@ -0,0 +1,11 @@ +puts "========================" +puts "Bug #25553" +puts "========================" + +brestore [locate_data_file bug25553_ii_73.brep] face + +fixshape result face 1e-7 1 +checkshape result +checknbshapes result -face 1 + +set 2dviewer 1 diff --git a/tests/bugs/heal/bug25553_2 b/tests/bugs/heal/bug25553_2 new file mode 100644 index 0000000000..6f90690d69 --- /dev/null +++ b/tests/bugs/heal/bug25553_2 @@ -0,0 +1,11 @@ +puts "========================" +puts "Bug #25553" +puts "========================" + +brestore [locate_data_file bug25553_f-cyl-no-seam-shifted-pcurves.brep] face + +fixshape result face 1e-7 1 +checkshape result +checknbshapes result -face 1 + +set 2dviewer 1 diff --git a/tests/bugs/heal/bug25553_3 b/tests/bugs/heal/bug25553_3 new file mode 100644 index 0000000000..7a5d439b32 --- /dev/null +++ b/tests/bugs/heal/bug25553_3 @@ -0,0 +1,11 @@ +puts "========================" +puts "Bug #25553" +puts "========================" + +brestore [locate_data_file bug25553_f-cyl-no-seam-shifted-pcurves-2.brep] face + +fixshape result face 1e-7 1 +checkshape result +checknbshapes result -face 1 + +set 2dviewer 1 diff --git a/tests/de/step_1/D1 b/tests/de/step_1/D1 index 4aca45d8b4..a090a45344 100644 --- a/tests/de/step_1/D1 +++ b/tests/de/step_1/D1 @@ -1,16 +1,15 @@ # !!!! This file is generated automatically, do not edit manually! See end script -puts "TODO CR23096 ALL: LABELS : Faulty" set filename trj9_b2-ai-214.stp set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 9 ( 40 ) Summary = 9 ( 40 ) -CHECKSHAPE : Wires = 0 ( 1 ) Faces = 0 ( 1 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) -NBSHAPES : Solid = 2 ( 2 ) Shell = 2 ( 2 ) Face = 222 ( 222 ) Summary = 1470 ( 1466 ) -STATSHAPE : Solid = 2 ( 2 ) Shell = 2 ( 2 ) Face = 222 ( 222 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 611 ( 609 ) -TOLERANCE : MaxTol = 0.004950186716 ( 0.004950186717 ) AvgTol = 0.0003554734562 ( 0.00035972426 ) -LABELS : N0Labels = 1 ( 1 ) N1Labels = 2 ( 0 ) N2Labels = 0 ( 0 ) TotalLabels = 3 ( 1 ) NameLabels = 1 ( 1 ) ColorLabels = 2 ( 1 ) LayerLabels = 0 ( 0 ) +TPSTAT : Faulties = 0 ( 0 ) Warnings = 8 ( 38 ) Summary = 8 ( 38 ) +CHECKSHAPE : Wires = 1 ( 1 ) Faces = 1 ( 1 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) +NBSHAPES : Solid = 1 ( 1 ) Shell = 1 ( 1 ) Face = 221 ( 221 ) Summary = 1465 ( 1463 ) +STATSHAPE : Solid = 1 ( 1 ) Shell = 1 ( 1 ) Face = 221 ( 221 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 610 ( 610 ) +TOLERANCE : MaxTol = 0.004950186716 ( 0.004950186717 ) AvgTol = 0.0003553188051 ( 0.0003621212346 ) +LABELS : N0Labels = 1 ( 1 ) N1Labels = 0 ( 0 ) N2Labels = 0 ( 0 ) TotalLabels = 1 ( 1 ) NameLabels = 1 ( 1 ) ColorLabels = 1 ( 1 ) LayerLabels = 0 ( 0 ) PROPS : Centroid = 1 ( 1 ) Volume = 1 ( 1 ) Area = 1 ( 1 ) NCOLORS : NColors = 1 ( 1 ) COLORS : Colors = YELLOW ( YELLOW ) diff --git a/tests/de/step_1/G9 b/tests/de/step_1/G9 index 316f8192cf..0515e43149 100644 --- a/tests/de/step_1/G9 +++ b/tests/de/step_1/G9 @@ -1,6 +1,5 @@ # !!!! This file is generated automatically, do not edit manually! See end script puts "TODO CR23096 ALL: STATSHAPE : Faulty" -puts "TODO CR23096 ALL: TOLERANCE : Faulty" puts "TODO CR23096 ALL: LABELS : Faulty" puts "TODO CR23096 ALL: LAYERS : Faulty" @@ -9,11 +8,11 @@ set filename trj4_k1_geo-tu-214.stp set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 5 ( 10 ) Summary = 5 ( 10 ) -CHECKSHAPE : Wires = 0 ( 1 ) Faces = 0 ( 2 ) Shells = 0 ( 2 ) Solids = 0 ( 0 ) -NBSHAPES : Solid = 0 ( 0 ) Shell = 51 ( 2 ) Face = 51 ( 48 ) Summary = 584 ( 569 ) -STATSHAPE : Solid = 0 ( 0 ) Shell = 51 ( 2 ) Face = 51 ( 48 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 220 ( 218 ) -TOLERANCE : MaxTol = 0.4289319668 ( 0.007688098235 ) AvgTol = 0.0122902841 ( 0.0002401295385 ) +TPSTAT : Faulties = 0 ( 0 ) Warnings = 1 ( 10 ) Summary = 1 ( 10 ) +CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) +NBSHAPES : Solid = 0 ( 0 ) Shell = 44 ( 0 ) Face = 44 ( 44 ) Summary = 559 ( 559 ) +STATSHAPE : Solid = 0 ( 0 ) Shell = 44 ( 0 ) Face = 44 ( 44 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 217 ( 217 ) +TOLERANCE : MaxTol = 0.0004382667275 ( 0.007688098235 ) AvgTol = 1.733348843e-005 ( 0.0002416764063 ) LABELS : N0Labels = 1 ( 1 ) N1Labels = 44 ( 44 ) N2Labels = 0 ( 0 ) TotalLabels = 45 ( 45 ) NameLabels = 1 ( 1 ) ColorLabels = 44 ( 44 ) LayerLabels = 0 ( 44 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 1 ( 1 ) diff --git a/tests/de/step_3/D8 b/tests/de/step_3/D8 index 3480b140ce..cb8acf9d52 100755 --- a/tests/de/step_3/D8 +++ b/tests/de/step_3/D8 @@ -1,16 +1,13 @@ # !!!! This file is generated automatically, do not edit manually! See end script -# No checkape error on WNT in 64-bit only (after 22598 and issue 25797 was registered for that) -puts "TODO CR23096 Linux: CHECKSHAPE : Faulty" - set filename trj6_pm4-hc-214.stp set ref_data { -DATA : Faulties = 0 ( 20 ) Warnings = 0 ( 0 ) Summary = 0 ( 20 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 19 ( 555 ) Summary = 19 ( 555 ) -CHECKSHAPE : Wires = 10 ( 0 ) Faces = 11 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) +DATA : Faulties = 0 ( 20 ) Warnings = 0 ( 60 ) Summary = 0 ( 80 ) +TPSTAT : Faulties = 0 ( 0 ) Warnings = 21 ( 557 ) Summary = 21 ( 557 ) +CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 98 ( 98 ) Shell = 98 ( 98 ) Face = 1506 ( 1506 ) Summary = 9262 ( 9257 ) STATSHAPE : Solid = 272 ( 272 ) Shell = 272 ( 272 ) Face = 3216 ( 3216 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 3315 ( 3311 ) -TOLERANCE : MaxTol = 0.9562231856 ( 3.3196868 ) AvgTol = 0.0007123152675 ( 0.003694409816 ) +TOLERANCE : MaxTol = 0.9562231856 ( 3.3196868 ) AvgTol = 0.0007127405962 ( 0.003722159881 ) LABELS : N0Labels = 230 ( 230 ) N1Labels = 1909 ( 1909 ) N2Labels = 0 ( 0 ) TotalLabels = 2139 ( 2139 ) NameLabels = 633 ( 633 ) ColorLabels = 1506 ( 1506 ) LayerLabels = 0 ( 0 ) PROPS : Centroid = 98 ( 98 ) Volume = 98 ( 98 ) Area = 98 ( 98 ) NCOLORS : NColors = 6 ( 6 ) diff --git a/tests/de/step_3/E6 b/tests/de/step_3/E6 index 07a99fd1b1..e2de50e0c9 100755 --- a/tests/de/step_3/E6 +++ b/tests/de/step_3/E6 @@ -2,18 +2,16 @@ puts "TODO CR23096 ALL: TPSTAT : Faulty" puts "TODO CR23096 ALL: CHECKSHAPE : Faulty" puts "TODO CR23096 ALL: STATSHAPE : Faulty" -puts "TODO CR23096 ALL: Error : 3 differences with reference data found" -set LinuxDiff 3 set filename Z8M6SAT.stp set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 7 ( 0 ) Warnings = 956 ( 3168 ) Summary = 963 ( 3168 ) -CHECKSHAPE : Wires = 50 ( 41 ) Faces = 49 ( 45 ) Shells = 0 ( 4 ) Solids = 0 ( 0 ) -NBSHAPES : Solid = 28 ( 28 ) Shell = 772 ( 32 ) Face = 3242 ( 3241 ) Summary = 29459 ( 28673 ) -STATSHAPE : Solid = 28 ( 28 ) Shell = 772 ( 32 ) Face = 3242 ( 3241 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 12632 ( 12599 ) -TOLERANCE : MaxTol = 15.00300076 ( 20.46526799 ) AvgTol = 0.0281001785 ( 0.03853100147 ) +TPSTAT : Faulties = 3 ( 0 ) Warnings = 944 ( 3168 ) Summary = 947 ( 3168 ) +CHECKSHAPE : Wires = 50 ( 41 ) Faces = 50 ( 46 ) Shells = 0 ( 2 ) Solids = 0 ( 0 ) +NBSHAPES : Solid = 28 ( 28 ) Shell = 768 ( 30 ) Face = 3240 ( 3239 ) Summary = 29374 ( 28630 ) +STATSHAPE : Solid = 28 ( 28 ) Shell = 768 ( 30 ) Face = 3240 ( 3239 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 12587 ( 12579 ) +TOLERANCE : MaxTol = 15.00300076 ( 20.46526799 ) AvgTol = 0.02248945623 ( 0.03724082116 ) LABELS : N0Labels = 3 ( 3 ) N1Labels = 2 ( 2 ) N2Labels = 0 ( 0 ) TotalLabels = 5 ( 5 ) NameLabels = 5 ( 5 ) ColorLabels = 0 ( 0 ) LayerLabels = 0 ( 0 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 0 ( 0 )