mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-22 04:28:05 +08:00
Use Transform3d in place of Transform3f as parameter of mesh transform functions
This commit is contained in:
parent
3aad8b5fd2
commit
7114b80882
@ -173,7 +173,7 @@ extern void stl_mirror_xy(stl_file *stl);
|
|||||||
extern void stl_mirror_yz(stl_file *stl);
|
extern void stl_mirror_yz(stl_file *stl);
|
||||||
extern void stl_mirror_xz(stl_file *stl);
|
extern void stl_mirror_xz(stl_file *stl);
|
||||||
extern void stl_transform(stl_file *stl, float *trafo3x4);
|
extern void stl_transform(stl_file *stl, float *trafo3x4);
|
||||||
extern void stl_transform(stl_file *stl, const Eigen::Transform<float, 3, Eigen::Affine, Eigen::DontAlign>& t);
|
extern void stl_transform(stl_file *stl, const Eigen::Transform<double, 3, Eigen::Affine, Eigen::DontAlign>& t);
|
||||||
extern void stl_open_merge(stl_file *stl, char *file);
|
extern void stl_open_merge(stl_file *stl, char *file);
|
||||||
extern void stl_invalidate_shared_vertices(stl_file *stl);
|
extern void stl_invalidate_shared_vertices(stl_file *stl);
|
||||||
extern void stl_generate_shared_vertices(stl_file *stl);
|
extern void stl_generate_shared_vertices(stl_file *stl);
|
||||||
|
@ -155,7 +155,7 @@ void stl_transform(stl_file *stl, float *trafo3x4) {
|
|||||||
calculate_normals(stl);
|
calculate_normals(stl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stl_transform(stl_file *stl, const Eigen::Transform<float, 3, Eigen::Affine, Eigen::DontAlign>& t)
|
void stl_transform(stl_file *stl, const Eigen::Transform<double, 3, Eigen::Affine, Eigen::DontAlign>& t)
|
||||||
{
|
{
|
||||||
if (stl->error)
|
if (stl->error)
|
||||||
return;
|
return;
|
||||||
@ -178,7 +178,7 @@ void stl_transform(stl_file *stl, const Eigen::Transform<float, 3, Eigen::Affine
|
|||||||
}
|
}
|
||||||
|
|
||||||
Eigen::MatrixXf dst_vertices(3, vertices_count);
|
Eigen::MatrixXf dst_vertices(3, vertices_count);
|
||||||
dst_vertices = t * src_vertices.colwise().homogeneous();
|
dst_vertices = t.cast<float>() * src_vertices.colwise().homogeneous();
|
||||||
|
|
||||||
facet_ptr = stl->facet_start;
|
facet_ptr = stl->facet_start;
|
||||||
v_id = 0;
|
v_id = 0;
|
||||||
|
@ -627,7 +627,7 @@ const BoundingBoxf3& ModelObject::bounding_box() const
|
|||||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||||
{
|
{
|
||||||
TriangleMesh m = v->mesh;
|
TriangleMesh m = v->mesh;
|
||||||
m.transform(v->get_matrix().cast<float>());
|
m.transform(v->get_matrix());
|
||||||
raw_bbox.merge(m.bounding_box());
|
raw_bbox.merge(m.bounding_box());
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -667,7 +667,7 @@ TriangleMesh ModelObject::raw_mesh() const
|
|||||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||||
{
|
{
|
||||||
TriangleMesh vol_mesh(v->mesh);
|
TriangleMesh vol_mesh(v->mesh);
|
||||||
vol_mesh.transform(v->get_matrix().cast<float>());
|
vol_mesh.transform(v->get_matrix());
|
||||||
mesh.merge(vol_mesh);
|
mesh.merge(vol_mesh);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -1212,14 +1212,14 @@ void ModelInstance::set_mirror(Axis axis, double mirror)
|
|||||||
|
|
||||||
void ModelInstance::transform_mesh(TriangleMesh* mesh, bool dont_translate) const
|
void ModelInstance::transform_mesh(TriangleMesh* mesh, bool dont_translate) const
|
||||||
{
|
{
|
||||||
mesh->transform(get_matrix(dont_translate).cast<float>());
|
mesh->transform(get_matrix(dont_translate));
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh* mesh, bool dont_translate) const
|
BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh* mesh, bool dont_translate) const
|
||||||
{
|
{
|
||||||
// Rotate around mesh origin.
|
// Rotate around mesh origin.
|
||||||
TriangleMesh copy(*mesh);
|
TriangleMesh copy(*mesh);
|
||||||
copy.transform(get_matrix(true, false, true, true).cast<float>());
|
copy.transform(get_matrix(true, false, true, true));
|
||||||
BoundingBoxf3 bbox = copy.bounding_box();
|
BoundingBoxf3 bbox = copy.bounding_box();
|
||||||
|
|
||||||
if (!empty(bbox)) {
|
if (!empty(bbox)) {
|
||||||
|
@ -1604,14 +1604,14 @@ std::vector<ExPolygons> PrintObject::_slice_volumes(const std::vector<float> &z,
|
|||||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||||
{
|
{
|
||||||
TriangleMesh vol_mesh(v->mesh);
|
TriangleMesh vol_mesh(v->mesh);
|
||||||
vol_mesh.transform(v->get_matrix().cast<float>());
|
vol_mesh.transform(v->get_matrix());
|
||||||
mesh.merge(vol_mesh);
|
mesh.merge(vol_mesh);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
mesh.merge(v->mesh);
|
mesh.merge(v->mesh);
|
||||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||||
if (mesh.stl.stats.number_of_facets > 0) {
|
if (mesh.stl.stats.number_of_facets > 0) {
|
||||||
mesh.transform(m_trafo.cast<float>());
|
mesh.transform(m_trafo);
|
||||||
// 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
|
||||||
|
@ -272,9 +272,9 @@ void TriangleMesh::rotate(float angle, const Vec3d& axis)
|
|||||||
if (angle == 0.f)
|
if (angle == 0.f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Vec3f axis_norm = axis.cast<float>().normalized();
|
Vec3d axis_norm = axis.normalized();
|
||||||
Transform3f m = Transform3f::Identity();
|
Transform3d m = Transform3d::Identity();
|
||||||
m.rotate(Eigen::AngleAxisf(angle, axis_norm));
|
m.rotate(Eigen::AngleAxisd(angle, axis_norm));
|
||||||
stl_transform(&stl, m);
|
stl_transform(&stl, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ void TriangleMesh::mirror(const Axis &axis)
|
|||||||
stl_invalidate_shared_vertices(&this->stl);
|
stl_invalidate_shared_vertices(&this->stl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriangleMesh::transform(const Transform3f& t)
|
void TriangleMesh::transform(const Transform3d& t)
|
||||||
{
|
{
|
||||||
stl_transform(&stl, t);
|
stl_transform(&stl, t);
|
||||||
}
|
}
|
||||||
|
@ -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 Transform3f& t);
|
void transform(const Transform3d& t);
|
||||||
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;
|
||||||
|
@ -1256,7 +1256,7 @@ void GLGizmoFlatten::update_planes()
|
|||||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||||
{
|
{
|
||||||
TriangleMesh vol_ch = vol->get_convex_hull();
|
TriangleMesh vol_ch = vol->get_convex_hull();
|
||||||
vol_ch.transform(vol->get_matrix().cast<float>());
|
vol_ch.transform(vol->get_matrix());
|
||||||
ch.merge(vol_ch);
|
ch.merge(vol_ch);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user