Part/Toponaming: Transfer WireJoiner
* Added test for WireJoiner::getOpenWires() Signed-off-by: CalligaroV <vincenzo.calligaro@gmail.com>
This commit is contained in:
@@ -588,4 +588,109 @@ TEST_F(WireJoinerTest, setTolerance)
|
||||
EXPECT_EQ(wireatol.getSubTopoShapes(TopAbs_EDGE).size(), 0);
|
||||
}
|
||||
|
||||
TEST_F(WireJoinerTest, getOpenWires)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
// Create various edges that will be used for the WireJoiner objects tests
|
||||
|
||||
auto edge1 {BRepBuilderAPI_MakeEdge(gp_Pnt(0.0, 0.0, 0.0), gp_Pnt(1.0, 0.0, 0.0)).Edge()};
|
||||
auto edge2 {BRepBuilderAPI_MakeEdge(gp_Pnt(1.0, 0.0, 0.0), gp_Pnt(1.0, 1.0, 0.0)).Edge()};
|
||||
auto edge3 {BRepBuilderAPI_MakeEdge(gp_Pnt(1.0, 1.0, 0.0), gp_Pnt(0.0, 0.0, 0.0)).Edge()};
|
||||
auto edge4 {BRepBuilderAPI_MakeEdge(gp_Pnt(0.5, 0.5, 0.0), gp_Pnt(1.5, 1.5, 0.0)).Edge()};
|
||||
|
||||
// A vector of edges used as argument for wjNoOpenWires.addShape()
|
||||
std::vector<TopoDS_Shape> edgesNoOpenWires {edge1, edge2, edge3};
|
||||
// A vector of edges used as argument for wjOriginal.addShape()
|
||||
std::vector<TopoDS_Shape> edgesOriginal {edge1, edge2, edge4};
|
||||
// A vector of edges used as argument for wjNoOriginal.addShape()
|
||||
std::vector<TopoDS_Shape> edgesNoOriginal {edge1, edge2, edge4};
|
||||
// A vector of TopoShape edges used as argument for wjNoOp.addShape(). A Tag is needed for every
|
||||
// TopoShape, otherwise no element map will be created and no op can be found
|
||||
std::vector<TopoShape> edgesNoOp {TopoShape(edge2, 6), TopoShape(edge4, 7)};
|
||||
// A vector of TopoShape edges used as argument for wjOp.addShape(). A Tag is needed for every
|
||||
// TopoShape, otherwise no element map will be created and no op can be found
|
||||
std::vector<TopoShape> edgesOp {TopoShape(edge2, 8), TopoShape(edge4, 9)};
|
||||
|
||||
// A WireJoiner object that will create a closed wire and no open wires
|
||||
auto wjNoOpenWires {WireJoiner()};
|
||||
|
||||
// A WireJoiner object where the argument noOriginal will be set to false and that will create
|
||||
// an open wire
|
||||
auto wjOriginal {WireJoiner()};
|
||||
// A WireJoiner object where the argument noOriginal will be set to true and that will create an
|
||||
// open wire
|
||||
auto wjNoOriginal {WireJoiner()};
|
||||
|
||||
// A WireJoiner object where the argument op won't be set and that will create an open wire
|
||||
auto wjNoOp {WireJoiner()};
|
||||
// A WireJoiner object where the argument op will be set and that will create an open wire
|
||||
auto wjOp {WireJoiner()};
|
||||
|
||||
// An empty TopoShape that will contain the shapes returned by wjNoOpenWires.getOpenWires()
|
||||
auto wireNoOpenWires {TopoShape(1)};
|
||||
|
||||
// An empty TopoShape that will contain the shapes returned by wjOriginal.getOpenWires()
|
||||
auto wireOriginal {TopoShape(2)};
|
||||
// An empty TopoShape that will contain the shapes returned by wjNoOriginal.getOpenWires()
|
||||
auto wireNoOriginal {TopoShape(3)};
|
||||
|
||||
// An empty TopoShape that will contain the shapes returned by wjNoOp.getOpenWires()
|
||||
auto wireNoOp {TopoShape(4)};
|
||||
// An empty TopoShape that will contain the shapes returned by wjOp.getOpenWires()
|
||||
auto wireOp {TopoShape(5)};
|
||||
|
||||
// Act
|
||||
|
||||
wjNoOpenWires.addShape(edgesNoOpenWires);
|
||||
// wjNoOpenWires.Build() is called by wjNoOpenWires.getOpenWires()
|
||||
wjNoOpenWires.getOpenWires(wireNoOpenWires);
|
||||
|
||||
wjOriginal.addShape(edgesOriginal);
|
||||
// wjOriginal.Build() is called by wjOriginal.getOpenWires()
|
||||
wjOriginal.getOpenWires(wireOriginal, nullptr, false);
|
||||
|
||||
wjNoOriginal.addShape(edgesNoOriginal);
|
||||
// wjNoOriginal.Build() is called by wjNoOriginal.getOpenWires()
|
||||
wjNoOriginal.getOpenWires(wireNoOriginal);
|
||||
|
||||
wjNoOp.addShape(edgesNoOp);
|
||||
// wjNoOp.Build() is called by wjNoOp.getOpenWires()
|
||||
wjNoOp.getOpenWires(wireNoOp, nullptr, false);
|
||||
|
||||
wjOp.addShape(edgesOp);
|
||||
// wjOp.Build() is called by wjOp.getOpenWires()
|
||||
wjOp.getOpenWires(wireOp, "getOpenWires", false);
|
||||
|
||||
// Assert
|
||||
|
||||
// All the edges added with wjNoOpenWires.addShape() are used to create a closed wire, therefor
|
||||
// wireNoOpenWires should be null
|
||||
EXPECT_TRUE(wireNoOpenWires.isNull());
|
||||
|
||||
// In this case wireOriginal should contain all the edges added with wjOriginal.addShape(),
|
||||
// except those ones that are split, and all the edges generated by splitting an edge with
|
||||
// another one.
|
||||
// edge1 and edge2 are left untouched, while edge4 is split in two at the intersection point
|
||||
// (1.0, 1.0, 0.0), therefor 4 edges.
|
||||
EXPECT_EQ(wireOriginal.getSubTopoShapes(TopAbs_EDGE).size(), 4);
|
||||
|
||||
// In this case wireNoOriginal should contain only the edges generated by splitting one of them
|
||||
// with another one.
|
||||
// As edge1 and edge2 are left untouched, the only edges we should find are the ones generated
|
||||
// by splitting edge4 in two at the intersection point (1.0, 1.0, 0.0)
|
||||
EXPECT_EQ(wireNoOriginal.getSubTopoShapes(TopAbs_EDGE).size(), 2);
|
||||
|
||||
// In this case, as we haven't set a value for op, WireJoiner::WireJoinerP::getOpenWires() will
|
||||
// call TopoShape::makeShapeWithElementMap() which, without a value for op, will use "MAK" as
|
||||
// value for the various element maps
|
||||
EXPECT_NE(wireNoOp.getElementMap()[0].name.find("MAK"), -1);
|
||||
|
||||
// In this case WireJoiner::WireJoinerP::getOpenWires() will call
|
||||
// TopoShape::makeShapeWithElementMap() giving "getOpenWires" as value for the op argument.
|
||||
// That value should be found in the various element maps instead of "MAK"
|
||||
EXPECT_EQ(wireOp.getElementMap()[0].name.find("MAK"), -1);
|
||||
EXPECT_NE(wireOp.getElementMap()[0].name.find("getOpenWires"), -1);
|
||||
}
|
||||
|
||||
// NOLINTEND(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers)
|
||||
|
||||
Reference in New Issue
Block a user