From 0e43336beff50e96d48d060b24f0e052824e5a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 28 May 2024 08:39:50 +0200 Subject: [PATCH 1/4] Fix using the fcolor pmap when there is no face color --- Lab/demo/Lab/Scene_surface_mesh_item.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Lab/demo/Lab/Scene_surface_mesh_item.cpp b/Lab/demo/Lab/Scene_surface_mesh_item.cpp index 5c021784cd1..30e0d59ab83 100644 --- a/Lab/demo/Lab/Scene_surface_mesh_item.cpp +++ b/Lab/demo/Lab/Scene_surface_mesh_item.cpp @@ -626,11 +626,17 @@ void Scene_surface_mesh_item_priv::compute_elements(Scene_item_rendering_helper: } else if(is_convex) { - triangulate_convex_facet(fd, &fnormals, &fcolors.value(), nullptr, name, false); + if(has_fcolors) + triangulate_convex_facet(fd, &fnormals, &fcolors.value(), nullptr, name, false); + else + triangulate_convex_facet(fd, &fnormals, nullptr, nullptr, name, false); } else { - triangulate_facet(fd, &fnormals, &fcolors.value(), nullptr, name, false); + if(has_fcolors) + triangulate_facet(fd, &fnormals, &fcolors.value(), nullptr, name, false); + else + triangulate_facet(fd, &fnormals, nullptr, nullptr, name, false); } } } From b5c6abf6d09923cb8737efe0618e694bb7c9a496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 29 May 2024 12:28:28 +0200 Subject: [PATCH 2/4] Fix CC selection + Selection widget UI improvements --- Lab/demo/Lab/Plugins/PMP/Selection_plugin.cpp | 68 ++- Lab/demo/Lab/Plugins/PMP/Selection_widget.ui | 467 +++++++++--------- .../Lab/Scene_polyhedron_selection_item.h | 7 +- Lab/demo/Lab/Travel_isolated_components.h | 14 +- 4 files changed, 303 insertions(+), 253 deletions(-) diff --git a/Lab/demo/Lab/Plugins/PMP/Selection_plugin.cpp b/Lab/demo/Lab/Plugins/PMP/Selection_plugin.cpp index f9ce55fd6f7..6f2f95671ae 100644 --- a/Lab/demo/Lab/Plugins/PMP/Selection_plugin.cpp +++ b/Lab/demo/Lab/Plugins/PMP/Selection_plugin.cpp @@ -211,8 +211,13 @@ public: connect(ui_widget.selectionOrEuler, SIGNAL(currentChanged(int)), this, SLOT(on_SelectionOrEuler_changed(int))); connect(ui_widget.editionBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_editionBox_changed(int))); + ui_widget.Sharp_edges_label->hide(); + ui_widget.Sharp_angle_spinbox->hide(); + ui_widget.Select_sharp_edges_button->hide(); + ui_widget.Select_boundaryButton->hide(); ui_widget.Add_to_selection_button->hide(); ui_widget.Select_all_NTButton->hide(); + QObject* scene = dynamic_cast(scene_interface); if(scene) { connect(scene, SIGNAL(itemAboutToBeDestroyed(CGAL::Three::Scene_item*)), this, SLOT(item_about_to_be_destroyed(CGAL::Three::Scene_item*))); @@ -544,55 +549,84 @@ public Q_SLOTS: for(Selection_item_map::iterator it = selection_item_map.begin(); it != selection_item_map.end(); ++it) { it->second->set_lasso_mode(b); + ui_widget.Brush_label->setEnabled(!b); + ui_widget.Brush_size_spin_box->setEnabled(!b); + ui_widget.Brush_size_spin_box->setValue(0); } } void on_Selection_type_combo_box_changed(int index) { + std::cout << "on_Selection_type_combo_box_changed(" << index << ")" << std::endl; + typedef Scene_polyhedron_selection_item::Active_handle Active_handle; for(Selection_item_map::iterator it = selection_item_map.begin(); it != selection_item_map.end(); ++it) { it->second->set_active_handle_type(static_cast(index)); Q_EMIT save_handleType(); + + it->second->setPathSelection(false); + + ui_widget.Sharp_edges_label->hide(); + ui_widget.Sharp_angle_spinbox->hide(); + ui_widget.Select_sharp_edges_button->hide(); + ui_widget.Select_boundaryButton->hide(); + ui_widget.Add_to_selection_button->hide(); + ui_widget.Select_all_NTButton->hide(); + + ui_widget.Get_minimum_button->setEnabled(false); + ui_widget.Select_isolated_components_button->setEnabled(false); + switch(index) { - case 0: - case 1: - case 2: + case 0: // vertex + case 1: // face + case 2: // edge ui_widget.lassoCheckBox->show(); + ui_widget.Brush_label->show(); + ui_widget.Brush_size_spin_box->show(); + + ui_widget.Get_minimum_button->setEnabled(true); + ui_widget.Select_isolated_components_button->setEnabled(true); break; + case 3: // CC of faces + case 4: // Path of edges default: ui_widget.lassoCheckBox->hide(); ui_widget.lassoCheckBox->setChecked(false); it->second->set_lasso_mode(false); + ui_widget.Brush_label->hide(); + ui_widget.Brush_size_spin_box->hide(); + ui_widget.Brush_size_spin_box->setValue(0); break; } - if(index == 1) + + if(index == 0) // vertex + { + Q_EMIT set_operation_mode(-1); + } + else if(index == 1) // face { ui_widget.Select_all_NTButton->show(); - ui_widget.Add_to_selection_button->hide(); - ui_widget.Select_boundaryButton->hide(); Q_EMIT set_operation_mode(-1); } - else if(index == 2) + else if(index == 2) // edge { - ui_widget.Select_all_NTButton->hide(); - ui_widget.Add_to_selection_button->hide(); ui_widget.Select_boundaryButton->show(); + ui_widget.Sharp_angle_spinbox->show(); + ui_widget.Select_sharp_edges_button->show(); Q_EMIT set_operation_mode(-1); } - else if(index == 4) + else if(index == 3) // CC of faces + { + Q_EMIT set_operation_mode(-1); + } + else if(index == 4) // Path of edges { it->second->setPathSelection(true); - ui_widget.Select_all_NTButton->hide(); ui_widget.Add_to_selection_button->show(); - ui_widget.Select_boundaryButton->show(); Q_EMIT set_operation_mode(-2); } else { - ui_widget.Add_to_selection_button->hide(); - ui_widget.Select_all_NTButton->hide(); - ui_widget.Select_boundaryButton->hide(); - it->second->setPathSelection(false); - Q_EMIT set_operation_mode(-1); + std::cerr << "Error: unknown selection type" << std::endl; } } filter_operations(); diff --git a/Lab/demo/Lab/Plugins/PMP/Selection_widget.ui b/Lab/demo/Lab/Plugins/PMP/Selection_widget.ui index f7d5f7e6302..a2d7fbd6b45 100644 --- a/Lab/demo/Lab/Plugins/PMP/Selection_widget.ui +++ b/Lab/demo/Lab/Plugins/PMP/Selection_widget.ui @@ -6,8 +6,8 @@ 0 0 - 613 - 409 + 630 + 532 @@ -21,7 +21,6 @@ - 75 true @@ -30,20 +29,20 @@ - - - - - - - Clear Selection - - - + + + + Show selector + + + true + + + @@ -57,16 +56,6 @@ - - - - Highlight - - - true - - - @@ -79,12 +68,52 @@ Selection + + + + + + Selection Type : + + + + + + + + Vertex + + + + + Facet + + + + + Edge + + + + + Facet Connected Component + + + + + Edge Path Between Vertices + + + + + + - 0 + 1 @@ -92,42 +121,55 @@ - + - - - Selection Type : - - + + + + + Insertion + + + true + + + + + + + Removal + + + + - + - - Vertex - + + + Lasso + + + + + + + + + + + Brush &size: + + + Brush_size_spin_box + + - - Facet - + - - - Edge - - - - - Connected Component (Facet) - - - - - Path Between Vertices - - - + @@ -145,36 +187,9 @@ - - - - - Lasso - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - + - - - - Select All Non Triangle - - - @@ -182,21 +197,78 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Sharp edges angle: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + 180 + + + 60 + + + + + + + Select + + + + + + + + + + 0 + 0 + + + + Add Path to Selection + + + + + + + Select All Non Triangle Facets + + + - - - - - 0 - 0 - - - - Add to Selection - - - @@ -212,40 +284,6 @@ - - - - - - Insertion - - - true - - - - - - - Removal - - - - - - - Brush &size: - - - Brush_size_spin_box - - - - - - - - @@ -253,55 +291,6 @@ Components - - - - - - - 0 - 0 - - - - Threshold: - - - Threshold_size_spin_box - - - - - - - - 0 - 0 - - - - 999999999 - - - 8 - - - - - - - - 0 - 0 - - - - &Get Minimum - - - - - @@ -316,11 +305,64 @@ - - - Select &Isolated Components Below Threshold - - + + + + + + + + 0 + 0 + + + + Threshold: + + + Threshold_size_spin_box + + + + + + + + 0 + 0 + + + + 999999999 + + + 8 + + + + + + + + + + 0 + 0 + + + + Set Threshold to Simplex Count of Smallest CC + + + + + + + Select CCs With Simplex Count Below Threshold + + + + @@ -335,43 +377,6 @@ - - - - - - Sharp edges angle: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - 180 - - - 60 - - - - - - - Select - - - - - @@ -432,12 +437,12 @@ - + - + - &Clear Current Type + Select &All Current Type @@ -452,12 +457,22 @@ - + - + - Select &All + &Clear Current Type + + + + + + + + + + Clear All @@ -638,7 +653,7 @@ - Instructions + Instructions diff --git a/Lab/demo/Lab/Scene_polyhedron_selection_item.h b/Lab/demo/Lab/Scene_polyhedron_selection_item.h index ff58bf5a658..c74837396e4 100644 --- a/Lab/demo/Lab/Scene_polyhedron_selection_item.h +++ b/Lab/demo/Lab/Scene_polyhedron_selection_item.h @@ -501,7 +501,7 @@ public: Selection_traits tr(this); Travel_isolated_components::Minimum_visitor visitor; Travel_isolated_components(*polyhedron()).travel - (tr.iterator_begin(), tr.iterator_end(), tr.size(), tr.container(), visitor); + (tr.iterator_begin(), tr.iterator_end(), tr.size(), visitor); return visitor.minimum; } @@ -516,7 +516,8 @@ public: } } template // use fg_vertex_descriptor, fg_face_descriptor, fg_edge_descriptor - std::optional select_isolated_components(std::size_t threshold) { + std::optional select_isolated_components(std::size_t threshold) + { typedef Selection_traits Tr; Tr tr(this); typedef std::insert_iterator Output_iterator; @@ -524,7 +525,7 @@ public: Travel_isolated_components::Selection_visitor visitor(threshold , out); Travel_isolated_components(*polyhedron()).travel - (tr.iterator_begin(), tr.iterator_end(), tr.size(), tr.container(), visitor); + (tr.iterator_begin(), tr.iterator_end(), tr.size(), visitor); if(visitor.any_inserted) { invalidateOpenGLBuffers(); Q_EMIT itemChanged(); } return visitor.minimum_visitor.minimum; diff --git a/Lab/demo/Lab/Travel_isolated_components.h b/Lab/demo/Lab/Travel_isolated_components.h index c1e1124f6b2..3ca03d70e1e 100644 --- a/Lab/demo/Lab/Travel_isolated_components.h +++ b/Lab/demo/Lab/Travel_isolated_components.h @@ -110,11 +110,10 @@ public: } */ // NOTE: prior to call this function, id fields should be updated - template + template void travel(InputIterator begin, InputIterator end, std::size_t size, - const IsSelected& selection, Visitor& visitor) { std::vector mark(size, false); @@ -123,28 +122,29 @@ public: { Descriptor h = *begin; - if(mark[id(h)] || selection.count(h)) { continue; } + if(mark[id(h)]) + continue; std::vector C; C.push_back(h); mark[id(h)] = true; std::size_t current_index = 0; - bool neigh_to_selection = false; while(current_index < C.size()) { Descriptor current = C[current_index++]; for(One_ring_iterator circ(current, mesh); circ; ++circ) { Descriptor nv = circ; - neigh_to_selection |= (selection.count(nv)!=0); - if(!mark[id(nv)] && !selection.count(nv)) { + if(!mark[id(nv)]) + { mark[id(nv)] = true; C.push_back(nv); } } } - if(neigh_to_selection) { visitor(C); } + + visitor(C); } } }; From 8e0e94b63a01f863865381ea010195e8f30a7f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 29 May 2024 12:29:05 +0200 Subject: [PATCH 3/4] Remove not useful CC selection in deformation widget --- .../Surface_mesh_deformation/Deform_mesh.ui | 43 +------------------ .../Edit_polyhedron_plugin.cpp | 26 ----------- .../Scene_edit_polyhedron_item.cpp | 22 ---------- .../Scene_edit_polyhedron_item.h | 1 - 4 files changed, 2 insertions(+), 90 deletions(-) diff --git a/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Deform_mesh.ui b/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Deform_mesh.ui index 2f7fdca658e..4f985764876 100644 --- a/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Deform_mesh.ui +++ b/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Deform_mesh.ui @@ -6,8 +6,8 @@ 0 0 - 547 - 347 + 561 + 294 @@ -135,45 +135,6 @@ - - - - - - - - Isolated Component Size: - - - - - - - 999999999 - - - 8 - - - - - - - Get Minimum - - - - - - - - - Select Isolated Components Below Threshold - - - - - diff --git a/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Edit_polyhedron_plugin.cpp b/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Edit_polyhedron_plugin.cpp index c83ba2b196d..1fb180c2526 100644 --- a/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Edit_polyhedron_plugin.cpp +++ b/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Edit_polyhedron_plugin.cpp @@ -62,8 +62,6 @@ public Q_SLOTS: void on_SaveROIPushButton_clicked(); void on_ReadROIPushButton_clicked(); void dock_widget_visibility_changed(bool visible); - void on_Select_isolated_components_button_clicked(); - void on_Get_minimum_button_clicked(); void on_BrushSpinBoxCtrlVert_changed(int); void on_BrushSpinBoxRoi_changed(int); @@ -150,8 +148,6 @@ void CGAL_Lab_edit_cgal_lab_plugin::init(QMainWindow* mainWindow, CGAL::Three::S connect(ui_widget.ActivateFixedPlaneCheckBox, SIGNAL(stateChanged(int)), this, SLOT(on_ActivateFixedPlaneCheckBox_stateChanged(int))); connect(ui_widget.ActivatePivotingCheckBox, SIGNAL(stateChanged(int)), this, SLOT(on_ActivatePivotingCheckBox_stateChanged(int))); connect(ui_widget.OverwritePushButton, SIGNAL(clicked()), this, SLOT(on_OverwritePushButton_clicked())); - connect(ui_widget.Select_isolated_components_button, SIGNAL(clicked()), this, SLOT(on_Select_isolated_components_button_clicked())); - connect(ui_widget.Get_minimum_button, SIGNAL(clicked()), this, SLOT(on_Get_minimum_button_clicked())); connect(ui_widget.SaveROIPushButton, SIGNAL(clicked()), this, SLOT(on_SaveROIPushButton_clicked())); connect(ui_widget.ReadROIPushButton, SIGNAL(clicked()), this, SLOT(on_ReadROIPushButton_clicked())); @@ -304,28 +300,6 @@ void CGAL_Lab_edit_cgal_lab_plugin::on_OverwritePushButton_clicked() edit_item->overwrite_deform_object(); } -void CGAL_Lab_edit_cgal_lab_plugin::on_Select_isolated_components_button_clicked() { - int item_id = scene->selectionIndices().front(); - Scene_edit_polyhedron_item* edit_item = qobject_cast(scene->item(item_id)); - if(!edit_item) return; // the selected item is not of the right type - - std::optional minimum = - edit_item->select_isolated_components(ui_widget.Threshold_size_spin_box->value()); - if(minimum) { - ui_widget.Threshold_size_spin_box->setValue((int) *minimum); - } -} - -void CGAL_Lab_edit_cgal_lab_plugin::on_Get_minimum_button_clicked() { - int item_id = scene->selectionIndices().front(); - Scene_edit_polyhedron_item* edit_item = qobject_cast(scene->item(item_id)); - if(!edit_item) return; // the selected item is not of the right type - - std::optional minimum = edit_item->get_minimum_isolated_component(); - if(minimum) { - ui_widget.Threshold_size_spin_box->setValue((int) *minimum); - } -} void CGAL_Lab_edit_cgal_lab_plugin::on_SaveROIPushButton_clicked() { diff --git a/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.cpp b/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.cpp index 86cd884ed14..786727bc145 100644 --- a/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.cpp +++ b/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.cpp @@ -1621,28 +1621,6 @@ void Scene_edit_polyhedron_item::reset_deform_object() refresh_all_group_centers(); } -std::optional Scene_edit_polyhedron_item::get_minimum_isolated_component() { - Travel_isolated_components::Minimum_visitor visitor; - Travel_isolated_components(*surface_mesh()).travel - (vertices(*surface_mesh()).first, vertices(*surface_mesh()).second, - num_vertices(*surface_mesh()), Is_selected(d->deform_sm_mesh), visitor); - return visitor.minimum; -} - - -std::optional Scene_edit_polyhedron_item::select_isolated_components(std::size_t threshold) { - typedef boost::function_output_iterator > Output_iterator; - Output_iterator out(d->deform_sm_mesh); - - Travel_isolated_components::Selection_visitor visitor(threshold, out); - Travel_isolated_components(*surface_mesh()).travel - (vertices(*surface_mesh()).first, vertices(*surface_mesh()).second, - num_vertices(*surface_mesh()), Is_selected(d->deform_sm_mesh), visitor); - - if(visitor.any_inserted) { invalidateOpenGLBuffers(); Q_EMIT itemChanged(); } - return visitor.minimum_visitor.minimum; -} - bool Scene_edit_polyhedron_item::is_there_any_ctrl_vertices_group() { if(d->sm_item) diff --git a/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.h b/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.h index cd185bd797d..4479cc63cc1 100644 --- a/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.h +++ b/Lab/demo/Lab/Plugins/Surface_mesh_deformation/Scene_edit_polyhedron_item.h @@ -379,7 +379,6 @@ public: } }; - std::optional get_minimum_isolated_component(); template struct Select_roi_output{ typedef typename CGAL::Surface_mesh_deformation Date: Wed, 29 May 2024 13:53:22 +0200 Subject: [PATCH 4/4] Fix default tab being components --- Lab/demo/Lab/Plugins/PMP/Selection_widget.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lab/demo/Lab/Plugins/PMP/Selection_widget.ui b/Lab/demo/Lab/Plugins/PMP/Selection_widget.ui index a2d7fbd6b45..d7b76c83d06 100644 --- a/Lab/demo/Lab/Plugins/PMP/Selection_widget.ui +++ b/Lab/demo/Lab/Plugins/PMP/Selection_widget.ui @@ -113,7 +113,7 @@ - 1 + 0