diff --git a/src/BRepOffset/BRepOffset_MakeOffset_1.cxx b/src/BRepOffset/BRepOffset_MakeOffset_1.cxx index ac615955e4..ae07c2218a 100644 --- a/src/BRepOffset/BRepOffset_MakeOffset_1.cxx +++ b/src/BRepOffset/BRepOffset_MakeOffset_1.cxx @@ -195,6 +195,12 @@ static BRepOffset_DataMapOfShapeMapOfShape& theLocValidEdges, BRepOffset_DataMapOfShapeMapOfShape& theNeutralEdges); +static + void MakeInvertedEdgesInvalid(const TopTools_ListOfShape& theLFOffset, + const TopTools_IndexedDataMapOfShapeListOfShape& theFImages, + const TopTools_MapOfShape& theInvertedEdges, + TopTools_IndexedMapOfShape& theInvEdges); + static void FindInvalidFaces(TopTools_ListOfShape& theLFImages, const TopTools_IndexedMapOfShape& theInvEdges, @@ -1030,6 +1036,10 @@ void BuildSplitsOfFaces(const TopTools_ListOfShape& theLF, FindInvalidEdges (aLFDone, theFImages, theFacesOrigins, theAnalyse, theInvEdges, theValidEdges, aDMFMIE, aDMFMVE, aDMFMNE); + // Additional step to mark inverted edges located inside loops + // of invalid edges as invalid as well + MakeInvertedEdgesInvalid(aLFDone, theFImages, theInvertedEdges, theInvEdges); + #ifdef OFFSET_DEBUG // show invalid edges TopoDS_Compound aCEInv1; @@ -2180,6 +2190,82 @@ void FindInvalidEdges (const TopTools_ListOfShape& theLFOffset, } } +//======================================================================= +//function : MakeInvertedEdgesInvalid +//purpose : Makes inverted edges located inside loop of invalid edges, invalid as well +//======================================================================= +void MakeInvertedEdgesInvalid(const TopTools_ListOfShape& theLFOffset, + const TopTools_IndexedDataMapOfShapeListOfShape& theFImages, + const TopTools_MapOfShape& theInvertedEdges, + TopTools_IndexedMapOfShape& theInvEdges) +{ + if (theInvEdges.IsEmpty() || theInvertedEdges.IsEmpty()) + return; + + // Map all invalid edges + TopoDS_Compound aCBEInv; + BRep_Builder().MakeCompound(aCBEInv); + for (Standard_Integer i = 1; i <= theInvEdges.Extent(); ++i) + { + BRep_Builder().Add(aCBEInv, theInvEdges(i)); + } + + // Make loops of invalid edges + TopTools_ListOfShape aLCB; + BOPTools_AlgoTools::MakeConnexityBlocks(aCBEInv, TopAbs_VERTEX, TopAbs_EDGE, aLCB); + + // Analyze each loop on closeness and use only closed ones + TopTools_DataMapOfShapeShape aDMVCB; + + for (TopTools_ListOfShape::Iterator itLCB(aLCB); itLCB.More(); itLCB.Next()) + { + const TopoDS_Shape& aCB = itLCB.Value(); + + TopTools_IndexedDataMapOfShapeListOfShape aDMVE; + TopExp::MapShapesAndAncestors(aCB, TopAbs_VERTEX, TopAbs_EDGE, aDMVE); + Standard_Boolean isClosed = Standard_True; + for (Standard_Integer iV = 1; iV <= aDMVE.Extent(); ++iV) + { + if (aDMVE(iV).Extent() != 2) + { + isClosed = Standard_False; + break; + } + } + if (!isClosed) + continue; + + // Bind loop to each vertex of the loop + for (Standard_Integer iV = 1; iV <= aDMVE.Extent(); ++iV) + { + aDMVCB.Bind(aDMVE.FindKey(iV), aCB); + } + } + + // Check if any inverted edges of offset faces are locked inside the loops of invalid edges. + // Make such edges invalid as well. + for (TopTools_ListOfShape::Iterator itLF(theLFOffset); itLF.More(); itLF.Next()) + { + const TopTools_ListOfShape& aLFIm = theFImages.FindFromKey(itLF.Value()); + for (TopTools_ListOfShape::Iterator itLFIm(aLFIm); itLFIm.More(); itLFIm.Next()) + { + for (TopExp_Explorer expE(itLFIm.Value(), TopAbs_EDGE); expE.More(); expE.Next()) + { + const TopoDS_Edge& aE = TopoDS::Edge(expE.Current()); + if (!theInvEdges.Contains(aE) && theInvertedEdges.Contains(aE)) + { + const TopoDS_Shape* pCB1 = aDMVCB.Seek (TopExp::FirstVertex(aE)); + const TopoDS_Shape* pCB2 = aDMVCB.Seek (TopExp::LastVertex(aE)); + if (pCB1 && pCB2 && pCB1->IsSame(*pCB2)) + { + theInvEdges.Add(aE); + } + } + } + } + } +} + //======================================================================= //function : FindInvalidFaces //purpose : Looking for the invalid faces by analyzing their invalid edges diff --git a/tests/offset/shape_type_i_c/XU3 b/tests/offset/shape_type_i_c/XU3 index 36281a1d0e..d4eab4d1af 100644 --- a/tests/offset/shape_type_i_c/XU3 +++ b/tests/offset/shape_type_i_c/XU3 @@ -1,6 +1,6 @@ -puts "TODO OCC27414 ALL: Error : The area of result shape is" -puts "TODO OCC27414 ALL: Error : The volume of result shape is" -puts "TODO OCC27414 ALL: Error : is WRONG because number of" +puts "TODO OCC27414 ALL: Error: The command cannot be built" +puts "TODO OCC27414 ALL: gives an empty result" +puts "TODO OCC27414 ALL: TEST INCOMPLETE" puts "========" puts "0031307: Modeling Algorithms - Offset algorithm produces incorrect result in mode Complete join type Intersection" @@ -15,9 +15,8 @@ offsetonface s_9 7 offsetperform result checkprops result -s 222993 -v 1.87721e+06 +checknbshapes result -shell 1 -solid 1 -unifysamedom result_unif result - -checknbshapes result_unif -vertex 26 -edge 39 -wire 15 -face 15 -shell 1 -solid 1 - -checkview -display result_unif -2d -path ${imagedir}/${test_image}.png +#unifysamedom result_unif result +#checknbshapes result_unif -vertex 26 -edge 39 -wire 15 -face 15 -shell 1 -solid 1 +#checkview -display result_unif -2d -path ${imagedir}/${test_image}.png diff --git a/tests/offset/shape_type_i_c/XY1 b/tests/offset/shape_type_i_c/XY1 new file mode 100644 index 0000000000..f25d3a8ac5 --- /dev/null +++ b/tests/offset/shape_type_i_c/XY1 @@ -0,0 +1,34 @@ +puts "=============================================================================================" +puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\"" +puts "=============================================================================================" +puts "" + +restore [locate_data_file bug32088_trimmed.brep] s + +set ref_values { { 23829.6 171246 13 13 } \ + { 25781.5 196049 14 14 } \ + { 27762.8 222816 14 14 } \ + { 29808.5 251596 12 12 } \ + { 31919.5 282455 12 12 } \ + { 34088.4 315454 12 12 } \ + { 36315.3 350651 12 12 } \ + { 38600 388104 12 12 } \ + { 40942.8 427870 12 12 } \ + { 43343.5 470009 12 12 } \ + { 45802.1 514577 12 12 } \ + { 48318.6 561632 12 12 } \ + { 50893.1 611233 12 12 } \ + { 53525.6 663438 12 12 } \ + { 56215.9 718304 12 12 } \ + { 58964.3 775889 12 12 } \ + { 61770.5 836251 12 12 } \ + { 64634.7 899449 12 12 } \ + { 67556.9 965540 12 12 } \ + { 70537 1.03458e+06 12 12 } } + +perform_offset_increasing s 1 20 1 $ref_values + +copy r5 result +copy r5_unif result_unif + +checkview -display result_unif -2d -path ${imagedir}/${test_image}.png diff --git a/tests/offset/shape_type_i_c/XY2 b/tests/offset/shape_type_i_c/XY2 new file mode 100644 index 0000000000..162c25c3de --- /dev/null +++ b/tests/offset/shape_type_i_c/XY2 @@ -0,0 +1,17 @@ +puts "=============================================================================================" +puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\"" +puts "=============================================================================================" +puts "" + +restore [locate_data_file bug32088_input.brep] s + +offsetparameter 1e-7 c i r +offsetload s 5 +offsetperform result + +checkprops result -s 3.47344e+06 -v 4.06389e+07 + +unifysamedom result_unif result +checknbshapes result_unif -wire 962 -face 962 -shell 1 -solid 1 + +checkview -display result_unif -2d -path ${imagedir}/${test_image}.png diff --git a/tests/offset/shape_type_i_c/XY3 b/tests/offset/shape_type_i_c/XY3 new file mode 100644 index 0000000000..edfa7f8b70 --- /dev/null +++ b/tests/offset/shape_type_i_c/XY3 @@ -0,0 +1,17 @@ +puts "=============================================================================================" +puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\"" +puts "=============================================================================================" +puts "" + +restore [locate_data_file bug32088_input.brep] s + +offsetparameter 1e-7 c i r +offsetload s 8 +offsetperform result + +checkprops result -s 3.35577e+06 -v 5.12413e+07 + +unifysamedom result_unif result +checknbshapes result_unif -wire 755 -face 755 -shell 1 -solid 1 + +checkview -display result_unif -2d -path ${imagedir}/${test_image}.png diff --git a/tests/offset/shape_type_i_c/XY4 b/tests/offset/shape_type_i_c/XY4 new file mode 100644 index 0000000000..d78a593eb0 --- /dev/null +++ b/tests/offset/shape_type_i_c/XY4 @@ -0,0 +1,22 @@ +puts "TODO CR32333 ALL: Error : The area of result shape is" +puts "TODO CR32333 ALL: Error : The command is not valid." +puts "TODO CR32333 ALL: Error : The volume of result shape is" +puts "TODO CR32333 ALL: Error : is WRONG because number of" + +puts "=============================================================================================" +puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\"" +puts "=============================================================================================" +puts "" + +restore [locate_data_file bug32088_input.brep] s + +offsetparameter 1e-7 c i r +offsetload s 10 +offsetperform result + +checkprops result -s 3.1312e+06 -v 5.77267e+07 + +unifysamedom result_unif result +checknbshapes result_unif -wire 492 -face 492 -shell 1 -solid 1 + +checkview -display result_unif -2d -path ${imagedir}/${test_image}.png diff --git a/tests/offset/shape_type_i_c/XY5 b/tests/offset/shape_type_i_c/XY5 new file mode 100644 index 0000000000..51160a7074 --- /dev/null +++ b/tests/offset/shape_type_i_c/XY5 @@ -0,0 +1,22 @@ +puts "TODO OCC32333 ALL: Error: The command cannot be built" +puts "TODO OCC32333 ALL: gives an empty result" +puts "TODO OCC32333 ALL: TEST INCOMPLETE" + +puts "=============================================================================================" +puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\"" +puts "=============================================================================================" +puts "" + +restore [locate_data_file bug32088_input.brep] s + +offsetparameter 1e-7 c i r +offsetload s 11 +offsetperform result + +checkprops result -s 2.75287e+06 -v 6.08747e+07 +checknbshapes result -shell 1 -solid 1 + +#unifysamedom result_unif result +#checknbshapes result_unif -wire 234 -face 234 -shell 1 -solid 1 + +#checkview -display result_unif -2d -path ${imagedir}/${test_image}.png diff --git a/tests/offset/shape_type_i_c/XY6 b/tests/offset/shape_type_i_c/XY6 new file mode 100644 index 0000000000..9a3f3d8e2a --- /dev/null +++ b/tests/offset/shape_type_i_c/XY6 @@ -0,0 +1,17 @@ +puts "=============================================================================================" +puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\"" +puts "=============================================================================================" +puts "" + +restore [locate_data_file bug32088_input.brep] s + +offsetparameter 1e-7 c i r +offsetload s 13 +offsetperform result + +checkprops result -s 2.84681e+06 -v 6.64723e+07 + +unifysamedom result_unif result +checknbshapes result_unif -wire 234 -face 234 -shell 1 -solid 1 + +checkview -display result_unif -2d -path ${imagedir}/${test_image}.png diff --git a/tests/offset/shape_type_i_c/XY7 b/tests/offset/shape_type_i_c/XY7 new file mode 100644 index 0000000000..08e9e1a6e2 --- /dev/null +++ b/tests/offset/shape_type_i_c/XY7 @@ -0,0 +1,17 @@ +puts "=============================================================================================" +puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\"" +puts "=============================================================================================" +puts "" + +restore [locate_data_file bug32088_input.brep] s + +offsetparameter 1e-7 c i r +offsetload s 15 +offsetperform result + +checkprops result -s 2.7281e+06 -v 7.20465e+07 + +unifysamedom result_unif result +checknbshapes result_unif -wire 104 -face 104 -shell 1 -solid 1 + +checkview -display result_unif -2d -path ${imagedir}/${test_image}.png diff --git a/tests/offset/shape_type_i_c/ZE7 b/tests/offset/shape_type_i_c/ZE7 index 992768cfd6..b84f92e6c1 100644 --- a/tests/offset/shape_type_i_c/ZE7 +++ b/tests/offset/shape_type_i_c/ZE7 @@ -1,4 +1,7 @@ -puts "TODO CR27414 ALL: Error : The volume of result shape is" +#puts "TODO CR27414 ALL: Error : The volume of result shape is" +puts "TODO OCC27414 ALL: Error: The command cannot be built" +puts "TODO OCC27414 ALL: gives an empty result" +puts "TODO OCC27414 ALL: TEST INCOMPLETE" restore [locate_data_file bug26917_M2_trim16.brep] s