diff --git a/src/libslic3r/Algorithm/LineSplit.cpp b/src/libslic3r/Algorithm/LineSplit.cpp index f63033c026..53ef00e0a5 100644 --- a/src/libslic3r/Algorithm/LineSplit.cpp +++ b/src/libslic3r/Algorithm/LineSplit.cpp @@ -48,8 +48,8 @@ using SplitNode = std::vector; static bool point_on_line(const Point& p, const Line& l) { // Check collinear - const auto d1 = l.b - l.a; - const auto d2 = p - l.a; + const Vec2crd d1 = l.b - l.a; + const Vec2crd d2 = p - l.a; if (d1.x() * d2.y() != d1.y() * d2.x()) { return false; } diff --git a/src/libslic3r/Arachne/utils/ExtrusionLine.cpp b/src/libslic3r/Arachne/utils/ExtrusionLine.cpp index 0ee40b2b42..1f8ed702c2 100644 --- a/src/libslic3r/Arachne/utils/ExtrusionLine.cpp +++ b/src/libslic3r/Arachne/utils/ExtrusionLine.cpp @@ -156,7 +156,7 @@ void ExtrusionLine::simplify(const int64_t smallest_line_segment_squared, const Point intersection_point; bool has_intersection = Line(previous_previous.p, previous.p).intersection_infinite(Line(current.p, next.p), &intersection_point); const auto dist_greater = [](const Point& p1, const Point& p2, const int64_t threshold) { - const auto vec = (p1 - p2).cwiseAbs().cast(); + const auto vec = (p1 - p2).cwiseAbs().cast().eval(); if(vec.x() > threshold || vec.y() > threshold) { // If this condition is true, the distance is definitely greater than the threshold. // We don't need to calculate the squared norm at all, which avoid potential arithmetic overflow. diff --git a/src/libslic3r/CutSurface.cpp b/src/libslic3r/CutSurface.cpp index 619e5e9f72..01a5a8383a 100644 --- a/src/libslic3r/CutSurface.cpp +++ b/src/libslic3r/CutSurface.cpp @@ -1887,7 +1887,7 @@ uint32_t priv::get_closest_point_index(const SearchData &sd, const Polygon &poly = (id.polygon_index == 0) ? shape.contour : shape.holes[id.polygon_index - 1]; - auto p_ = p.cast(); + Vec2crd p_ = p.cast(); return p_ == poly[id.point_index]; }; diff --git a/src/libslic3r/Emboss.cpp b/src/libslic3r/Emboss.cpp index 82015c4827..ef144b48d3 100644 --- a/src/libslic3r/Emboss.cpp +++ b/src/libslic3r/Emboss.cpp @@ -1672,7 +1672,7 @@ Vec3d Emboss::suggest_up(const Vec3d normal, double up_limit) std::optional Emboss::calc_up(const Transform3d &tr, double up_limit) { - auto tr_linear = tr.linear(); + auto tr_linear = tr.linear().eval(); // z base of transformation ( tr * UnitZ ) Vec3d normal = tr_linear.col(2); // scaled matrix has base with different size diff --git a/src/libslic3r/Fill/FillAdaptive.cpp b/src/libslic3r/Fill/FillAdaptive.cpp index bc1b24a81d..8f28697eb8 100644 --- a/src/libslic3r/Fill/FillAdaptive.cpp +++ b/src/libslic3r/Fill/FillAdaptive.cpp @@ -1447,7 +1447,7 @@ static std::vector make_cubes_properties(double max_cube_edge_le static inline bool is_overhang_triangle(const Vec3d &a, const Vec3d &b, const Vec3d &c, const Vec3d &up) { // Calculate triangle normal. - auto n = (b - a).cross(c - b); + Vec3d n = (b - a).cross(c - b); return n.dot(up) > 0.707 * n.norm(); } @@ -1493,9 +1493,9 @@ OctreePtr build_octree( }; auto up_vector = support_overhangs_only ? Vec3d(transform_to_octree() * Vec3d(0., 0., 1.)) : Vec3d(); for (auto &tri : triangle_mesh.indices) { - auto a = triangle_mesh.vertices[tri[0]].cast(); - auto b = triangle_mesh.vertices[tri[1]].cast(); - auto c = triangle_mesh.vertices[tri[2]].cast(); + Vec3d a = triangle_mesh.vertices[tri[0]].cast(); + Vec3d b = triangle_mesh.vertices[tri[1]].cast(); + Vec3d c = triangle_mesh.vertices[tri[2]].cast(); if (! support_overhangs_only || is_overhang_triangle(a, b, c, up_vector)) process_triangle(a, b, c); } diff --git a/src/libslic3r/GCode/ExtrusionProcessor.hpp b/src/libslic3r/GCode/ExtrusionProcessor.hpp index a8fd775e2a..dd0065247d 100644 --- a/src/libslic3r/GCode/ExtrusionProcessor.hpp +++ b/src/libslic3r/GCode/ExtrusionProcessor.hpp @@ -144,7 +144,7 @@ std::vector estimate_points_properties(const POINTS double t1 = std::max(a0, a1); if (t0 < 1.0) { - auto p0 = curr.position + t0 * (next.position - curr.position); + Vec2d p0 = curr.position + t0 * (next.position - curr.position); auto [p0_dist, p0_near_l, p0_x] = unscaled_prev_layer.template distance_from_lines_extra(p0.cast()); ExtendedPoint new_p{}; @@ -161,7 +161,7 @@ std::vector estimate_points_properties(const POINTS } } if (t1 > 0.0) { - auto p1 = curr.position + t1 * (next.position - curr.position); + Vec2d p1 = curr.position + t1 * (next.position - curr.position); auto [p1_dist, p1_near_l, p1_x] = unscaled_prev_layer.template distance_from_lines_extra(p1.cast()); ExtendedPoint new_p{}; diff --git a/src/libslic3r/Geometry.cpp b/src/libslic3r/Geometry.cpp index 7c89a5c00a..90e65f5103 100644 --- a/src/libslic3r/Geometry.cpp +++ b/src/libslic3r/Geometry.cpp @@ -693,10 +693,10 @@ Transformation Transformation::volume_to_bed_transformation(const Transformation pts(7, 0) = bbox.max.x(); pts(7, 1) = bbox.max.y(); pts(7, 2) = bbox.max.z(); // Corners of the bounding box transformed into the modifier mesh coordinate space, with inverse rotation applied to the modifier. - auto qs = pts * + auto qs = (pts * (instance_rotation_trafo * Eigen::Scaling(instance_transformation.get_scaling_factor().cwiseProduct(instance_transformation.get_mirror())) * - volume_rotation_trafo).inverse().transpose(); + volume_rotation_trafo).inverse().transpose()).eval(); // Fill in scaling based on least squares fitting of the bounding box corners. Vec3d scale; for (int i = 0; i < 3; ++i) @@ -767,7 +767,7 @@ double rotation_diff_z(const Vec3d &rot_xyz_from, const Vec3d &rot_xyz_to) TransformationSVD::TransformationSVD(const Transform3d& trafo) { - const auto &m0 = trafo.matrix().block<3, 3>(0, 0); + const Matrix3d m0 = trafo.matrix().block<3, 3>(0, 0); mirror = m0.determinant() < 0.0; Matrix3d m; @@ -832,8 +832,8 @@ TransformationSVD::TransformationSVD(const Transform3d& trafo) qua_world.normalize(); Transform3d cur_matrix_world; temp_world.set_matrix(cur_matrix_world.fromPositionOrientationScale(pt, qua_world, Vec3d(1., 1., 1.))); - auto temp_xyz = temp_world.get_matrix().inverse() * xyz; - auto new_pos = temp_world.get_matrix() * (rotateMat4.get_matrix() * temp_xyz); + Vec3d temp_xyz = temp_world.get_matrix().inverse() * xyz; + Vec3d new_pos = temp_world.get_matrix() * (rotateMat4.get_matrix() * temp_xyz); curMat.set_offset(new_pos); return curMat; diff --git a/src/libslic3r/Line.cpp b/src/libslic3r/Line.cpp index 7e75d56322..20591f0377 100644 --- a/src/libslic3r/Line.cpp +++ b/src/libslic3r/Line.cpp @@ -114,7 +114,7 @@ void Line::extend(double offset) Vec3d Linef3::intersect_plane(double z) const { - auto v = (this->b - this->a).cast(); + Vec3d v = (this->b - this->a).cast(); double t = (z - this->a(2)) / v(2); return Vec3d(this->a(0) + v(0) * t, this->a(1) + v(1) * t, z); } diff --git a/src/libslic3r/Measure.cpp b/src/libslic3r/Measure.cpp index 43e20a0373..ad34752685 100644 --- a/src/libslic3r/Measure.cpp +++ b/src/libslic3r/Measure.cpp @@ -15,8 +15,8 @@ namespace Slic3r { namespace Measure { bool get_point_projection_to_plane(const Vec3d &pt, const Vec3d &plane_origin, const Vec3d &plane_normal, Vec3d &intersection_pt) { - auto normal = plane_normal.normalized(); - auto BA = plane_origin - pt; + Vec3d normal = plane_normal.normalized(); + Vec3d BA = plane_origin - pt; auto length = BA.dot(normal); intersection_pt = pt + length * normal; return true; @@ -29,7 +29,7 @@ Vec3d get_one_point_in_plane(const Vec3d &plane_origin, const Vec3d &plane_norma if (abs(plane_normal.dot(dir)) > 1 - eps) { dir = Vec3d(0, 1, 0); } - auto new_pt = plane_origin + dir; + Vec3d new_pt = plane_origin + dir; Vec3d retult; get_point_projection_to_plane(new_pt, plane_origin, plane_normal, retult); return retult; diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index d7b23b6b7e..a047d1db48 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -2991,11 +2991,11 @@ bool Model::obj_import_vertex_color_deal(const std::vector &verte auto v0 = volume->mesh().its.vertices[face[0]]; auto v1 = volume->mesh().its.vertices[face[1]]; auto v2 = volume->mesh().its.vertices[face[2]]; - auto dir_0_1 = (v1 - v0).normalized(); - auto dir_0_2 = (v2 - v0).normalized(); + auto dir_0_1 = (v1 - v0).normalized().eval(); + auto dir_0_2 = (v2 - v0).normalized().eval(); float sita0 = acos(dir_0_1.dot(dir_0_2)); - auto dir_1_0 = -dir_0_1; - auto dir_1_2 = (v2 - v1).normalized(); + auto dir_1_0 = (-dir_0_1).eval(); + auto dir_1_2 = (v2 - v1).normalized().eval(); float sita1 = acos(dir_1_0.dot(dir_1_2)); float sita2 = PI - sita0 - sita1; std::array sitas = {sita0, sita1, sita2}; diff --git a/src/libslic3r/Orient.cpp b/src/libslic3r/Orient.cpp index ce448fc7e6..c09ccf1fae 100644 --- a/src/libslic3r/Orient.cpp +++ b/src/libslic3r/Orient.cpp @@ -132,7 +132,7 @@ public: BOOST_LOG_TRIVIAL(info) << CostItems::field_names(); std::cout << CostItems::field_names() << std::endl; for (int i = 0; i < orientations.size();i++) { - auto orientation = -orientations[i]; + Vec3f orientation = -orientations[i]; project_vertices(orientation); @@ -382,9 +382,9 @@ public: float total_min_z = z_projected.minCoeff(); // filter bottom area - auto bottom_condition = z_max.array() < total_min_z + this->params.FIRST_LAY_H - EPSILON; - auto bottom_condition_hull = z_max_hull.array() < total_min_z + this->params.FIRST_LAY_H - EPSILON; - auto bottom_condition_2nd = z_max.array() < total_min_z + this->params.FIRST_LAY_H/2.f - EPSILON; + auto bottom_condition = (z_max.array() < total_min_z + this->params.FIRST_LAY_H - EPSILON).eval(); + auto bottom_condition_hull = (z_max_hull.array() < total_min_z + this->params.FIRST_LAY_H - EPSILON).eval(); + auto bottom_condition_2nd = (z_max.array() < total_min_z + this->params.FIRST_LAY_H / 2.f - EPSILON).eval(); //The first layer is sliced on half of the first layer height. //The bottom area is measured by accumulating first layer area with the facets area below first layer height. //By combining these two factors, we can avoid the wrong orientation of large planar faces while not influence the @@ -397,8 +397,8 @@ public: { normal_projection(i) = normals.row(i).dot(orientation); } - auto areas_appearance = areas.cwiseProduct((is_apperance * params.APPERANCE_FACE_SUPP + Eigen::VectorXf::Ones(is_apperance.rows(), is_apperance.cols()))); - auto overhang_areas = ((normal_projection.array() < params.ASCENT) * (!bottom_condition_2nd)).select(areas_appearance, 0); + auto areas_appearance = areas.cwiseProduct((is_apperance * params.APPERANCE_FACE_SUPP + Eigen::VectorXf::Ones(is_apperance.rows(), is_apperance.cols()))).eval(); + auto overhang_areas = ((normal_projection.array() < params.ASCENT) * (!bottom_condition_2nd)).select(areas_appearance, 0).eval(); Eigen::MatrixXf inner = normal_projection.array() - params.ASCENT; inner = inner.cwiseMin(0).cwiseAbs(); if (min_volume) @@ -437,7 +437,7 @@ public: costs.bottom_hull = (bottom_condition_hull).select(areas_hull, 0).sum(); // low angle faces - auto normal_projection_abs = normal_projection.cwiseAbs(); + auto normal_projection_abs = normal_projection.cwiseAbs().eval(); Eigen::MatrixXf laf_areas = ((normal_projection_abs.array() < params.LAF_MAX) * (normal_projection_abs.array() > params.LAF_MIN) * (z_max.array() > total_min_z + params.FIRST_LAY_H)).select(areas, 0); costs.area_laf = laf_areas.sum(); diff --git a/src/libslic3r/Point.cpp b/src/libslic3r/Point.cpp index e06b3d5ca6..80c4d9815a 100644 --- a/src/libslic3r/Point.cpp +++ b/src/libslic3r/Point.cpp @@ -50,7 +50,7 @@ void Point::rotate(double angle, const Point ¢er) Vec2d cur = this->cast(); double s = ::sin(angle); double c = ::cos(angle); - auto d = cur - center.cast(); + Vec2d d = cur - center.cast(); this->x() = fast_round_up(center.x() + c * d.x() - s * d.y()); this->y() = fast_round_up(center.y() + s * d.x() + c * d.y()); } diff --git a/src/libslic3r/Support/TreeSupport.cpp b/src/libslic3r/Support/TreeSupport.cpp index 139ae42597..9404d56e2d 100644 --- a/src/libslic3r/Support/TreeSupport.cpp +++ b/src/libslic3r/Support/TreeSupport.cpp @@ -3296,8 +3296,8 @@ void TreeSupport::generate_contact_points() int nSize = points.size(); for (int i = 0; i < nSize; i++) { auto pt = points[i]; - auto v1 = (pt - points[(i - 1 + nSize) % nSize]).cast().normalized(); - auto v2 = (pt - points[(i + 1) % nSize]).cast().normalized(); + Vec2d v1 = (pt - points[(i - 1 + nSize) % nSize]).cast().normalized(); + Vec2d v2 = (pt - points[(i + 1) % nSize]).cast().normalized(); if (v1.dot(v2) > -0.7) { // angle smaller than 135 degrees SupportNode *contact_node = insert_point(pt, overhang, radius, false, add_interface); if (contact_node) { diff --git a/src/libslic3r/Support/TreeSupport3D.cpp b/src/libslic3r/Support/TreeSupport3D.cpp index e1971e9b4c..4301b0ac0c 100644 --- a/src/libslic3r/Support/TreeSupport3D.cpp +++ b/src/libslic3r/Support/TreeSupport3D.cpp @@ -1480,8 +1480,8 @@ static unsigned int move_inside(const Polygons &polygons, Point &from, int dista const Point& a = p1; const Point& b = p2; const Point& p = from; - auto ab = (b - a).cast(); - auto ap = (p - a).cast(); + Vec2i64 ab = (b - a).cast(); + Vec2i64 ap = (p - a).cast(); int64_t ab_length2 = ab.squaredNorm(); if (ab_length2 <= 0) { //A = B, i.e. the input polygon had two adjacent points on top of each other. p1 = p2; //Skip only one of the points. @@ -1506,7 +1506,7 @@ static unsigned int move_inside(const Polygons &polygons, Point &from, int dista double lab = abd.norm(); double lp1p2 = p1p2.norm(); // inward direction irrespective of sign of [distance] - auto inward_dir = perp(abd * (scaled(10.0) / lab) + p1p2 * (scaled(10.0) / lp1p2)); + Vec2d inward_dir = perp(abd * (scaled(10.0) / lab) + p1p2 * (scaled(10.0) / lp1p2)); // MM2INT(10.0) to retain precision for the eventual normalization ret = x + (inward_dir * (distance / inward_dir.norm())).cast(); is_already_on_correct_side_of_boundary = inward_dir.dot((p - x).cast()) * distance >= 0; diff --git a/src/slic3r/GUI/2DBed.cpp b/src/slic3r/GUI/2DBed.cpp index e0feac0605..2921e064cf 100644 --- a/src/slic3r/GUI/2DBed.cpp +++ b/src/slic3r/GUI/2DBed.cpp @@ -121,7 +121,7 @@ void Bed_2D::repaint(const std::vector& shape) auto x_end = Vec2d(origin_px(0) + axes_len, origin_px(1)); dc.DrawLine(wxPoint(origin_px(0), origin_px(1)), wxPoint(x_end(0), x_end(1))); for (auto angle : { -arrow_angle, arrow_angle }) { - auto end = Eigen::Translation2d(x_end) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- x_end) * Eigen::Vector2d(x_end(0) - arrow_len, x_end(1)); + Vec2d end = Eigen::Translation2d(x_end) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- x_end) * Eigen::Vector2d(x_end(0) - arrow_len, x_end(1)); dc.DrawLine(wxPoint(x_end(0), x_end(1)), wxPoint(end(0), end(1))); } @@ -129,7 +129,7 @@ void Bed_2D::repaint(const std::vector& shape) auto y_end = Vec2d(origin_px(0), origin_px(1) - axes_len); dc.DrawLine(wxPoint(origin_px(0), origin_px(1)), wxPoint(y_end(0), y_end(1))); for (auto angle : { -arrow_angle, arrow_angle }) { - auto end = Eigen::Translation2d(y_end) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- y_end) * Eigen::Vector2d(y_end(0), y_end(1) + arrow_len); + Vec2d end = Eigen::Translation2d(y_end) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- y_end) * Eigen::Vector2d(y_end(0), y_end(1) + arrow_len); dc.DrawLine(wxPoint(y_end(0), y_end(1)), wxPoint(end(0), end(1))); } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp index e513fdb03f..68fc3deeef 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp @@ -2470,11 +2470,11 @@ void GLGizmoMeasure::set_distance(bool same_model_object, const Vec3d &displacem selection->set_mode(same_model_object ? Selection::Volume : Selection::Instance); m_pending_scale ++; if (same_model_object == false) { - auto object_displacement = v->get_instance_transformation().get_matrix_no_offset().inverse() * displacement; + Vec3d object_displacement = v->get_instance_transformation().get_matrix_no_offset().inverse() * displacement; v->set_instance_transformation(v->get_instance_transformation().get_matrix() * Geometry::translation_transform(object_displacement)); } else { Geometry::Transformation tran(v->world_matrix()); - auto local_displacement = tran.get_matrix_no_offset().inverse() * displacement; + Vec3d local_displacement = tran.get_matrix_no_offset().inverse() * displacement; v->set_volume_transformation(v->get_volume_transformation().get_matrix() * Geometry::translation_transform(local_displacement)); } wxGetApp().plater()->canvas3D()->do_move(""); @@ -2647,7 +2647,7 @@ void GLGizmoMeasure::set_parallel_distance(bool same_model_object, float dist) const auto [idx2, normal2, pt2] = m_selected_features.second.feature->get_plane(); Vec3d proj_pt2; Measure::get_point_projection_to_plane(pt2, pt1, normal1, proj_pt2); - auto new_pt2 = proj_pt2 + normal1 * dist; + Vec3d new_pt2 = proj_pt2 + normal1 * dist; Vec3d displacement = new_pt2 - pt2; diff --git a/src/slic3r/GUI/SurfaceDrag.cpp b/src/slic3r/GUI/SurfaceDrag.cpp index 6547c8d8c5..025b1d71c6 100644 --- a/src/slic3r/GUI/SurfaceDrag.cpp +++ b/src/slic3r/GUI/SurfaceDrag.cpp @@ -596,7 +596,7 @@ Transform3d get_volume_transformation( std::optional current_angle, const std::optional &up_limit) { - auto world_linear = world.linear(); + auto world_linear = world.linear().eval(); // Calculate offset: transformation to wanted position { // Reset skew of the text Z axis: @@ -609,7 +609,7 @@ Transform3d get_volume_transformation( Vec3d text_z_world = world_linear.col(2); // world_linear * Vec3d::UnitZ() auto z_rotation = Eigen::Quaternion::FromTwoVectors(text_z_world, world_dir); Transform3d world_new = z_rotation * world; - auto world_new_linear = world_new.linear(); + auto world_new_linear = world_new.linear().eval(); // Fix direction of up vector to zero initial rotation if(up_limit.has_value()){ diff --git a/src/slic3r/Utils/RaycastManager.cpp b/src/slic3r/Utils/RaycastManager.cpp index e3200a1317..c51a19ebd9 100644 --- a/src/slic3r/Utils/RaycastManager.cpp +++ b/src/slic3r/Utils/RaycastManager.cpp @@ -149,7 +149,7 @@ std::optional RaycastManager::first_hit(const Vec3d& point, // NOTE: Anisotropic transformation of normal is not perpendiculat to triangle const Vec3i32 tri = hit_mesh->indices(hit_face); std::array pts; - auto tr = hit_tramsformation->linear(); + auto tr = hit_tramsformation->linear().eval(); for (int i = 0; i < 3; ++i) pts[i] = tr * hit_mesh->vertices(tri[i]).cast(); Vec3d normal_world = (pts[1] - pts[0]).cross(pts[2] - pts[1]);