From c70f34b1f41c604de51b26c1ca2af46e60c92008 Mon Sep 17 00:00:00 2001 From: CalligaroV Date: Thu, 14 Mar 2024 11:27:41 +0100 Subject: [PATCH] Part/Toponaming: Transfer WireJoiner * Added test for WireJoiner::Modified() * Fixed typo in test for WireJoiner::getResultWires() Signed-off-by: CalligaroV --- tests/src/Mod/Part/App/WireJoiner.cpp | 46 ++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/tests/src/Mod/Part/App/WireJoiner.cpp b/tests/src/Mod/Part/App/WireJoiner.cpp index 2dc546f4dc..6fa98445cb 100644 --- a/tests/src/Mod/Part/App/WireJoiner.cpp +++ b/tests/src/Mod/Part/App/WireJoiner.cpp @@ -739,7 +739,7 @@ TEST_F(WireJoinerTest, getResultWires) // Act wjNoResultWires.addShape(edgesNoResultWires); - // wjNoOpenWires.Build() is called by wjNoResultWires.getResultWires() + // wjNoResultWires.Build() is called by wjNoResultWires.getResultWires() wjNoResultWires.getResultWires(wireNoResultWires); wjNoOp.addShape(edgesNoOp); @@ -809,4 +809,48 @@ TEST_F(WireJoinerTest, Build) } #endif +TEST_F(WireJoinerTest, Modified) +{ + // Arrange + + // Create various edges that will be used for the WireJoiner objects tests + + auto edge1 {BRepBuilderAPI_MakeEdge(gp_Pnt(-0.1, 0.0, 0.0), gp_Pnt(1.1, 0.0, 0.0)).Edge()}; + auto edge2 {BRepBuilderAPI_MakeEdge(gp_Pnt(1.0, -0.1, 0.0), gp_Pnt(1.0, 1.1, 0.0)).Edge()}; + auto edge3 {BRepBuilderAPI_MakeEdge(gp_Pnt(1.1, 1.1, 0.0), gp_Pnt(-0.1, -0.1, 0.0)).Edge()}; + + // A vector of edges used as argument for wjModified.addShape() + std::vector edges {edge1, edge2, edge3}; + + // A WireJoiner object that will create no closed wires + auto wjModified {WireJoiner()}; + + // Act + + wjModified.addShape(edges); + wjModified.Build(); + + // Assert + + // In this case, every edge added with wjModified.addShape() modifies other shapes 3 times + + // edge1 modifies the edges with vertexes: + // (0.0, 0.0, 0.0) - (1.0, 1.0, 0.0) + // (-0.1, -0.1, 0.0) - (0.0, 0.0, 0.0) + // (1.0, -0.1, 0.0) - (1.0, 0.0, 0.0) + EXPECT_EQ(wjModified.Modified(edge1).Size(), 3); + + // edge2 modifies the edges with vertexes: + // (1.0, 1.0, 0.0) - (1.1, 1.1, 0.0) + // (0.0, 0.0, 0.0) - (1.0, 0.0, 0.0) + // (1.0, 0.0, 0.0) - (1.1, 0.0, 0.0) + EXPECT_EQ(wjModified.Modified(edge2).Size(), 3); + + // edge3 modifies the edges with vertexes: + // (1.0, 0.0, 0.0) - (1.0, 1.0, 0.0) + // (1.0, 1.0, 0.0) - (1.0, 1.1, 0.0) + // (-0.1, 0.0, 0.0) - (0.0, 0.0, 0.0) + EXPECT_EQ(wjModified.Modified(edge3).Size(), 3); +} + // NOLINTEND(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers)