Planar meshing library

I have been searching a long time for a good meshing library and have struggled to find something that meets my criteria. My criteria are:

  • Meshes planar surfaces (potentially with holes)
  • Mesh can be constrained to mesh around a given point within the planar surface
  • Mesh can be constrained to mesh around a given line on the planar surface
  • Can be integrated into a Grasshopper based workflow

The middle two criteria seem to give me the most problem.

Bonus points would be given for:

  • Quad elements instead of triangles
  • Some way to control mesh size / refinement at features
  • Some mesh quality controls

As you may have guessed from my requirements I am looking to construct finite element meshes. These features seem pretty common across finite element software so algorithms / libraries must exist - it’s getting them into grasshopper which is hard!

The libraries I have come across so far:

  • Millipede (ticks most boxes, but is sometimes unstable, plus its wire overrides are really annoying)
  • Kangaroo mesh machine (I can’t work out how to constrain it to given points / lines)
  • Default Rhino / Grasshopper meshing (reasonable results with some subdivision, but again cannot be constrained)
  • Triangle.NET (I’ve wrapped this into a component, it’s quick and gives good elements, again cannot be constrained to points / lines, plus the licence is a bit confusing)
  • Rhino quad mesher (does not seem to suit planar surfaces)

Do the points/lines you want to constrain to already exist in your starting mesh as edges/vertices?
If so then you can constrain them in MeshMachine by putting these into FixV and FixV respectively.

If the points you want to constrain to don’t coincide with a mesh vertex, or the lines you want to constrain to don’t coincide with sets of edges, then you’d need to somehow adjust your mesh first so that they do.

Unfortunately its the second. I’d be happy to discretise my line into a sequence of points, and so the problem is how to manipulate my mesh structure to include points. Perhaps if anyone knew of a good library for doing this it would be an alternative route to a solution i.e. generate a mesh with one of the above tools and then add the required points into it.

Here’s one possible way of including a line in a given mesh, using mesh split. Didn’t test this approach much, so not sure how robust this is, but seems to work at least for simple cases. (14.0 KB)



For points I guess you could use ClosestMeshPoint, then
if it is on a vertex, no problem
if it is on a triangular face, split that triangle into 3, with the new point shared by all 3.
if on an edge, split both the adjacent faces into 2

Thanks Dan. Your example works well. I may explore the remeshing option so that I can wrap the process up in a single component.

If anyone else knows of libraries that offer this kind of meshing in a single component I’d still be interested to hear, would save me reinventing the wheel!

You might also want to look at this:

which can generate either triangles or quads, using 2 different external libraries.
I don’t think there’s any way with that to fix internal edges/points though

Thanks for the recommendation. I did look into it previously and the algorithms employed created a mesh that did not maintain connectivity to the edges of the surface, and also did not have options for including lines / points.

As a follow-up for anyone else who is searching, I have just found that its possible to get Triangle.NET to mesh to internal points.

This now meets my requirements.


may I ask if you could give a small guide how you did this?

I imagine you have to compile the triangle library to get the dll and reference it in VS.
Inside VS is it straight forward?May you give a pseudoCode?

Thanks in advance!

Sure. I’ve attached the Triangle .dll (57.8 KB) file here so you don’t have to recompile from source.

The bones of the C# code I have used is below to get it working with Rhino. It’s a bit rough but should be sufficient for you to build upon.

// Inputs
Polyline perimeter = new Polyline(); // perimeter of your mesh
List<Polyline> holes = new List<Polyline>(); // openings in your mesh
List<Point3d> pts = new List<Point3d>(); // additional points to be included on the mesh

// TO-DO - assign inputs & error check

// Main
List<Point3d> allPolPoints = new List<Point3d>();
foreach (Polyline h in holes)

var g = new TriangleNet.Geometry.InputGeometry(perimeter.Count);

foreach (Point3d p in perimeter)
    g.AddPoint(p.X, p.Y);

for(int i = 0; i < perimeter.Count - 1; i++)
    g.AddSegment(i, i + 1);
g.AddSegment(perimeter.Count - 1, 0);
int topV = perimeter.Count;

foreach(Polyline h in holes)
    foreach(Point3d p in h)
        g.AddPoint(p.X, p.Y);
    for (int i = 0; i < h.Count - 1; i++)
        g.AddSegment(topV + i, topV + i + 1);
    g.AddSegment(topV + h.Count - 1, topV);

    AreaMassProperties ap = AreaMassProperties.Compute(h.ToNurbsCurve());
    g.AddHole(ap.Centroid.X, ap.Centroid.Y);

    topV = topV + h.Count;

// Additional points
foreach(Point3d p in pts)
    g.AddPoint(p.X, p.Y);

TriangleNet.Mesh m = new TriangleNet.Mesh();

m.Behavior.Quality = true;

Rhino.Geometry.Mesh rMesh = new Rhino.Geometry.Mesh();

foreach(TriangleNet.Data.Vertex v in m.Vertices)
    Point3d p = new Point3d(v.X, v.Y, 0.0);

var ts = m.Triangles;
foreach (TriangleNet.Data.Triangle t in ts)
    rMesh.Faces.AddFace(t.P0, t.P1, t.P2);

rMesh.RebuildNormals(); // I've not been super clean in how I create the Rhino mesh, this step helps clean things up!

Thanks a lot, will try it at home!