Mesh - Determining which Face belongs to a Vertice

Using VB.NET, when I examine a Rhino.Geometry.Mesh and its properties


… then I believe that the Vertices and their Normals are accessed at the same index.

Q1: But how do I find a Face starting from a Vertex or a (vertex) Normal? (not conflating Normals with FaceNormals). What I want to do is to delete the Face that references a certain Vertex.
Q2: And before deleting the Face, I guess that have to delete each Vertex of the Face explicitly?
Q3: Would the result be a valid mesh only if ensuring that the Mesh is unwelded before starting to delete faces & vertices?

// Rolf

Hi Rolf,

once you have mesh.Vertices you can iterate over it’s items or query a vertex using mesh.Vertices.GetVertexFaces(vertexIndex) to find out which faces it belongs to.

Deleting the face can be done using mesh.Faces.DeleteFaces(FaceIndices) without removing it’s face vertices, note that the vertices may belong to other faces too. You may clean up unused vertices with mesh.Compact() before adding the mesh to the doc.

You can add unwelded meshes which are valid and use IsValid to query meshes and mesh faces to make sure nothing went wrong. Does that help ?


Thank you @clement for a very helpful answer! This was exactly what I needed to know in order to do what I plan to do.


// Rolf

Hm, while at it, I stumbled on a type cast from Point3f to Point3d.

When I iterate over the vertices (Point3f) I need to evaluate the point against a reference point which is Point3d. But I can’t find any info about how to cast 3f to 3d (new to this .NET stuff. In Delphi I would just have applied some raw violence pressing ot down over the smaller type, since in Pascal a “bigger” type always is considered “covering” the smaller type leaving no space undefined).

What is the straightforward way to cast 3d to 3f? (or if better, from 3f to 3d). Why I would like to go from 3d to 3f is because the ref point means a one single cast, while the 3f:s come in the thousands, from the vertices.

// Rolf

Hi Rolf,

store the mesh vertices in a variable before accessing it:

vertices = mesh.Vertices.ToPoint3dArray()

here is a link, there is also ToPoint3dArray().


1 Like