Fixed FFF slicing of meshes with left hand oriented transformations applied.
Slight optimization of FFF slicing - optimized copy of an object with just a single volume.
This commit is contained in:
parent
eeae1c0495
commit
382326ffc8
@ -1790,15 +1790,16 @@ std::vector<ExPolygons> PrintObject::_slice_volumes(const std::vector<float> &z,
|
|||||||
if (! volumes.empty()) {
|
if (! volumes.empty()) {
|
||||||
// Compose mesh.
|
// Compose mesh.
|
||||||
//FIXME better to perform slicing over each volume separately and then to use a Boolean operation to merge them.
|
//FIXME better to perform slicing over each volume separately and then to use a Boolean operation to merge them.
|
||||||
TriangleMesh mesh;
|
TriangleMesh mesh(volumes.front()->mesh);
|
||||||
for (const ModelVolume *v : volumes)
|
mesh.transform(volumes.front()->get_matrix(), true);
|
||||||
{
|
for (size_t idx_volume = 1; idx_volume < volumes.size(); ++ idx_volume) {
|
||||||
TriangleMesh vol_mesh(v->mesh);
|
const ModelVolume &model_volume = *volumes[idx_volume];
|
||||||
vol_mesh.transform(v->get_matrix());
|
TriangleMesh vol_mesh(model_volume.mesh);
|
||||||
|
vol_mesh.transform(model_volume.get_matrix(), true);
|
||||||
mesh.merge(vol_mesh);
|
mesh.merge(vol_mesh);
|
||||||
}
|
}
|
||||||
if (mesh.stl.stats.number_of_facets > 0) {
|
if (mesh.stl.stats.number_of_facets > 0) {
|
||||||
mesh.transform(m_trafo);
|
mesh.transform(m_trafo, true);
|
||||||
// apply XY shift
|
// apply XY shift
|
||||||
mesh.translate(- unscale<float>(m_copies_shift(0)), - unscale<float>(m_copies_shift(1)), 0);
|
mesh.translate(- unscale<float>(m_copies_shift(0)), - unscale<float>(m_copies_shift(1)), 0);
|
||||||
// perform actual slicing
|
// perform actual slicing
|
||||||
@ -1819,9 +1820,9 @@ std::vector<ExPolygons> PrintObject::_slice_volume(const std::vector<float> &z,
|
|||||||
// Compose mesh.
|
// Compose mesh.
|
||||||
//FIXME better to perform slicing over each volume separately and then to use a Boolean operation to merge them.
|
//FIXME better to perform slicing over each volume separately and then to use a Boolean operation to merge them.
|
||||||
TriangleMesh mesh(volume.mesh);
|
TriangleMesh mesh(volume.mesh);
|
||||||
mesh.transform(volume.get_matrix());
|
mesh.transform(volume.get_matrix(), true);
|
||||||
if (mesh.stl.stats.number_of_facets > 0) {
|
if (mesh.stl.stats.number_of_facets > 0) {
|
||||||
mesh.transform(m_trafo);
|
mesh.transform(m_trafo, true);
|
||||||
// apply XY shift
|
// apply XY shift
|
||||||
mesh.translate(- unscale<float>(m_copies_shift(0)), - unscale<float>(m_copies_shift(1)), 0);
|
mesh.translate(- unscale<float>(m_copies_shift(0)), - unscale<float>(m_copies_shift(1)), 0);
|
||||||
// perform actual slicing
|
// perform actual slicing
|
||||||
|
@ -314,10 +314,15 @@ void TriangleMesh::mirror(const Axis &axis)
|
|||||||
stl_invalidate_shared_vertices(&this->stl);
|
stl_invalidate_shared_vertices(&this->stl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriangleMesh::transform(const Transform3d& t)
|
void TriangleMesh::transform(const Transform3d& t, bool fix_left_handed)
|
||||||
{
|
{
|
||||||
stl_transform(&stl, t);
|
stl_transform(&stl, t);
|
||||||
stl_invalidate_shared_vertices(&stl);
|
stl_invalidate_shared_vertices(&stl);
|
||||||
|
if (fix_left_handed && t.matrix().block(0, 0, 3, 3).determinant() < 0.) {
|
||||||
|
// Left handed transformation is being applied. It is a good idea to flip the faces and their normals.
|
||||||
|
this->repair();
|
||||||
|
stl_reverse_all_facets(&stl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriangleMesh::align_to_origin()
|
void TriangleMesh::align_to_origin()
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
void mirror_x() { this->mirror(X); }
|
void mirror_x() { this->mirror(X); }
|
||||||
void mirror_y() { this->mirror(Y); }
|
void mirror_y() { this->mirror(Y); }
|
||||||
void mirror_z() { this->mirror(Z); }
|
void mirror_z() { this->mirror(Z); }
|
||||||
void transform(const Transform3d& t);
|
void transform(const Transform3d& t, bool fix_left_handed = false);
|
||||||
void align_to_origin();
|
void align_to_origin();
|
||||||
void rotate(double angle, Point* center);
|
void rotate(double angle, Point* center);
|
||||||
TriangleMeshPtrs split() const;
|
TriangleMeshPtrs split() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user