GH: Script or Component for Isotropic remeshing

I will try that.

I would have tried already but I got stuck on hye command Rhino.Geometry.Mesh.ExtractNonManifoldEdges(…) command (doesn’t exist, although the RhinoCommon documentation says that it exists).

Thanks, I’ll try that one as well. Too bad if the command doesn’t take tolerance parameters as well. But I can use the GH version if need be.

// Rolf

I tried the Rhino command MMTriangles. Nothing happens (I set edge length > 0.5 but no go).

I also tried the Gh version but I can’t get any meaningful output from the MeshMachine. The output is of type “Plankton.PlanktonMesh”. Where can I find such a component? I would need a Mesh or GH_Mesh type.

I tried after install to search for “Plankton” etc but no such component names show up. The std preview in GH doesn’t draw the result (i.e. the Plankton.PlanktonMesh).

What to try next?

// Rolf

Ping; @DanielPiker and @DavidRutten,

Where can I find and utilize a Plankton.PlanktonMesh? Or, how can cast the PlanktonMesh to something useful?

I also found several plankton.dll’s in my GrassHopper libraries, among them in the folder for MeshEdit. But I can’t see any mesh components of that kind in my menus.

Anyhow, can a PlanktonMesh be converted to Rhino.Geometry.Mesh?

// Rolf

Hi Rolf,

I was forgetting that the MMTriangles command currently only works with a Brep input. I’ll try and make a version that can work from a starting mesh too.

For the casting of the Plankton output - you should have a PlanktonMesh param component under the Params>Geometry tab. If you connect this to the output of MeshMachine, you can either bake it directly or convert to a regular Rhino mesh.

Ah yes, there it was.

Strange that it didn’t show up when I searched for the component names though (perhaps there was a conflict when I had newer and older Kangaroo & Plankton dll’s installed…). Unfortunately I get an exception when running the component

Same error as i get when I tried compiling into a GH Component some code you had in a C# script component in a Gh definition (“Remeshimg.gha”) which was commented by you like so:

        // Dynamic remeshing script
        // Daniel Piker 07/01/2014
        // This approach is loosely based on that described in
        // "A Remeshing Approach to Multiresolution Modeling" by Botsch and Kobbelt

however, I keep getting a runtime error (probably from a Plankton.dll) saying so:


The code line where it crashes (at "CollapseEdge) :

A problem with the mesh, or a dll mismatch?

// Rolf

That looks like it might a problem with the input mesh.
The triangle sizes and aspect ratios can be bad, but it does need to start out as a good mesh topologically.
If there are any naked edges they need to be restrained.
What does Rhino’s Mesh Repair command say about your input mesh?

Is there any analysis report tool inbuilt in Rhino? Anyway, it has non-manifold edges according to Gh analyis component (Elements*)

I also just noticed that the RhinoCommon command for M_Rhino_Geometry_Mesh_ExtractNonManifoldEdges doesn’t work. :frowning:

Two of the “clean components” I have tried doesn’t remove the non-manifold edges.

// Rolf

Yes - Type MeshRepair on the command line, then click Check Mesh.

Also - You might be able to get around the problems with the input mesh by only using it as a target, yet starting off from some other mesh with clean topology.

So you would make some clean mesh surrounding your object, such as a simple mesh sphere, put that into the Geom input of MeshMachine and initialise it by switching Reset from True to False.
Then you replace the Geom input with your actual target mesh. It will keep the valid topology from the sphere, but now will try and pull it onto the shape you want.

Hm, the thing is that I need to automate all this. But for now I used another mesh which was repaired with meshlab). The initial cleanup must not even be visible to the user. The user only opens up a file with the mesh which then gets cleaned and prepared for some geometric analysis. Some of these analyses are based on the vertices, which is why I need to have an isotropic mesh.

It seems difficult to make the MeshMachine end up with a specific edge length within a specific number of iterations. And if letting it run too long it fails with some error.

If you have any code that “goes right at it” i’d be very interested, otherwise I will have to let MeshLab or InstantMesher do the job in an external process (which I really want to avoid). If I’m not mistaken, it seems that RhinoCommon doesn’t have any mesh repair tools for fixing non-manifold etc).

// Rolf

@DanielPiker, I seemed like an interesting approach. However, I tried several times to shrink a sphere over my mesh, but the inital clean mesh doesn’t stop at the target mesh. It either doesn’t shrink at all or just keeps shrinking once I start the timer.

