Makes the parameters for the meshing of gray images editable by the user.

This commit is contained in:
Maxime Gimeno 2016-05-24 16:13:33 +02:00
parent be1ac690b5
commit 39a4ad8534
5 changed files with 201 additions and 67 deletions

View File

@ -269,6 +269,12 @@ void Mesh_3_plugin::mesh_3()
// -----------------------------------
// Get values
// -----------------------------------
if(image_item && image_item->isGray())
ui.groupBox_3->setVisible(true);
else
ui.groupBox_3->setVisible(false);
int i = dialog.exec();
if( i == QDialog::Rejected ) { return; }
@ -280,6 +286,9 @@ void Mesh_3_plugin::mesh_3()
const double tet_sizing = !ui.noTetSizing->isChecked() ? 0 : ui.tetSizing->value();
const bool protect_features = ui.protect->isChecked();
const int manifold = ui.manifoldCheckBox->isChecked() ? 1 : 0;
const float iso_value = !ui.groupBox_3->isVisible() ? 0 : ui.iso_value_spinBox->value();
const float value_outside = !ui.groupBox_3->isVisible() ? 0 : ui.value_outside_spinBox->value();
const float inside_is_less = !ui.groupBox_3->isVisible() ? false : ui.inside_is_less_checkBox->isChecked();
QApplication::setOverrideCursor(Qt::WaitCursor);
@ -352,7 +361,10 @@ void Mesh_3_plugin::mesh_3()
protect_features,
manifold,
scene,
image_item->isGray());
image_item->isGray(),
iso_value,
value_outside,
inside_is_less);
}
#endif

View File

@ -115,8 +115,11 @@ Meshing_thread* cgal_code_mesh_3(const Implicit_function_interface* pfunction,
#ifdef CGAL_MESH_3_DEMO_ACTIVATE_SEGMENTED_IMAGES
#include <CGAL/Gray_image_mesh_domain_3.h>
typedef CGAL::Gray_image_mesh_domain_3<CGAL::Image_3, Kernel, float, std::binder1st< std::less<float> > > Gray_image_domain1;
typedef CGAL::Polyhedron_demo_labeled_mesh_domain_3<Gray_image_domain1> Gray_image_domain;
typedef CGAL::Mesh_domain_with_polyline_features_3<Gray_image_domain> Gray_Image_mesh_domain;
typedef CGAL::Gray_image_mesh_domain_3<CGAL::Image_3, Kernel, float, std::binder1st< std::greater<float> > > Gray_image_domain2;
typedef CGAL::Polyhedron_demo_labeled_mesh_domain_3<Gray_image_domain1> Gray_image_less_domain;
typedef CGAL::Mesh_domain_with_polyline_features_3<Gray_image_less_domain> Gray_Image_mesh_less_domain;
typedef CGAL::Polyhedron_demo_labeled_mesh_domain_3<Gray_image_domain2> Gray_image_more_domain;
typedef CGAL::Mesh_domain_with_polyline_features_3<Gray_image_more_domain> Gray_Image_mesh_more_domain;
Meshing_thread* cgal_code_mesh_3(const Image* pImage,
const Polylines_container& polylines,
@ -128,7 +131,10 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage,
bool protect_features,
const int manifold,
CGAL::Three::Scene_interface* scene,
bool is_gray)
bool is_gray,
float iso_value,
float value_outside,
bool inside_is_less)
{
if (NULL == pImage) { return NULL; }
@ -167,36 +173,70 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage,
}
else
{
Gray_Image_mesh_domain* p_domain = new Gray_Image_mesh_domain(*pImage, std::bind1st(std::less<float>(), 3), 0);
if(inside_is_less)
{
Gray_Image_mesh_less_domain* p_domain = new Gray_Image_mesh_less_domain(*pImage, std::bind1st(std::less<float>(), iso_value), value_outside);
if(protect_features && polylines.empty()){
std::vector<std::vector<Point_3> > polylines_on_bbox;
CGAL::polylines_to_protect<Point_3>(*pImage, polylines_on_bbox);
p_domain->add_features(polylines_on_bbox.begin(), polylines_on_bbox.end());
}
if(! polylines.empty()){
// Insert edge in domain
p_domain->add_features(polylines.begin(), polylines.end());
protect_features = true; // so that it will be passed in make_mesh_3
}
CGAL::Timer timer;
timer.start();
Scene_c3t3_item* p_new_item = new Scene_c3t3_item;
p_new_item->setScene(scene);
if(protect_features && polylines.empty()){
std::vector<std::vector<Point_3> > polylines_on_bbox;
CGAL::polylines_to_protect<Point_3>(*pImage, polylines_on_bbox);
p_domain->add_features(polylines_on_bbox.begin(), polylines_on_bbox.end());
Mesh_parameters param;
param.protect_features = protect_features;
param.facet_angle = facet_angle;
param.facet_sizing = facet_sizing;
param.facet_approx = facet_approx;
param.tet_sizing = tet_sizing;
param.tet_shape = tet_shape;
param.manifold = manifold;
typedef ::Mesh_function<Gray_Image_mesh_less_domain> Mesh_function;
Mesh_function* p_mesh_function = new Mesh_function(p_new_item->c3t3(),
p_domain, param);
return new Meshing_thread(p_mesh_function, p_new_item);
}
if(! polylines.empty()){
// Insert edge in domain
p_domain->add_features(polylines.begin(), polylines.end());
protect_features = true; // so that it will be passed in make_mesh_3
else
{
Gray_Image_mesh_more_domain*p_domain = new Gray_Image_mesh_more_domain(*pImage, std::bind1st(std::greater<float>(), iso_value), value_outside);
if(protect_features && polylines.empty()){
std::vector<std::vector<Point_3> > polylines_on_bbox;
CGAL::polylines_to_protect<Point_3>(*pImage, polylines_on_bbox);
p_domain->add_features(polylines_on_bbox.begin(), polylines_on_bbox.end());
}
if(! polylines.empty()){
// Insert edge in domain
p_domain->add_features(polylines.begin(), polylines.end());
protect_features = true; // so that it will be passed in make_mesh_3
}
CGAL::Timer timer;
timer.start();
Scene_c3t3_item* p_new_item = new Scene_c3t3_item;
p_new_item->setScene(scene);
Mesh_parameters param;
param.protect_features = protect_features;
param.facet_angle = facet_angle;
param.facet_sizing = facet_sizing;
param.facet_approx = facet_approx;
param.tet_sizing = tet_sizing;
param.tet_shape = tet_shape;
param.manifold = manifold;
typedef ::Mesh_function<Gray_Image_mesh_more_domain> Mesh_function;
Mesh_function* p_mesh_function = new Mesh_function(p_new_item->c3t3(),
p_domain, param);
return new Meshing_thread(p_mesh_function, p_new_item);
}
CGAL::Timer timer;
timer.start();
Scene_c3t3_item* p_new_item = new Scene_c3t3_item;
p_new_item->setScene(scene);
Mesh_parameters param;
param.protect_features = protect_features;
param.facet_angle = facet_angle;
param.facet_sizing = facet_sizing;
param.facet_approx = facet_approx;
param.tet_sizing = tet_sizing;
param.tet_shape = tet_shape;
param.manifold = manifold;
typedef ::Mesh_function<Gray_Image_mesh_domain> Mesh_function;
Mesh_function* p_mesh_function = new Mesh_function(p_new_item->c3t3(),
p_domain, param);
return new Meshing_thread(p_mesh_function, p_new_item);
}
}

View File

@ -52,5 +52,8 @@ Meshing_thread* cgal_code_mesh_3(const CGAL::Image_3* pImage,
bool protect_features,
const int manifold,
CGAL::Three::Scene_interface* scene,
bool is_gray = false);
bool is_gray = false,
float iso_value = 3.f,
float value_outside = 0.f,
bool inside_is_less = true);
#endif

