Be clearer about minimal distance magic numbers

This commit is contained in:
bgbsww
2023-12-23 06:54:43 -05:00
parent abf7fb0791
commit b8ac7f833e
5 changed files with 9 additions and 10 deletions

View File

@@ -112,8 +112,7 @@ TEST_F(FeaturePartCommonTest, testBarelyIntersecting)
_common->execute();
Part::TopoShape ts = _common->Shape.getValue();
double volume = PartTestHelpers::getVolume(ts.getShape());
double target =
Base::Precision::Confusion() * 3 * 1000; // Reduce precision to 1e04 over 3 dimensions
double target = PartTestHelpers::minimalDistance * 3; // 3 dimensions in a Volume
Base::BoundBox3d bb = ts.getBoundBox();
// Assert
@@ -123,7 +122,7 @@ TEST_F(FeaturePartCommonTest, testBarelyIntersecting)
EXPECT_FLOAT_EQ(volume, target); // Should be approximately 0.00029999999999996696
// double check using bounds:
EXPECT_DOUBLE_EQ(bb.MinX, 0.0);
EXPECT_DOUBLE_EQ(bb.MinY, 1.9999);
EXPECT_DOUBLE_EQ(bb.MinY, 2.0 - PartTestHelpers::minimalDistance);
EXPECT_DOUBLE_EQ(bb.MinZ, 0.0);
EXPECT_DOUBLE_EQ(bb.MaxX, 1.0);
EXPECT_DOUBLE_EQ(bb.MaxY, 2.0);

View File

@@ -129,8 +129,7 @@ TEST_F(FeaturePartCutTest, testBarelyIntersecting)
_cut->execute();
Part::TopoShape ts = _cut->Shape.getValue();
double volume = PartTestHelpers::getVolume(ts.getShape());
double target =
6 - Base::Precision::Confusion() * 3 * 1000; // Reduce precision to 1e04 over 3 dimensions
double target = 6 - PartTestHelpers::minimalDistance * 3; // 3 dimensions in a Volume
Base::BoundBox3d bb = ts.getBoundBox();
// Assert
@@ -143,7 +142,7 @@ TEST_F(FeaturePartCutTest, testBarelyIntersecting)
EXPECT_DOUBLE_EQ(bb.MinY, 0.0);
EXPECT_DOUBLE_EQ(bb.MinZ, 0.0);
EXPECT_DOUBLE_EQ(bb.MaxX, 1.0);
EXPECT_DOUBLE_EQ(bb.MaxY, 1.9999);
EXPECT_DOUBLE_EQ(bb.MaxY, 2.0 - PartTestHelpers::minimalDistance);
EXPECT_DOUBLE_EQ(bb.MaxZ, 3.0);
}

View File

@@ -130,8 +130,7 @@ TEST_F(FeaturePartFuseTest, testBarelyIntersecting)
_fuse->execute();
Part::TopoShape ts = _fuse->Shape.getValue();
double volume = PartTestHelpers::getVolume(ts.getShape());
double target =
12 - Base::Precision::Confusion() * 3 * 1000; // Reduce precision to 1e04 over 3 dimensions
double target = 12 - PartTestHelpers::minimalDistance * 3; // 3 dimensions in a Volume
Base::BoundBox3d bb = ts.getBoundBox();
// Assert
@@ -144,7 +143,7 @@ TEST_F(FeaturePartFuseTest, testBarelyIntersecting)
EXPECT_DOUBLE_EQ(bb.MinY, 0.0);
EXPECT_DOUBLE_EQ(bb.MinZ, 0.0);
EXPECT_DOUBLE_EQ(bb.MaxX, 1.0);
EXPECT_DOUBLE_EQ(bb.MaxY, 3.9999);
EXPECT_DOUBLE_EQ(bb.MaxY, 4.0 - PartTestHelpers::minimalDistance);
EXPECT_DOUBLE_EQ(bb.MaxZ, 3.0);
}

View File

@@ -22,7 +22,7 @@ void PartTestHelperClass::createTestDoc()
Base::Vector3d(0, 2, 0), // Touch the first box
Base::Vector3d(0, 2 + Base::Precision::Confusion(), 0), // Just Outside of touching
// For just inside of touching, go enough that precision rounding doesn't make us overlap.
Base::Vector3d(0, 2 - Base::Precision::Confusion() * 1000, 0)};
Base::Vector3d(0, 2 - minimalDistance, 0)};
// for (auto& [box, origin] : zip(_boxes, box_origins) ) {
// for ( int i : range(0,_boxes.size())) {

View File

@@ -20,4 +20,6 @@ public:
void createTestDoc();
};
const double minimalDistance = Base::Precision::Confusion() * 1000;
} // namespace PartTestHelpers