test_data.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef SLIC3R_TEST_DATA_HPP
  2. #define SLIC3R_TEST_DATA_HPP
  3. #include <libslic3r/Point.hpp>
  4. #include <libslic3r/TriangleMesh.hpp>
  5. #include <libslic3r/Geometry.hpp>
  6. #include <libslic3r/Model.hpp>
  7. #include <libslic3r/Print.hpp>
  8. #include <libslic3r/Config.hpp>
  9. #include <test_utils.hpp>
  10. #include <unordered_map>
  11. namespace Slic3r { namespace Test {
  12. /// Enumeration of test meshes
  13. enum class TestMesh {
  14. A,
  15. L,
  16. V,
  17. _40x10,
  18. cube_20x20x20,
  19. sphere_50mm,
  20. bridge,
  21. bridge_with_hole,
  22. cube_with_concave_hole,
  23. cube_with_hole,
  24. gt2_teeth,
  25. ipadstand,
  26. overhang,
  27. pyramid,
  28. sloping_hole,
  29. slopy_cube,
  30. small_dorito,
  31. step,
  32. two_hollow_squares,
  33. di_5mm_center_notch,
  34. di_10mm_notch,
  35. di_20mm_notch,
  36. di_25mm_notch
  37. };
  38. // Neccessary for <c++17
  39. struct TestMeshHash {
  40. std::size_t operator()(TestMesh tm) const {
  41. return static_cast<std::size_t>(tm);
  42. }
  43. };
  44. /// Mesh enumeration to name mapping
  45. extern const std::unordered_map<TestMesh, const std::string, TestMeshHash> mesh_names;
  46. /// Port of Slic3r::Test::mesh
  47. /// Basic cubes/boxes should call TriangleMesh::make_cube() directly and rescale/translate it
  48. TriangleMesh mesh(TestMesh m);
  49. TriangleMesh mesh(TestMesh m, Vec3f translate, Vec3f scale = Vec3f(1.0, 1.0, 1.0));
  50. TriangleMesh mesh(TestMesh m, Vec3f translate, double scale = 1.0);
  51. /// Templated function to see if two values are equivalent (+/- epsilon)
  52. template <typename T>
  53. bool _equiv(const T& a, const T& b) { return abs(a - b) < Slic3r::Geometry::epsilon; }
  54. template <typename T>
  55. bool _equiv(const T& a, const T& b, double epsilon) { return abs(a - b) < epsilon; }
  56. //Slic3r::Model model(const std::string& model_name, TestMesh m, Vec3f translate = Vec3f(0,0,0), Vec3f scale = Vec3f(1.0,1.0,1.0));
  57. //Slic3r::Model model(const std::string& model_name, TestMesh m, Vec3f translate = Vec3f(0,0,0), double scale = 1.0);
  58. Slic3r::Model model(const std::string& model_name, TriangleMesh&& _mesh);
  59. void init_print(Print& print, std::initializer_list<TestMesh> meshes, Slic3r::Model& model, DynamicPrintConfig* _config, bool comments = false);
  60. void init_print(Print& print, std::vector<TriangleMesh> meshes, Slic3r::Model& model, DynamicPrintConfig* _config, bool comments = false);
  61. void gcode(std::string& gcode, Print& print);
  62. std::string read_to_string(const std::string& name);
  63. void clean_file(const std::string& name, const std::string& ext, bool glob = false);
  64. } } // namespace Slic3r::Test
  65. #endif // SLIC3R_TEST_DATA_HPP