diff --git a/src/Mod/MeshPart/Gui/Tessellation.cpp b/src/Mod/MeshPart/Gui/Tessellation.cpp index 0291e58d5a..68259a8882 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.cpp +++ b/src/Mod/MeshPart/Gui/Tessellation.cpp @@ -193,6 +193,34 @@ struct ShapeInfo { }; } +void Tessellation::on_estimateMaximumEdgeLength_clicked() +{ + std::list shapeObjects; + App::Document* activeDoc = App::GetApplication().getActiveDocument(); + if (!activeDoc) { + return; + } + + Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); + if (!activeGui) { + return; + } + + double edgeLen = 0; + for (auto &sel : Gui::Selection().getSelection("*",0)) { + auto shape = Part::Feature::getTopoShape(sel.pObject,sel.SubName); + if (shape.hasSubShape(TopAbs_FACE)) { + Base::BoundBox3d bbox = shape.getBoundBox(); + edgeLen = std::max(edgeLen, bbox.LengthX()); + edgeLen = std::max(edgeLen, bbox.LengthY()); + edgeLen = std::max(edgeLen, bbox.LengthZ()); + shapeObjects.emplace_back(sel.pObject, sel.SubName); + } + } + + ui->spinMaximumEdgeLength->setValue(edgeLen/10); +} + bool Tessellation::accept() { std::list shapeObjects; @@ -210,20 +238,13 @@ bool Tessellation::accept() this->document = QString::fromLatin1(activeDoc->getName()); - double edgeLen = 0; for (auto &sel : Gui::Selection().getSelection("*",0)) { auto shape = Part::Feature::getTopoShape(sel.pObject,sel.SubName); if (shape.hasSubShape(TopAbs_FACE)) { - Base::BoundBox3d bbox = shape.getBoundBox(); - edgeLen = std::max(edgeLen, bbox.LengthX()); - edgeLen = std::max(edgeLen, bbox.LengthY()); - edgeLen = std::max(edgeLen, bbox.LengthZ()); - shapeObjects.emplace_back(sel.pObject,sel.SubName); + shapeObjects.emplace_back(sel.pObject, sel.SubName); } } - ui->spinMaximumEdgeLength->setValue(edgeLen/10); - if (shapeObjects.empty()) { QMessageBox::critical(this, windowTitle(), tr("Select a shape for meshing, first.")); diff --git a/src/Mod/MeshPart/Gui/Tessellation.h b/src/Mod/MeshPart/Gui/Tessellation.h index 438f7918df..6b9bdc1f88 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.h +++ b/src/Mod/MeshPart/Gui/Tessellation.h @@ -49,6 +49,7 @@ protected: private Q_SLOTS: void meshingMethod(int id); + void on_estimateMaximumEdgeLength_clicked(); void on_comboFineness_currentIndexChanged(int); void on_checkSecondOrder_toggled(bool); void on_checkQuadDominated_toggled(bool); diff --git a/src/Mod/MeshPart/Gui/Tessellation.ui b/src/Mod/MeshPart/Gui/Tessellation.ui index 1eeab865fd..2a95fcbacc 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.ui +++ b/src/Mod/MeshPart/Gui/Tessellation.ui @@ -195,6 +195,13 @@ The smallest value is 0. + + + + Estimate + + +