60 #include "DecimaterPlugin.hh" 62 #if QT_VERSION >= 0x050000 68 #define DECIMATER "DecimaterData" 81 void DecimaterPlugin::initializePlugin()
84 if ( OpenFlipper::Options::gui()) {
98 connect(
tool_->edgeLength,SIGNAL(valueChanged(
double) ),
this,SLOT(slotUpdateEdgeLength()) );
99 connect(
tool_->normalDeviation,SIGNAL(valueChanged(
int) ),
this,SLOT(slotUpdateNormalDev()) );
100 connect(
tool_->normalDeviationSlider,SIGNAL(valueChanged(
int) ),
this,SLOT(slotUpdateNormalDev()) );
101 connect(
tool_->verticesCount,SIGNAL(valueChanged(
int) ),
this,SLOT(slotUpdateVertices()) );
102 connect(
tool_->verticesCountSlider,SIGNAL(valueChanged(
int) ),
this,SLOT(slotUpdateVertices()) );
103 connect(
tool_->trianglesCount,SIGNAL(valueChanged(
int) ),
this,SLOT(slotUpdateTriangles()) );
104 connect(
tool_->trianglesCountSlider,SIGNAL(valueChanged(
int) ),
this,SLOT(slotUpdateTriangles()) );
109 connect(
tool_->mixedFactorCounter, SIGNAL(valueChanged(
double)),
this, SLOT(slotMixedCounterValueChanged(
double)) );
110 connect(
tool_->mixedFactorSlider, SIGNAL(valueChanged(
int)),
this, SLOT(slotMixedSliderValueChanged(
int)) );
111 connect(
tool_->cbDistance, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
112 connect(
tool_->cbNormalDev, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
113 connect(
tool_->cbEdgeLength, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
114 connect(
tool_->cbIndependentSets, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
115 connect(
tool_->cbRoundness, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
116 connect(
tool_->cbAspectRatio, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
117 connect(
tool_->rbByDistance, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
118 connect(
tool_->rbByEdgeLength, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
119 connect(
tool_->rbByNormalDeviation, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
120 connect(
tool_->rbConstraintsOnly, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
121 connect(
tool_->rbTriangles, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
122 connect(
tool_->rbUseDecimater, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
123 connect(
tool_->rbUseMC, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
124 connect(
tool_->rbUseMixed, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
125 connect(
tool_->rbVertices, SIGNAL(toggled(
bool)),
this, SLOT(slotDisableDecimation()));
127 toolIcon_ =
new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"decimater.png");
128 emit addToolbox( tr(
"Decimater") ,
tool_, toolIcon_ );
133 tool_->pbInitialize->setWhatsThis(
tool_->pbInitialize->whatsThis()+generator.
generateLink(
"quick_tutorial"));
134 tool_->rbUseDecimater->setWhatsThis(
tool_->rbUseDecimater->whatsThis()+generator.
generateLink(
"incremental"));
145 tool_->rbByNormalDeviation->setWhatsThis(
tool_->rbByNormalDeviation->whatsThis()+generator.
generateLink());
151 tool_->randomSamplesCounter->setWhatsThis(
tool_->randomSamplesCounter->whatsThis()+generator.
generateLink(
"multiple_choice"));
152 tool_->mixedFactorCounter->setWhatsThis(
tool_->mixedFactorCounter->whatsThis()+generator.
generateLink(
"mixed"));
167 emit setSlotDescription(
"decimate(int,QVariantMap)",tr(
"Decimate a given object"),
168 QString(tr(
"objectId,constraints")).split(
","),
169 QString(tr(
"ID of an object; Object that can has one or more constraint properties (" 170 "decimater_type [0 (Incremental), 1 (MC), 2 (Mixed)], " 171 "random_samples [For MC/Mixed], " 172 "incremental_percentage [For Mixed], " 173 "decimation_order [0 (by distance), 1 (by normal deviation), 2 (by edge length)], " 178 "aspect_ratio,independent_sets, " 180 "triangles)")).split(
";"));
182 if ( OpenFlipper::Options::gui()) {
183 tool_->decTypeOps->setVisible(
false);
196 tool_->roundness->setValue( (
double) _value / 100.0 );
197 tool_->cbRoundness->setChecked (
true);
200 void DecimaterPlugin::slotMixedCounterValueChanged(
double _value)
202 tool_->mixedFactorLabel->setText(QString::number(100-_value)+QString(
"%"));
203 tool_->mixedFactorSlider->setValue(100-_value);
205 void DecimaterPlugin::slotMixedSliderValueChanged(
int _value)
207 tool_->mixedFactorLabel->setText(QString::number(_value)+QString(
"%"));
208 tool_->mixedFactorCounter->setValue(100.0-_value);
219 tool_->roundnessSlider->setValue( (
int) (_value * 100) );
220 tool_->cbRoundness->setChecked (
true);
232 tool_->aspectRatio->setValue( (
double) _value / 100.0 );
233 tool_->cbAspectRatio->setChecked (
true);
245 tool_->aspectRatioSlider->setValue( (
int) (_value * 100) );
246 tool_->cbAspectRatio->setChecked (
true);
257 if ( ! OpenFlipper::Options::gui())
260 decimater_objects_.clear();
265 initialize_object(*o_it);
268 tool_->pbDecimate->setEnabled(
true);
276 emit log(
LOGWARN , tr(
"Unable to get object"));
288 ModAspectRatioH hModAspectRatio;
289 ModEdgeLengthH hModEdgeLength;
290 ModHausdorffH hModHausdorff;
291 ModIndependentH hModIndependent;
292 ModNormalDeviationH hModNormalDeviation;
293 ModNormalFlippingH hModNormalFlipping;
294 ModQuadricH hModQuadric;
295 ModRoundnessH hModRoundness;
298 ptr::shared_ptr<BaseDecimaterType> decimater_object;
299 if (
tool_->rbUseDecimater->isChecked())
300 decimater_object = ptr::shared_ptr<DecimaterType>(
new DecimaterType(*mesh));
301 else if(
tool_->rbUseMC->isChecked())
302 decimater_object = ptr::shared_ptr<McDecimaterType>(
new McDecimaterType(*mesh));
303 else if(
tool_->rbUseMixed->isChecked())
304 decimater_object = ptr::shared_ptr<MixedDecimaterType>(
new MixedDecimaterType(*mesh));
308 if(decimater->distance()) {
309 decimater->removeDistanceConstraint();
310 decimater_object->remove(hModHausdorff);
312 if(decimater->normalDeviation()) {
313 decimater->removeNormalDeviationConstraint();
314 decimater_object->remove(hModNormalDeviation);
316 if(decimater->normalFlipping()) {
317 decimater->removeNormalFlippingConstraint();
318 decimater_object->remove(hModNormalFlipping);
320 if(decimater->roundness()) {
321 decimater->removeRoundnessConstraint();
322 decimater_object->remove(hModRoundness);
324 if(decimater->aspectRatio()) {
325 decimater->removeAspectRatioConstraint();
326 decimater_object->remove(hModAspectRatio);
328 if(decimater->edgeLength()) {
329 decimater->removeEdgeLengthConstraint();
330 decimater_object->remove(hModEdgeLength);
332 if(decimater->independentSets()) {
333 decimater->removeIndependentSetsConstraint();
334 decimater_object->remove(hModIndependent);
338 if (
tool_->rbByDistance->isChecked()) {
339 decimater->setDecimationOrder(DecimaterInfo::DISTANCE);
340 decimater_object->add( hModQuadric );
341 decimater_object->module( hModQuadric ).unset_max_err();
342 }
else if (
tool_->rbByNormalDeviation->isChecked()) {
343 decimater->setDecimationOrder(DecimaterInfo::NORMALDEV);
344 decimater_object->add(hModNormalDeviation);
345 decimater_object->module(hModNormalDeviation).set_binary(
false);
346 }
else if (
tool_->rbByEdgeLength->isChecked()) {
347 decimater->setDecimationOrder(DecimaterInfo::EDGELENGTH);
348 decimater_object->add(hModEdgeLength);
349 decimater_object->module(hModEdgeLength).set_binary(
false);
354 if (
tool_->cbDistance->isChecked() ) {
355 if ( decimater_object->add( decInit->hModHausdorff ) ||
tool_->rbConstraintsOnly->isChecked() ) {
356 decimater->setDistanceConstraint(
tool_->distance->value() );
357 decimater_object->module( decInit->hModHausdorff ).set_tolerance( decimater->distanceValue() );
361 if (
tool_->cbNormalDev->isChecked() ) {
362 if ( decimater_object->add( decInit->hModNormalDeviation ) ||
tool_->rbConstraintsOnly->isChecked() ) {
363 decimater->setNormalDeviationConstraint(
tool_->normalDeviation->value() );
364 decimater_object->module( decInit->hModNormalDeviation ).set_normal_deviation( decimater->normalDeviationValue() );
367 if ( decimater_object->add( decInit->hModNormalFlipping ) ||
tool_->rbConstraintsOnly->isChecked() ) {
368 decimater->setNormalFlippingConstraint();
372 if (
tool_->cbRoundness->isChecked() ) {
373 if ( decimater_object->add( decInit->hModRoundness ) ||
tool_->rbConstraintsOnly->isChecked() ) {
374 decimater->setRoundnessConstraint(
tool_->roundness->value() );
375 decimater_object->module( decInit->hModRoundness ).set_min_roundness( decimater->roundnessValue(), true );
379 if (
tool_->cbAspectRatio->isChecked() ) {
380 if ( decimater_object->add( decInit->hModAspectRatio ) ||
tool_->rbConstraintsOnly->isChecked() ) {
381 decimater->setAspectRatioConstraint(
tool_->aspectRatio->value() );
382 decimater_object->module( decInit->hModAspectRatio ).set_aspect_ratio( decimater->aspectRatioValue() );
386 if (
tool_->cbEdgeLength->isChecked() ) {
387 if ( decimater_object->add( decInit->hModEdgeLength ) ||
tool_->rbConstraintsOnly->isChecked() ) {
388 decimater->setEdgeLengthConstraint(
tool_->edgeLength->value() );
389 decimater_object->module( decInit->hModEdgeLength ).set_edge_length( decimater->edgeLengthValue() );
393 if (
tool_->cbIndependentSets->isChecked() ) {
394 if ( decimater_object->add( decInit->hModIndependent ) ||
tool_->rbConstraintsOnly->isChecked() ) {
395 decimater->setIndependentSetsConstraint();
401 if( ! decimater_object->initialize() ){
402 emit log(
LOGWARN, tr(
"Decimater could not be initialized"));
406 decInit->decimater = decimater_object;
407 decInit->objId = obj->
id();
409 decimater_objects_.push_back(decInit);
412 void DecimaterPlugin::slot_initialize_object(
int obj_id,
bool clear) {
414 decimater_objects_.clear();
420 initialize_object(obj);
422 tool_->pbDecimate->setEnabled(
true);
432 if ( ! OpenFlipper::Options::gui())
436 runningJobs_ = decimater_objects_.size();
437 for (std::vector< ptr::shared_ptr<DecimaterInit> >::iterator decIter = decimater_objects_.begin();
438 decIter != decimater_objects_.end(); ++decIter)
440 ptr::shared_ptr<DecimaterInit> decInit = *decIter;
441 ptr::shared_ptr<BaseDecimaterType> decimater = decInit->decimater;
444 if (
tool_->cbDistance->isChecked() ) {
445 decimater->module( decInit->hModHausdorff ).set_tolerance(
tool_->distance->value() );
448 if (
tool_->cbNormalDev->isChecked() ) {
449 decimater->module( decInit->hModNormalDeviation ).set_normal_deviation(
tool_->normalDeviation->value() );
452 if (
tool_->cbRoundness->isChecked() ) {
453 decimater->module( decInit->hModRoundness ).set_min_roundness(
tool_->roundness->value(), true );
456 if (
tool_->cbAspectRatio->isChecked() ) {
457 decimater->module( decInit->hModAspectRatio ).set_aspect_ratio(
tool_->aspectRatio->value() );
460 if (
tool_->cbEdgeLength->isChecked() ) {
461 decimater->module( decInit->hModEdgeLength ).set_edge_length(
tool_->edgeLength->value() );
466 params.dec = (
tool_->rbUseDecimater->isChecked()) ? dynamic_cast<DecimaterType*>(decimater.get()) : NULL;
467 params.mcDec = (
tool_->rbUseMC->isChecked()) ? dynamic_cast<McDecimaterType*>(decimater.get()) : NULL;
468 params.mixedDec = (
tool_->rbUseMixed->isChecked()) ? dynamic_cast<MixedDecimaterType*>(decimater.get()) : NULL;
470 params.facesCount = (
tool_->rbTriangles->isChecked()) ?
tool_->trianglesCount->value() : -1;
471 params.verticesCount = (
tool_->rbVertices->isChecked() ) ?
tool_->verticesCount->value() : -1;
472 params.samples =
tool_->randomSamplesCounter->value();
473 params.mc_factor = 1.0 - (
tool_->mixedFactorCounter->value()*0.01);
476 QString jobId = QString(
"Decimate_Object_%1").arg(decInit->objId);
478 connect(th, SIGNAL(finished(QString)),
this,SIGNAL(finishJob(QString)));
479 connect(th, SIGNAL(finished(QString)),
this, SLOT(slot_decimate_finished(QString)));
480 connect(th, SIGNAL(state(QString,
int)),
this, SIGNAL(setJobState(QString,
int)));
481 connect(
this, SIGNAL(jobCanceled(QString)), th, SLOT(slotCancel(QString)));
483 tool_->pbDecimate->setEnabled(
false);
484 tool_->pbInitialize->setEnabled(
false);
486 emit startJob(jobId , QString(
"Decimate Object with Id %1").arg(decInit->objId) , 0, 100,
false);
498 emit jobCanceled(_job);
501 void DecimaterPlugin::slot_decimate_finished(QString _jobId)
508 if (!thread->baseDecimater())
512 thread->baseDecimater()->mesh().garbage_collection();
513 thread->baseDecimater()->mesh().update_normals();
516 emit createBackup( thread->objectId(),
"Decimation");
520 if (runningJobs_ == 0)
522 tool_->pbDecimate->setEnabled(
true);
523 tool_->pbInitialize->setEnabled(
true);
535 emit log(
LOGERR,tr(
"Unable to get Object"));
543 emit log(
LOGWARN , tr(
"Unable to get object ( Only Triangle Meshes supported)"));
553 object->setObjectData(DECIMATER, decimater);
557 ModAspectRatioH hModAspectRatio;
558 ModEdgeLengthH hModEdgeLength;
559 ModHausdorffH hModHausdorff;
560 ModIndependentH hModIndependent;
561 ModNormalDeviationH hModNormalDeviation;
562 ModNormalFlippingH hModNormalFlipping;
563 ModQuadricH hModQuadric;
564 ModRoundnessH hModRoundness;
567 ptr::shared_ptr<BaseDecimaterType> decimater_object;
568 if (_constraints.contains(
"decimater_type"))
571 int value = _constraints[
"decimater_type"].toInt(&ok);
575 decimater_object = ptr::shared_ptr<DecimaterType>(
new DecimaterType(*mesh));
577 decimater_object = ptr::shared_ptr<McDecimaterType>(
new McDecimaterType(*mesh));
579 decimater_object = ptr::shared_ptr<MixedDecimaterType>(
new MixedDecimaterType(*mesh));
584 if (!decimater_object)
585 decimater_object = ptr::shared_ptr<DecimaterType>(
new DecimaterType(*mesh));
588 if(decimater->distance()) {
589 decimater->removeDistanceConstraint();
590 decimater_object->remove(hModHausdorff);
592 if(decimater->normalDeviation()) {
593 decimater->removeNormalDeviationConstraint();
594 decimater_object->remove(hModNormalDeviation);
596 if(decimater->normalFlipping()) {
597 decimater->removeNormalFlippingConstraint();
598 decimater_object->remove(hModNormalFlipping);
600 if(decimater->roundness()) {
601 decimater->removeRoundnessConstraint();
602 decimater_object->remove(hModRoundness);
604 if(decimater->aspectRatio()) {
605 decimater->removeAspectRatioConstraint();
606 decimater_object->remove(hModAspectRatio);
608 if(decimater->edgeLength()) {
609 decimater->removeEdgeLengthConstraint();
610 decimater_object->remove(hModEdgeLength);
612 if(decimater->independentSets()) {
613 decimater->removeIndependentSetsConstraint();
614 decimater_object->remove(hModIndependent);
618 if ( _constraints.contains(
"decimation_order") ){
621 int value = _constraints[
"decimation_order"].toInt(&ok);
626 decimater->setDecimationOrder(DecimaterInfo::DISTANCE);
627 decimater_object->add( hModQuadric );
628 decimater_object->module( hModQuadric ).unset_max_err();
631 decimater->setDecimationOrder(DecimaterInfo::NORMALDEV);
632 decimater_object->add(hModNormalDeviation);
633 decimater_object->module(hModNormalDeviation).set_binary(
false);
636 decimater->setDecimationOrder(DecimaterInfo::EDGELENGTH);
637 decimater_object->add(hModEdgeLength);
638 decimater_object->module(hModEdgeLength).set_binary(
false);
641 emit log(
LOGERR,tr(
"Invalid Decimation Order"));
646 emit log(
LOGERR,tr(
"No Decimation Order set"));
651 bool verticesCount =
false;
652 bool trianglesCount =
false;
656 if ( _constraints.contains(
"vertices") ){
660 int value = _constraints[
"vertices"].toInt(&ok);
663 verticesCount =
true;
666 }
else if ( _constraints.contains(
"triangles") ){
670 int value = _constraints[
"triangles"].toInt(&ok);
673 trianglesCount =
true;
679 if ( _constraints.contains(
"distance") ){
683 double value = _constraints[
"distance"].toDouble(&ok);
686 if ( decimater_object->add( hModHausdorff ) || (!verticesCount && !trianglesCount) ) {
687 decimater->setDistanceConstraint( value );
688 decimater_object->module( hModHausdorff ).set_tolerance( decimater->distanceValue() );
694 if ( _constraints.contains(
"normal_deviation") ){
698 int value = _constraints[
"normal_deviation"].toInt(&ok);
701 if ( decimater_object->add( hModNormalDeviation ) || (!verticesCount && !trianglesCount) ) {
702 decimater->setNormalDeviationConstraint( value );
703 decimater_object->module( hModNormalDeviation ).set_normal_deviation( decimater->normalDeviationValue() );
707 if ( decimater_object->add( hModNormalFlipping ) || (!verticesCount && !trianglesCount) ) {
708 decimater->setNormalFlippingConstraint();
714 if ( _constraints.contains(
"roundness") ){
718 double value = _constraints[
"roundness"].toDouble(&ok);
721 if ( decimater_object->add( hModRoundness ) || (!verticesCount && !trianglesCount) ) {
722 decimater->setRoundnessConstraint( value );
723 decimater_object->module( hModRoundness ).set_min_roundness( decimater->roundnessValue(), true );
729 if ( _constraints.contains(
"aspect_ratio") ){
733 double value = _constraints[
"aspect_ratio"].toDouble(&ok);
736 if ( decimater_object->add( hModAspectRatio ) || (!verticesCount && !trianglesCount) ) {
737 decimater->setAspectRatioConstraint( value );
738 decimater_object->module( hModAspectRatio ).set_aspect_ratio( decimater->aspectRatioValue() );
744 if ( _constraints.contains(
"edge_length") ){
748 double value = _constraints[
"edge_length"].toDouble(&ok);
751 if ( decimater_object->add( hModEdgeLength ) || (!verticesCount && !trianglesCount) ) {
752 decimater->setEdgeLengthConstraint( value );
753 decimater_object->module( hModEdgeLength ).set_edge_length( decimater->edgeLengthValue() );
759 if ( _constraints.contains(
"independent_sets") ){
761 bool value = _constraints[
"independent_sets"].toBool();
764 if ( decimater_object->add( hModIndependent ) || (!verticesCount && !trianglesCount) ) {
765 decimater->setIndependentSetsConstraint();
771 if( ! decimater_object->initialize() ){
772 emit log(
LOGWARN, tr(
"Decimater could not be initialized"));
776 float mc_factor = 0.5;
777 size_t randomSamples = 8;
779 if (_constraints.contains(
"random_samples"))
782 unsigned value =_constraints[
"random_samples"].toUInt(&ok);
784 randomSamples = value;
787 if (_constraints.contains(
"incremental_percentage"))
790 unsigned value =_constraints[
"incremental_percentage"].toUInt(&ok);
792 mc_factor = 1.f - (value*0.01f);
796 DecimaterType* dec =
dynamic_cast<DecimaterType*
>(decimater_object.get());
797 McDecimaterType* mcDec =
dynamic_cast<McDecimaterType*
>(decimater_object.get());
798 MixedDecimaterType* mixedDec =
dynamic_cast<MixedDecimaterType*
>(decimater_object.get());
803 dec->decimate_to(vertices);
804 else if (trianglesCount )
805 dec->decimate_to_faces(0, triangles);
807 dec->decimate_to_faces(0, 1);
809 else if (mcDec && !mixedDec)
811 mcDec->set_samples(randomSamples);
813 mcDec->decimate_to(vertices);
814 else if (trianglesCount)
815 mcDec->decimate_to_faces(0, triangles);
817 mcDec->decimate_to_faces(0, 1);
821 mixedDec->set_samples(randomSamples);
823 mixedDec->decimate_to(vertices,mc_factor);
824 else if (trianglesCount)
825 mixedDec->decimate_to_faces(0, triangles,mc_factor);
827 mixedDec->decimate_to_faces(0, 1,mc_factor);
830 emit log(
LOGERR,tr(
"Could not find Decimater Type"));
833 object->mesh()->garbage_collection();
834 object->mesh()->update_normals();
839 emit createBackup(_objID,
"Decimation");
842 QString param =
"(" + (_constraints.contains(
"decimation_order") ? tr(
"decimation_order = %1").arg(_constraints[
"decimation_order"].toString()) :
"") +
843 ", " + (_constraints.contains(
"distance") ? tr(
"distance = %1").arg(_constraints[
"distance"].toString()) :
"") +
844 ", " + (_constraints.contains(
"normal_deviation") ? tr(
"normal_deviation = %1").arg(_constraints[
"normal_deviation"].toString()) :
"") +
845 ", " + (_constraints.contains(
"edge_length") ? tr(
"edge_length = %1").arg(_constraints[
"edge_length"].toString()) :
"") +
846 ", " + (_constraints.contains(
"roundness") ? tr(
"roundness = %1").arg(_constraints[
"roundness"].toString()) :
"") +
847 ", " + (_constraints.contains(
"aspect_ratio") ? tr(
"aspect_ratio = %1").arg(_constraints[
"aspect_ratio"].toString()) :
"") +
848 ", " + (_constraints.contains(
"independent_sets") ? tr(
"independent_sets = %1").arg(_constraints[
"independent_sets"].toString()) :
"") +
849 ", " + (_constraints.contains(
"triangles") ? tr(
"triangles = %1").arg(_constraints[
"triangles"].toString()) :
"") +
850 ", " + (_constraints.contains(
"vertices") ? tr(
"vertices = %1").arg(_constraints[
"vertices"].toString()) :
"") +
")";
852 emit scriptInfo(
"decimate(" + QString::number(_objID) +
", " + param +
")" );
856 emit log(
LOGERR,tr(
"Unsupported object type for decimater"));
868 if ( !OpenFlipper::Options::gui() || !
tool_->isVisible() ) {
876 emit functionExists(
"infomeshobject" ,
"vertexCount(int)", ok ) ;
879 tool_->currentNumVertices->setText (
"<not available>");
887 max = std::max( RPC::callFunctionValue<int> (
"infomeshobject" ,
"vertexCount",o_it->id()) , max );
892 tool_->currentNumVertices->setText (
"<not available>");
894 tool_->verticesCount->blockSignals(
true);
895 tool_->verticesCountSlider->blockSignals(
true);
897 tool_->currentNumVertices->setText (QString::number(max));
898 tool_->verticesCount->setMaximum(max);
899 tool_->verticesCountSlider->setMaximum(max);
901 if (
tool_->verticesCount->value() < 2 )
903 tool_->verticesCount->setValue( max / 2 );
904 tool_->verticesCountSlider->setValue( max / 2);
907 tool_->verticesCount->blockSignals(
false);
908 tool_->verticesCountSlider->blockSignals(
false);
919 if (!OpenFlipper::Options::gui() || !
tool_->isVisible())
928 max = std::max(mesh->n_faces(), max);
932 tool_->trianglesCount->blockSignals(
true);
933 tool_->trianglesCountSlider->blockSignals(
true);
935 tool_->trianglesCount->setMinimum(1);
936 tool_->trianglesCount->setMaximum(max);
937 tool_->trianglesCountSlider->setMinimum(1);
938 tool_->trianglesCountSlider->setMaximum(max);
940 if (
tool_->trianglesCount->value() < 2)
942 tool_->trianglesCount->setValue (max / 2 );
943 tool_->trianglesCountSlider->setValue( max / 2);
946 tool_->trianglesCount->blockSignals(
false);
947 tool_->trianglesCountSlider->blockSignals(
false);
952 void DecimaterPlugin::slotObjectSelectionChanged(
int )
959 void DecimaterPlugin::objectDeleted(
int _id)
961 slotDisableDecimation();
966 void DecimaterPlugin::slotAboutToRestore(
int _id)
968 slotDisableDecimation();
973 void DecimaterPlugin::slotDisableDecimation()
975 if ( ! OpenFlipper::Options::gui())
978 decimater_objects_.clear();
979 tool_->pbDecimate->setEnabled(
false);
984 void DecimaterPlugin::slotObjectUpdated(
int ,
const UpdateType& _type )
995 void DecimaterPlugin::slotUpdateVertices()
997 tool_->rbVertices->setChecked (
true);
1003 void DecimaterPlugin::slotUpdateTriangles()
1005 tool_->rbTriangles->setChecked (
true);
1011 void DecimaterPlugin::slotUpdateNormalDev()
1013 tool_->cbNormalDev->setChecked (
true);
1019 void DecimaterPlugin::slotUpdateEdgeLength()
1021 tool_->cbEdgeLength->setChecked (
true);
1029 tool_->cbDistance->setChecked (
true);
1032 #if QT_VERSION < 0x050000 void slot_decimate()
decimating called from button in toolbox
DecimaterPlugin()
Default constructor.
void slotUpdateDistance()
slider / spinbox updates
Type for a MeshObject containing a triangle mesh.
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(1)<< 3)
Topology updated.
bool getObject(int _identifier, BSplineCurveObject *&_object)
bool dataType(DataType _type) const
const QStringList TARGET_OBJECTS("target")
Iterable object range.
void slotUpdateNumVertices()
update number of vertices information
void slotUpdateRoundness(int _value)
roundness slider - spinbox sync
void slotUpdateNumTriangles()
gets and sets the current maximum number of triangles
void canceledJob(QString _job)
A job has been canceled.
void startProcessing()
start processing
void setObjectData(QString _dataName, PerObjectData *_data)
a class which provides an link generator for WhatsThisMessages linking to the user doc If you have an...
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
TriMeshObject * triMeshObject(BaseObjectData *_object)
Cast an BaseObject to a TriMeshObject if possible.
void slotUpdateAspectRatio(int _value)
sync between values of aspect ratio slider and spinbox in the toolbox
void slot_initialize()
init called from button in toolbox
void pluginsInitialized()
Initialization of the plugin when it is loaded by the core.
void decimate(int _objID, QVariantMap _constraints)
decimate an object
#define DATA_TRIANGLE_MESH
QString generateLink(const QString &_ref="", const QString &_site="index.html") const
generates a clickable link to the documentation for whatsThis Messages
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
DecimaterToolbarWidget * tool_
Widget for Toolbox.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
PerObjectData * objectData(QString _dataName)
Returns the object data pointer.