From d805c8ac3bcaa3310b2c3542da061657a192c3b3 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 18 Jul 2018 14:26:42 +0200 Subject: Disable slicing when one object crosses the print volume boundary --- xs/src/libslic3r/Model.hpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'xs/src/libslic3r/Model.hpp') diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp index 08ba8487d..f5e97fb6a 100644 --- a/xs/src/libslic3r/Model.hpp +++ b/xs/src/libslic3r/Model.hpp @@ -131,7 +131,8 @@ public: bool needed_repair() const; void cut(coordf_t z, Model* model) const; void split(ModelObjectPtrs* new_objects); - void check_instances_printability(const BoundingBoxf3& print_volume); + + void check_instances_print_volume_state(const BoundingBoxf3& print_volume); // Print object statistics to console. void print_info() const; @@ -198,14 +199,23 @@ private: // Knows the affine transformation of an object. class ModelInstance { - friend class ModelObject; public: + enum EPrintVolumeState : unsigned char + { + PVS_Inside, + PVS_Partly_Outside, + PVS_Fully_Outside, + Num_BedStates + }; + + friend class ModelObject; + double rotation; // Rotation around the Z axis, in radians around mesh center point double scaling_factor; Pointf offset; // in unscaled coordinates - // whether or not this instance is contained in the print volume (set by Print::validate() using ModelObject::check_instances_printability()) - bool is_printable; + // flag showing the position of this instance with respect to the print volume (set by Print::validate() using ModelObject::check_instances_print_volume_state()) + EPrintVolumeState print_volume_state; ModelObject* get_object() const { return this->object; } @@ -217,14 +227,16 @@ public: BoundingBoxf3 transform_bounding_box(const BoundingBoxf3 &bbox, bool dont_translate = false) const; // To be called on an external polygon. It does not translate the polygon, only rotates and scales. void transform_polygon(Polygon* polygon) const; - + + bool is_printable() const { return print_volume_state == PVS_Inside; } + private: // Parent object, owning this instance. ModelObject* object; - ModelInstance(ModelObject *object) : rotation(0), scaling_factor(1), object(object), is_printable(false) {} + ModelInstance(ModelObject *object) : rotation(0), scaling_factor(1), object(object), print_volume_state(PVS_Inside) {} ModelInstance(ModelObject *object, const ModelInstance &other) : - rotation(other.rotation), scaling_factor(other.scaling_factor), offset(other.offset), object(object), is_printable(false) {} + rotation(other.rotation), scaling_factor(other.scaling_factor), offset(other.offset), object(object), print_volume_state(PVS_Inside) {} }; -- cgit v1.2.3