View File

@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>473</width>
<height>482</height>
<height>637</height>
</rect>
</property>
<property name="sizePolicy">
@ -254,17 +254,46 @@
<property name="title">
<string>Volume</string>
</property>
<layout class="QGridLayout" name="gridLayout_3" columnstretch="2,1,0">
<item row="0" column="0">
<widget class="QLabel" name="label">
<layout class="QGridLayout" name="gridLayout_3" columnstretch="2,0,0">
<item row="0" column="2">
<widget class="QCheckBox" name="noTetSizing">
<property name="toolTip">
<string>Enable/Disable parameter</string>
</property>
<property name="text">
<string>&amp;Tetrahedron max. size</string>
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="checked">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>tetSizing</cstring>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="noTetShape">
<property name="toolTip">
<string>Enable/Disable parameter</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="tetShape">
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>3.000000000000000</double>
</property>
</widget>
</item>
@ -298,45 +327,90 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Tetrahedron max. size</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>tetSizing</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Gray Images</string>
</property>
<layout class="QGridLayout" name="gridLayout_4" columnstretch="2,0">
<item row="2" column="1">
<widget class="QCheckBox" name="inside_is_less_checkBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="tetShape">
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<double>1.000000000000000</double>
</property>
<widget class="QDoubleSpinBox" name="iso_value_spinBox">
<property name="value">
<double>3.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="noTetShape">
<property name="toolTip">
<string>Enable/Disable parameter</string>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="value_outside_spinBox"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
<string>Value outside: </string>
</property>
<property name="checked">
<bool>true</bool>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="noTetSizing">
<property name="toolTip">
<string>Enable/Disable parameter</string>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
<string>Iso value:</string>
</property>
<property name="checked">
<bool>true</bool>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Value &quot;inside&quot; is less that iso value:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>

View File

@ -85,7 +85,7 @@ public:
p_rng)
{}
///Constructor for the Gray-level Images
///Constructors for the Gray-level Images
Polyhedron_demo_labeled_mesh_domain_3(
const Image& img,
const std::binder1st<std::less<float> > iso_value = std::bind1st(std::less<float>(), 3),
@ -93,7 +93,12 @@ public:
: Base(img, iso_value)
{}
Polyhedron_demo_labeled_mesh_domain_3(
const Image& img,
const std::binder1st<std::greater<float> > iso_value = std::bind1st(std::greater<float>(), 3),
const float value_outside = 0)
: Base(img, iso_value)
{}
/**
* Returns the index to be stored in a vertex lying on the surface identified