Could you think of making a demo definition in which it actually works, or a new component with a source and a target mesh?

// Rolf

Hi Rolf,

Here’s an example that shrinkwraps while remeshing, it also works without the timer.
Tested here on a bad mesh with non-manifold edges, degenerate and duplicate faces.
It uses a different build of the remesher that I don’t think I ever officially released before, so I’m including it below too. The first time you open the definition you’ll need to set the assembly locations in the script components. (34.6 KB)
remesher.gha (20 KB)

Thank you very much!

I will try this right away.

// Rolf

1 Like

Unfortunately the component doesn’t show up, neither in Rh5 nor WIP. The first time I open up the GH definition I set the Plankton.dll’s, that was ok, but then it fails with the following message.


I do have a MeshMachine installed (in a separate Kangaroo tab) but it seems like something is missing or I have the wrong version of the Meshmachine? (at least it doesn’t look like your version of MeshMachine in your earlier post in this thread):



Where can I download your version of the MM?

// Rolf

Hi Rolf,

The file remesher.gha in my last post above is the version you need. Did you already try installing this one? Are there any error messages on grasshopper startup?

Yes I tried installing the files in your last post, but I get error messages. In WIP I get this:

An error occured during GHA assembly loading:
  Path: C:\Users\RIL\AppData\Roaming\Grasshopper\Libraries\MeshMachine\remesher.gha
  Exception System.IO.FileLoadException: 
  Message: Could not load file or assembly 
  or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

  Exception System.NotSupportedException: 
  Message: An attempt was made to load an assembly from a network location which would have 
caused the assembly to be sandboxed in previous versions of the .NET Framework. This release 
of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. 
If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources 
switch. See for more information.

In Rhino 5 it doesn’t show up at all, not even attempting to.

In any case, I’m working on an application based on Rhino5 (still too many plugins missing for WIP for my project).

// Rolf

I just tested on another machine here in both R5 and the WIP and it works on both.
That error is often related to a file not being unblocked. Could you check that it is? Also, if there is another copy still in your downloads folder, try removing that.

Also, you might need to update to the latest Plankton release:

FWIW, this seems to work here both in RH5 and RH6 - I had to plug in the new path to the Plankton.gha component and the Plankton.dll. Perhaps that is to be expected…

Yes, did all that. And Unblocked the dll’s.

Even if I removed the old MeshMachine (pictured in my post) it’s still de old one… indicates that something is stuck in memory.

Last resort - try to restart the machine. :slight_smile:

// Rolf

OK, I got it working.

Now this starts to look very interesting. The algorithm is tough in that it doesn’t choke due to bad meshes and it seems that I can control the process programmatically.

This means for example that my originally bad meshes doesn’t get any better (…) but, that problem can be dealt with separately, with other tools. The big problem “out there” isn’t the fixing of bad meshes, instead it’s exactly this part - a reasonably good ShrinkWrapping tool.

In short - this component has a lot of potential and provides already as is" more than most other mesh tools, at least among free tools. I give it 8 out of 10 stars :

[¤|¤|¤|¤|¤|¤|¤|¤| | ]  

One star missing due to speed and another one for some issues with fixed boundaries (“FixCurves” input).

In the picture below, compare the green “naked edge” with the remeshing result (black mesh). The bottom of the mesh was open and the algorithm tends to shrink such edges up along the surface, even double fold the surface (see the more dense part near the edge) and “sucking up” the (patched) bottom hole up into the mesh a bit. Fixed Vertices along this edge didn’t fix the problem.
Edit: Another problem I noticed was that inner “splinters” in the mesh affects the algorithm in that it seems it cannot fully determine which is the “outermost surface”. So it produces some strange craters (I made an algorithm for cleaning up such “bonemarrow” splinters, and starting from such a cleaned mesh I get the results shown here).

Fig 1. Remeshed :

Fig. 2: Original mesh:

I don’t know if the boundary problem can be enhanced in this apporach, but whatever you do, please maintain and enhance this ShrinkWrap component as a separate first class citizen because it does something rather unique.

I will definietly try using this component for my challenging project, so I will probably give some more feedback.

Many thumbs up!

// Rolf

Edit: I used the following configuration (0.05 tolerance and 0.5 mm edge length, and 40 iterations):

The original mesh (195.0 KB)

The GH Definition: (23.2 KB)

// Rolf