CutUtils.hpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ///|/ Copyright (c) Prusa Research 2023 Oleksandra Iushchenko @YuSanka
  2. ///|/
  3. ///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
  4. ///|/
  5. #ifndef slic3r_CutUtils_hpp_
  6. #define slic3r_CutUtils_hpp_
  7. #include "enum_bitmask.hpp"
  8. #include "Point.hpp"
  9. #include "Model.hpp"
  10. #include <vector>
  11. namespace Slic3r {
  12. using ModelObjectPtrs = std::vector<ModelObject*>;
  13. enum class ModelObjectCutAttribute : int { KeepUpper, KeepLower, KeepAsParts, FlipUpper, FlipLower, PlaceOnCutUpper, PlaceOnCutLower, CreateDowels, InvalidateCutInfo };
  14. using ModelObjectCutAttributes = enum_bitmask<ModelObjectCutAttribute>;
  15. ENABLE_ENUM_BITMASK_OPERATORS(ModelObjectCutAttribute);
  16. class Cut {
  17. Model m_model;
  18. int m_instance;
  19. const Transform3d m_cut_matrix;
  20. ModelObjectCutAttributes m_attributes;
  21. void post_process(ModelObject* object, ModelObjectPtrs& objects, bool keep, bool place_on_cut, bool flip);
  22. void post_process(ModelObject* upper_object, ModelObject* lower_object, ModelObjectPtrs& objects);
  23. void finalize(const ModelObjectPtrs& objects);
  24. public:
  25. Cut(const ModelObject* object, int instance, const Transform3d& cut_matrix,
  26. ModelObjectCutAttributes attributes = ModelObjectCutAttribute::KeepUpper |
  27. ModelObjectCutAttribute::KeepLower |
  28. ModelObjectCutAttribute::KeepAsParts );
  29. ~Cut() { m_model.clear_objects(); }
  30. struct Groove
  31. {
  32. float depth{ 0.f };
  33. float width{ 0.f };
  34. float flaps_angle{ 0.f };
  35. float angle{ 0.f };
  36. float depth_init{ 0.f };
  37. float width_init{ 0.f };
  38. float flaps_angle_init{ 0.f };
  39. float angle_init{ 0.f };
  40. float depth_tolerance{ 0.1f };
  41. float width_tolerance{ 0.1f };
  42. };
  43. struct Part
  44. {
  45. bool selected;
  46. bool is_modifier;
  47. };
  48. const ModelObjectPtrs& perform_with_plane();
  49. const ModelObjectPtrs& perform_by_contour(std::vector<Part> parts, int dowels_count);
  50. const ModelObjectPtrs& perform_with_groove(const Groove& groove, const Transform3d& rotation_m, bool keep_as_parts = false);
  51. }; // namespace Cut
  52. } // namespace Slic3r
  53. #endif /* slic3r_CutUtils_hpp_ */