Added epsilon to Slic3r::Geometry; added _equiv for comparing two items that have operator- overloaded.

This commit is contained in:
Joseph Lenox 2018-07-13 19:36:01 -05:00
parent f29768ff8e
commit 3f3de067f8
2 changed files with 11 additions and 2 deletions

View File

@ -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 <typename T, typename U>
bool _equiv(T a, U b) { return abs(a - b) < Slic3r::Geometry::epsilon; }
} } // namespace Slic3r::Test
#endif // SLIC3R_TEST_DATA_HPP

View File

@ -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<coord_t>(epsilon / SCALING_FACTOR) };
double linint(double value, double oldmin, double oldmax, double newmin, double newmax);
bool arrange(
// input