Closed petrasvestartas closed 7 years ago
There isn't currently a method which constructs a Rhino.Geometry.Line
from a PlanktonHalfedge
. There are a bunch of extension methods in PlanktonGh.RhinoSupport
so – if you also reference Plankton.gha
in the C# script component – you could do the following...
// "i" is the index of a halfedge
var from = pmesh.Vertices[pmesh.Halfedges[i].StartVertex].ToPoint3d();
var to = pmesh.Vertices[pmesh.Halfedges.EndVertex(i)].ToPoint3d(); // uses EndVertex helper
var line = new Rhino.Geometry.Line(from, to);
You can use PlanktonVertexList.SetVertex
to change the position of a vertex. There are also extension methods for Point3f and Point3d.
pmesh.Vertices.SetVertex(i, x, y, z);
pmesh.Vertices.SetVertex(j, new Point3d(x, y, z));
See PlanktonVertexList.GetVertexNeighbours
and PlanktonVertexList.GetHalfedges
.
// "i" is the index of a vertex
int[] vertexNeighbours = pmesh.Vertices.GetVertexNeighbours(i);
int[] outgoingHalfedges = pmesh.Vertices.GetHalfedges(i);
Under the hood Plankton uses "circulators" to handle adjacency queries; there are vertex circulators for when you want to iterate through all the halfedges around a vertex and face circulators for when you want to iterate through all the halfedges around a face.
To duplicate a PlanktonMesh
simply construct a new one.
var dup = new PlanktonMesh(orig);
Check out the PlanktonHalfedgeList.IsBoundary
method.
bool naked = pmesh.Halfedges.IsBoundary(i);
Thank you very much for such a detail overview:)
Hi,
I would like to ask several questions regarding plankton:
How to get HalfEdge as rhino Line? First I was thinking that I can get start and end vertices, but in the drop-down menu I only see StartVertex field.
What is the method to change mesh vertex position (similarly as in Rhino Mesh setVertex function)?
Is it possible to know how many connected vertices / edges each vertex/halfedge has?
How to duplicate PlanktonMesh? In rhinomesh I used mesh.DuplicateMesh()
How can I check if halfed is naked?
Sorry for so many question but I am translating one script from rhino to plankton meshes. It is so nice that there is no difference between vertex and topology vertex, rhino mesh is such a workaround in some cases.
Thank you, Petras