diff --git a/src/ModelingAlgorithms/TKShHealing/GTests/ShapeAnalysis_FreeBounds_Test.cxx b/src/ModelingAlgorithms/TKShHealing/GTests/ShapeAnalysis_FreeBounds_Test.cxx index 6774a2a2a7..88d9481ccc 100644 --- a/src/ModelingAlgorithms/TKShHealing/GTests/ShapeAnalysis_FreeBounds_Test.cxx +++ b/src/ModelingAlgorithms/TKShHealing/GTests/ShapeAnalysis_FreeBounds_Test.cxx @@ -244,7 +244,7 @@ TEST(ShapeAnalysis_FreeBoundsTest, ConnectEdges_InternalEdgeAfterManifoldEdges) occ::handle> aResult = ShapeAnalysis_FreeBounds::ConnectEdgesToWires(anInput, Precision::Confusion(), true); - checkResult(aResult, 2, 4, 1, 0, true); + checkResult(aResult, 1, 3, 0, 0, true); } TEST(ShapeAnalysis_FreeBoundsTest, ConnectEdges_InternalEdgeBeforeManifoldEdges) @@ -260,7 +260,23 @@ TEST(ShapeAnalysis_FreeBoundsTest, ConnectEdges_InternalEdgeBeforeManifoldEdges) occ::handle> aResult = ShapeAnalysis_FreeBounds::ConnectEdgesToWires(anInput, Precision::Confusion(), true); - checkResult(aResult, 2, 4, 1, 0, true); + checkResult(aResult, 1, 3, 0, 0, true); +} + +TEST(ShapeAnalysis_FreeBoundsTest, ConnectEdges_ExternalEdgeIsSkipped) +{ + TestData aData; + ASSERT_TRUE(makeTestData(aData)); + occ::handle> anInput = + new NCollection_HSequence(); + anInput->Append(aData.Edge1); + anInput->Append(aData.Edge2); + anInput->Append(aData.Edge3); + anInput->Append(aData.ExternalEdge); + + occ::handle> aResult = + ShapeAnalysis_FreeBounds::ConnectEdgesToWires(anInput, Precision::Confusion(), true); + checkResult(aResult, 1, 3, 0, 0, true); } // Baseline: a single closed face alone does not trigger the bug (see below). diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBounds.cxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBounds.cxx index 4a3f0cfd1a..c6551761e8 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBounds.cxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBounds.cxx @@ -36,8 +36,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -137,25 +137,33 @@ occ::handle> ShapeAnalysis_FreeBounds::Conne const bool shared) { occ::handle> iwires = new NCollection_HSequence; + NCollection_LinearVector anEdgeIndices; BRep_Builder B; int i; // svv #1 for (i = 1; i <= edges->Length(); i++) { + const TopAbs_Orientation anOrientation = edges->Value(i).Orientation(); + if (anOrientation == TopAbs_INTERNAL || anOrientation == TopAbs_EXTERNAL) + { + continue; + } + TopoDS_Wire wire; B.MakeWire(wire); B.Add(wire, edges->Value(i)); iwires->Append(wire); + anEdgeIndices.Append(i); } occ::handle> wires = ConnectWiresToWires(iwires, toler, shared); - for (i = 1; i <= edges->Length(); i++) + for (i = 1; i <= iwires->Length(); i++) { if (iwires->Value(i).Orientation() == TopAbs_REVERSED) { - edges->ChangeValue(i).Reverse(); + edges->ChangeValue(anEdgeIndices[i - 1]).Reverse(); } } diff --git a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBounds.hxx b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBounds.hxx index cddc8582ee..7c47cc09d9 100644 --- a/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBounds.hxx +++ b/src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_FreeBounds.hxx @@ -110,6 +110,7 @@ public: //! at its tail. //! //! Orientation of the edge can change when connecting. + //! Edges having INTERNAL or EXTERNAL orientation are ignored. //! If is True connection is performed only when //! adjacent edges share the same vertex. //! If is False connection is performed only when