How to Understand Meshes in Grasshopper, Foundations in Grasshopper
This week, we are taking a look at the final geometry type that Rhino/Grasshopper has to offer, meshes.
You have probably heard of the term meshes before and what it actually is, by the end of this post, you should hopefully have a better understanding of what they are, why they are so useful, and what it means to use meshes in Rhino/Grasshopper.
The Definition of Meshes
As we have looked at the definition of B-reps in the previous edition, meshes are used in a very similar fashion but are arguably more efficient and accurate.
Meshes are in part just made of points and lines which is why they are a very efficient form of data type. A B-rep datatype has to keep track of the mathematical representation of the object, a mesh datatype only has to keep track of its points and its connectivity data.
By connectivity data, I just mean the index of two points that make up a line and the index of n-amount of lines that make up a face.
From our perspective, this seems like a lot of data to keep track of. I mean isn’t it easier to just know the equation of a B-rep instead of keeping track of all these numbers?
Well from a human standpoint it is easier to remember a single equation rather than three tables of numbers but a computer is better suited to remember raw data like numbers than operations that need interpreting like an equation.
Mesh Face Types
As I mentioned before a mesh face can be made up of n-number of lines but the two most common ones are tri (3 lines ) and a quad (4 lines) mesh.
Depending on what you need to use the mesh for the distinction between how many lines make up a face may be important.
Meshing geometry is an art and a whole research field in itself and to truly master meshes, you need a good understanding of maths, geometry, and computers.
But Rhino does come with its own triangular mesher and now with Rhino 7, it also has its own quad mesher. And they work pretty well but there are other programs out there whose sole purpose is meshing. They can handle a lot more complicated geometry than Rhino can.
That being said, let’s take a quick look into the various ways we can create a mesh in Rhino / Grasshopper.
Meshing in Grasshopper Or Rhino
In terms of mesh creation, there are 2 ways we can do this in Rhino but a lot more ways to do this in Grasshopper.
Meshing in Rhino
We can use the Mesh command which turns any surface into a mesh by a few options but the end result is usually a mix of quad and triangular faces. We can also use the QuadRemesh command which makes a much nicer-looking mesh.
Note: the meshes were created with their default options
Meshing in Grasshopper
While we have a lot more options on how to create a mesh in Grasshopper, I find myself using the TriRemesh, QuadRemesh, and Mesh the most often.
Meshes Vs B-reps
Throughout the world of modeling, meshes and B-reps are used interchangeably depending on their use and the representation of the model itself. There are 3 key differences between meshes and B-reps that I think are important to look at.
As meshes are a more efficient data type, any time you need to perform a large geometrical operation, you should think about using a mesh instead of a B-rep because they are more performant.
Rhino as a program allows us to do this fairly seamlessly but we have to use different commands as the logic between B-reps and meshes are sometimes different.
For example, if we wanted to split a meshed rectangle and a B-rep rectangle. We have to use the MeshSplit command instead of the regular Split command.
From a pure function perspective, MeshSplit works the same way as Split but when we zoom in on the mesh after the MeshSplit, we get a glimpse of Rhino’s automatic processing of splitting meshes.
Rhino has actually turned the Quad meshed rectangle into a mix of quads and triangles. This may be a good or a bad thing depending on your need for the mesh, but it is something to be aware of.
Of course, meshes are more efficient but when performing operations on them, it can lead to some side effects which is where the ease of using B-reps comes in because we mostly don’t have to worry about any side effects.
Meshes are made from points and lines and strictly lines only, which means meshes normally have a hard time representing objects of curvature.
And you can see that on the right side, the meshed version of the circle isn’t as smooth as the one on the left. We can of course increase the density of the mesh to get a better curvature definition, like so.
But then we now run the risk of storing so much more information for a simple circle, at this point, we might be better off using the B-rep because it might actually need less information to maintain the curvature of the circle.
However, there are other, more efficient meshers that can better handle curvature. Like increasing the number of faces (called inflation) on the edges but still retaining as few faces as possible for the inside of the shape.
Manipulation of meshes is also made more difficult than B-reps because they are only made of points and lines. For example, if you want to change the shape of the B-rep with its control points.
All I had to do is move the 4 control points to manipulate the B-rep but to do the same for the meshed version of this shape, we would have to move all the related points.
Of course, with programming tools like Grasshopper, manipulation of this mesh is definitely possible but it requires a fair bit of effort in comparison to the B-rep.
Meshes are a very useful data type to know and understand even if they are harder to manipulate and move around. Especially, if you find yourself performing large amounts of geometrical operations, using meshes can help speed that process up.
Not to mention, most 3D models that you can get off the internet these days are made from meshes, and understanding how they work will help unlock more modeling possibilities.
If you liked what you read, consider subscribing to the Newsletter at no cost at all. I am on a mission to help people learn more about all things computational.
Thanks for reading,
P.S. I also made a video covering this very topic on Youtube, check it out!
Originally published at https://allthingscomputational.substack.com on March 8, 2022.