View Issue Details

IDProjectCategoryView StatusLast Update
0004426FreeCADPatchpublic2020-09-12 18:00
ReporterthomasFreeCAD Assigned Towmayer  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version0.19 
Fixed in Version0.19 
Summary0004426: Patch to add MinLength and MaxLenght to the Netgen options in the Python API
Descriptiononly tested with python , I have no idea if this will work in the GUI

before this patch the Netgen Signature was like this
mesh=MeshPart.meshFromShape(Shape=geometry,Fineness=5,SecondOrder=0,Optimize=0,AllowQuad=1)

now it allows this
mesh=MeshPart.meshFromShape(Shape=geometry,Fineness=5,SecondOrder=0,Optimize=0,AllowQuad=1, MinLength=min_elt_length, MaxLength=max_elt_length)
TagsNo tags attached.
FreeCAD Informationonly tested with the python interface

Activities

thomasFreeCAD

2020-09-04 11:36

reporter  

minMaxNetgen.diff (5,426 bytes)   
diff --git a/src/Main/freecad.rc b/src/Main/freecad.rc
index 31c7a1a73..0bfd99668 100644
--- a/src/Main/freecad.rc
+++ b/src/Main/freecad.rc
@@ -1,35 +1,35 @@
-/////////////////////////////////////////////////////////////////////////////
-// For info about the file structrure see
-// https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
-// and
-// https://docs.microsoft.com/en-us/windows/win32/menurc/stringfileinfo-block
-
-// Icon
-//
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_ICON1               ICON    DISCARDABLE     "icon.ico"
-
-// File info for the FreeCAD.exe
-//
-1 VERSIONINFO 
-FILEVERSION ${PACKAGE_VERSION_MAJOR},${PACKAGE_VERSION_MINOR},${FREECAD_VERSION_PATCH},${PACKAGE_VERSION_PATCH}
-BEGIN
-    BLOCK "StringFileInfo"
-    BEGIN
-        BLOCK "040904b0" // 409 stands for US English
-        BEGIN
-            VALUE "CompanyName", "${PROJECT_NAME} Team"
-            VALUE "FileDescription", "${PROJECT_NAME} main executable"
-            VALUE "InternalName", "FreeCAD.exe"
-            VALUE "LegalCopyright", "Copyright (C) 2020"
-            VALUE "OriginalFilename", "FreeCAD.exe"
-            VALUE "ProductName", "${PROJECT_NAME}"
-            VALUE "${FREECAD_VERSION}.${PACKAGE_VERSION_SUFFIX}"
-        END
-    END
-    BLOCK "VarFileInfo"
-    BEGIN
-        VALUE "Translation", 0x409, 1200 //US English, Unicode
-    END
-END
+/////////////////////////////////////////////////////////////////////////////
+// For info about the file structrure see
+// https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
+// and
+// https://docs.microsoft.com/en-us/windows/win32/menurc/stringfileinfo-block
+
+// Icon
+//
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON1               ICON    DISCARDABLE     "icon.ico"
+
+// File info for the FreeCAD.exe
+//
+1 VERSIONINFO 
+FILEVERSION 0,19,0,16100
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0" // 409 stands for US English
+        BEGIN
+            VALUE "CompanyName", "FreeCAD Team"
+            VALUE "FileDescription", "FreeCAD main executable"
+            VALUE "InternalName", "FreeCAD.exe"
+            VALUE "LegalCopyright", "Copyright (C) 2020"
+            VALUE "OriginalFilename", "FreeCAD.exe"
+            VALUE "ProductName", "FreeCAD"
+            VALUE "ProductVersion", "0.19.0dev"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200 //US English, Unicode
+    END
+END
diff --git a/src/Mod/MeshPart/App/AppMeshPartPy.cpp b/src/Mod/MeshPart/App/AppMeshPartPy.cpp
index 9666c5bc0..43d2c22d6 100644
--- a/src/Mod/MeshPart/App/AppMeshPartPy.cpp
+++ b/src/Mod/MeshPart/App/AppMeshPartPy.cpp
@@ -116,7 +116,7 @@ public:
             "currently):\n"
             "\n"
             "    meshFromShape(Shape, Fineness, SecondOrder=0,\n"
