area smoothing tolerance fix

This commit is contained in:
konstantinos katrioplas 2017-11-15 14:18:35 +01:00
parent 45063e1346
commit 2ca3d01e35
4 changed files with 34 additions and 46 deletions

View File

@ -165,14 +165,14 @@ public:
#endif
}
void area_relaxation(const double& precision)
void area_relaxation(const double& tolerance)
{
std::size_t moved_points = 0;
BOOST_FOREACH(vertex_descriptor v, vrange_)
{
if(!is_border(v, mesh_) && !is_constrained(v))
{
if (gradient_descent(v, precision))
if (gradient_descent(v, tolerance))
moved_points++;
}
}
@ -465,7 +465,7 @@ private:
// gradient descent
// ----------------
bool gradient_descent(const vertex_descriptor& v, const double& precision)
bool gradient_descent(const vertex_descriptor& v, const double& tolerance)
{
bool move_flag;
double x, y, z, x_new, y_new, z_new, drdx, drdy, drdz;
@ -481,14 +481,14 @@ private:
return false;
double energy_new = 0;
double relative_energy = precision + 1;
double relative_energy = 1;
unsigned int t = 1;
double eta0 = 0.01;
//double power_t = 0.25;
double t0 = 0.001;
double eta = eta0 / (1 + t0*t);
while(relative_energy > precision)
while(relative_energy > tolerance)
{
drdx=0, drdy=0, drdz=0;
compute_derivatives(drdx, drdy, drdz, v, S_av);

View File

@ -364,7 +364,7 @@ void area_smoothing(PolygonMesh& pmesh, const FaceRange& faces, const NamedParam
unsigned int nb_iterations = choose_param(get_param(np, internal_np::number_of_iterations), 1);
//gradient descent precision
double gd_precision = choose_param(get_param(np, internal_np::gradient_descent_precision), 0.001);
double gd_precision = choose_param(get_param(np, internal_np::gradient_descent_precision), 0.000001);
internal::Compatible_remesher<PolygonMesh, VertexPointMap, VCMap, ECMap, GeomTraits>
remesher(pmesh, vpmap, vcmap, ecmap);

View File

@ -119,6 +119,7 @@ public:
ui_widget.iterations_spinBox->setSingleStep(1);
ui_widget.iterations_spinBox->setMinimum(1);
/*
ui_widget.curv_iterations_spinBox->setValue(1);
ui_widget.curv_iterations_spinBox->setSingleStep(1);
ui_widget.curv_iterations_spinBox->setMinimum(1);
@ -126,6 +127,7 @@ public:
ui_widget.curv_iterations_spinBox_2->setValue(1);
ui_widget.curv_iterations_spinBox_2->setSingleStep(1);
ui_widget.curv_iterations_spinBox_2->setMinimum(1);
*/
}
@ -167,8 +169,7 @@ public Q_SLOTS:
{
unsigned int nb_iter = ui_widget.Angle_spinBox->value();
//bool use_weights = ui_widget.use_weights_checkBox->isChecked();
angle_smoothing(pmesh,
parameters::number_of_iterations(nb_iter));
angle_smoothing(pmesh, parameters::number_of_iterations(nb_iter));
poly_item->invalidateOpenGLBuffers();
Q_EMIT poly_item->itemChanged();
@ -176,11 +177,9 @@ public Q_SLOTS:
if(ui_widget.Area_checkBox->isChecked())
{
std::cout<<"Area_checkBox\n";
unsigned int nb_iter = ui_widget.Area_spinBox->value();
//double gd_precision = ui_widget.gd_dSpinBox->value();
area_smoothing(pmesh,
parameters::number_of_iterations(nb_iter));
area_smoothing(pmesh, parameters::number_of_iterations(nb_iter));
poly_item->invalidateOpenGLBuffers();
Q_EMIT poly_item->itemChanged();
@ -202,9 +201,9 @@ public Q_SLOTS:
QApplication::setOverrideCursor(Qt::WaitCursor);
unsigned int nb_iter = ui_widget.curv_iterations_spinBox->value();
curvature_flow_smoothing(pmesh,
parameters::number_of_iterations(nb_iter));
//unsigned int nb_iter = ui_widget.curv_iterations_spinBox->value();
unsigned int nb_iter = 1;
curvature_flow_smoothing(pmesh, parameters::number_of_iterations(nb_iter));
poly_item->invalidateOpenGLBuffers();
Q_EMIT poly_item->itemChanged();
@ -226,7 +225,8 @@ public Q_SLOTS:
QApplication::setOverrideCursor(Qt::WaitCursor);
unsigned int nb_iter = ui_widget.curv_iterations_spinBox_2->value();
//unsigned int nb_iter = ui_widget.curv_iterations_spinBox_2->value();
unsigned int nb_iter = 1;
if(!is_stiffness_matrix_setup)
{

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>590</width>
<height>387</height>
<width>570</width>
<height>383</height>
</rect>
</property>
<property name="windowTitle">
@ -19,50 +19,38 @@
<rect>
<x>10</x>
<y>230</y>
<width>571</width>
<width>551</width>
<height>121</height>
</rect>
</property>
<property name="title">
<string>Shape smoothing</string>
</property>
<widget class="QWidget" name="layoutWidget">
<widget class="QPushButton" name="MCF_Button">
<property name="geometry">
<rect>
<x>10</x>
<x>160</x>
<y>40</y>
<width>551</width>
<height>33</height>
<width>211</width>
<height>30</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="MCF_Button">
<property name="text">
<string>MCF</string>
</property>
</widget>
</item>
</layout>
<property name="text">
<string>MCF</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QPushButton" name="modified_MCF_button">
<property name="geometry">
<rect>
<x>10</x>
<x>160</x>
<y>80</y>
<width>551</width>
<height>33</height>
<width>211</width>
<height>30</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="modified_MCF_button">
<property name="text">
<string>Modified MCF</string>
</property>
</widget>
</item>
</layout>
<property name="text">
<string>Modified MCF</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="Mesh_groupBox">
@ -70,7 +58,7 @@
<rect>
<x>10</x>
<y>0</y>
<width>571</width>
<width>551</width>
<height>227</height>
</rect>
</property>
@ -82,7 +70,7 @@
<rect>
<x>10</x>
<y>30</y>
<width>551</width>
<width>531</width>
<height>183</height>
</rect>
</property>