Grasshopper

algorithmic modeling for Rhino

I was looking for a way find the connectivity of mesh vertices, and I did by using TopologyVertices. The problem for me now is that the TopologyVertices are not listed in the same order as Rhino.Geometry.Mesh.Vertices (or the vertices output of deconstruct mesh in grasshopper) so I am unable to rebuild the mesh from the mesh face list. Essentially, I am looking to deconstruct a mesh, adjust its vertices and then reconstruct it.

I tried reordering the TopologyVertices by first doing Rhino.Geometry.PointCloud.ClosestPoint(TopologyVertices,myregularmeshvertices[n]) but I am having trouble converting the TopologyVertices into a list of points. Is there a way to convert MeshTopologyVertexList into a regular list of points and then to a PointCloud?

Or even better, is there a way to get TopologyVertices to come out in the correct order to start with?

Thanks,

Lawrence Yun

Views: 2219

Replies to This Discussion

Thanks for pointing me to your script. I would still like to understand why TopologyVertices are not in order and how to convert MeshTopologyVertexList to a list of points. Or if there is a way to get TopologyVertices in the correct order to start with. I am using Python by the way.

I can not help you directly from Python, but in VB I did this to sort the list of topology points as the vertices list.

Private Sub RunScript(ByVal Mesh As Mesh, ByRef A As Object)

'Puntos de topología.
Dim MTVL As Rhino.Geometry.Collections.MeshTopologyVertexList = Mesh.TopologyVertices
'
'Indices topología.
Dim TVI As New list (Of Integer) 'The list with indices of topology.
Dim NaturalIndex As New list (Of Integer) 'A list of natural indices (0, 1, 2, 3, 4...)
For i As int32 = 0 To Mesh.vertices.count - 1
TVI.add(MTVL.TopologyVertexIndex(i))
NaturalIndex.add(i)
Next
'
'Ordenar puntos por topología.
Dim arrNI As Integer() = NaturalIndex.toarray()
Dim arrTVI As Integer() = TVI.toarray()
array.Sort(arrTVI, arrNI) 'Sort the naturalIndex list with the TopologyIndex list as keys.

Dim VL As Point3f() = MTVL.ToArray() 'Get the Topology Points as array.
array.Sort(arrNI, VL) 'Sort TopologyPoints with naturalIndexSorted (of previous step) as keys.

A = VL

End Sub

Are you looking for TopologyVertices.MeshVertexIndices and TopologyVertices.TopologyVertexIndex?

These let you get the indices of either one from the other.

The first one returns an array, but one thing you can do to make things a bit easier is first combine all coincident vertices using CombineIdentical and Weld. Then at least you have a 1 to 1 correspondence.

So for example, you can then do something like:

Mesh.Vertices[M.TopologyVertices.MeshVertexIndices(i)[0]]

to get the point at TopologyVertex i

It's still a pain though, and frustration from dealing with Vertices vs TopologyVertices was one of the primary motivations for starting Plankton.

Thanks, .MeshVertexIndices worked.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service