mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-21 20:18:17 +08:00
Added mirror factors to .3mf import and enabled import factors
This commit is contained in:
parent
84de664fb5
commit
2a2d1d85f8
@ -1249,14 +1249,25 @@ namespace Slic3r {
|
|||||||
|
|
||||||
void _3MF_Importer::_apply_transform(ModelInstance& instance, const Transform3d& transform)
|
void _3MF_Importer::_apply_transform(ModelInstance& instance, const Transform3d& transform)
|
||||||
{
|
{
|
||||||
// slic3r ModelInstance cannot be transformed using a matrix
|
|
||||||
// we extract from the given matrix only the values currently used
|
|
||||||
|
|
||||||
// translation
|
// translation
|
||||||
Vec3d offset = transform.matrix().block(0, 3, 3, 1);
|
Vec3d offset = transform.matrix().block(0, 3, 3, 1);
|
||||||
|
|
||||||
// scale
|
|
||||||
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> m3x3 = transform.matrix().block(0, 0, 3, 3);
|
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> m3x3 = transform.matrix().block(0, 0, 3, 3);
|
||||||
|
#if ENABLE_MIRROR
|
||||||
|
// mirror
|
||||||
|
// it is impossible to reconstruct the original mirroring factors from a matrix,
|
||||||
|
// we can only detect if the matrix contains a left handed reference system
|
||||||
|
// in which case we reorient it back to right handed by mirroring the x axis
|
||||||
|
Vec3d mirror = Vec3d::Ones();
|
||||||
|
if (m3x3.col(0).dot(m3x3.col(1).cross(m3x3.col(2))) < 0.0)
|
||||||
|
{
|
||||||
|
mirror(0) = -1.0;
|
||||||
|
// remove mirror
|
||||||
|
m3x3.col(0) *= -1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// scale
|
||||||
|
#endif // ENABLE_MIRROR
|
||||||
Vec3d scale(m3x3.col(0).norm(), m3x3.col(1).norm(), m3x3.col(2).norm());
|
Vec3d scale(m3x3.col(0).norm(), m3x3.col(1).norm(), m3x3.col(2).norm());
|
||||||
|
|
||||||
// invalid scale value, return
|
// invalid scale value, return
|
||||||
@ -1273,6 +1284,9 @@ namespace Slic3r {
|
|||||||
instance.set_offset(offset);
|
instance.set_offset(offset);
|
||||||
instance.set_scaling_factor(scale);
|
instance.set_scaling_factor(scale);
|
||||||
instance.set_rotation(rotation);
|
instance.set_rotation(rotation);
|
||||||
|
#if ENABLE_MIRROR
|
||||||
|
instance.set_mirror(mirror);
|
||||||
|
#endif // ENABLE_MIRROR
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _3MF_Importer::_handle_start_config(const char** attributes, unsigned int num_attributes)
|
bool _3MF_Importer::_handle_start_config(const char** attributes, unsigned int num_attributes)
|
||||||
|
@ -711,9 +711,13 @@ void ModelObject::center_around_origin()
|
|||||||
|
|
||||||
if (!this->instances.empty()) {
|
if (!this->instances.empty()) {
|
||||||
for (ModelInstance *i : this->instances) {
|
for (ModelInstance *i : this->instances) {
|
||||||
|
#if ENABLE_MIRROR
|
||||||
|
i->set_offset(i->get_offset() - shift);
|
||||||
|
#else
|
||||||
// apply rotation and scaling to vector as well before translating instance,
|
// apply rotation and scaling to vector as well before translating instance,
|
||||||
// in order to leave final position unaltered
|
// in order to leave final position unaltered
|
||||||
i->set_offset(i->get_offset() + i->transform_vector(-shift, true));
|
i->set_offset(i->get_offset() + i->transform_vector(-shift, true));
|
||||||
|
#endif // ENABLE_MIRROR
|
||||||
}
|
}
|
||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
// New selections
|
// New selections
|
||||||
#define ENABLE_EXTENDED_SELECTION (1 && ENABLE_1_42_0)
|
#define ENABLE_EXTENDED_SELECTION (1 && ENABLE_1_42_0)
|
||||||
// Add mirror components along the three axes in ModelInstance and GLVolume
|
// Add mirror components along the three axes in ModelInstance and GLVolume
|
||||||
#define ENABLE_MIRROR (0 && ENABLE_1_42_0)
|
#define ENABLE_MIRROR (1 && ENABLE_1_42_0)
|
||||||
|
|
||||||
#endif // _technologies_h_
|
#endif // _technologies_h_
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user