WIP: Transformation of instances in world coordinate space:

Ulocking the "anisotropic" scaling checkbox will bake the transformation
into meshes to allow for scaling in world axes.

Optimized and templated the stl_transform functions, now also available for 3x3 matrices.
The Canvas3D::reload_scene() now maintains selection even if all volumes of an instance changed their IDs.
This commit is contained in:
bubnikv 2019-04-26 17:28:31 +02:00
parent f78c3a0f1b
commit 6526a8fcaf
14 changed files with 237 additions and 118 deletions

View file

@ -54,6 +54,10 @@ struct ModelID
size_t id;
};
// Unique object / instance ID for the wipe tower.
extern ModelID wipe_tower_object_id();
extern ModelID wipe_tower_instance_id();
// Base for Model, ModelObject, ModelVolume, ModelInstance or ModelMaterial to provide a unique ID
// to synchronize the front end (UI) with the back end (BackgroundSlicingProcess / Print / PrintObject).
// Achtung! The s_last_id counter is not thread safe, so it is expected, that the ModelBase derived instances
@ -85,6 +89,9 @@ private:
static inline ModelID generate_new_id() { return ModelID(++ s_last_id); }
static size_t s_last_id;
friend ModelID wipe_tower_object_id();
friend ModelID wipe_tower_instance_id();
};
#define MODELBASE_DERIVED_COPY_MOVE_CLONE(TYPE) \
@ -265,6 +272,11 @@ public:
ModelObjectPtrs cut(size_t instance, coordf_t z, bool keep_upper = true, bool keep_lower = true, bool rotate_lower = false); // Note: z is in world coordinates
void split(ModelObjectPtrs* new_objects);
void repair();
// Support for non-uniform scaling of instances. If an instance is rotated by angles, which are not multiples of ninety degrees,
// then the scaling in world coordinate system is not representable by the Geometry::Transformation structure.
// This situation is solved by baking in the instance transformation into the mesh vertices.
// Rotation and mirroring is being baked in. In case the instance scaling was non-uniform, it is baked in as well.
void bake_xy_rotation_into_meshes(size_t instance_idx);
double get_min_z() const;
double get_instance_min_z(size_t instance_idx) const;
@ -414,6 +426,8 @@ protected:
explicit ModelVolume(const ModelVolume &rhs) = default;
void set_model_object(ModelObject *model_object) { object = model_object; }
void transform_mesh(const Transform3d& t, bool fix_left_handed);
void transform_mesh(const Matrix3d& m, bool fix_left_handed);
private:
// Parent object owning this ModelVolume.