From 55455ec8040e5c48b3f62a077e9d2f74beae1d96 Mon Sep 17 00:00:00 2001 From: CalligaroV Date: Wed, 7 Feb 2024 15:10:58 +0100 Subject: [PATCH] Part/Toponaming: makeElementWires * Added test for MapperMaker::modified Signed-off-by: CalligaroV --- tests/src/Mod/Part/App/TopoShapeExpansion.cpp | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tests/src/Mod/Part/App/TopoShapeExpansion.cpp b/tests/src/Mod/Part/App/TopoShapeExpansion.cpp index 0ba897a78a..5b936354d8 100644 --- a/tests/src/Mod/Part/App/TopoShapeExpansion.cpp +++ b/tests/src/Mod/Part/App/TopoShapeExpansion.cpp @@ -9,6 +9,8 @@ #include #include +#include +#include #include #include #include @@ -152,6 +154,63 @@ TEST_F(TopoShapeExpansionTest, makeElementCompoundTwoCubes) // 26 subshapes each } +TEST_F(TopoShapeExpansionTest, MapperMakerModified) +{ + // Arrange + // Definition of all the objects needed for a Transformation + // (https://dev.opencascade.org/doc/refman/html/class_b_rep_builder_a_p_i___transform.html) + auto translation {gp_Trsf()}; + auto transform {BRepBuilderAPI_Transform(translation)}; + auto transformMprMkr {MapperMaker(transform)}; + + // Definition of all the objects needed for a Shape Splitting + // (https://dev.opencascade.org/doc/refman/html/class_b_rep_feat___split_shape.html) + auto split {BRepFeat_SplitShape()}; + auto splitMprMkr {MapperMaker(split)}; + + // Creating a Wire, used later to create a Face + auto wireMkr {BRepBuilderAPI_MakeWire( + BRepBuilderAPI_MakeEdge(gp_Pnt(0.0, 0.0, 0.0), gp_Pnt(1.0, 0.0, 0.0)), + BRepBuilderAPI_MakeEdge(gp_Pnt(1.0, 0.0, 0.0), gp_Pnt(1.0, 1.0, 0.0)), + BRepBuilderAPI_MakeEdge(gp_Pnt(1.0, 1.0, 0.0), gp_Pnt(0.0, 0.0, 0.0)))}; + auto wire = wireMkr.Wire(); + + // Creating a Face using the Wire created before + auto faceMkr {BRepBuilderAPI_MakeFace(wire)}; + auto face = faceMkr.Face(); + + // Creating an Edge to split the Face and the Wire + auto edgeMkr {BRepBuilderAPI_MakeEdge(gp_Pnt(0.5, 1.0, 0.0), gp_Pnt(0.5, -1.0, 0.0))}; + auto edge = edgeMkr.Edge(); + + // Act + // Performing the Transformation + translation.SetTranslation(gp_Pnt(0.0, 0.0, 0.0), gp_Pnt(1.0, 0.0, 0.0)); + transform.Perform(wire); + + // Initializing and performing the Split + split.Init(face); + split.Add(edge, face); + split.Build(); + + // Assert + // Check that all the shapes and operations have been performed + EXPECT_TRUE(wireMkr.IsDone()); + EXPECT_TRUE(faceMkr.IsDone()); + EXPECT_TRUE(edgeMkr.IsDone()); + EXPECT_TRUE(split.IsDone()); + EXPECT_TRUE(transform.IsDone()); + + // Check the result of the operations + EXPECT_EQ(transformMprMkr.modified(wire).size(), 1); // The Transformation acts on the Wire... + EXPECT_EQ(transformMprMkr.modified(face).size(), 1); // ... and therefor on the created Face... + EXPECT_EQ(transformMprMkr.modified(edge).size(), 1); // ... and on the Edge added to the Face + + EXPECT_EQ(splitMprMkr.modified(edge).size(), 0); // The Split doesn't modify the Edge + EXPECT_EQ(splitMprMkr.modified(wire).size(), 2); // The Split modifies the Wire into 2 Wires + EXPECT_EQ(splitMprMkr.modified(face).size(), 2); // The Split modifies the Face into 2 Faces +} + TEST_F(TopoShapeExpansionTest, makeElementWiresCombinesAdjacent) { // Arrange