Use Transform3d in place of Transform3f as parameter of mesh transform functions

This commit is contained in:
Enrico Turri 2018-11-02 13:47:47 +01:00
parent 3aad8b5fd2
commit 7114b80882
7 changed files with 15 additions and 15 deletions

View File

@ -173,7 +173,7 @@ extern void stl_mirror_xy(stl_file *stl);
extern void stl_mirror_yz(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, 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_invalidate_shared_vertices(stl_file *stl);
extern void stl_generate_shared_vertices(stl_file *stl);

View File

@ -155,7 +155,7 @@ void stl_transform(stl_file *stl, float *trafo3x4) {
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)
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);
dst_vertices = t * src_vertices.colwise().homogeneous();
dst_vertices = t.cast<float>() * src_vertices.colwise().homogeneous();
facet_ptr = stl->facet_start;
v_id = 0;

View File

@ -627,7 +627,7 @@ const BoundingBoxf3& ModelObject::bounding_box() const
#if ENABLE_MODELVOLUME_TRANSFORM
{
TriangleMesh m = v->mesh;
m.transform(v->get_matrix().cast<float>());
m.transform(v->get_matrix());
raw_bbox.merge(m.bounding_box());
}
#else
@ -667,7 +667,7 @@ TriangleMesh ModelObject::raw_mesh() const
#if ENABLE_MODELVOLUME_TRANSFORM
{
TriangleMesh vol_mesh(v->mesh);
vol_mesh.transform(v->get_matrix().cast<float>());
vol_mesh.transform(v->get_matrix());
mesh.merge(vol_mesh);
}
#else
@ -1212,14 +1212,14 @@ void ModelInstance::set_mirror(Axis axis, double mirror)
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
{
// Rotate around mesh origin.
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();
if (!empty(bbox)) {

View File

@ -1604,14 +1604,14 @@ std::vector<ExPolygons> PrintObject::_slice_volumes(const std::vector<float> &z,
#if ENABLE_MODELVOLUME_TRANSFORM
{
TriangleMesh vol_mesh(v->mesh);
vol_mesh.transform(v->get_matrix().cast<float>());
vol_mesh.transform(v->get_matrix());
mesh.merge(vol_mesh);
}
#else
mesh.merge(v->mesh);
#endif // ENABLE_MODELVOLUME_TRANSFORM
if (mesh.stl.stats.number_of_facets > 0) {
mesh.transform(m_trafo.cast<float>());
mesh.transform(m_trafo);
// apply XY shift
mesh.translate(- unscale<float>(m_copies_shift(0)), - unscale<float>(m_copies_shift(1)), 0);
// perform actual slicing

View File

@ -272,9 +272,9 @@ void TriangleMesh::rotate(float angle, const Vec3d& axis)
if (angle == 0.f)
return;
Vec3f axis_norm = axis.cast<float>().normalized();
Transform3f m = Transform3f::Identity();
m.rotate(Eigen::AngleAxisf(angle, axis_norm));
Vec3d axis_norm = axis.normalized();
Transform3d m = Transform3d::Identity();
m.rotate(Eigen::AngleAxisd(angle, axis_norm));
stl_transform(&stl, m);
}
@ -290,7 +290,7 @@ void TriangleMesh::mirror(const Axis &axis)
stl_invalidate_shared_vertices(&this->stl);
}
void TriangleMesh::transform(const Transform3f& t)
void TriangleMesh::transform(const Transform3d& t)
{
stl_transform(&stl, t);
}

View File

@ -49,7 +49,7 @@ public:
void mirror_x() { this->mirror(X); }
void mirror_y() { this->mirror(Y); }
void mirror_z() { this->mirror(Z); }
void transform(const Transform3f& t);
void transform(const Transform3d& t);
void align_to_origin();
void rotate(double angle, Point* center);
TriangleMeshPtrs split() const;

View File

@ -1256,7 +1256,7 @@ void GLGizmoFlatten::update_planes()
#if ENABLE_MODELVOLUME_TRANSFORM
{
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);
}
#else