52 #include "DecimaterPlugin.hh" 54 #include <OpenFlipper/BasePlugin/WhatsThisGenerator.hh> 56 #define DECIMATER "DecimaterData" 69 void DecimaterPlugin::initializePlugin()
72 if ( OpenFlipper::Options::gui()) {
86 connect(
tool_->edgeLength,SIGNAL(valueChanged(
double) ),
this,SLOT(slotUpdateEdgeLength()) );
87 connect(
tool_->normalDeviation,SIGNAL(valueChanged(
int) ),
this,SLOT(slotUpdateNormalDev()) );
88 connect(
tool_->normalDeviationSlider,SIGNAL(valueChanged(
int) ),
this,SLOT(slotUpdateNormalDev()) );
89 connect(
tool_->verticesCount,SIGNAL(valueChanged(
int) ),
this,SLOT(slotUpdateVertices()) );
90 connect(
tool_->verticesCountSlider,SIGNAL(valueChanged(
int) ),
this,SLOT(slotUpdateVertices()) );
91 connect(
tool_->trianglesCount,SIGNAL(valueChanged(
int) ),
this,SLOT(slotUpdateTriangles()) );
92 connect(
tool_->trianglesCountSlider,SIGNAL(valueChanged(
int) ),
this,SLOT(slotUpdateTriangles()) );
97 connect(
tool_->mixedFactorCounter, SIGNAL(valueChanged(
double)),
this, SLOT(slotMixedCounterValueChanged(
double)) );
98 connect(
tool_->mixedFactorSlider, SIGNAL(valueChanged(
int)),
this, SLOT(slotMixedSliderValueChanged(
int)) );
99 connect(
tool_->cbDistance, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
100 connect(
tool_->cbNormalDev, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
101 connect(
tool_->cbEdgeLength, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
102 connect(
tool_->cbIndependentSets, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
103 connect(
tool_->cbRoundness, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
104 connect(
tool_->cbAspectRatio, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
105 connect(
tool_->rbByDistance, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
106 connect(
tool_->rbByEdgeLength, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
107 connect(
tool_->rbByNormalDeviation, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
108 connect(
tool_->rbConstraintsOnly, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
109 connect(
tool_->rbTriangles, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
110 connect(
tool_->rbUseDecimater, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
111 connect(
tool_->rbUseMC, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
112 connect(
tool_->rbUseMixed, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
113 connect(
tool_->rbVertices, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
115 toolIcon_ =
new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"decimater.png");
116 emit addToolbox( tr(
"Decimater") ,
tool_, toolIcon_ );
121 tool_->pbInitialize->setWhatsThis(
tool_->pbInitialize->whatsThis()+generator.
generateLink(
"quick_tutorial"));
122 tool_->rbUseDecimater->setWhatsThis(
tool_->rbUseDecimater->whatsThis()+generator.
generateLink(
"incremental"));
133 tool_->rbByNormalDeviation->setWhatsThis(
tool_->rbByNormalDeviation->whatsThis()+generator.
generateLink());
139 tool_->randomSamplesCounter->setWhatsThis(
tool_->randomSamplesCounter->whatsThis()+generator.
generateLink(
"multiple_choice"));
140 tool_->mixedFactorCounter->setWhatsThis(
tool_->mixedFactorCounter->whatsThis()+generator.
generateLink(
"mixed"));
155 emit setSlotDescription(
"decimate(int,QVariantMap)",tr(
"Decimate a given object"),
156 QString(tr(
"objectId,constraints")).split(
","),
157 QString(tr(
"ID of an object; Object that can has one or more constraint properties (" 158 "decimater_type [0 (Incremental), 1 (MC), 2 (Mixed)], " 159 "random_samples [For MC/Mixed], " 160 "incremental_percentage [For Mixed], " 161 "decimation_order [0 (by distance), 1 (by normal deviation), 2 (by edge length)], " 166 "aspect_ratio,independent_sets, " 168 "triangles)")).split(
";"));
170 if ( OpenFlipper::Options::gui()) {
171 tool_->decTypeOps->setVisible(
false);
184 tool_->roundness->setValue( (
double) _value / 100.0 );
185 tool_->cbRoundness->setChecked (
true);
188 void DecimaterPlugin::slotMixedCounterValueChanged(
double _value)
190 tool_->mixedFactorLabel->setText(QString::number(100-_value)+QString(
"%"));
191 tool_->mixedFactorSlider->setValue(100-_value);
193 void DecimaterPlugin::slotMixedSliderValueChanged(
int _value)
195 tool_->mixedFactorLabel->setText(QString::number(_value)+QString(
"%"));
196 tool_->mixedFactorCounter->setValue(100.0-_value);
207 tool_->roundnessSlider->setValue( (
int) (_value * 100) );
208 tool_->cbRoundness->setChecked (
true);
220 tool_->aspectRatio->setValue( (
double) _value / 100.0 );
221 tool_->cbAspectRatio->setChecked (
true);
233 tool_->aspectRatioSlider->setValue( (
int) (_value * 100) );
234 tool_->cbAspectRatio->setChecked (
true);
245 if ( ! OpenFlipper::Options::gui())
248 decimater_objects_.clear();
253 initialize_object(*o_it);
256 tool_->pbDecimate->setEnabled(
true);
264 emit log(
LOGWARN , tr(
"Unable to get object"));
276 ModAspectRatioH hModAspectRatio;
277 ModEdgeLengthH hModEdgeLength;
278 ModHausdorffH hModHausdorff;
279 ModIndependentH hModIndependent;
280 ModNormalDeviationH hModNormalDeviation;
281 ModNormalFlippingH hModNormalFlipping;
282 ModQuadricH hModQuadric;
283 ModRoundnessH hModRoundness;
286 ptr::shared_ptr<BaseDecimaterType> decimater_object;
287 if (
tool_->rbUseDecimater->isChecked())
288 decimater_object = ptr::shared_ptr<DecimaterType>(
new DecimaterType(*mesh));
289 else if(
tool_->rbUseMC->isChecked())
290 decimater_object = ptr::shared_ptr<McDecimaterType>(
new McDecimaterType(*mesh));
291 else if(
tool_->rbUseMixed->isChecked())
292 decimater_object = ptr::shared_ptr<MixedDecimaterType>(
new MixedDecimaterType(*mesh));
296 if(decimater->distance()) {
297 decimater->removeDistanceConstraint();
298 decimater_object->remove(hModHausdorff);
300 if(decimater->normalDeviation()) {
301 decimater->removeNormalDeviationConstraint();
302 decimater_object->remove(hModNormalDeviation);
304 if(decimater->normalFlipping()) {
305 decimater->removeNormalFlippingConstraint();
306 decimater_object->remove(hModNormalFlipping);
308 if(decimater->roundness()) {
309 decimater->removeRoundnessConstraint();
310 decimater_object->remove(hModRoundness);
312 if(decimater->aspectRatio()) {
313 decimater->removeAspectRatioConstraint();
314 decimater_object->remove(hModAspectRatio);
316 if(decimater->edgeLength()) {
317 decimater->removeEdgeLengthConstraint();
318 decimater_object->remove(hModEdgeLength);
320 if(decimater->independentSets()) {
321 decimater->removeIndependentSetsConstraint();
322 decimater_object->remove(hModIndependent);
326 if (
tool_->rbByDistance->isChecked()) {
327 decimater->setDecimationOrder(DecimaterInfo::DISTANCE);
328 decimater_object->add( hModQuadric );
329 decimater_object->module( hModQuadric ).unset_max_err();
330 }
else if (
tool_->rbByNormalDeviation->isChecked()) {
331 decimater->setDecimationOrder(DecimaterInfo::NORMALDEV);
332 decimater_object->add(hModNormalDeviation);
333 decimater_object->module(hModNormalDeviation).set_binary(
false);
334 }
else if (
tool_->rbByEdgeLength->isChecked()) {
335 decimater->setDecimationOrder(DecimaterInfo::EDGELENGTH);
336 decimater_object->add(hModEdgeLength);
337 decimater_object->module(hModEdgeLength).set_binary(
false);
342 if (
tool_->cbDistance->isChecked() ) {
343 if ( decimater_object->add( decInit->hModHausdorff ) ||
tool_->rbConstraintsOnly->isChecked() ) {
344 decimater->setDistanceConstraint(
tool_->distance->value() );
345 decimater_object->module( decInit->hModHausdorff ).set_tolerance( decimater->distanceValue() );
349 if (
tool_->cbNormalDev->isChecked() ) {
350 if ( decimater_object->add( decInit->hModNormalDeviation ) ||
tool_->rbConstraintsOnly->isChecked() ) {
351 decimater->setNormalDeviationConstraint(
tool_->normalDeviation->value() );
352 decimater_object->module( decInit->hModNormalDeviation ).set_normal_deviation( decimater->normalDeviationValue() );
355 if ( decimater_object->add( decInit->hModNormalFlipping ) ||
tool_->rbConstraintsOnly->isChecked() ) {
356 decimater->setNormalFlippingConstraint();
360 if (
tool_->cbRoundness->isChecked() ) {
361 if ( decimater_object->add( decInit->hModRoundness ) ||
tool_->rbConstraintsOnly->isChecked() ) {
362 decimater->setRoundnessConstraint(
tool_->roundness->value() );
363 decimater_object->module( decInit->hModRoundness ).set_min_roundness( decimater->roundnessValue(), true );
367 if (
tool_->cbAspectRatio->isChecked() ) {
368 if ( decimater_object->add( decInit->hModAspectRatio ) ||
tool_->rbConstraintsOnly->isChecked() ) {
369 decimater->setAspectRatioConstraint(
tool_->aspectRatio->value() );
370 decimater_object->module( decInit->hModAspectRatio ).set_aspect_ratio( decimater->aspectRatioValue() );
374 if (
tool_->cbEdgeLength->isChecked() ) {
375 if ( decimater_object->add( decInit->hModEdgeLength ) ||
tool_->rbConstraintsOnly->isChecked() ) {
376 decimater->setEdgeLengthConstraint(
tool_->edgeLength->value() );
377 decimater_object->module( decInit->hModEdgeLength ).set_edge_length( decimater->edgeLengthValue() );
381 if (
tool_->cbIndependentSets->isChecked() ) {
382 if ( decimater_object->add( decInit->hModIndependent ) ||
tool_->rbConstraintsOnly->isChecked() ) {
383 decimater->setIndependentSetsConstraint();
389 if( ! decimater_object->initialize() ){
390 emit log(
LOGWARN, tr(
"Decimater could not be initialized"));
394 decInit->decimater = decimater_object;
395 decInit->objId = obj->
id();
397 decimater_objects_.push_back(decInit);
400 void DecimaterPlugin::slot_initialize_object(
int obj_id,
bool clear) {
402 decimater_objects_.clear();
408 initialize_object(obj);
410 tool_->pbDecimate->setEnabled(
true);
420 if ( ! OpenFlipper::Options::gui())
424 runningJobs_ = decimater_objects_.size();
425 for (std::vector< ptr::shared_ptr<DecimaterInit> >::iterator decIter = decimater_objects_.begin();
426 decIter != decimater_objects_.end(); ++decIter)
428 ptr::shared_ptr<DecimaterInit> decInit = *decIter;
429 ptr::shared_ptr<BaseDecimaterType> decimater = decInit->decimater;
432 if (
tool_->cbDistance->isChecked() ) {
433 decimater->module( decInit->hModHausdorff ).set_tolerance(
tool_->distance->value() );
436 if (
tool_->cbNormalDev->isChecked() ) {
437 decimater->module( decInit->hModNormalDeviation ).set_normal_deviation(
tool_->normalDeviation->value() );
440 if (
tool_->cbRoundness->isChecked() ) {
441 decimater->module( decInit->hModRoundness ).set_min_roundness(
tool_->roundness->value(), true );
444 if (
tool_->cbAspectRatio->isChecked() ) {
445 decimater->module( decInit->hModAspectRatio ).set_aspect_ratio(
tool_->aspectRatio->value() );
448 if (
tool_->cbEdgeLength->isChecked() ) {
449 decimater->module( decInit->hModEdgeLength ).set_edge_length(
tool_->edgeLength->value() );
454 params.dec = (
tool_->rbUseDecimater->isChecked()) ? dynamic_cast<DecimaterType*>(decimater.get()) : NULL;
455 params.mcDec = (
tool_->rbUseMC->isChecked()) ? dynamic_cast<McDecimaterType*>(decimater.get()) : NULL;
456 params.mixedDec = (
tool_->rbUseMixed->isChecked()) ? dynamic_cast<MixedDecimaterType*>(decimater.get()) : NULL;
458 params.facesCount = (
tool_->rbTriangles->isChecked()) ?
tool_->trianglesCount->value() : -1;
459 params.verticesCount = (
tool_->rbVertices->isChecked() ) ?
tool_->verticesCount->value() : -1;
460 params.samples =
tool_->randomSamplesCounter->value();
461 params.mc_factor = 1.0 - (
tool_->mixedFactorCounter->value()*0.01);
464 QString jobId = QString(
"Decimate_Object_%1").arg(decInit->objId);
466 connect(th, SIGNAL(finished(QString)),
this,SIGNAL(finishJob(QString)));
467 connect(th, SIGNAL(finished(QString)),
this, SLOT(slot_decimate_finished(QString)));
468 connect(th, SIGNAL(state(QString,
int)),
this, SIGNAL(setJobState(QString,
int)));
469 connect(
this, SIGNAL(jobCanceled(QString)), th, SLOT(slotCancel(QString)));
471 tool_->pbDecimate->setEnabled(
false);
472 tool_->pbInitialize->setEnabled(
false);
474 emit startJob(jobId , QString(
"Decimate Object with Id %1").arg(decInit->objId) , 0, 100,
false);
486 emit jobCanceled(_job);
489 void DecimaterPlugin::slot_decimate_finished(QString _jobId)
496 if (!thread->baseDecimater())
500 thread->baseDecimater()->mesh().garbage_collection();
501 thread->baseDecimater()->mesh().update_normals();
504 emit createBackup( thread->objectId(),
"Decimation");
508 if (runningJobs_ == 0)
510 tool_->pbDecimate->setEnabled(
true);
511 tool_->pbInitialize->setEnabled(
true);
520 QStringList constraintList = _constraints.split(
";");
524 for (
auto i = 0 ; i < constraintList.size() ; ++i) {
525 const auto& currentConstraint = constraintList[i];
527 int pos = currentConstraint.indexOf(
"=" );
530 emit log(
LOGERR,
"Wrong parameter format for decimater: " + currentConstraint);
534 QString constraintName = currentConstraint.left(pos);
535 QString constraintValue = currentConstraint.right(currentConstraint.size() - pos -1 );
539 double value = constraintValue.toDouble(&ok);
542 emit log(
LOGERR,
"Wrong parameter format for decimater. Conversion failed!");
543 emit log(
LOGERR,
"Got Name : " + constraintName );
544 emit log(
LOGERR,
"Got Value: " + constraintValue);
549 map[constraintName] = value;
563 emit log(
LOGERR,tr(
"Unable to get Object"));
571 emit log(
LOGWARN , tr(
"Unable to get object ( Only Triangle Meshes supported)"));
581 object->setObjectData(DECIMATER, decimater);
585 ModAspectRatioH hModAspectRatio;
586 ModEdgeLengthH hModEdgeLength;
587 ModHausdorffH hModHausdorff;
588 ModIndependentH hModIndependent;
589 ModNormalDeviationH hModNormalDeviation;
590 ModNormalFlippingH hModNormalFlipping;
591 ModQuadricH hModQuadric;
592 ModRoundnessH hModRoundness;
595 ptr::shared_ptr<BaseDecimaterType> decimater_object;
596 if (_constraints.contains(
"decimater_type"))
599 int value = _constraints[
"decimater_type"].toInt(&ok);
603 decimater_object = ptr::shared_ptr<DecimaterType>(
new DecimaterType(*mesh));
605 decimater_object = ptr::shared_ptr<McDecimaterType>(
new McDecimaterType(*mesh));
607 decimater_object = ptr::shared_ptr<MixedDecimaterType>(
new MixedDecimaterType(*mesh));
612 if (!decimater_object)
613 decimater_object = ptr::shared_ptr<DecimaterType>(
new DecimaterType(*mesh));
616 if(decimater->distance()) {
617 decimater->removeDistanceConstraint();
618 decimater_object->remove(hModHausdorff);
620 if(decimater->normalDeviation()) {
621 decimater->removeNormalDeviationConstraint();
622 decimater_object->remove(hModNormalDeviation);
624 if(decimater->normalFlipping()) {
625 decimater->removeNormalFlippingConstraint();
626 decimater_object->remove(hModNormalFlipping);
628 if(decimater->roundness()) {
629 decimater->removeRoundnessConstraint();
630 decimater_object->remove(hModRoundness);
632 if(decimater->aspectRatio()) {
633 decimater->removeAspectRatioConstraint();
634 decimater_object->remove(hModAspectRatio);
636 if(decimater->edgeLength()) {
637 decimater->removeEdgeLengthConstraint();
638 decimater_object->remove(hModEdgeLength);
640 if(decimater->independentSets()) {
641 decimater->removeIndependentSetsConstraint();
642 decimater_object->remove(hModIndependent);
646 if ( _constraints.contains(
"decimation_order") ){
649 int value = _constraints[
"decimation_order"].toInt(&ok);
654 decimater->setDecimationOrder(DecimaterInfo::DISTANCE);
655 decimater_object->add( hModQuadric );
656 decimater_object->module( hModQuadric ).unset_max_err();
659 decimater->setDecimationOrder(DecimaterInfo::NORMALDEV);
660 decimater_object->add(hModNormalDeviation);
661 decimater_object->module(hModNormalDeviation).set_binary(
false);
664 decimater->setDecimationOrder(DecimaterInfo::EDGELENGTH);
665 decimater_object->add(hModEdgeLength);
666 decimater_object->module(hModEdgeLength).set_binary(
false);
669 emit log(
LOGERR,tr(
"Invalid Decimation Order"));
674 emit log(
LOGERR,tr(
"No Decimation Order set"));
679 bool verticesCount =
false;
680 bool trianglesCount =
false;
684 if ( _constraints.contains(
"vertices") ){
688 int value = _constraints[
"vertices"].toInt(&ok);
691 verticesCount =
true;
694 }
else if ( _constraints.contains(
"triangles") ){
698 int value = _constraints[
"triangles"].toInt(&ok);
701 trianglesCount =
true;
707 if ( _constraints.contains(
"distance") ){
711 double value = _constraints[
"distance"].toDouble(&ok);
714 if ( decimater_object->add( hModHausdorff ) || (!verticesCount && !trianglesCount) ) {
715 decimater->setDistanceConstraint( value );
716 decimater_object->module( hModHausdorff ).set_tolerance( decimater->distanceValue() );
722 if ( _constraints.contains(
"normal_deviation") ){
726 int value = _constraints[
"normal_deviation"].toInt(&ok);
729 if ( decimater_object->add( hModNormalDeviation ) || (!verticesCount && !trianglesCount) ) {
730 decimater->setNormalDeviationConstraint( value );
731 decimater_object->module( hModNormalDeviation ).set_normal_deviation( decimater->normalDeviationValue() );
735 if ( decimater_object->add( hModNormalFlipping ) || (!verticesCount && !trianglesCount) ) {
736 decimater->setNormalFlippingConstraint();
742 if ( _constraints.contains(
"roundness") ){
746 double value = _constraints[
"roundness"].toDouble(&ok);
749 if ( decimater_object->add( hModRoundness ) || (!verticesCount && !trianglesCount) ) {
750 decimater->setRoundnessConstraint( value );
751 decimater_object->module( hModRoundness ).set_min_roundness( decimater->roundnessValue(), true );
757 if ( _constraints.contains(
"aspect_ratio") ){
761 double value = _constraints[
"aspect_ratio"].toDouble(&ok);
764 if ( decimater_object->add( hModAspectRatio ) || (!verticesCount && !trianglesCount) ) {
765 decimater->setAspectRatioConstraint( value );
766 decimater_object->module( hModAspectRatio ).set_aspect_ratio( decimater->aspectRatioValue() );
772 if ( _constraints.contains(
"edge_length") ){
776 double value = _constraints[
"edge_length"].toDouble(&ok);
779 if ( decimater_object->add( hModEdgeLength ) || (!verticesCount && !trianglesCount) ) {
780 decimater->setEdgeLengthConstraint( value );
781 decimater_object->module( hModEdgeLength ).set_edge_length( decimater->edgeLengthValue() );
787 if ( _constraints.contains(
"independent_sets") ){
789 bool value = _constraints[
"independent_sets"].toBool();
792 if ( decimater_object->add( hModIndependent ) || (!verticesCount && !trianglesCount) ) {
793 decimater->setIndependentSetsConstraint();
799 if( ! decimater_object->initialize() ){
800 emit log(
LOGWARN, tr(
"Decimater could not be initialized"));
804 float mc_factor = 0.5;
805 size_t randomSamples = 8;
807 if (_constraints.contains(
"random_samples"))
810 unsigned value =_constraints[
"random_samples"].toUInt(&ok);
812 randomSamples = value;
815 if (_constraints.contains(
"incremental_percentage"))
818 unsigned value =_constraints[
"incremental_percentage"].toUInt(&ok);
820 mc_factor = 1.f - (value*0.01f);
824 DecimaterType* dec =
dynamic_cast<DecimaterType*
>(decimater_object.get());
825 McDecimaterType* mcDec =
dynamic_cast<McDecimaterType*
>(decimater_object.get());
826 MixedDecimaterType* mixedDec =
dynamic_cast<MixedDecimaterType*
>(decimater_object.get());
831 dec->decimate_to(vertices);
832 else if (trianglesCount )
833 dec->decimate_to_faces(0, triangles);
835 dec->decimate_to_faces(0, 1);
837 else if (mcDec && !mixedDec)
839 mcDec->set_samples(randomSamples);
841 mcDec->decimate_to(vertices);
842 else if (trianglesCount)
843 mcDec->decimate_to_faces(0, triangles);
845 mcDec->decimate_to_faces(0, 1);
849 mixedDec->set_samples(randomSamples);
851 mixedDec->decimate_to(vertices,mc_factor);
852 else if (trianglesCount)
853 mixedDec->decimate_to_faces(0, triangles,mc_factor);
855 mixedDec->decimate_to_faces(0, 1,mc_factor);
858 emit log(
LOGERR,tr(
"Could not find Decimater Type"));
861 object->mesh()->garbage_collection();
862 object->mesh()->update_normals();
867 emit createBackup(_objID,
"Decimation");
870 QString param =
"(" + (_constraints.contains(
"decimation_order") ? tr(
"decimation_order = %1").arg(_constraints[
"decimation_order"].toString()) :
"") +
871 ", " + (_constraints.contains(
"distance") ? tr(
"distance = %1").arg(_constraints[
"distance"].toString()) :
"") +
872 ", " + (_constraints.contains(
"normal_deviation") ? tr(
"normal_deviation = %1").arg(_constraints[
"normal_deviation"].toString()) :
"") +
873 ", " + (_constraints.contains(
"edge_length") ? tr(
"edge_length = %1").arg(_constraints[
"edge_length"].toString()) :
"") +
874 ", " + (_constraints.contains(
"roundness") ? tr(
"roundness = %1").arg(_constraints[
"roundness"].toString()) :
"") +
875 ", " + (_constraints.contains(
"aspect_ratio") ? tr(
"aspect_ratio = %1").arg(_constraints[
"aspect_ratio"].toString()) :
"") +
876 ", " + (_constraints.contains(
"independent_sets") ? tr(
"independent_sets = %1").arg(_constraints[
"independent_sets"].toString()) :
"") +
877 ", " + (_constraints.contains(
"triangles") ? tr(
"triangles = %1").arg(_constraints[
"triangles"].toString()) :
"") +
878 ", " + (_constraints.contains(
"vertices") ? tr(
"vertices = %1").arg(_constraints[
"vertices"].toString()) :
"") +
")";
880 emit scriptInfo(
"decimate(" + QString::number(_objID) +
", " + param +
")" );
884 emit log(
LOGERR,tr(
"Unsupported object type for decimater"));
896 if ( !OpenFlipper::Options::gui() || !
tool_->isVisible() ) {
904 emit functionExists(
"infomeshobject" ,
"vertexCount(int)", ok ) ;
907 tool_->currentNumVertices->setText (
"<not available>");
915 max = std::max( RPC::callFunctionValue<int> (
"infomeshobject" ,
"vertexCount",o_it->id()) , max );
920 tool_->currentNumVertices->setText (
"<not available>");
922 tool_->verticesCount->blockSignals(
true);
923 tool_->verticesCountSlider->blockSignals(
true);
925 tool_->currentNumVertices->setText (QString::number(max));
926 tool_->verticesCount->setMaximum(max);
927 tool_->verticesCountSlider->setMaximum(max);
929 if (
tool_->verticesCount->value() < 2 )
931 tool_->verticesCount->setValue( max / 2 );
932 tool_->verticesCountSlider->setValue( max / 2);
935 tool_->verticesCount->blockSignals(
false);
936 tool_->verticesCountSlider->blockSignals(
false);
947 if (!OpenFlipper::Options::gui() || !
tool_->isVisible())
956 max = std::max(mesh->n_faces(), max);
960 tool_->trianglesCount->blockSignals(
true);
961 tool_->trianglesCountSlider->blockSignals(
true);
963 tool_->trianglesCount->setMinimum(1);
964 tool_->trianglesCount->setMaximum(max);
965 tool_->trianglesCountSlider->setMinimum(1);
966 tool_->trianglesCountSlider->setMaximum(max);
968 if (
tool_->trianglesCount->value() < 2)
970 tool_->trianglesCount->setValue (max / 2 );
971 tool_->trianglesCountSlider->setValue( max / 2);
974 tool_->trianglesCount->blockSignals(
false);
975 tool_->trianglesCountSlider->blockSignals(
false);
980 void DecimaterPlugin::slotObjectSelectionChanged(
int )
987 void DecimaterPlugin::objectDeleted(
int _id)
989 slotDisableDecimation();
994 void DecimaterPlugin::slotAboutToRestore(
int _id)
996 slotDisableDecimation();
1001 void DecimaterPlugin::slotDisableDecimation()
1003 if ( ! OpenFlipper::Options::gui())
1006 decimater_objects_.clear();
1007 tool_->pbDecimate->setEnabled(
false);
1012 void DecimaterPlugin::slotObjectUpdated(
int ,
const UpdateType& _type )
1023 void DecimaterPlugin::slotUpdateVertices()
1025 tool_->rbVertices->setChecked (
true);
1031 void DecimaterPlugin::slotUpdateTriangles()
1033 tool_->rbTriangles->setChecked (
true);
1039 void DecimaterPlugin::slotUpdateNormalDev()
1041 tool_->cbNormalDev->setChecked (
true);
1047 void DecimaterPlugin::slotUpdateEdgeLength()
1049 tool_->cbEdgeLength->setChecked (
true);
1057 tool_->cbDistance->setChecked (
true);
a class which provides an link generator for WhatsThisMessages linking to the user doc If you have an...
#define DATA_TRIANGLE_MESH
void setObjectData(QString _dataName, PerObjectData *_data)
void canceledJob(QString _job)
A job has been canceled.
void slotUpdateRoundness(int _value)
roundness slider - spinbox sync
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
void pluginsInitialized()
Initialization of the plugin when it is loaded by the core.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
void slot_decimate()
decimating called from button in toolbox
void startProcessing()
start processing
void slotUpdateNumVertices()
update number of vertices information
bool dataType(DataType _type) const
void slotUpdateAspectRatio(int _value)
sync between values of aspect ratio slider and spinbox in the toolbox
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
void decimate(int _objID, QVariantMap _constraints)
decimate an object
DecimaterToolbarWidget * tool_
Widget for Toolbox.
void slotUpdateDistance()
slider / spinbox updates
TriMeshObject * triMeshObject(BaseObjectData *_object)
Cast an BaseObject to a TriMeshObject if possible.
Type for a MeshObject containing a triangle mesh.
void slot_initialize()
init called from button in toolbox
const QStringList TARGET_OBJECTS("target")
Iterable object range.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(1)<< 3)
Topology updated.
PerObjectData * objectData(QString _dataName)
Returns the object data pointer.
QString generateLink(const QString &_ref="", const QString &_site="index.html") const
generates a clickable link to the documentation for whatsThis Messages
void slotUpdateNumTriangles()
gets and sets the current maximum number of triangles
DecimaterPlugin()
Default constructor.