diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Optimization_plugin_cgal_code.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Optimization_plugin_cgal_code.cpp index ea98ff61bfd..3475f12e163 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Optimization_plugin_cgal_code.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Optimization_plugin_cgal_code.cpp @@ -133,6 +133,7 @@ Optimizer_thread* cgal_code_optimization(Scene_c3t3_item& c3t3_item, if ( NULL != sm_item ) { const_cast(sm_item)->setItemIsMulticolor(true); + const_cast(sm_item)->computeItemColorVectorAutomatically(true); // Build domain const SMesh* smesh = sm_item->face_graph(); if ( NULL == smesh ) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Partition_graph_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Partition_graph_plugin.cpp index 8a252edf612..c2b390a14bd 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Partition_graph_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Partition_graph_plugin.cpp @@ -97,8 +97,11 @@ private: QApplication::setOverrideCursor(Qt::WaitCursor); item->face_graph()->collect_garbage(); item->color_vector().clear(); - if(!item->hasPatchIds()) + if(!item->hasPatchIds()){ item->setItemIsMulticolor(true); + item->computeItemColorVectorAutomatically(true); + } + typedef boost::property_map >::type PatchIDMap; FaceGraph* fg =item->face_graph(); boost::property_map::type diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Detect_sharp_edges_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Detect_sharp_edges_plugin.cpp index f7f559c373c..357f34c8eca 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Detect_sharp_edges_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Detect_sharp_edges_plugin.cpp @@ -133,6 +133,7 @@ void Polyhedron_demo_detect_sharp_edges_plugin::detectSharpEdges(bool input_dial .vertex_incident_patches_map(vip)); //update item item->setItemIsMulticolor(true); + item->computeItemColorVectorAutomatically(true); item->invalidateOpenGLBuffers(); // update scene diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp index 3fa8fcca4fe..60a0209510c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Isotropic_remeshing_plugin.cpp @@ -473,7 +473,16 @@ public Q_SLOTS: } selection_item->polyhedron_item()->setColor( selection_item->polyhedron_item()->color()); - selection_item->polyhedron_item()->setItemIsMulticolor(fpmap_valid); + if(fpmap_valid) + { + selection_item->polyhedron_item()->setItemIsMulticolor(true); + selection_item->polyhedron_item()->computeItemColorVectorAutomatically(true); + } + else + { + selection_item->polyhedron_item()->setItemIsMulticolor(false); + } + selection_item->polyhedron_item()->polyhedron()->collect_garbage(); //fix constrained_edges_map for(int i=0; i< nE; ++i) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp index fa58b268279..a04801e613c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Join_and_split_polyhedra_plugin.cpp @@ -244,6 +244,7 @@ void Polyhedron_demo_join_and_split_polyhedra_plugin::on_actionColorConnectedCom typedef boost::graph_traits::face_descriptor face_descriptor; selection_item->polyhedron_item()->setItemIsMulticolor(true); + selection_item->polyhedron_item()->computeItemColorVectorAutomatically(true); FaceGraph& pmesh = *(selection_item->polyhedron()); boost::property_map::type fim diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Mean_curvature_flow_skeleton_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Mean_curvature_flow_skeleton_plugin.cpp index fb4ccf514bf..cd7f6c5fbab 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Mean_curvature_flow_skeleton_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Mean_curvature_flow_skeleton_plugin.cpp @@ -429,6 +429,7 @@ void Polyhedron_demo_mean_curvature_flow_skeleton_plugin::on_actionSegment() } item_segmentation->setItemIsMulticolor(true); + item_segmentation->computeItemColorVectorAutomatically(true); item_segmentation->setProperty("NbPatchIds", nb_segment); //for join_and_split plugin item_segmentation->invalidateOpenGLBuffers(); scene->addItem(item_segmentation); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_plane_detection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_plane_detection_plugin.cpp index 4fb812dae88..28de24b4acc 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_plane_detection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_plane_detection_plugin.cpp @@ -229,6 +229,7 @@ void Polyhedron_demo_mesh_plane_detection_plugin::colorize_segmentation( std::vector& color_vector) { item->setItemIsMulticolor(true); + item->computeItemColorVectorAutomatically(true); SMesh* sm = item->face_graph(); color_vector.clear(); std::size_t max_segment = 0; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_segmentation_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_segmentation_plugin.cpp index a4f5d553b81..02b3740984f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_segmentation_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Mesh_segmentation_plugin.cpp @@ -377,7 +377,8 @@ void Polyhedron_demo_mesh_segmentation_plugin::colorize_sdf( } put(pidmap, *facet_it, static_cast(patch_id)); } - item->setItemIsMulticolor(true, false); + item->setItemIsMulticolor(true); + item->computeItemColorVectorAutomatically(false); } @@ -407,6 +408,7 @@ void Polyhedron_demo_mesh_segmentation_plugin::colorize_segmentation( color_vector.push_back(aColor); } item->setItemIsMulticolor(true); + item->computeItemColorVectorAutomatically(true); item->setProperty("NbPatchIds", static_cast(max_segment + 1)); //for join_and_split plugin } diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h index 8791f416e93..ba3617816b1 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h @@ -793,6 +793,7 @@ public: void setItemIsMulticolor(bool b) { poly_item->setItemIsMulticolor(b); + poly_item->computeItemColorVectorAutomatically(b); } void selection_changed(bool b); diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index 1f8fb0058f5..0013b1e4313 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -1381,9 +1381,8 @@ bool Scene_surface_mesh_item::intersect_face(double orig_x, return false; } -void Scene_surface_mesh_item::setItemIsMulticolor(bool b, bool recompute_colors) +void Scene_surface_mesh_item::setItemIsMulticolor(bool b) { - this->setProperty("recompute_colors",recompute_colors); if(b) { d->fpatch_id_map = d->smesh_->add_property_map("f:patch_id", 1).first; @@ -2219,3 +2218,8 @@ void Scene_surface_mesh_item::copyProperties(Scene_item *item) int value = sm_item->alphaSlider()->value(); alphaSlider()->setValue(value); } + +void Scene_surface_mesh_item::computeItemColorVectorAutomatically(bool b) +{ + this->setProperty("recompute_colors",b); +} diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h index b38db8a218f..6f2bc777a61 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h @@ -68,11 +68,14 @@ public: QMenu* contextMenu() Q_DECL_OVERRIDE; - //first bool to set property, second to disable the recomputation of the colors_ vector - //to scale on min_patch value. For example, the Mesh_segmentation_plugin computes the colors_ - // vector itself, so it must set recompute_colors to false to avoid having it ovewritten + void setItemIsMulticolor(bool); + //to be called before invalidate() to enable or disable the recomputation + //of the colors_ vector to scale on min_patch value. + // For example, the Mesh_segmentation_plugin computes the colors_ + // vector itself, so it must set recompute_colors to false to avoid + // having it ovewritten // in the code of this item. - void setItemIsMulticolor(bool, bool recompute_colors = true); + void computeItemColorVectorAutomatically(bool); bool isItemMulticolor(); bool hasPatchIds(); Vertex_selection_map vertex_selection_map();