From 93c32f0aa93ec622c38293fce9cf7b69c124f778 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 30 Sep 2017 16:15:24 +0200 Subject: [PATCH] fixes #0001906: add Parameters isRelative, theAngDeflection of BRepMesh_IncrementalMesh in MeshFromShape Gui command --- src/Mod/MeshPart/App/AppMeshPartPy.cpp | 16 ++++-- src/Mod/MeshPart/App/Mesher.cpp | 3 +- src/Mod/MeshPart/App/Mesher.h | 5 ++ src/Mod/MeshPart/Gui/Tessellation.cpp | 13 ++++- src/Mod/MeshPart/Gui/Tessellation.ui | 77 ++++++++++++++++++-------- 5 files changed, 84 insertions(+), 30 deletions(-) diff --git a/src/Mod/MeshPart/App/AppMeshPartPy.cpp b/src/Mod/MeshPart/App/AppMeshPartPy.cpp index 98eeac9def..f57064fd35 100644 --- a/src/Mod/MeshPart/App/AppMeshPartPy.cpp +++ b/src/Mod/MeshPart/App/AppMeshPartPy.cpp @@ -67,8 +67,11 @@ public: "Multiple signatures are available:\n" "\n" " meshFromShape(Shape)\n" - " meshFromShape(Shape, LinearDeflection, AngularDeflection=0.5,\n" - " Segments=False, GroupColors=[])\n" + " meshFromShape(Shape, LinearDeflection,\n" + " AngularDeflection=0.5,\n" + " Relative=False," + " Segments=False,\n" + " GroupColors=[])\n" " meshFromShape(Shape, MaxLength)\n" " meshFromShape(Shape, MaxArea)\n" " meshFromShape(Shape, LocalLength)\n" @@ -230,20 +233,23 @@ private: PyObject *shape; static char* kwds_lindeflection[] = {"Shape", "LinearDeflection", "AngularDeflection", - "Segments", "GroupColors", NULL}; + "Relative", "Segments", "GroupColors", NULL}; PyErr_Clear(); double lindeflection=0; double angdeflection=0.5; + PyObject* relative = Py_False; PyObject* segment = Py_False; PyObject* groupColors = 0; - if (PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O!d|dO!O", kwds_lindeflection, - &(Part::TopoShapePy::Type), &shape, &lindeflection, &angdeflection, + if (PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O!d|dO!O!O", kwds_lindeflection, + &(Part::TopoShapePy::Type), &shape, &lindeflection, + &angdeflection, &(PyBool_Type), &relative, &(PyBool_Type), &segment, &groupColors)) { MeshPart::Mesher mesher(static_cast(shape)->getTopoShapePtr()->getShape()); mesher.setMethod(MeshPart::Mesher::Standard); mesher.setDeflection(lindeflection); mesher.setAngularDeflection(angdeflection); mesher.setRegular(true); + mesher.setRelative(PyObject_IsTrue(relative) ? true : false); mesher.setSegments(PyObject_IsTrue(segment) ? true : false); if (groupColors) { Py::Sequence list(groupColors); diff --git a/src/Mod/MeshPart/App/Mesher.cpp b/src/Mod/MeshPart/App/Mesher.cpp index a5749c90ed..5c181ca8bf 100644 --- a/src/Mod/MeshPart/App/Mesher.cpp +++ b/src/Mod/MeshPart/App/Mesher.cpp @@ -148,6 +148,7 @@ Mesher::Mesher(const TopoDS_Shape& s) , angularDeflection(0.5) , minLen(0) , maxLen(0) + , relative(false) , regular(false) , segments(false) #if defined (HAVE_NETGEN) @@ -172,7 +173,7 @@ Mesh::MeshObject* Mesher::createMesh() const if (method == Standard) { if (!shape.IsNull()) { BRepTools::Clean(shape); - BRepMesh_IncrementalMesh aMesh(shape, deflection, Standard_False, angularDeflection); + BRepMesh_IncrementalMesh aMesh(shape, deflection, relative, angularDeflection); } std::vector domains; diff --git a/src/Mod/MeshPart/App/Mesher.h b/src/Mod/MeshPart/App/Mesher.h index 700677fa9f..93d70e3d4d 100644 --- a/src/Mod/MeshPart/App/Mesher.h +++ b/src/Mod/MeshPart/App/Mesher.h @@ -81,6 +81,10 @@ public: { regular = s; } bool isRegular() const { return regular; } + void setRelative(bool s) + { relative = s; } + bool isRelative() const + { return relative; } void setSegments(bool s) { segments = s; } bool isSegments() const @@ -134,6 +138,7 @@ private: double deflection; double angularDeflection; double minLen, maxLen; + bool relative; bool regular; bool segments; #if defined (HAVE_NETGEN) diff --git a/src/Mod/MeshPart/Gui/Tessellation.cpp b/src/Mod/MeshPart/Gui/Tessellation.cpp index 3ed380a444..e392d470b7 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.cpp +++ b/src/Mod/MeshPart/Gui/Tessellation.cpp @@ -31,6 +31,7 @@ #include "ui_Tessellation.h" #include #include +#include #include #include #include @@ -248,9 +249,17 @@ bool Tessellation::accept() QString cmd; if (method == 0) { // Standard double devFace = ui->spinSurfaceDeviation->value().getValue(); - QString param = QString::fromLatin1("Shape=__doc__.getObject(\"%1\").Shape,LinearDeflection=%2") + double devAngle = ui->spinAngularDeviation->value().getValue(); + devAngle = Base::toRadians(devAngle); + bool relative = ui->relativeDeviation->isChecked(); + QString param = QString::fromLatin1("Shape=__doc__.getObject(\"%1\").Shape, " + "LinearDeflection=%2, " + "AngularDeflection=%3, " + "Relative=%4") .arg(shape) - .arg(devFace); + .arg(devFace) + .arg(devAngle) + .arg(relative ? QString::fromLatin1("True") : QString::fromLatin1("False")); if (ui->meshShapeColors->isChecked()) param += QString::fromLatin1(",Segments=True"); if (ui->groupsFaceColors->isChecked()) diff --git a/src/Mod/MeshPart/Gui/Tessellation.ui b/src/Mod/MeshPart/Gui/Tessellation.ui index 7d2614eff8..5ddee89512 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.ui +++ b/src/Mod/MeshPart/Gui/Tessellation.ui @@ -59,30 +59,17 @@ 0 - - - - - Qt::Vertical - - - - 20 - 189 - - - - + - - + + Surface deviation: - + mm @@ -98,21 +85,67 @@ + + + + Angular deviation: + + + + + + + deg + + + 1.000000000000000 + + + 180.000000000000000 + + + 5.000000000000000 + + + 30.000000000000000 + + + + + + + Relative surface deviation + + + + + + Apply face colors to mesh + + + + Define segments by face colors - - - - Apply face colors to mesh + + + + Qt::Vertical - + + + 20 + 189 + + +