meshmash / Plankton

A C# half-edge mesh data structure, and components for using this in Grasshopper/Rhino
http://meshmash.github.io/Plankton
GNU Lesser General Public License v3.0
216 stars 66 forks source link

Plankton vertex index to mesh vertex index #38

Closed petrasvestartas closed 7 years ago

petrasvestartas commented 7 years ago

Hi,

Is it possible to take plankton mesh vertex index:

int index = planktonMesh.Halfedges[i].StartVertex;

and get the index of rhino mesh vertex?

var someVertex = rhinoMesh.Vertex[ indexFromPlankton ]

Kind Regards, Petras

pearswj commented 7 years ago

Hey Petras, I'm not really sure what you're trying to achieve. To answer simply, no, the PlanktonMesh doesn't know anything about the Rhino.Geometry.Mesh that it may have been created from.

However, if you study the ToPlanktonMesh() code then you'll see that each Rhino Topological Vertex becomes a PlanktonVertex, so if you're careful about not modifying the topology after constructing the PlanktonMesh, then you could use this relationship.

int v1 = planktonMesh.Halfedges[i].StartVertex;
int v2 = planktonMesh.Halfedges.EndVertex(i); // shortcut to get the start vertex of the previous halfedge

This isn't foolproof though. This method attempts to tidy up the Rhino.Geometry.Mesh before constructing the PlanktonMesh (welding, unifying normals, etc.).

petrasvestartas commented 7 years ago

Hi,

Thanks, this is only for kangaroo hinge goal, where I take original mesh and decompose to 4 points.

I have example with rhinocommon which is ... long one.

And plankton example with 4 lines.

Does the index of plankton mesh corresponds to mesh.vertex or mesh.topologyvertex index?

pearswj commented 7 years ago

If you use ToPlanktonMesh() then the initial indices of vertices in the PlanktonMesh correspond to the topology vertices, not the actual vertices.

petrasvestartas commented 7 years ago

Works like a charm thanks:)