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
This commit is contained in:
wmayer
2019-12-10 16:43:10 +01:00
parent d17b3c68d1
commit 36bd2f987c
3 changed files with 37 additions and 8 deletions

View File

@@ -193,6 +193,34 @@ struct ShapeInfo {
};
}
void Tessellation::on_estimateMaximumEdgeLength_clicked()
{
std::list<ShapeInfo> 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<double>(edgeLen, bbox.LengthX());
edgeLen = std::max<double>(edgeLen, bbox.LengthY());
edgeLen = std::max<double>(edgeLen, bbox.LengthZ());
shapeObjects.emplace_back(sel.pObject, sel.SubName);
}
}
ui->spinMaximumEdgeLength->setValue(edgeLen/10);
}
bool Tessellation::accept()
{
std::list<ShapeInfo> 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<double>(edgeLen, bbox.LengthX());
edgeLen = std::max<double>(edgeLen, bbox.LengthY());
edgeLen = std::max<double>(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."));

View File

@@ -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);

View File

@@ -195,6 +195,13 @@ The smallest value is 0.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="estimateMaximumEdgeLength">
<property name="text">
<string>Estimate</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">