diff --git a/Lab/demo/Lab/Plugins/Display/Display_property_plugin.cpp b/Lab/demo/Lab/Plugins/Display/Display_property_plugin.cpp index f0eb9086215..4156305559e 100644 --- a/Lab/demo/Lab/Plugins/Display/Display_property_plugin.cpp +++ b/Lab/demo/Lab/Plugins/Display/Display_property_plugin.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -350,11 +351,11 @@ private: template void displayMapLegend(const std::vector& values) { - const std::size_t size = (std::min)(color_map.size(), std::size_t(1024)); + const std::size_t size = (std::min)(color_map.size(), std::size_t(4096)); const int text_height = 20; const int height = text_height * static_cast(size) + text_height; - const int width = 140; + const int width = 200; const int cell_width = width / 3; const int top_margin = 15; const int left_margin = 5; @@ -381,13 +382,13 @@ private: tick_height, color); - QRect text_rect(left_margin + cell_width + 10, drawing_height - top_margin - j, 50, text_height); - painter.drawText(text_rect, Qt::AlignCenter, QObject::tr("%1").arg(values[i], 0, 'f', 3, QLatin1Char(' '))); + QRect text_rect(left_margin + cell_width + 10, drawing_height - top_margin - j, 100, text_height); + painter.drawText(text_rect, Qt::AlignCenter, QObject::tr("%1").arg(values[i], 0, 'f', 6, QLatin1Char(' '))); } if(color_map.size() > size) { - QRect text_rect(left_margin + cell_width + 10, 0, 50, text_height); + QRect text_rect(left_margin + cell_width + 10, 0, 100, text_height); painter.drawText(text_rect, Qt::AlignCenter, QObject::tr("[...]")); } @@ -463,6 +464,8 @@ private: "Largest Angle Per Face", "Scaled Jacobian", "Face Area", + "Discrete Mean Curvature", + "Discrete Gaussian Curvature", "Interpolated Corrected Mean Curvature", "Interpolated Corrected Gaussian Curvature"}); property_simplex_types = { Property_simplex_type::FACE, @@ -470,6 +473,8 @@ private: Property_simplex_type::FACE, Property_simplex_type::FACE, Property_simplex_type::VERTEX, + Property_simplex_type::VERTEX, + Property_simplex_type::VERTEX, Property_simplex_type::VERTEX }; detectSMScalarProperties(*(sm_item->face_graph())); } @@ -516,12 +521,12 @@ private Q_SLOTS: // Curvature property-specific slider const std::string& property_name = dock_widget->propertyBox->currentText().toStdString(); - const bool is_curvature_property = (property_name == "Interpolated Corrected Mean Curvature" || - property_name == "Interpolated Corrected Gaussian Curvature"); - dock_widget->expandingRadiusLabel->setVisible(is_curvature_property); - dock_widget->expandingRadiusSlider->setVisible(is_curvature_property); - dock_widget->expandingRadiusLabel->setEnabled(is_curvature_property); - dock_widget->expandingRadiusSlider->setEnabled(is_curvature_property); + const bool is_interpolated_curvature_property = (property_name == "Interpolated Corrected Mean Curvature" || + property_name == "Interpolated Corrected Gaussian Curvature"); + dock_widget->expandingRadiusLabel->setVisible(is_interpolated_curvature_property); + dock_widget->expandingRadiusSlider->setVisible(is_interpolated_curvature_property); + dock_widget->expandingRadiusLabel->setEnabled(is_interpolated_curvature_property); + dock_widget->expandingRadiusSlider->setEnabled(is_interpolated_curvature_property); } else // no or broken property { @@ -570,6 +575,16 @@ private: { displayArea(sm_item); } + else if(property_name == "Discrete Mean Curvature") + { + displayDiscreteCurvatureMeasure(sm_item, MEAN_CURVATURE); + sm_item->setRenderingMode(Gouraud); + } + else if(property_name == "Discrete Gaussian Curvature") + { + displayDiscreteCurvatureMeasure(sm_item, GAUSSIAN_CURVATURE); + sm_item->setRenderingMode(Gouraud); + } else if(property_name == "Interpolated Corrected Mean Curvature") { displayInterpolatedCurvatureMeasure(sm_item, MEAN_CURVATURE); @@ -682,6 +697,8 @@ private: removeDisplayPluginProperty(item, "f:display_plugin_largest_angle"); removeDisplayPluginProperty(item, "f:display_plugin_scaled_jacobian"); removeDisplayPluginProperty(item, "f:display_plugin_area"); + removeDisplayPluginProperty(item, "v:display_plugin_discrete_mean_curvature"); + removeDisplayPluginProperty(item, "v:display_plugin_discrete_Gaussian_curvature"); removeDisplayPluginProperty(item, "v:display_plugin_interpolated_corrected_mean_curvature"); removeDisplayPluginProperty(item, "v:display_plugin_interpolated_corrected_Gaussian_curvature"); } @@ -864,6 +881,35 @@ private: displaySMProperty("f:display_plugin_area", *sm); } +private: + void displayDiscreteCurvatureMeasure(Scene_surface_mesh_item* sm_item, + CurvatureType mu_index) + { + SMesh* sm = sm_item->face_graph(); + if(sm == nullptr) + return; + + if(mu_index != MEAN_CURVATURE && mu_index != GAUSSIAN_CURVATURE) + return; + + std::string vdc_name = (mu_index == MEAN_CURVATURE) ? "v:display_plugin_discrete_mean_curvature" + : "v:display_plugin_discrete_Gaussian_curvature"; + + bool not_initialized; + SMesh::Property_map vdc; + std::tie(vdc, not_initialized) = sm->add_property_map(vdc_name, 0); + + if(not_initialized) + { + if(mu_index == MEAN_CURVATURE) + PMP::discrete_mean_curvatures(*sm, vdc); + else + PMP::discrete_Gaussian_curvatures(*sm, vdc); + } + + displaySMProperty(vdc_name, *sm); + } + private Q_SLOTS: void setExpandingRadius() { @@ -1131,6 +1177,10 @@ private: zoomToSimplexWithPropertyExtremum(faces(mesh), mesh, "f:display_plugin_scaled_jacobian", extremum); else if(property_name == "Face Area") zoomToSimplexWithPropertyExtremum(faces(mesh), mesh, "f:display_plugin_area", extremum); + else if(property_name == "Discrete Mean Curvature") + zoomToSimplexWithPropertyExtremum(vertices(mesh), mesh, "v:display_plugin_discrete_mean_curvature", extremum); + else if(property_name == "Discrete Gaussian Curvature") + zoomToSimplexWithPropertyExtremum(vertices(mesh), mesh, "v:display_plugin_discrete_Gaussian_curvature", extremum); else if(property_name == "Interpolated Corrected Mean Curvature") zoomToSimplexWithPropertyExtremum(vertices(mesh), mesh, "v:display_plugin_interpolated_corrected_mean_curvature", extremum); else if(property_name == "Interpolated Corrected Gaussian Curvature") @@ -1470,6 +1520,8 @@ isSMPropertyScalar(const std::string& name, name == "f:display_plugin_largest_angle" || name == "f:display_plugin_scaled_jacobian" || name == "f:display_plugin_area" || + name == "v:display_plugin_discrete_mean_curvature" || + name == "v:display_plugin_discrete_Gaussian_curvature" || name == "v:display_plugin_interpolated_corrected_mean_curvature" || name == "v:display_plugin_interpolated_corrected_Gaussian_curvature") return false;