Testing for makeElementEvolve

This commit is contained in:
bgbsww
2024-02-23 17:36:11 -05:00
committed by Chris Hennes
parent 110f3e000d
commit 68fd2934cf
5 changed files with 128 additions and 51 deletions

View File

@@ -201,7 +201,7 @@ TEST_F(PartFeaturesTest, testReverse)
EXPECT_EQ(originalFaces[3].getShape().Orientation(), TopAbs_FORWARD);
EXPECT_EQ(originalFaces[4].getShape().Orientation(), TopAbs_REVERSED);
EXPECT_EQ(originalFaces[5].getShape().Orientation(), TopAbs_FORWARD);
EXPECT_DOUBLE_EQ(volume, -6.0);
EXPECT_DOUBLE_EQ(volume, 6.0);
EXPECT_DOUBLE_EQ(area, 22.0);
EXPECT_TRUE(PartTestHelpers::boxesMatch(bb, Base::BoundBox3d(0, 0, 0, 1, 2, 3)));
// Assert element map is correct

View File

@@ -12,21 +12,21 @@ double getVolume(const TopoDS_Shape& shape)
{
GProp_GProps prop;
BRepGProp::VolumeProperties(shape, prop);
return prop.Mass();
return abs(prop.Mass());
}
double getArea(const TopoDS_Shape& shape)
{
GProp_GProps prop;
BRepGProp::SurfaceProperties(shape, prop);
return prop.Mass();
return abs(prop.Mass());
}
double getLength(const TopoDS_Shape& shape)
{
GProp_GProps prop;
BRepGProp::LinearProperties(shape, prop);
return prop.Mass();
return abs(prop.Mass());
}

View File

@@ -12,9 +12,11 @@
#include <BRepAdaptor_Surface.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_Transform.hxx>
#include <BRepFeat_SplitShape.hxx>
#include <BRepOffsetAPI_MakeEvolved.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <GeomAPI_PointsToBSpline.hxx>
@@ -2346,4 +2348,37 @@ TEST_F(TopoShapeExpansionTest, removeElementShape)
}));
}
TEST_F(TopoShapeExpansionTest, makeElementEvolve)
{
BRepBuilderAPI_MakePolygon polygon(gp_Pnt(0.0, 0.0, 0.0),
gp_Pnt(200.0, 0.0, 0.0),
gp_Pnt(200.0, 200.0, 0.0),
gp_Pnt(0.0, 200.0, 0.0));
polygon.Close();
TopoShape spine {polygon.Wire(), 1L};
// Alternative:
// auto face {BRepBuilderAPI_MakeFace(polygon.Wire()).Face()};
// TopoShape spine {face, 11L};
BRepBuilderAPI_MakePolygon polygon2(gp_Pnt(0.0, 0.0, 0.0), gp_Pnt(-60.0, -60.0, -200.0));
TopoShape profile {polygon2.Wire(), 2L};
// Alternative:
// TopoShape profile {
// BRepBuilderAPI_MakeEdge(gp_Pnt(0.0, 0.0, 0.0), gp_Pnt(-60.0, -60.0, -200.0)).Edge(),
// 10L};
// Act
TopoShape topoShape {3L};
auto& result = topoShape.makeElementEvolve(spine, profile);
Base::BoundBox3d bb = result.getBoundBox();
// Assert shape is correct
EXPECT_TRUE(
PartTestHelpers::boxesMatch(bb, Base::BoundBox3d(-60.0, -60.0, -200.0, 260.0, 260.0, 0)));
EXPECT_FLOAT_EQ(getVolume(result.getShape()), 8910324);
// Assert elementMap is correct
EXPECT_EQ(topoShape.getElementMap().size(), 0);
// Neither the Spine nor the Profile have an elementMap, because they are simple wires or faces.
// The resulting Evolved also does not populate the elementMap, but that might be a bug in
// underutilized code.
EXPECT_EQ(spine.getElementMap().size(), 0);
}
// NOLINTEND(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers)