test_data.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. cube_2x20x10,
  20. sphere_50mm,
  21. bridge,
  22. bridge_with_hole,
  23. cube_with_concave_hole,
  24. cube_with_hole,
  25. gt2_teeth,
  26. ipadstand,
  27. overhang,
  28. pyramid,
  29. sloping_hole,
  30. slopy_cube,
  31. small_dorito,
  32. step,
  33. two_hollow_squares
  34. };
  35. // Neccessary for <c++17
  36. struct TestMeshHash {
  37. std::size_t operator()(TestMesh tm) const {
  38. return static_cast<std::size_t>(tm);
  39. }
  40. };
  41. /// Mesh enumeration to name mapping
  42. extern const std::unordered_map<TestMesh, const char*, TestMeshHash> mesh_names;
  43. /// Port of Slic3r::Test::mesh
  44. /// Basic cubes/boxes should call TriangleMesh::make_cube() directly and rescale/translate it
  45. TriangleMesh mesh(TestMesh m);
  46. TriangleMesh mesh(TestMesh m, Vec3d translate, Vec3d scale = Vec3d(1.0, 1.0, 1.0));
  47. TriangleMesh mesh(TestMesh m, Vec3d translate, double scale = 1.0);
  48. /// Templated function to see if two values are equivalent (+/- epsilon)
  49. template <typename T>
  50. bool _equiv(const T& a, const T& b) { return std::abs(a - b) < EPSILON; }
  51. template <typename T>
  52. bool _equiv(const T& a, const T& b, double epsilon) { return abs(a - b) < epsilon; }
  53. Slic3r::Model model(const std::string& model_name, TriangleMesh&& _mesh);
  54. void init_print(std::vector<TriangleMesh> &&meshes, Slic3r::Print &print, Slic3r::Model& model, const DynamicPrintConfig &config_in, bool comments = false);
  55. 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);
  56. 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);
  57. 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);
  58. 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);
  59. void init_and_process_print(std::initializer_list<TestMesh> meshes, Slic3r::Print &print, const DynamicPrintConfig& config, bool comments = false);
  60. void init_and_process_print(std::initializer_list<TriangleMesh> meshes, Slic3r::Print &print, const DynamicPrintConfig& config, bool comments = false);
  61. void init_and_process_print(std::initializer_list<TestMesh> meshes, Slic3r::Print &print, std::initializer_list<Slic3r::ConfigBase::SetDeserializeItem> config_items, bool comments = false);
  62. void init_and_process_print(std::initializer_list<TriangleMesh> meshes, Slic3r::Print &print, std::initializer_list<Slic3r::ConfigBase::SetDeserializeItem> config_items, bool comments = false);
  63. std::string gcode(Print& print);
  64. std::string slice(std::initializer_list<TestMesh> meshes, const DynamicPrintConfig &config, bool comments = false);
  65. std::string slice(std::initializer_list<TriangleMesh> meshes, const DynamicPrintConfig &config, bool comments = false);
  66. std::string slice(std::initializer_list<TestMesh> meshes, std::initializer_list<Slic3r::ConfigBase::SetDeserializeItem> config_items, bool comments = false);
  67. std::string slice(std::initializer_list<TriangleMesh> meshes, std::initializer_list<Slic3r::ConfigBase::SetDeserializeItem> config_items, bool comments = false);
  68. bool contains(const std::string &data, const std::string &pattern);
  69. bool contains_regex(const std::string &data, const std::string &pattern);
  70. } } // namespace Slic3r::Test
  71. #endif // SLIC3R_TEST_DATA_HPP