Categories
Mesh

Half-edge mesh

Beside the default mesh that Rhino provide, there’s another type of mesh that is very popular among Rhino, grasshopper developers: Half-edge mesh. The half edge mesh concept was first introduced in computational geometry world. Very fortunately, Daniel Piker and Will Person created an open source assembly for half edge mesh named Plankton.

https://www.grasshopper3d.com/group/plankton

Half-edge mesh  is defined by a directed graph of halfedges, each of which represents half of an edge. As its name suggest, edge is the most important, central component of the mesh. From an edge, we can deduce other info of the mesh.

Since we already a built assembly like plankton, I didnt dig deep in how a half edge mesh is created, its extensive theory but more on how can we use the methods in Plankton. For more information on half edge theory, you can follow this link

Half-edge based mesh representations: theory

Mesh image

In general:

Each vertex reference one outgoing halfedge.
Each face reference one of the halfedges bounding it.
Each halfedge can reference to, its opposite half edge, its face, its vertices. Each halfedge has a direction indicating which vertex it going from and to.
Halfedges in each face go in counter clockwise direction.

I will go through 3 topics in details about half edge mesh, each with an example line of code: its connectivity (how does vertex, halfedge etc. relate to each other), how to edit mesh, how to split mesh.

Mesh Topology

I will list out what info you can get from each mesh element

PlanktonMesh

Example photo.JPG

 

Faces

mesh.Faces

HalfEdges

mesh.Halfedges

Vertices

mesh.Vertices

PlanktonHalfedge:

For Example: for half edge 25, we can get previous half edge 22, next half edge 19 (according to the direction, not number) and start vertex 6

HalfEdge

 

var halfEdge = mesh.HalfEdges[i]

Adjacent Face

int adjacentFace = halfEdge.AdjacentFace

Next HalfEdge

int nextHE = halfEdge.NextHalfedge

Previous Half Edge

int prevHE = halfEdge.PrevHalfedge

Start Vertex

int startV = halfEdge.StartVertex

 

PlanktonFace

For example: for face 4, we can get first half edge 19.

Face

var face = mesh.Faces[i]

First half edge

int firstHE = face.FirstHalfedge

 

Vertex

For example: for vertex 6, we can get outgoing halfedge 23

Vertex

var vertex = mesh.Vertices[i]

Outgoing half edge

var outgoingHE = vertex.OutgoingHalfedge

 

Categories
Mesh

Mesh 101

Manipulating mesh is one of very common tasks in design computation. In this post today, I want to have a quick write up about mesh and mesh topology in Rhino. My ultimate goal is to write about half edge mesh and how to use half edge mesh. I think mesh operation will  be very useful in many cases.

This slide introduce mesh, especially Rhino Mesh pretty well…

Basically mesh is an entity that is made up of planar polygonal faces. I will try to summarize the mesh topology in Rhino

Mesh:

– Faces    -Vertices

-Topology Edges

Faces

– Vertices

Vertices can be accessed in different ways

  1. To call each vertex from each face by calling Faces[face index].A  or Faces[face index].B or Faces[face index].C. The result will be the index referring to the corresponding vertex in vertex list
  2. GetFaceVertices( face index ) to get points Point3f() of each face
  3. GetTopologicalVertices( face index ) to get an array of indices that refer to the corresponding vertices

– Neighbouring Faces – indexes of neighbouring faces

– GetFaceCenter( face index )

Vertices

-GetVertexFaces( vertex index )

-GetConnectedVertices( vertex index)  to get an array of vertex indices that are connected with the specified vertex.

Topology Edges

– ConnectedFaces ( edge index) to get indices of faces connected to an edge

– GetTopoVertices ( edge index) to get the index pair of the vertices that belong to the edge.