From 97e69c04f87a4b3d6d34b406c56808b8e04f27e5 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 30 Sep 2022 08:52:38 +0200 Subject: [PATCH] Fixed crashing asserts due to a bug in the just merged branch --- src/libslic3r/Measure.cpp | 1 + src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp | 26 +++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/libslic3r/Measure.cpp b/src/libslic3r/Measure.cpp index fbf248c0f..78d3d524e 100644 --- a/src/libslic3r/Measure.cpp +++ b/src/libslic3r/Measure.cpp @@ -646,6 +646,7 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature& angle = std::acos(std::abs(normal1.dot(normal2))); } result.angle = std::make_optional(AngleAndPoints(angle, Vec3d::Zero(), Vec3d::UnitX(), Vec3d::UnitX(), 0., false)); // TODO + result.distance_infinite = std::make_optional(DistAndPoints{0., Vec3d::Zero(), Vec3d::Zero()}); // TODO } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp index 568d5db3a..6aebd0fa3 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp @@ -858,8 +858,8 @@ void GLGizmoMeasure::render_dimensioning() const double radius = res.angle->radius; const bool coplanar = res.angle->coplanar; - std::pair e1 = m_selected_features.first.feature->get_edge(); - std::pair e2 = m_selected_features.second.feature->get_edge(); + std::pair e1 = f1.get_edge(); + std::pair e2 = f2.get_edge(); if ((e1.second - e1.first).dot(e1_unit) < 0.) std::swap(e1.first, e1.second); @@ -1019,23 +1019,25 @@ void GLGizmoMeasure::render_dimensioning() : *m_measurement_result.distance_strict; point_point(dap.from, dap.to); - const Measure::SurfaceFeature& f1 = *m_selected_features.first.feature; - const Measure::SurfaceFeature& f2 = *m_selected_features.second.feature; - Measure::SurfaceFeatureType ft1 = f1.get_type(); - Measure::SurfaceFeatureType ft2 = f2.get_type(); + const Measure::SurfaceFeature* f1 = &(*m_selected_features.first.feature); + const Measure::SurfaceFeature* f2 = &(*m_selected_features.second.feature); + Measure::SurfaceFeatureType ft1 = f1->get_type(); + Measure::SurfaceFeatureType ft2 = f2->get_type(); + // Order features by type so following conditions are simple. + if (ft2 > ft2) + std::swap(ft1, ft2); // Where needed, draw also the extension of the edge to where the dist is measured: - if ((int(ft1) | int(ft2)) == - (int(Measure::SurfaceFeatureType::Point) | int(Measure::SurfaceFeatureType::Edge))) - point_edge(f1, f2); + if (ft1 == Measure::SurfaceFeatureType::Point && ft2 == Measure::SurfaceFeatureType::Edge) + point_edge(*f1, *f2); // Now if there is an angle to show, draw the arc: if (ft1 == Measure::SurfaceFeatureType::Edge && ft2 == Measure::SurfaceFeatureType::Edge) - arc_edge_edge(f1, f2); - if (int(ft1) | int(ft2) == (int(Measure::SurfaceFeatureType::Edge) | int(Measure::SurfaceFeatureType::Plane))) - arc_edge_plane(f1, f2); + arc_edge_edge(*f1, *f2); + if (ft1 == Measure::SurfaceFeatureType::Edge && ft2 == Measure::SurfaceFeatureType::Plane) + arc_edge_plane(*f1, *f2); }