mirror of https://github.com/CGAL/cgal
add a dialog box to set options
This commit is contained in:
parent
624b6389f3
commit
a41ac02cc2
|
|
@ -336,7 +336,8 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
|||
target_link_libraries(pca_plugin scene_polyhedron_item scene_basic_objects)
|
||||
|
||||
if(EIGEN3_FOUND)
|
||||
polyhedron_demo_plugin(scale_space_reconstruction_plugin Polyhedron_demo_scale_space_reconstruction_plugin)
|
||||
qt4_wrap_ui( scale_spaceUI_FILES Polyhedron_demo_scale_space_reconstruction_plugin.ui)
|
||||
polyhedron_demo_plugin(scale_space_reconstruction_plugin Polyhedron_demo_scale_space_reconstruction_plugin ${scale_spaceUI_FILES})
|
||||
target_link_libraries(scale_space_reconstruction_plugin scene_polygon_soup_item scene_polyhedron_item scene_points_with_normal_item)
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,24 @@
|
|||
#include "Polyhedron_demo_plugin_helper.h"
|
||||
#include "Polyhedron_demo_plugin_interface.h"
|
||||
|
||||
#include "ui_Polyhedron_demo_scale_space_reconstruction_plugin.h"
|
||||
|
||||
|
||||
class Polyhedron_demo_scale_space_reconstruction_plugin_dialog : public QDialog, private Ui::ScaleSpaceOptionsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Polyhedron_demo_scale_space_reconstruction_plugin_dialog(QWidget* /*parent*/ = 0)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
double neighbors() const { return m_neighbors->value(); }
|
||||
double iterations() const { return m_iterations->value(); }
|
||||
double samples() const { return m_samples->value(); }
|
||||
bool generate_smoothed() const { return m_genSmooth->isChecked(); }
|
||||
};
|
||||
|
||||
#include <CGAL/Scale_space_surface_reconstructer_3.h>
|
||||
|
||||
class Polyhedron_demo_scale_space_reconstruction_plugin :
|
||||
|
|
@ -54,6 +72,11 @@ void Polyhedron_demo_scale_space_reconstruction_plugin::on_actionScaleSpaceRecon
|
|||
|
||||
if(pts_item)
|
||||
{
|
||||
//generate the dialog box to set the options
|
||||
Polyhedron_demo_scale_space_reconstruction_plugin_dialog dialog;
|
||||
if(!dialog.exec())
|
||||
return;
|
||||
|
||||
// wait cursor
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
|
|
@ -61,62 +84,69 @@ void Polyhedron_demo_scale_space_reconstruction_plugin::on_actionScaleSpaceRecon
|
|||
time.start();
|
||||
std::cout << "Scale scape surface reconstruction...";
|
||||
|
||||
// TODO add dialog box for the parameters
|
||||
unsigned int neighbors = 30;
|
||||
unsigned int iterations = 4;
|
||||
unsigned int samples = 200;
|
||||
|
||||
typedef CGAL::Scale_space_surface_reconstructer_3<Kernel> Recontructor;
|
||||
Recontructor reconstruct( neighbors, samples );
|
||||
Recontructor reconstruct( dialog.neighbors(), dialog.samples() );
|
||||
reconstruct.reconstruct_surface(
|
||||
pts_item->point_set()->begin(),
|
||||
pts_item->point_set()->end(),
|
||||
iterations
|
||||
dialog.iterations()
|
||||
);
|
||||
std::cout << "ok (" << time.elapsed() << " ms)" << std::endl;
|
||||
|
||||
|
||||
//create the non-smoothed and the smoothed polygon soup items
|
||||
Scene_polygon_soup_item *new_item = new Scene_polygon_soup_item();
|
||||
Scene_polygon_soup_item *new_item_smoothed = new Scene_polygon_soup_item();
|
||||
//create item for the reconstruction output with input point set
|
||||
Scene_polygon_soup_item* new_item = new Scene_polygon_soup_item();
|
||||
new_item->init_polygon_soup(pts_item->point_set()->size(),
|
||||
reconstruct.get_surface_size() );
|
||||
new_item_smoothed->init_polygon_soup(pts_item->point_set()->size(),
|
||||
reconstruct.get_surface_size() );
|
||||
reconstruct.get_surface_size() );
|
||||
|
||||
typedef Point_set::iterator Point_iterator;
|
||||
|
||||
for(Point_iterator it = pts_item->point_set()->begin(),
|
||||
end = pts_item->point_set()->end(); it!=end; ++it)
|
||||
{
|
||||
new_item->new_vertex(it->x(), it->y(), it->z());
|
||||
}
|
||||
|
||||
typedef Recontructor::Point_iterator SS_point_iterator;
|
||||
for(SS_point_iterator it = reconstruct.scale_space_begin(),
|
||||
end = reconstruct.scale_space_end(); it!=end; ++it)
|
||||
{
|
||||
new_item_smoothed->new_vertex(it->x(), it->y(), it->z());
|
||||
}
|
||||
|
||||
for (Recontructor::Triple_iterator it=reconstruct.surface_begin(),
|
||||
end=reconstruct.surface_end();it!=end;++it)
|
||||
{
|
||||
new_item->new_triangle(it->first, it->second, it->third);
|
||||
new_item_smoothed->new_triangle(it->first, it->second, it->third);
|
||||
}
|
||||
|
||||
new_item->finalize_polygon_soup();
|
||||
new_item_smoothed->finalize_polygon_soup();
|
||||
|
||||
new_item->setName(tr("%1 (ss reconstruction)").arg(scene->item(index)->name()));
|
||||
new_item->setColor(Qt::magenta);
|
||||
new_item->setRenderingMode(FlatPlusEdges);
|
||||
scene->addItem(new_item);
|
||||
|
||||
new_item_smoothed->setName(tr("%1 (ss smoothed reconstruction)").arg(scene->item(index)->name()));
|
||||
new_item_smoothed->setColor(Qt::magenta);
|
||||
new_item_smoothed->setRenderingMode(FlatPlusEdges);
|
||||
scene->addItem(new_item_smoothed);
|
||||
if ( dialog.generate_smoothed() ){
|
||||
//create item for the reconstruction output with input point set smoothed
|
||||
Scene_polygon_soup_item *new_item_smoothed = new Scene_polygon_soup_item();
|
||||
|
||||
new_item_smoothed->init_polygon_soup(pts_item->point_set()->size(),
|
||||
reconstruct.get_surface_size() );
|
||||
|
||||
typedef Recontructor::Point_iterator SS_point_iterator;
|
||||
for(SS_point_iterator it = reconstruct.scale_space_begin(),
|
||||
end = reconstruct.scale_space_end(); it!=end; ++it)
|
||||
{
|
||||
new_item_smoothed->new_vertex(it->x(), it->y(), it->z());
|
||||
}
|
||||
|
||||
for (Recontructor::Triple_iterator it=reconstruct.surface_begin(),
|
||||
end=reconstruct.surface_end();it!=end;++it)
|
||||
{
|
||||
new_item_smoothed->new_triangle(it->first, it->second, it->third);
|
||||
}
|
||||
|
||||
new_item_smoothed->finalize_polygon_soup();
|
||||
|
||||
new_item_smoothed->setName(tr("%1 (ss smoothed reconstruction)").arg(scene->item(index)->name()));
|
||||
new_item_smoothed->setColor(Qt::magenta);
|
||||
new_item_smoothed->setRenderingMode(FlatPlusEdges);
|
||||
scene->addItem(new_item_smoothed);
|
||||
}
|
||||
|
||||
// default cursor
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,128 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ScaleSpaceOptionsDialog</class>
|
||||
<widget class="QDialog" name="ScaleSpaceOptionsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>476</width>
|
||||
<height>272</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Scale-Space Surface Reconstruction</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="m_genSmooth">
|
||||
<property name="text">
|
||||
<string>Also generate the smoothed version</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Iterations</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Size of sample to estimate neighborhood</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Average neighborhood size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QSpinBox" name="m_samples">
|
||||
<property name="maximum">
|
||||
<number>1000000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>200</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QSpinBox" name="m_iterations">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>4</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QSpinBox" name="m_neighbors">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>30</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ScaleSpaceOptionsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>177</x>
|
||||
<y>123</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>53</x>
|
||||
<y>125</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ScaleSpaceOptionsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>257</x>
|
||||
<y>119</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>257</x>
|
||||
<y>143</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Loading…
Reference in New Issue