Commit db8cc687 authored by Jan Möbius's avatar Jan Möbius

Decimate only on selected vertices

parent 5b47a3f9
......@@ -101,31 +101,31 @@ void DecimateThread::decimate()
if(param_.dec )
{
if ( param_.verticesCount != -1 )
param_.dec->decimate_to(param_.verticesCount);
param_.dec->decimate_to(param_.verticesCount,param_.selectionOnly);
else if (param_.facesCount != -1)
param_.dec->decimate_to_faces(0, param_.facesCount);
param_.dec->decimate_to_faces(0, param_.facesCount,param_.selectionOnly);
else // constraints only
param_.dec->decimate_to_faces(0, 1);
param_.dec->decimate_to_faces(0, 1,param_.selectionOnly);
}
else if (param_.mcDec)
{
param_.mcDec->set_samples(param_.samples);
if ( param_.verticesCount != -1 )
param_.mcDec->decimate_to(param_.verticesCount);
param_.mcDec->decimate_to(param_.verticesCount,param_.selectionOnly);
else if (param_.facesCount != -1 )
param_.mcDec->decimate_to_faces(0, param_.facesCount);
param_.mcDec->decimate_to_faces(0, param_.facesCount,param_.selectionOnly);
else // constraints only
param_.mcDec->decimate_to_faces(0, 1);
param_.mcDec->decimate_to_faces(0, 1,param_.selectionOnly);
}
else if (param_.mixedDec)
{
param_.mixedDec->set_samples(param_.samples);
if ( param_.verticesCount != -1 )
param_.mixedDec->decimate_to(param_.verticesCount,param_.mc_factor);
param_.mixedDec->decimate_to(param_.verticesCount,param_.mc_factor,param_.selectionOnly);
else if (param_.facesCount != -1 )
param_.mixedDec->decimate_to_faces(0, param_.facesCount,param_.mc_factor);
param_.mixedDec->decimate_to_faces(0, param_.facesCount,param_.mc_factor,param_.selectionOnly);
else // constraints only
param_.mixedDec->decimate_to_faces(0, 1,param_.mc_factor);
param_.mixedDec->decimate_to_faces(0, 1,param_.mc_factor,param_.selectionOnly);
}
emit state(jobId(),100);
}
......
......@@ -71,6 +71,7 @@ public:
bool useIncremental;
bool useMC;
bool useMixed;
bool selectionOnly;
float mc_factor;
int verticesCount; // -1 if not decimate to vertices
int facesCount; // -1 if not decimate to faces
......
......@@ -459,6 +459,7 @@ void DecimaterPlugin::slot_decimate()
params.verticesCount = (tool_->rbVertices->isChecked() ) ? tool_->verticesCount->value() : -1;
params.samples = tool_->randomSamplesCounter->value();
params.mc_factor = 1.0 - (tool_->mixedFactorCounter->value()*0.01);
params.selectionOnly = tool_->selectionOnly->isChecked();
// create and start decimate thread
QString jobId = QString("Decimate_Object_%1").arg(decInit->objId);
......@@ -795,6 +796,14 @@ void DecimaterPlugin::decimate(int _objID, QVariantMap _constraints) {
}
}
//independent sets constraint
bool selection_only = false;
if ( _constraints.contains("selection_only") ){
selection_only = _constraints["selection_only"].toBool();
}
//init the decimater
if( ! decimater_object->initialize() ){
emit log(LOGWARN, tr("Decimater could not be initialized"));
......@@ -828,31 +837,31 @@ void DecimaterPlugin::decimate(int _objID, QVariantMap _constraints) {
if(dec && !mixedDec)
{
if ( verticesCount )
dec->decimate_to(vertices);
dec->decimate_to(vertices,selection_only);
else if (trianglesCount )
dec->decimate_to_faces(0, triangles);
dec->decimate_to_faces(0, triangles,selection_only);
else // constraints only
dec->decimate_to_faces(0, 1);
dec->decimate_to_faces(0, 1,selection_only);
}
else if (mcDec && !mixedDec)
{
mcDec->set_samples(randomSamples);
if ( verticesCount )
mcDec->decimate_to(vertices);
mcDec->decimate_to(vertices,selection_only);
else if (trianglesCount)
mcDec->decimate_to_faces(0, triangles);
mcDec->decimate_to_faces(0, triangles,selection_only);
else // constraints only
mcDec->decimate_to_faces(0, 1);
mcDec->decimate_to_faces(0, 1,selection_only);
}
else if (mixedDec)
{
mixedDec->set_samples(randomSamples);
if ( verticesCount )
mixedDec->decimate_to(vertices,mc_factor);
mixedDec->decimate_to(vertices,mc_factor,selection_only);
else if (trianglesCount)
mixedDec->decimate_to_faces(0, triangles,mc_factor);
mixedDec->decimate_to_faces(0, triangles,mc_factor,selection_only);
else // constraints only
mixedDec->decimate_to_faces(0, 1,mc_factor);
mixedDec->decimate_to_faces(0, 1,mc_factor,selection_only);
}else
{
emit log(LOGERR,tr("Could not find Decimater Type"));
......
......@@ -92,6 +92,7 @@ roundness \n\
aspect_ratio,independent_sets \n\
vertices \n\
triangles \n\
selection_only\n\
\n\
\n\
Example call: \n\
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>378</width>
<height>740</height>
<width>386</width>
<height>958</height>
</rect>
</property>
<property name="windowTitle">
......@@ -45,7 +45,7 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Multiple choice decimater&lt;/p&gt;&lt;p&gt;The multiple choice decimater checks #Random Samples and takes the best one for the next collapse. As there is no heap involved, this is &lt;span style=&quot; font-weight:600;&quot;&gt;faster&lt;/span&gt; than the incremental decimater but as it is randomized, the result is not guaranteed to be the best, but still inside the specified constraints.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Multiple Choice</string>
<string>M&amp;ultiple Choice</string>
</property>
</widget>
</item>
......@@ -58,7 +58,7 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Mixed Decimater&lt;/p&gt;&lt;p&gt;Uses Multiple Choice Decimater and Incremental Decimater to get as &lt;span style=&quot; font-weight:600;&quot;&gt;good and fast results&lt;/span&gt; as possible. This decimater uses several steps of the Multiple Choice Decimater with increasing constraint threshold. When 80% of the maximal error are reached or 80% of the collapses have been performed, it switches back to the Incremental Decimater to do the rest.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Mixed</string>
<string>Mi&amp;xed</string>
</property>
</widget>
</item>
......@@ -207,7 +207,7 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Sets the collapse priority to the distance to the original surface (Quadrics).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>by Distance</string>
<string>by &amp;Distance</string>
</property>
<property name="checked">
<bool>true</bool>
......@@ -220,7 +220,7 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Sets the collapse priority to the normal deviaton.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>by Normal Deviation</string>
<string>by &amp;Normal Deviation</string>
</property>
</widget>
</item>
......@@ -233,7 +233,7 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Sets the collapse priority to the edge length.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>by Edge length</string>
<string>by Edge &amp;length</string>
</property>
</widget>
</item>
......@@ -246,6 +246,13 @@
<string>Constraints</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="selectionOnly">
<property name="text">
<string>Only Decimate selection (Vertex selection)</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
......@@ -553,7 +560,7 @@ p, li { white-space: pre-wrap; }
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Decimate until the given number of triangles is reached, or constraint limits would be violated.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>#Triangles</string>
<string>#&amp;Triangles</string>
</property>
</widget>
</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment