diff --git a/src/PlanktonGh/PMeshFromPoints.cs b/src/PlanktonGh/PMeshFromPoints.cs
new file mode 100644
index 0000000..f9b4fe6
--- /dev/null
+++ b/src/PlanktonGh/PMeshFromPoints.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Rhino.Geometry;
+using Grasshopper.Kernel;
+using Plankton;
+
+namespace PlanktonGh
+{
+
+ public class PMeshFromPoints : GH_Component
+ {
+ ///
+ /// Each implementation of GH_Component must provide a public
+ /// constructor without any arguments.
+ /// Category represents the Tab in which the component will appear,
+ /// Subcategory the panel. If you use non-existing tab or panel names,
+ /// new tabs/panels will automatically be created.
+ ///
+ public PMeshFromPoints()
+ : base("PlanktonFromPoints", "PlanktonFromPoints",
+ "Create a new Plankton mesh from an existing Plankton mesh and a list of points",
+ "Mesh", "Triangulation")
+ {
+ }
+
+ ///
+ /// Registers all the input parameters for this component.
+ ///
+ protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
+ {
+ pManager.AddGenericParameter("PMesh", "PMesh", "The input PlanktonMesh to use the topology from", GH_ParamAccess.item);
+ pManager.AddPointParameter("Vertices", "Vertices", "The new list of vertex positions", GH_ParamAccess.list);
+ }
+
+ ///
+ /// Registers all the output parameters for this component.
+ ///
+ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
+ {
+ pManager.Register_GenericParam("PlanktonMesh", "P", "Plankton Mesh");
+ }
+
+ ///
+ /// This is the method that actually does the work.
+ ///
+ /// The DA object can be used to retrieve data from input parameters and
+ /// to store data in output parameters.
+
+ protected override void SolveInstance(IGH_DataAccess DA)
+ {
+ PlanktonMesh P = new PlanktonMesh();
+ List Points = new List();
+ if ((!DA.GetData(0, ref P)) || (!DA.GetDataList(1, Points))) return;
+ PlanktonMesh pMesh = P.ReplaceVertices(Points);
+ DA.SetData(0, pMesh);
+ }
+
+ ///
+ /// Provides an Icon for every component that will be visible in the User Interface.
+ /// Icons need to be 24x24 pixels.
+ ///
+ protected override System.Drawing.Bitmap Icon
+ {
+ get
+ {
+ return PlanktonGh.Properties.Resources.plankton_verts;
+ }
+ }
+
+ ///
+ /// Each component must have a unique Guid to identify it.
+ /// It is vital this Guid doesn't change otherwise old ghx files
+ /// that use the old ID will partially fail during loading.
+ ///
+ public override Guid ComponentGuid
+ {
+ get { return new Guid("{c9377989-c89e-477d-8dd2-b35af0c3b25d}"); }
+ }
+ }
+}
diff --git a/src/PlanktonGh/PlanktonGh.csproj b/src/PlanktonGh/PlanktonGh.csproj
index 0dfc066..5d5d2ee 100644
--- a/src/PlanktonGh/PlanktonGh.csproj
+++ b/src/PlanktonGh/PlanktonGh.csproj
@@ -31,20 +31,17 @@
TRACE
prompt
4
- ..\bin\Release\PlanktonGh.xml
+ ..\bin\Release\PlanktonGh.xml
- ..\..\lib\GH_IO.dll
- False
+ ..\..\..\..\..\..\..\Program Files\Common Files\McNeel\Rhinoceros\5.0\Plug-ins\Grasshopper (b45a29b1-4343-4035-989e-044e8580d9cf)\0.9.64.0\GH_IO.dll
- ..\..\lib\Grasshopper.dll
- False
+ ..\..\..\..\..\..\..\Program Files\Common Files\McNeel\Rhinoceros\5.0\Plug-ins\Grasshopper (b45a29b1-4343-4035-989e-044e8580d9cf)\0.9.64.0\Grasshopper.dll
- ..\..\lib\RhinoCommon.dll
- False
+ ..\..\..\..\..\..\..\Program Files\Rhinoceros 5.0 (64-bit)\System\RhinoCommon.dll
@@ -56,6 +53,7 @@
+
True
@@ -83,6 +81,9 @@
+
+
+
Copy "$(TargetPath)" "$(TargetDir)$(SolutionName).gha"
diff --git a/src/PlanktonGh/Properties/Resources.Designer.cs b/src/PlanktonGh/Properties/Resources.Designer.cs
index 0fc5624..a244306 100644
--- a/src/PlanktonGh/Properties/Resources.Designer.cs
+++ b/src/PlanktonGh/Properties/Resources.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.18034
+// Runtime Version:4.0.30319.18052
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -79,5 +79,15 @@ internal static System.Drawing.Bitmap plankton_decon {
return ((System.Drawing.Bitmap)(obj));
}
}
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap plankton_verts {
+ get {
+ object obj = ResourceManager.GetObject("plankton_verts", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
}
}
diff --git a/src/PlanktonGh/Properties/Resources.resx b/src/PlanktonGh/Properties/Resources.resx
index 8af698d..460390e 100644
--- a/src/PlanktonGh/Properties/Resources.resx
+++ b/src/PlanktonGh/Properties/Resources.resx
@@ -124,4 +124,7 @@
..\Resources\plankton_decon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\plankton_verts.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/src/PlanktonGh/Resources/plankton_verts.png b/src/PlanktonGh/Resources/plankton_verts.png
new file mode 100644
index 0000000..3e246c0
Binary files /dev/null and b/src/PlanktonGh/Resources/plankton_verts.png differ
diff --git a/src/PlanktonGh/RhinoSupport.cs b/src/PlanktonGh/RhinoSupport.cs
index ef6a5ee..9a802dc 100644
--- a/src/PlanktonGh/RhinoSupport.cs
+++ b/src/PlanktonGh/RhinoSupport.cs
@@ -1,6 +1,7 @@
using Plankton;
using Rhino.Geometry;
using System;
+using System.Collections.Generic;
namespace PlanktonGh
{
@@ -251,6 +252,22 @@ public static Mesh ToRhinoMesh(this PlanktonMesh source)
return rMesh;
}
+ ///
+ /// Replaces the vertices of a PlanktonMesh with a new list of points
+ ///
+ /// A list of closed polylines representing the boundary edges of each face.
+ /// A Plankton mesh.
+ /// A list of points.
+ public static PlanktonMesh ReplaceVertices(this PlanktonMesh source, List points)
+ {
+ PlanktonMesh pMesh = source;
+ for (int i = 0; i < points.Count; i++)
+ {
+ pMesh.Vertices.SetVertex(i, points[i]);
+ }
+ return pMesh;
+ }
+
///
/// Converts each face to a closed polyline.
///