PlanktonMesh/C# Get adjacent Face Center

Hi all,

I am trying to figure out how to connect some FaceCenters of a PlanktonMesh.

I couldnt figure it out yet, and cant find many examples about PlanktonMesh in the scripting component.

My future aim would be connect the faceCenters to a dual graph.

I found this thread on github and asked but nobody answered https://github.com/meshmash/Plankton/issues/41

Here the ghFile:pmMeshF.gh (4.6 KB)

Maybe here somebody could help me.

Also in general I am really interested in moreexapmles of the use of the PlanktonLibrary.

Thanks and a nice day!

Hi Baris, here’s a simple script for creating a dual mesh using Plankton… Hope it helps!

// convert the input Rhino mesh to a Plankton mesh 
var pmesh = x.ToPlanktonMesh();

// create a new, empty Plankton mesh
var dual = new PlanktonMesh();

// add a vertex to the dual for every face of the input mesh
for (int i = 0; i < pmesh.Faces.Count; i++)
{
  var fc = pmesh.Faces.GetFaceCenter(i);
  dual.Vertices.Add(fc.X, fc.Y, fc.Z);
}

// add a face to the dual for every interior vertex of the input mesh
for (int i = 0; i < pmesh.Vertices.Count; i++)
{
  // skip boundary vertices (require special rules)
  if (pmesh.Vertices.IsBoundary(i))
    continue;

  // create a face from the neighbouring faces of each vertex
  dual.Faces.AddFace(pmesh.Vertices.GetVertexFaces(i));
}

// output
A = dual;
1 Like

Thanks a lot @will!

1 Like