algorithmic modeling for Rhino
MeshMachine, a part of Kangaroo 1, is prone to blowing up as you add more iterations, assuming you can get it to work at all in an hour or more. It has ability to relax a mesh, and to fix in place sharp edges fairly well, but since it has such kinetic behavior, seemingly optimized for speed on small test systems, it doesn't give the most uniform mesh, most of the time. If you take the dual of the triangular mesh, you see lots of squares and octagons.
I also had to rely on MeshMachine to refine Cocoon marching cubes organic surfaces, since the refine component of Cocoon blows up even worse than MeshMachine, which it is black box based on, with five completely undocumented parameters.
So I searched for many days for various scriptable libraries, all of them in C++, and not only did few work well as software, they gave lots of squares too, meaning they are poor at dividing up a surface evenly, since those four triangles per square dual shape are so small of an area. I want something more like a beehive or a fly's eye.
The standard library for geometry out there is CGAL, and it would be nearly impossible for most Grasshopper users to install it, since there are no binaries of the latest versions, and you have to compile several smaller libraries as you spend upwards of many full days searching forums for answers to errors in just installing it. And who knows how good of meshes it makes? I can only test it in C++, fairly easy enough, and may be able to compile a remeshing function that I can call from the command line which I can upload as a working binary, that will write the output to disk. That means I could call it from Python, anybody could, since Python is so simple. But what I can't do after the installation is get Python bindings to work on Windows. That's just broken completely.
The breakthrough, after struggling through truly terrible Windows utility programs, was finding OpenFlipper, a geometry plug-in development platform. It even has a Grasshopper-like nodal editor to build scripts, but that's so far limited. The normal scripting commands are easy to pick up on though, so I wrote Grasshopper wrappers for three remeshing strategies that result in no squares or even octagons and above, only pentagons, hexagons and septagons in the resulting dual of the triangle mesh. I used Python to write an input mesh to disk as an STL, then I create an OpenFlipper script on the fly, also written to disk, then I have OpenFlipper run and I read in the resulting STL file back into Python and spit out a Rhino/Grasshopper mesh again. It briefly brings up the GUI of OpenFlipper then closes it to put you back in Grasshopper, since the command-line-only option seems to be broken and this allows all commands to run, not just blind capable ones.
The Python scripts are simple enough to modify on your own to add more OpenFlipper commands.
Just download the Windows program here, the "Staging" version being the desired beta version with more features:
Install it in the normal Programs Folder. In the future you will have to edit the path in Python with updated OpenFlipper version numbers, in line 35 below. [See troubleshooting posts below about right clicking on Rhino.exe and OpenFlipper.exe to set the Compatibility tab checkbox in Properties to "Open this program as administrator." and to also check that OpenFlipper's directory matches what's in the Python code that you can view by double clicking the Python component on the Grasshopper canvas.]
None of the three strategies automatically preserves hard edges, so for those the adaptive strategy is often best.
Use Weaverbird Dual to gain quick access to this blissfully better distribution of cells on a surface than the "alien slime" of random Voronoi diagrams.
These will not smooth out original large facets from crude meshes, so subdivide those first using Weaverbird. I included a source meshing group, to apply to NURBS polysurfaces, too, since OpenFlipper won't import surfaces, only meshes.
Such ideal meshing that lack tight little square areas in the dual will also afford highest quality 3D tetrahedral meshes. I ported Tetgen to Grasshopper too, in the past, for that, and that also affords 3D polyhedral cells.
Getting the more open, less dense dual of 3D tetrahedral meshes is still too slow and failure prone since Tetgen doesn't clip it's Voronoi-like output cells at the mesh surface so I can only obtain inner cells readily. It only offers endless direction vectors for the outermost wires.
Inner truss breakthough, to avoid slow and disorderly (overly surface constrained) tetrahedral meshing and dual extraction:
This one is a puzzle. I'm on Rhino Version 5 SR14 64-bit (5.14.522.8390, 05/22/2017) with Grasshopper Version 5 SR14 64-bit (5.14.522.8390, 05/22/2017) with I believe the latest Grasshopper Python plug-in (0.6.0.3 as seen in the editor window).
As I answered below, it may be permissions in Windows, so try that kludge after confirming the latest versions above. Windows likes to protect system folders.
Line 35 is where I call OpenFlipper to issue command line options, here the file name and the script name. Line 488 in the subprocess.py seems intact, but is failing for some reason:
Ah, I could test my script on my dual boot of Windows 7 instead of Windows 10 to see if I get the same problem, and then learn to fix it there, since it's working on Windows 10 so I can't troubleshoot it....
Indeed, I got this same error when I ran the script from Windows 7. I already had Rhino set to run as administrator though. At least I'll be able to debug it now. It was very hectic to get the command line option call to work at all, having to do with spaces in directory paths, mostly. Just terrible and conflicting advise out there on Stackexchange. Stay tuned....
Are you on Windows 10? That would clear up if it's a version conflict or not.
Ah, I simply haven't installed OpenFlipper yet on Windows 7 via the OpenFlipper-Staging-3.1-64-Bit.exe installer.
...and it then works fine. I didn't have to set it to run as administrator, actually. And even when I made Rhino.exe not run as admin, it still worked. That is different than Arturo below, where the kludge worked for him on a different error.
I've installed the "OpenFlipper-Free-3.1-64-Bit" Should I install the other one? I mean the OpenFlipper-Staging-3.1-64-Bit.exe installer.
Nik, thanks for looking into the issue. I'm working with 64 bit Windows 7. All software is on newest release. Even running both Rhino 64 bit version and Open Flipper 64 bit version as administrator I get the same error as mentioned before.
I just could solve my problem: OpenFlipper on my computer is in C:\Program Files\OpenFlipper 3.0\OpenFlipper.exe not in OpenFlipper 3.1 as in your script.
Changing the script accordingly and it works fine. Thanks again for your effort!
Yes, there's two versions, and mine is the beta one with more features, so that's the 3.1, I guess. They call it the "staging" version, though on their web site both normal and staging are listed under 3.1 version.
You can also tell OpenFlipper to not show the splash screen, which is a bit more bewildering than just having the program come up while it's working. I would also like to tell it to start up in hidden line mode so I could briefly see the mesh. By the way, if OpenFlipper is taking too long, it will lock up Grasshopper until you cont-alt-del quit OpenFlipper.
I got the following error with sample file. Any idea of what have I done wrong?
Runtime error (IOException): Access to the path 'C:\NIKS_OPENFLIPPER_PARSER_TEMP.stl' is denied.
line 8, in script
This is some entry level Python issue, just to create ("open") a file.
Try this first: right click both Rhino.exe and OpenFlipper.exe to get to the Properties/Compatibility tab and set them to "Run this program as administrator." Perhaps Windows is protecting the bare C:/ top directory.