-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubdivideExtrudToPointWithValues.cs
72 lines (64 loc) · 2.56 KB
/
SubdivideExtrudToPointWithValues.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Collections.Generic;
using Mola;
using Grasshopper;
using Grasshopper.Kernel;
using Rhino.Geometry;
using System.Linq;
namespace HDMolaGH
{
public class SubdivideExtrudToPointWithValues : GH_Component
{
public SubdivideExtrudToPointWithValues()
: base("Subdivide Extrude to Point Center with Values", "Extrude Point Center with Values",
"extrudes the all faces their center point moved by hieght normal",
"Mola", "2-Subdivisions")
{
}
public override GH_Exposure Exposure => GH_Exposure.secondary;
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddGenericParameter("MolaMesh", "M", "mesh to be subdivided", GH_ParamAccess.item);
pManager.AddNumberParameter("Height values", "Hs", "a list of extrude height", GH_ParamAccess.list);
pManager.AddIntegerParameter("Iteration", "I", "subdivide times", GH_ParamAccess.item, 1);
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddGenericParameter("MolaMesh", "M", "result mesh", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
MolaMesh mMesh = new MolaMesh();
List<double> doubleList = new List<double>();
List<float> floatList = new List<float>();
int iteration = 1;
DA.GetData(0, ref mMesh);
DA.GetDataList(1, doubleList);
DA.GetData(2, ref iteration);
floatList = doubleList.Select(a => (float)a).ToList();
for (int i = 0; i < iteration; i++)
{
mMesh = MeshSubdivision.ExtrudeToPointCenter(mMesh, floatList);
}
DA.SetData(0, mMesh);
}
protected override System.Drawing.Bitmap Icon
{
get
{
// You can add image files to your project resources and access them like this:
//return Resources.IconForThisComponent;
return null;
}
}
/// <summary>
/// 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.
/// </summary>
public override Guid ComponentGuid
{
get { return new Guid("c55b14b3-7d6b-45f5-b349-6ad6be1c78a0"); }
}
}
}