mirror of https://github.com/CGAL/cgal
Secure the invalid c3t3_items to keep from calling algorithm that won't work on them.
This commit is contained in:
parent
a50606ca6f
commit
45effcef68
|
|
@ -97,6 +97,7 @@ Polyhedron_demo_c3t3_binary_io_plugin::load(QFileInfo fileinfo) {
|
|||
Scene_c3t3_item* item = new Scene_c3t3_item();
|
||||
item->setName(fileinfo.baseName());
|
||||
item->setScene(scene);
|
||||
item->set_valid(false);
|
||||
std::vector<bool> border_infos;
|
||||
bool facets_in_complex = false;
|
||||
if(CGAL::build_triangulation_from_file<C3t3::Triangulation, true>(in, item->c3t3().triangulation(), border_infos))
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ public:
|
|||
{
|
||||
return QList<QAction*>() << actionCreateRib;
|
||||
}
|
||||
bool applicable(QAction*)const{return qobject_cast<Scene_c3t3_item*>(scene->item(scene->mainSelectionIndex()));}
|
||||
bool applicable(QAction*)const{
|
||||
Scene_c3t3_item* item = qobject_cast<Scene_c3t3_item*>(scene->item(scene->mainSelectionIndex()));
|
||||
return item && item->is_valid();}
|
||||
|
||||
public Q_SLOTS:
|
||||
void create_rib();
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public:
|
|||
bool applicable(QAction* a) const {
|
||||
Scene_c3t3_item* item
|
||||
= qobject_cast<Scene_c3t3_item*>(scene->item(scene->mainSelectionIndex()));
|
||||
if (NULL == item)
|
||||
if (NULL == item || !item->is_valid())
|
||||
return false;
|
||||
|
||||
if (a == actionOdt || a == actionLloyd)
|
||||
|
|
|
|||
|
|
@ -231,6 +231,7 @@ struct Scene_c3t3_item_priv {
|
|||
, histogram_()
|
||||
, surface_patch_indices_()
|
||||
, subdomain_indices_()
|
||||
, is_valid(true)
|
||||
{
|
||||
init_default_values();
|
||||
}
|
||||
|
|
@ -241,6 +242,7 @@ struct Scene_c3t3_item_priv {
|
|||
, histogram_()
|
||||
, surface_patch_indices_()
|
||||
, subdomain_indices_()
|
||||
, is_valid(true)
|
||||
{
|
||||
init_default_values();
|
||||
}
|
||||
|
|
@ -389,6 +391,7 @@ struct Scene_c3t3_item_priv {
|
|||
bool show_tetrahedra;
|
||||
bool is_aabb_tree_built;
|
||||
bool cnc_are_shown;
|
||||
bool is_valid;
|
||||
};
|
||||
|
||||
struct Set_show_tetrahedra {
|
||||
|
|
@ -1129,20 +1132,22 @@ QMenu* Scene_c3t3_item::contextMenu()
|
|||
SIGNAL(triggered()), this,
|
||||
SLOT(export_facets_in_complex()));
|
||||
|
||||
QAction* actionShowSpheres =
|
||||
menu->addAction(tr("Show protecting &spheres"));
|
||||
actionShowSpheres->setCheckable(true);
|
||||
actionShowSpheres->setObjectName("actionShowSpheres");
|
||||
connect(actionShowSpheres, SIGNAL(toggled(bool)),
|
||||
this, SLOT(show_spheres(bool)));
|
||||
|
||||
QAction* actionShowCNC =
|
||||
menu->addAction(tr("Show cells not in complex"));
|
||||
actionShowCNC->setCheckable(true);
|
||||
actionShowCNC->setObjectName("actionShowCNC");
|
||||
connect(actionShowCNC, SIGNAL(toggled(bool)),
|
||||
this, SLOT(show_cnc(bool)));
|
||||
if(is_valid())
|
||||
{
|
||||
QAction* actionShowSpheres =
|
||||
menu->addAction(tr("Show protecting &spheres"));
|
||||
actionShowSpheres->setCheckable(true);
|
||||
actionShowSpheres->setObjectName("actionShowSpheres");
|
||||
connect(actionShowSpheres, SIGNAL(toggled(bool)),
|
||||
this, SLOT(show_spheres(bool)));
|
||||
|
||||
QAction* actionShowCNC =
|
||||
menu->addAction(tr("Show cells not in complex"));
|
||||
actionShowCNC->setCheckable(true);
|
||||
actionShowCNC->setObjectName("actionShowCNC");
|
||||
connect(actionShowCNC, SIGNAL(toggled(bool)),
|
||||
this, SLOT(show_cnc(bool)));
|
||||
}
|
||||
QAction* actionShowTets =
|
||||
menu->addAction(tr("Show &tetrahedra"));
|
||||
actionShowTets->setCheckable(true);
|
||||
|
|
@ -1624,4 +1629,13 @@ void Scene_c3t3_item::copyProperties(Scene_item *item)
|
|||
|
||||
show_grid(c3t3_item->has_grid());
|
||||
}
|
||||
|
||||
bool Scene_c3t3_item::is_valid() const
|
||||
{
|
||||
return d->is_valid;
|
||||
}
|
||||
void Scene_c3t3_item::set_valid(bool b)
|
||||
{
|
||||
d->is_valid = b;
|
||||
}
|
||||
#include "Scene_c3t3_item.moc"
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ public:
|
|||
|
||||
void c3t3_changed();
|
||||
|
||||
void set_valid(bool);
|
||||
|
||||
const C3t3& c3t3() const;
|
||||
C3t3& c3t3();
|
||||
|
||||
|
|
@ -70,6 +72,7 @@ public:
|
|||
bool has_grid() const;
|
||||
bool has_cnc() const;
|
||||
bool has_tets() const;
|
||||
bool is_valid() const;//true if the c3t3 is correct, false if it was made from a .mesh, for example
|
||||
ManipulatedFrame* manipulatedFrame();
|
||||
|
||||
void setPosition(float x, float y, float z) ;
|
||||
|
|
|
|||
Loading…
Reference in New Issue