-            "                         Optimize=1, AllowQuad=0)\n"
+            "                         Optimize=1, AllowQuad=0,MaxLength=0,MinLength=0)\n"
             "    meshFromShape(Shape, GrowthRate=0, SegPerEdge=0,\n"
             "                  SegPerRadius=0, SecondOrder=0, Optimize=1,\n"
             "                  AllowQuad=0)\n"
@@ -576,18 +576,19 @@ private:
         }
 
 #if defined (HAVE_NETGEN)
-        static char* kwds_fineness[] = {"Shape", "Fineness", "SecondOrder", "Optimize", "AllowQuad",NULL};
+        static char* kwds_fineness[] = {"Shape", "Fineness", "SecondOrder", "Optimize", "AllowQuad","MinLength","MaxLength", NULL};
         PyErr_Clear();
         int fineness=0, secondOrder=0, optimize=1, allowquad=0;
-        if (PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O!i|iii", kwds_fineness,
+        if (PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O!i|iiidd", kwds_fineness,
                                         &(Part::TopoShapePy::Type), &shape, &fineness,
-                                        &secondOrder, &optimize, &allowquad)) {
+                                        &secondOrder, &optimize, &allowquad,&minLen, &maxLen)) {
             MeshPart::Mesher mesher(static_cast<Part::TopoShapePy*>(shape)->getTopoShapePtr()->getShape());
             mesher.setMethod(MeshPart::Mesher::Netgen);
             mesher.setFineness(fineness);
             mesher.setSecondOrder(secondOrder != 0);
             mesher.setOptimize(optimize != 0);
             mesher.setQuadAllowed(allowquad != 0);
+            mesher.setMinMaxLengths(minLen, maxLen);
             return Py::asObject(new Mesh::MeshPy(mesher.createMesh()));
         }
 
diff --git a/src/Mod/MeshPart/App/Mesher.cpp b/src/Mod/MeshPart/App/Mesher.cpp
index b83d22d48..4890f8d0e 100644
--- a/src/Mod/MeshPart/App/Mesher.cpp
+++ b/src/Mod/MeshPart/App/Mesher.cpp
@@ -356,7 +356,9 @@ Mesh::MeshObject* Mesher::createMesh() const
             if (nbSegPerRadius > 0)
                 hyp2d->SetNbSegPerRadius(nbSegPerRadius);
         }
-
+        if (maxLen >0 ) hyp2d->SetMaxSize(maxLen);
+        if (minLen >0 ) hyp2d->SetMinSize(maxLen);
+ 
         hyp2d->SetQuadAllowed(allowquad);
         hyp2d->SetOptimize(optimize);
         hyp2d->SetSecondOrder(secondOrder); // apply bisecting to create four triangles out of one
minMaxNetgen.diff (5,426 bytes)   

wmayer

2020-09-12 17:42

administrator   ~0014745

https://github.com/FreeCAD/FreeCAD/commit/f681b86abdddd55e2dcb80bc4612251570cc9b8b

wmayer

2020-09-12 18:00

administrator   ~0014746

Fix committed to master branch.

Related Changesets

FreeCAD: master f681b86a

2020-09-12 17:34:41

wmayer

Details Diff
fixes 0004426: [skip ci] Patch to add MinLength and MaxLenght to the Netgen options in the Python API (provided by thomasFreeCAD) Affected Issues
0004426
mod - src/Mod/MeshPart/App/AppMeshPartPy.cpp Diff File
mod - src/Mod/MeshPart/App/Mesher.cpp Diff File

Issue History

Date Modified Username Field Change
2020-09-04 11:36 thomasFreeCAD New Issue
2020-09-04 11:36 thomasFreeCAD File Added: minMaxNetgen.diff
2020-09-12 17:42 wmayer Assigned To => wmayer
2020-09-12 17:42 wmayer Status new => closed
2020-09-12 17:42 wmayer Resolution open => fixed
2020-09-12 17:42 wmayer Fixed in Version => 0.19
2020-09-12 17:42 wmayer Note Added: 0014745
2020-09-12 18:00 wmayer Changeset attached => FreeCAD master f681b86a
2020-09-12 18:00 wmayer Note Added: 0014746