diff --git a/src/test/test_data.hpp b/src/test/test_data.hpp index de7dbcf64..9edd37629 100644 --- a/src/test/test_data.hpp +++ b/src/test/test_data.hpp @@ -1,6 +1,7 @@ #ifndef SLIC3R_TEST_DATA_HPP #include "Point.hpp" #include "TriangleMesh.hpp" +#include "Geometry.hpp" namespace Slic3r { namespace Test { @@ -24,12 +25,16 @@ enum class TestMesh { two_hollow_squares }; -/// Port of Slic3r::Test::Mesh -/// Basic cubes/boxes should call TriangleMesh::make_cube() directly and rescale it +/// Port of Slic3r::Test::mesh +/// Basic cubes/boxes should call TriangleMesh::make_cube() directly and rescale/translate it TriangleMesh mesh(TestMesh m); TriangleMesh mesh(TestMesh m, Pointf3 translate, Pointf3 scale = Pointf3(1.0, 1.0, 1.0)); +/// Templated function to see if two values are equivalent (+/- epsilon) +template +bool _equiv(T a, U b) { return abs(a - b) < Slic3r::Geometry::epsilon; } + } } // namespace Slic3r::Test #endif // SLIC3R_TEST_DATA_HPP diff --git a/xs/src/libslic3r/Geometry.hpp b/xs/src/libslic3r/Geometry.hpp index 7a4c304f4..a64fdcd5d 100644 --- a/xs/src/libslic3r/Geometry.hpp +++ b/xs/src/libslic3r/Geometry.hpp @@ -25,6 +25,10 @@ double rad2deg(double angle); double rad2deg_dir(double angle); double deg2rad(double angle); +/// Epsilon value +constexpr double epsilon { 1e-4 }; +constexpr coord_t scaled_epsilon { static_cast(epsilon / SCALING_FACTOR) }; + double linint(double value, double oldmin, double oldmax, double newmin, double newmax); bool arrange( // input