From 36bd2f987c1e538c7c6bcf13e9d80bd7b8387f2e Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 10 Dec 2019 16:43:10 +0100 Subject: [PATCH] fix usability regression of Mefisto mesher cuased by 95f20b9d The maximum edge length for the Mefisto mesher is always set in the accept() method so that effectively user input is always ignored. There is now a button Estimate to guess a good default value. And user input is no longer ingored --- src/Mod/MeshPart/Gui/Tessellation.cpp | 37 +++++++++++++++++++++------ src/Mod/MeshPart/Gui/Tessellation.h | 1 + src/Mod/MeshPart/Gui/Tessellation.ui | 7 +++++ 3 files changed, 37 insertions(+), 8 deletions(-) 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 + + +