Plankton

Plankton is a free and open library implementing the half-edge data structure for polygon meshes.

This way of storing the mesh connectivity information allows easier adjacency queries and supports mesh faces with any number of sides (Ngons), not just quads and triangles.

The plankton library is intended primarily to be referenced and used from scripts, but  basic GH components for conversion and topology extraction are provided, and more may be added at a future date.

Plankton is still very much a work in progress. This is a first release, and methods/features will change in future versions.

Currently most of the methods relate to extracting topology information from existing meshes, and converting between Rhino meshes and Plankton meshes, but the intent is to over time add more ways of actually modifying and building meshes.

Please share your thoughts and ideas in the forum...

download the latest release here:

https://github.com/meshmash/Plankton/releases/latest

This library is distributed under the terms of the GNU Lesser General Public License (LGPL).

(The source is available on GitHub here)

Copyright 2013 Daniel Piker and Will Pearson

For more on half-edges, see:

http://www.flipcode.com/archives/The_Half-Edge_Data_Structure.shtml

http://openmesh.org/Documentation/OpenMesh-2.0-Documentation/mesh_hds.html

http://www.graphics.rwth-aachen.de/media/papers/directed.pdf

Thanks to the people I have had many conversations about meshes with over the last few years that have really helped inspire and inform this work: including: Daniel Hambleton, John Harding, Kristoffer Josefsson, Harri Lewis, Giulio Piacentino, and especially Dave Stasiuk, who also shared code that helped get this working.

