Don't add empty items in plugin

This commit is contained in:
Maxime Gimeno 2021-04-01 15:39:45 +02:00
parent 34e2180b22
commit 0dd0b96586
1 changed files with 30 additions and 17 deletions

View File

@ -98,18 +98,25 @@ void Polyhedron_demo_diff_between_meshes_plugin::diff()
Filtered_graph filter1(m1, m1_only);
SMesh mesh1_only, mesh2_only, common_mesh;
CGAL::copy_face_graph(filter1, mesh1_only);
Scene_surface_mesh_item* mesh1_only_item = new Scene_surface_mesh_item(mesh1_only);
mesh1_only_item->setColor(QColor(Qt::blue));
mesh1_only_item->setName(QString("%1_only").arg(m1_item->name()));
CGAL::Three::Three::scene()->addItem(mesh1_only_item);
Scene_surface_mesh_item* mesh1_only_item = nullptr;
if(mesh1_only.faces().size() > 0)
{
mesh1_only_item = new Scene_surface_mesh_item(mesh1_only);
mesh1_only_item->setColor(QColor(Qt::blue));
mesh1_only_item->setName(QString("%1_only").arg(m1_item->name()));
CGAL::Three::Three::scene()->addItem(mesh1_only_item);
}
Filtered_graph filter2(m2, m2_only);
CGAL::copy_face_graph(filter2, mesh2_only);
Scene_surface_mesh_item* mesh2_only_item = new Scene_surface_mesh_item(mesh2_only);
mesh2_only_item->setColor(QColor(Qt::red));
mesh2_only_item->setName(QString("%1_only").arg(m2_item->name()));
CGAL::Three::Three::scene()->addItem(mesh2_only_item);
Scene_surface_mesh_item* mesh2_only_item = nullptr;
if(mesh2_only.faces().size() > 0)
{
mesh2_only_item = new Scene_surface_mesh_item(mesh2_only);
mesh2_only_item->setColor(QColor(Qt::red));
mesh2_only_item->setName(QString("%1_only").arg(m2_item->name()));
CGAL::Three::Three::scene()->addItem(mesh2_only_item);
}
m1_only.clear();
m1_only.reserve(common.size());
for(const auto& f_pair : common)
@ -118,17 +125,23 @@ void Polyhedron_demo_diff_between_meshes_plugin::diff()
}
Filtered_graph filter_common(m1, m1_only);
CGAL::copy_face_graph(filter_common, common_mesh);
Scene_surface_mesh_item* common_item = new Scene_surface_mesh_item(common_mesh);
common_item->setColor(QColor(Qt::green));
CGAL::Three::Three::scene()->addItem(common_item);
common_item->setName(QString("%1 && %2").arg(m1_item->name()).arg(m2_item->name()));
Scene_surface_mesh_item* common_item = nullptr;
if(common_mesh.faces().size() > 0)
{
common_item = new Scene_surface_mesh_item(common_mesh);
common_item->setColor(QColor(Qt::green));
CGAL::Three::Three::scene()->addItem(common_item);
common_item->setName(QString("%1 && %2").arg(m1_item->name()).arg(m2_item->name()));
}
Scene_group_item* group = new Scene_group_item();
group->setName("Diff result");
CGAL::Three::Three::scene()->addItem(group);
CGAL::Three::Three::scene()->changeGroup(mesh1_only_item, group);
CGAL::Three::Three::scene()->changeGroup(mesh2_only_item, group);
CGAL::Three::Three::scene()->changeGroup(common_item, group);
if(mesh1_only_item)
CGAL::Three::Three::scene()->changeGroup(mesh1_only_item, group);
if(mesh2_only_item)
CGAL::Three::Three::scene()->changeGroup(mesh2_only_item, group);
if(common_item)
CGAL::Three::Three::scene()->changeGroup(common_item, group);
m1_item->setVisible(false);
m2_item->setVisible(false);