| | |
| |
|
| | #include <gtest/gtest.h> |
| |
|
| | #include <src/App/InitApplication.h> |
| |
|
| | #include "PartTestHelpers.h" |
| | #include "Mod/Part/App/FeatureOffset.h" |
| |
|
| | using namespace PartTestHelpers; |
| |
|
| | |
| | class FeatureOffsetTest: public ::testing::Test, public PartTestHelperClass |
| | { |
| | protected: |
| | static void SetUpTestSuite() |
| | { |
| | tests::initApplication(); |
| | } |
| |
|
| | void SetUp() override |
| | { |
| | createTestDoc(); |
| | _offset = _doc->addObject<Part::Offset>(); |
| | _offset->Source.setValue(_boxes[0]); |
| | _offset->Value.setValue(1); |
| | _offset->Join.setValue((int)JoinType::intersection); |
| | _offset->execute(); |
| | } |
| |
|
| | void TearDown() override |
| | {} |
| |
|
| | Part::Offset* _offset = nullptr; |
| | }; |
| |
|
| | TEST_F(FeatureOffsetTest, testOffset3D) |
| | { |
| | |
| | Base::BoundBox3d bb = _offset->Shape.getShape().getBoundBox(); |
| | |
| | |
| | EXPECT_EQ(getVolume(_offset->Shape.getShape().getShape()), 60); |
| | EXPECT_TRUE(boxesMatch(bb, Base::BoundBox3d(-1, -1, -1, 2, 3, 4))); |
| | |
| | EXPECT_EQ(_offset->Shape.getShape().countSubElements("Vertex"), 8); |
| | EXPECT_EQ(_offset->Shape.getShape().countSubElements("Edge"), 12); |
| | EXPECT_EQ(_offset->Shape.getShape().countSubElements("Face"), 6); |
| | } |
| |
|
| | TEST_F(FeatureOffsetTest, testOffset3DWithExistingElementMap) |
| | { |
| | |
| | Part::Fuse* _fuse = nullptr; |
| | _fuse = _doc->addObject<Part::Fuse>(); |
| | _fuse->Base.setValue(_boxes[0]); |
| | _fuse->Tool.setValue(_boxes[1]); |
| | _fuse->Refine.setValue(true); |
| | |
| | _fuse->execute(); |
| | _offset->Source.setValue(_fuse); |
| | _offset->Value.setValue(2); |
| | _offset->execute(); |
| | Base::BoundBox3d bb = _offset->Shape.getShape().getBoundBox(); |
| | |
| | |
| | EXPECT_EQ(getVolume(_fuse->Shape.getShape().getShape()), 9); |
| | EXPECT_EQ(getVolume(_offset->Shape.getShape().getShape()), 245); |
| | EXPECT_TRUE(boxesMatch(bb, Base::BoundBox3d(-2, -2, -2, 3, 5, 5))); |
| | |
| | EXPECT_EQ(_offset->Shape.getShape().countSubElements("Vertex"), 8); |
| | EXPECT_EQ(_offset->Shape.getShape().countSubElements("Edge"), 12); |
| | EXPECT_EQ(_offset->Shape.getShape().countSubElements("Face"), 6); |
| | } |
| |
|
| | TEST_F(FeatureOffsetTest, testOffset2D) |
| | { |
| | |
| | Part::Offset2D* _offset2 = _doc->addObject<Part::Offset2D>(); |
| | Part::Plane* _pln = _doc->addObject<Part::Plane>(); |
| | _pln->Length.setValue(2); |
| | _pln->Width.setValue(3); |
| | _offset2->Source.setValue(_pln); |
| | _offset2->Value.setValue(1); |
| | _offset2->Join.setValue((int)JoinType::intersection); |
| | |
| | _offset2->execute(); |
| | Base::BoundBox3d bb = _offset2->Shape.getShape().getBoundBox(); |
| | |
| | |
| | EXPECT_EQ(getArea(_offset2->Shape.getShape().getShape()), 20); |
| | EXPECT_TRUE(boxesMatch(bb, Base::BoundBox3d(-1, -1, 0, 3, 4, 0))); |
| | |
| | EXPECT_EQ(_offset2->Shape.getShape().getElementMapSize(), 9); |
| | } |
| |
|
| | |
| |
|