Load Previous Comments
  • Daniel Piker

    Hi Mathias, hi Anders, thanks for updating this.

    It should be possible though to use Mesh.ToPlanktonMesh() in the latest Plankton

  • Anders Holden Deleuran

    Hi Daniel,
    Do you mean that a Rhino.Geometry.Mesh now has a method for converting it to a PlanktonMesh? If so, I'm not able to call it I'm afraid. I'm Running Rhino 5 SR8 64-bit (5.8.40305.11495, 03/05/2014), GH 0.9.0072 with the latest Plankton.dll and Plankton.gha installed. I'm doing good Mathias, likewise :)

  • Daniel Piker

    Hi Anders - yes, but it needs both the Plankton.dll and Plankton.gha referenced (thanks to Will, there is now a clearer distinction between the mesh library itself, and the parts which interface with Rhino/Grasshopper). It works fine in C#, but I'm always getting mixed up with right way of importing references in Python

  • Daniel Piker

    ok - this seems to work:

    import clr
    clr.AddReferenceToFileAndPath("C:\Users\Daniel\AppData\Roaming\Grasshopper\Libraries\Plankton.gha")
    import PlanktonGh as pl

    pMesh = pl.RhinoSupport.ToPlanktonMesh(mesh)

  • Anders Holden Deleuran

    Thanks Daniel,

    This does seem to make Plankton more tricky for Python implementation. In order to reference the Plankton.gha I renamed it PlanktonGh.dll and imported in the same way as Plankton.dll. This provides access to the RhinoSupport class which contains the ToPlanktonMesh() method, allowing us to call it in a procedural manor. This is not exactly pretty, but does seem to work. Attached the example from before.

    Perhaps this is something for Giulio/Steve to have a closer look at. I have already suggested that the Grasshopper library folder be add..., but it seems that this could use some deeper thinking/planning in general (should we be able to import .gha files etc.).

    Best,

    Anders

    140401_PlanktonDemoPython_Update02.gh

  • Anders Holden Deleuran

    Edit: I see you already figured it out Daniel. I attached another version which assumes that the GH library folder is read by RhinoPython, but offers the perhaps least "ugly" method :)

    140401_PlanktonDemoPython_Update03.gh

  • Giulio Piacentino

    Hi guys,

    right now clr.AddReferenceToFileAndPath is I think the correct method to use here. That .dll has to ultimately be added to the Python context. More in general, McNeel might want to add a new registration to AssemblyResolve for .gha files. Let's see also what Steve thinks.

    Giulio
    --
    Giulio Piacentino
    for Robert McNeel & Associates
    giulio@mcneel.com

  • Mathias Gmachl

    Thanks everyone for looking into this. I did see the ToPlanktonMesh command in the C# examples, but couldn't get it to work without the references.

    In order to script Kangaroo functions like in the remeshing examples, I assume I need to reference the kangaroo .dll and .gha aswell?

  • Daniel Piker

    Hi Mathias,

    Yes - that's correct, the remeshing example uses some functions from GhKangaroo.MeshPhysics, so you'll need those libraries referenced. (I'm looking though at whether it might be better to keep all these functions in the .dll in future)

  • Will Pearson

    It's all personal preference but here's how I do things (off the top of my head):


    import clr
    clr.AddReference('Plankton')
    clr.AddReference('PlanktonGh')
    import Plankton
    import PlanktonGh.RhinoSupport as planktongh
    pmesh = planktongh.ToRhinoMesh(mesh)

    (Note that Plankton.dll and PlanktonGh.gha are in my Libraries folder.)

  • Anders Holden Deleuran

    Thanks Will. That's certainly true. In your example "PlanktonGh" refers to the "old" .dll correct? The one which is now simply called "Plankton.gha"? In which case one has to use "AddReferenceToFile" as there are now two files with the same name, but different extensions (which I think I prefer actually). Anywho, just tried out the following which seems to work for importing all the dependencies for both Plankton and Kangaroo:

    # Reference .NET assemblies
    import clr
    clr.AddReferenceToFile("Plankton.dll")
    clr.AddReferenceToFile("Plankton.gha")
    clr.AddReferenceToFile("KangarooLib0096.dll")
    clr.AddReferenceToFile("Kangaroo0096.gha")

    # Import Plankton
    import Plankton as pl
    import PlanktonGh as plGh

    # Import Kangaroo
    import Kangaroo as ka
    import KangarooLib as kaLib
    import GhKangaroo as kaGh

    Let the digging begin :)

     

  • Will Pearson

    Oh gosh, you're right. I've just realised I've got both Plankton.gha and the PlanktonGh.dll that Daniel packaged with Kangaroo... Sorry for muddying the waters!

  • Anders Holden Deleuran

    Hehe, no worries. One of my main headaches with assemblies was always trying to figure out their actual name (as in, not the file name) and their actual content (available types), I just spent a little time looking into assembly introspection. Seems pretty straight forward, attached a small example. I suspect this could be useful for you Mathias. Best, Anders

    140402_AssemblyIntrospection.gh

  • Mathias Gmachl

    Thanks, Anders, you have been reading my mind. I've got some sleepless nights ahead.

  • Will Pearson

    All, just pushed some documentation to pearswj.co.uk/plankton.

    I'm deliberately trying something different (rather than the usual Sandcastle docs as used by Rhinocommon and Grasshopper) in an attempt to bring users closer to the code.

  • Lionel

    Hello Will,

    I've seen a little bit of what you do on Plankton ... and I'm interesting about the documentation you've pushed on your website !

    I'm developing rhino & gh tools in my research lab right now and I'm seeking a way to document it in a "friendly" way for others.

    How did you manage to make the doc on your website ? Is it auto-generated from a XML doc file (from VS) ?

    Thanks in advance for your advice ...

    Lionel

  • Will Pearson

    Lionel, I added the XML comment parsing to an existing Python documentation program. It's a bit hacky. It runs on the .cs files themselves. Check it out below, instructions in the README.

    https://github.com/pearswj/pycco/tree/csharp-xml-docs

  • Lionel

    Tks Will !

    I've manage to install pycco and it's dependencies. But I can't get it work properly ...

    Is it working with python 3.4 or 2.7 ?

    I get this error (see below) when launching the script from the consol on the Compass.cs file in a \src folder in the C:\Python34\Scripts\pycco folder

    Any idea where it comes from ??

    Thanks again,

    Lionel

    C:\Python34\Scripts\pycco>python pycco/main.py src/Compass.cs
    File "pycco/main.py", line 484
    print "pycco = %s -> %s" % (s, dest)
    ^
    SyntaxError: invalid syntax

     

  • Lionel

    I also tried to launch pycco on the pycco/main.py and got the same kind of error :

    C:\Python34\Scripts\pycco\pycco>pycco main.py -p
    lionel
    Traceback (most recent call last):
    File "C:\Python34\Scripts\pycco-script.py", line 10, in <module>
    load_entry_point('Pycco==0.3.0', 'console_scripts', 'pycco')()
    File "C:\Python34\lib\site-packages\pkg_resources.py", line 353, in load_entry
    _point
    return get_distribution(dist).load_entry_point(group, name)
    File "C:\Python34\lib\site-packages\pkg_resources.py", line 2302, in load_entr
    y_point
    return ep.load()
    File "C:\Python34\lib\site-packages\pkg_resources.py", line 2029, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
    File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
    File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
    File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
    File "C:\Python34\lib\site-packages\pycco-0.3.0-py3.4.egg\pycco\__init__.py",
    line 1, in <module>
    File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
    File "<frozen importlib._bootstrap>", line 2222, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 2164, in _find_spec
    File "<frozen importlib._bootstrap>", line 1940, in find_spec
    File "<frozen importlib._bootstrap>", line 1916, in _get_spec
    File "<frozen importlib._bootstrap>", line 1897, in _legacy_get_spec
    File "<frozen importlib._bootstrap>", line 863, in spec_from_loader
    File "<frozen importlib._bootstrap>", line 904, in spec_from_file_location
    File "C:\Python34\lib\site-packages\pycco-0.3.0-py3.4.egg\pycco\main.py", line
    484
    print "pycco = %s -> %s" % (s, dest)
    ^
    SyntaxError: invalid syntax

  • Will Pearson

    Try Python 2.7. If you have any more questions can we discuss them elsewhere? Perhaps http://discourse.mcneel.com/c/uncategorized would be appropriate, or open a github issue :)

  • Lionel

    Ok, I finally manage to make it work. Some thing was wrong with my python Install. Now it's working for both 2.7 and 3.4.

    Tks,
    Lionel

  • spiral

    how to use the Plankton in order to build net (mesh) Chebyshev on the surface?

  • Daniel Piker

    Hi Spiral - generating Chebyshev nets can be done in Kangaroo by fixing or equalizing the edge lengths, and draping over or pulling to some target surface.

  • spiral

    Thanks Daniel, it is possible to make the edges of equal length? changing only the angle between them.

  • Daniel Piker

    Hi Spiral, could you post this as a question on the Kangaroo group? It's easier than having a conversation in these comments.

  • Brendan

    ScreenShot022.jpg

    I cannot get plankton installed. I downloaded the shown files and placed them in my AppData>Roaming>Grasshopper>Libraries folder.  I then restarted Rhino and opened Grasshopper and there is no Plankton tab.

  • Will Pearson

    Hi Brendan, Plankton comes with very few components and parameters so, rather than clutter up the UI with an extra tab, we put them under the Mesh tab. Primarily we use Plankton inside script components. What are you hoping to use Plankton for?
  • Brendan

    Thanks, I found the components.  What I'm trying to do is remesh the attached surface or other surfaces like it (it's a mesh) in hopes of flattening it using Rhino's Squish command.  If there are any other, better methods using other Grasshopper components or Rhino tools or (free) plugins, I'm open to that as well.

    sample%20surface.3dm

  • Dekani Fisher

    The latest version from the link below is downloading the 0.3.0 instead...? i can't get the 0.3.4 version...

    https://github.com/meshmash/Plankton/releases

    plankton.PNG

  • Will Pearson

    Dekani, you've got the right one. We just forgot to bump the assembly release number...

  • Dekani Fisher

    okay how do i change it because other components won't work unless it sees the correct number?
  • Will Pearson

    What problems are you having?

  • Dekani Fisher

    HI thanks for your replies, i just had to unblock the dlls and they worked. 

  • Will Pearson

    Glad it's working for you now :)

  • josh lopez-binder

    Hi all, Is anyone is using plankton for scripting on mac?

    more specifically, for rhino python scripting?

    I am considering trying it out, and curious if there are any tips/tricks known already.

  • Will Pearson

    Josh, please let us know how you get on! I've used Plankton on the Mac via compiled Grasshopper components (MeshMachine, for example) but not yet via scripting as that's only available for Rhino right now, not Grasshopper. Please shout if we can help along the way :)
  • johnnyUtah05

    Hi, 

    I am wondering how to draw hexagons/circles around clothed vertices by using their neighboring vertices distances. I have some confusion... Can this be achieved with 'Deconstruct Plankton'? (I assume yes, by getting the proper half edges). 

    Also, I have looked inside the 'Tangent Circle' component and see that it only measures the distance from two neighboring vertices. I believe this is why my result is imperfect. See below. 

    How can I tweak the tangentCircles component to achieve a more accurate result, or how can I use 'deconstructPlankton' to achieve this?

    Thank you in advance. EriktangentCirclePLANKTON.gh

  • Gene Kao

    Hi all, 

    We created an open source plugin "Leopard" using Plankton for internal mesh processing. We hope that this can be a good example to demonstrate the advantage using Plankton and help improve it. 

    More feedback and insights are welcome to discuss in Leopard forum

    Source code can be downloaded on GitHub

    Cheers, 

    Gene

  • Jay

    This may be a really dumb question but how do I install the plankton 0.4.0 gha file. I've used grasshopper for a couple years now and normally just drag and drop. I have tried that, restarting grasshopper, restarting my computer and it never seems to load...??

  • Farah

    1. Solution exception:Could not load file or assembly 'Plankton, Version=0.3.4.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

    why does this happen? I have it download in pluggin folder, all 3 parts :(

  • Will Pearson

    Farah – When/where are you seeing this error? Have you unblocked all the .dll/.gha files? (right-click, properties, unblock)

    Jay – Plankton doesn't have very many components as it's mostly used for scripting. I wonder if this is why it seems not to be loading... There are a few components which can be found in the "Mesh" tab, under "Triangulation". Are these present?

    Gene – Thanks for sharing! I'm really glad that you've been able to build something so cool on top of Plankton! I'll keep an eye on the Leopard forum/github in case there are any cross-over support topics that I can help with :)

  • thomas_do

    Hi,

    I have finally managed to load Meshmachine within Kangaroo0099 following the tip in this forum:

    https://discourse.mcneel.com/t/meshmachine-plankton-related-questio...

    Am I right that it is not possible to run meshmachine within Kangaroo2?

    Now my problem is similar to Farah's. In Grasshopper, the component does not work. The error message says:

    1. Solution exception:Could not load file or assembly 'PlanktonGh, Version=0.3.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

    So unlike Farah's error message it's looking for PlanktonGh and version 0.3.0.0

    Trying this on a university PC

    Cheers 

    Thomas

  • thomas_do

    Hi again, one thing to add:

    I have problems installing weaverbird due to a missing admin licence. 

    Could that be the reason that meshmachine does not work?

  • thomas_do

    Meshmachine works for me now with Kangaroo0099 on a different PC where I do not need admin rights to install software. Looks like that was the problem.

  • David Bachman

    Can someone help me find the documentation for Plankton's Halfedge data structure? I seem to have lost the link to it, and Google isn't helping. 

  • Ortler Mark

    @DavidBachmann

    The source may help u...
    https://github.com/meshmash/Plankton

  • David Bachman

    @OrtlerMark

    There used to be a documentation page with a description of each half edge operator, in addition to the GitHub page. I believe the location was here:

    https://pearswj.co.uk/Plankton/docs/

    I can get the info from the source files, but its not as easy.

  • Will Pearson

    The docs have moved to http://meshmash.github.io/Plankton/.
  • David Bachman

    @Will Pearson

    Thank you!!!

  • David Bachman

    First time trying to write a C# script using a plankton mesh. I've connected the output of a PMesh component to the input of a C# component, and named that input "pmesh". Inside the script I'd like to call a method such as:

    int count=pmesh.Vertices.Count;

    However, I get an error that `object` does not contain a definition for `Vertices`.

    Any advice?

    Thanks,

    Dave