Part/Toponaming: Refactor makeElementCompound

Refactor to address linter issues, breaking up large methods, renaming variables, etc.
This commit is contained in:
Chris Hennes
2024-01-11 15:15:30 -06:00
committed by Yorik van Havre
parent 60a7f45ece
commit ed6230093f
4 changed files with 352 additions and 154 deletions

View File

@@ -4,7 +4,9 @@
#include "src/App/InitApplication.h"
#include <Mod/Part/App/TopoShape.h>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <TopoDS_Edge.hxx>
#include <BRep_Builder.hxx>
@@ -115,4 +117,48 @@ TEST_F(TopoShapeExpansionTest, makeElementCompoundTwoShapesGeneratesMap)
EXPECT_EQ(4, topoShape.getMappedChildElements().size()); // two vertices and two edges
}
namespace
{
std::pair<TopoDS_Shape, TopoDS_Shape> CreateTwoCubes()
{
auto boxMaker1 = BRepPrimAPI_MakeBox(1.0, 1.0, 1.0);
boxMaker1.Build();
auto box1 = boxMaker1.Shape();
auto boxMaker2 = BRepPrimAPI_MakeBox(1.0, 1.0, 1.0);
boxMaker2.Build();
auto box2 = boxMaker2.Shape();
auto transform = gp_Trsf();
transform.SetTranslation(gp_Pnt(0.0, 0.0, 0.0), gp_Pnt(1.0, 0.0, 0.0));
box2.Location(TopLoc_Location(transform));
return {box1, box2};
}
} // namespace
TEST_F(TopoShapeExpansionTest, makeElementCompoundTwoCubes)
{
// Arrange
auto [cube1, cube2] = CreateTwoCubes();
Part::TopoShape cube1TS {cube1};
cube1TS.Tag = 1;
Part::TopoShape cube2TS {cube2};
cube2TS.Tag = 2;
// Act
Part::TopoShape topoShape;
topoShape.makeElementCompound({cube1TS, cube2TS});
// Assert
auto elementMap = topoShape.getElementMap();
EXPECT_EQ(52, elementMap.size());
// Two cubes, each consisting of:
// 8 Vertices
// 12 Edges
// 6 Faces
// ----------
// 26 subshapes each
}
// NOLINTEND(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers)