test_data.hpp 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef SLIC3R_TEST_DATA_HPP
  2. #define SLIC3R_TEST_DATA_HPP
  3. #include "libslic3r/Config.hpp"
  4. #include "libslic3r/Geometry.hpp"
  5. #include "libslic3r/Model.hpp"
  6. #include "libslic3r/Point.hpp"
  7. #include "libslic3r/Print.hpp"
  8. #include "libslic3r/TriangleMesh.hpp"
  9. #include <unordered_map>
  10. namespace Slic3r { namespace Test {
  11. constexpr double MM_PER_MIN = 60.0;
  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. };
  34. // Neccessary for <c++17
  35. struct TestMeshHash {
  36. std::size_t operator()(TestMesh tm) const {
  37. return static_cast<std::size_t>(tm);
  38. }
  39. };
  40. /// Mesh enumeration to name mapping
  41. extern const std::unordered_map<TestMesh, const char*, TestMeshHash> mesh_names;
  42. /// Port of Slic3r::Test::mesh
  43. /// Basic cubes/boxes should call TriangleMesh::make_cube() directly and rescale/translate it
  44. TriangleMesh mesh(TestMesh m);
  45. TriangleMesh mesh(TestMesh m, Vec3d translate, Vec3d scale = Vec3d(1.0, 1.0, 1.0));
  46. TriangleMesh mesh(TestMesh m, Vec3d translate, double scale = 1.0);
  47. /// Templated function to see if two values are equivalent (+/- epsilon)
  48. template <typename T>
  49. bool _equiv(const T& a, const T& b) { return std::abs(a - b) < EPSILON; }
  50. template <typename T>
  51. bool _equiv(const T& a, const T& b, double epsilon) { return abs(a - b) < epsilon; }
  52. Slic3r::Model model(const std::string& model_name, TriangleMesh&& _mesh);
  53. void init_print(std::vector<TriangleMesh> &&meshes, Slic3r::Print &print, Slic3r::Model& model, const DynamicPrintConfig &config_in, bool comments = false);
  54. void init_print(std::initializer_list<TestMesh> meshes, Slic3r::Print &print, Slic3r::Model& model, const Slic3r::DynamicPrintConfig &config_in = Slic3r::DynamicPrintConfig::full_print_config(), bool comments = false);
  55. void init_print(std::initializer_list<TriangleMesh> meshes, Slic3r::Print &print, Slic3r::Model& model, const Slic3r::DynamicPrintConfig &config_in = Slic3r::DynamicPrintConfig::full_print_config(), bool comments = false);
  56. void init_print(std::initializer_list<TestMesh> meshes, Slic3r::Print &print, Slic3r::Model& model, std::initializer_list<Slic3r::ConfigBase::SetDeserializeItem> config_items, bool comments = false);
  57. void init_print(std::initializer_list<TriangleMesh> meshes, Slic3r::Print &print, Slic3r::Model& model, std::initializer_list<Slic3r::ConfigBase::SetDeserializeItem> config_items, bool comments = false);
  58. void init_and_process_print(std::initializer_list<TestMesh> meshes, Slic3r::Print &print, const DynamicPrintConfig& config, bool comments = false);
  59. void init_and_process_print(std::initializer_list<TriangleMesh> meshes, Slic3r::Print &print, const DynamicPrintConfig& config, bool comments = false);
  60. void init_and_process_print(std::initializer_list<TestMesh> meshes, Slic3r::Print &print, std::initializer_list<Slic3r::ConfigBase::SetDeserializeItem> config_items, bool comments = false);
  61. void init_and_process_print(std::initializer_list<TriangleMesh> meshes, Slic3r::Print &print, std::initializer_list<Slic3r::ConfigBase::SetDeserializeItem> config_items, bool comments = false);
  62. std::string gcode(Print& print);
  63. std::string slice(std::initializer_list<TestMesh> meshes, const DynamicPrintConfig &config, bool comments = false);
  64. std::string slice(std::initializer_list<TriangleMesh> meshes, const DynamicPrintConfig &config, bool comments = false);
  65. std::string slice(std::initializer_list<TestMesh> meshes, std::initializer_list<Slic3r::ConfigBase::SetDeserializeItem> config_items, bool comments = false);
  66. std::string slice(std::initializer_list<TriangleMesh> meshes, std::initializer_list<Slic3r::ConfigBase::SetDeserializeItem> config_items, bool comments = false);
  67. } } // namespace Slic3r::Test
  68. #endif // SLIC3R_TEST_DATA_HPP