mirror of https://github.com/CGAL/cgal
Mesh_3_optimization_plugin
+ Add an error window if selected object is not a scene_c3t3_item
This commit is contained in:
parent
90c4a4f0e2
commit
660d56a9b1
|
|
@ -75,6 +75,8 @@ public slots:
|
||||||
void optimization_done(Optimizer_thread* t);
|
void optimization_done(Optimizer_thread* t);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Scene_c3t3_item* get_c3t3_item() const;
|
||||||
|
|
||||||
void treat_result(Scene_c3t3_item& source_item, Scene_c3t3_item& result_item,
|
void treat_result(Scene_c3t3_item& source_item, Scene_c3t3_item& result_item,
|
||||||
const QString& name) const;
|
const QString& name) const;
|
||||||
|
|
||||||
|
|
@ -143,22 +145,10 @@ void
|
||||||
Mesh_3_optimization_plugin::odt()
|
Mesh_3_optimization_plugin::odt()
|
||||||
{
|
{
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Get source item
|
// Get c3t3 item
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
const Scene_interface::Item_id index = scene->mainSelectionIndex();
|
Scene_c3t3_item* item = get_c3t3_item();
|
||||||
Scene_c3t3_item* item = qobject_cast<Scene_c3t3_item*>(scene->item(index));
|
if ( NULL == item ) { return; }
|
||||||
|
|
||||||
if ( NULL == item )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( NULL == item->data_item() )
|
|
||||||
{
|
|
||||||
QMessageBox::critical(mw,tr(""),
|
|
||||||
tr("Can't optimize: data object has been destroyed !"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Dialog box
|
// Dialog box
|
||||||
|
|
@ -218,22 +208,10 @@ void
|
||||||
Mesh_3_optimization_plugin::lloyd()
|
Mesh_3_optimization_plugin::lloyd()
|
||||||
{
|
{
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Get source item
|
// Get c3t3 item
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
const Scene_interface::Item_id index = scene->mainSelectionIndex();
|
Scene_c3t3_item* item = get_c3t3_item();
|
||||||
Scene_c3t3_item* item = qobject_cast<Scene_c3t3_item*>(scene->item(index));
|
if ( NULL == item ) { return; }
|
||||||
|
|
||||||
if ( NULL == item )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( NULL == item->data_item() )
|
|
||||||
{
|
|
||||||
QMessageBox::critical(mw,tr(""),
|
|
||||||
tr("Can't optimize: data object has been destroyed !"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Dialog box
|
// Dialog box
|
||||||
|
|
@ -293,22 +271,10 @@ void
|
||||||
Mesh_3_optimization_plugin::perturb()
|
Mesh_3_optimization_plugin::perturb()
|
||||||
{
|
{
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Get source item
|
// Get c3t3 item
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
const Scene_interface::Item_id index = scene->mainSelectionIndex();
|
Scene_c3t3_item* item = get_c3t3_item();
|
||||||
Scene_c3t3_item* item = qobject_cast<Scene_c3t3_item*>(scene->item(index));
|
if ( NULL == item ) { return; }
|
||||||
|
|
||||||
if ( NULL == item )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( NULL == item->data_item() )
|
|
||||||
{
|
|
||||||
QMessageBox::critical(mw,tr(""),
|
|
||||||
tr("Can't perturb: data object has been destroyed !"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Dialog box
|
// Dialog box
|
||||||
|
|
@ -361,15 +327,10 @@ void
|
||||||
Mesh_3_optimization_plugin::exude()
|
Mesh_3_optimization_plugin::exude()
|
||||||
{
|
{
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Get source item
|
// Get c3t3 item
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
const Scene_interface::Item_id index = scene->mainSelectionIndex();
|
Scene_c3t3_item* item = get_c3t3_item();
|
||||||
Scene_c3t3_item* item = qobject_cast<Scene_c3t3_item*>(scene->item(index));
|
if ( NULL == item ) { return; }
|
||||||
|
|
||||||
if ( NULL == item )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Dialog box
|
// Dialog box
|
||||||
|
|
@ -418,6 +379,31 @@ Mesh_3_optimization_plugin::exude()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Scene_c3t3_item*
|
||||||
|
Mesh_3_optimization_plugin::
|
||||||
|
get_c3t3_item() const
|
||||||
|
{
|
||||||
|
const Scene_interface::Item_id index = scene->mainSelectionIndex();
|
||||||
|
Scene_c3t3_item* item = qobject_cast<Scene_c3t3_item*>(scene->item(index));
|
||||||
|
|
||||||
|
if ( NULL == item )
|
||||||
|
{
|
||||||
|
QMessageBox::critical(mw,tr(""),
|
||||||
|
tr("Selected object is not a mesh... optimization can't be performed"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( NULL == item->data_item() )
|
||||||
|
{
|
||||||
|
QMessageBox::critical(mw,tr(""),
|
||||||
|
tr("Can't perturb: data object has been destroyed !"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Mesh_3_optimization_plugin::
|
Mesh_3_optimization_plugin::
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue