I’m new to Grasshopper and I can’t figure something out…
I’ve generated a triangulated mesh and extracted all the faces, edges, vertex normals and face normals. The one thing that I really need but can’t get are the edge normal vectors.
I can calculate this vector but how do I return the faces of a shared edge?
This is so close to what I need to do, but I’m finding it very hard to reverse the flow of information so that I can manipulate the edges and reconstruct a mesh based on the original topology.
In this example, I’m offsetting each edge along its normal and shrinking it to form a truncated triangle. It’s easy enough to generate the “side walls” but the blue “top face” eludes me.
(Let’s not worry about the little truncation faces at the source mesh vertices for now!)
The C# component reports “connTree” which is a tree of edges, each leaf being a list of faces belonging to that edge. What I want is the opposite: A tree of faces, each leaf being a list of edges belonging to that face. I’ve marked up this transformation by hand here:
That works really well, cheers! Butl if you’re offering to code to order, I’ll be a bit more specific, because that “moved” mesh collection is really what I’m after and all the other bits (edge quads, vertext tris) I can do myself, (along with anything else that might crop up as I develop this thing).
The less that ends up buried in an opaque (to me) C# component the better tbh!
The only other change I’d need is for the edge shortening effect to be a linear subtraction from each end rather than a scaling effect (I was using Extend Curve with a negative value in my original). This is important for manufacturing reasons I won’t bore you with.
hah! no, if anything I prefer keeping things in component land. I’ve tried learning to code many times in my life at this point and I keep bouncing off. I just get lost in the abstraction (despite knowing full well that abstraction is what makes it a better and more flexible approach).The visual nature of grasshopper, and other node-based editors, is an absolute godsend for my kind of brain.
Alas, I get some exceptions. The majority of the edges come out of Peter’s C# component in the same order, but a handful are different. When I try and create meshes from them, I get these self-intersections as a result:
Well, I didn’t know how to offset the mesh, so if you are willing to use the Pufferfish plugin for its Offset Mesh component, this will create you your mesh:
If my source was a flat plane or a sphere or a torus, then every face would have similar vertex normals and an Offset Mesh would then also have identical edge normals resulting in coplanar edges (left). But when the vertex normals are all over the place, it twists the resulting edges (right).
Well … in the latest C# attached that works by computing pts - given the Edge diherdral Vector3d as the unitized sum of the adjacent Faces normal Vectors - on both sides of the Edges (i.e. Line.PointAt(at), Line.PointAt(1 - at)). The at var varies from some small value (say 0.05) to 0.5 - that small value. So … I’ll replace the at var with some real-life value (but this requires more checks: you should restrict the value in order: 2*value + some pragmatic minDist <= Edge Length - plus you’ll need some report - per Topology Edge index - if the value is not appropriate for a given Edge).
Other than that I’ll add some lines more in order to get the “moved” combo of the 6 meshes
Yes, I already have some edge length checking in the main project and the subtraction amount is limited to a fraction of the minimum reported length. Thanks for your help!
The ones that join the edges of the source triangles to the edges of the offset ones.
This is a problem fundamental to offsetting meshes. The standard approach is to move each source vertex along its normal and remake the mesh using the new positions.
If the source is a flat plane of faces, then the offset mesh is identical and creates perfect prisms with rectangular sides (the quads in question).
If the source has uniform curvature - the surface of a cylinder for example, then each face offsets to a larger copy of itself and creates fustrums with flat sides.
But my source has non-uniform curvature. When you offset along each vertex normal, the edges of the new offset mesh are no longer parallel with the source.
My solution is to offset edges along their normals instead. Normally this would create intersections where curvature is concave, so I’m truncating the edges to allow for it.