-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrimitiveTorus.cs
58 lines (54 loc) · 1.91 KB
/
PrimitiveTorus.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
using System;
using System.Collections.Generic;
using Mola;
using Grasshopper;
using Grasshopper.Kernel;
using Rhino.Geometry;
namespace HDMolaGH
{
public class PrimitiveTorus : GH_Component
{
public PrimitiveTorus()
: base("Mola Torus", "Torus",
"create a Torus MolaMesh",
"Mola", "1-Primitives")
{
}
public override GH_Exposure Exposure => GH_Exposure.secondary;
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddNumberParameter("r1", "r1", "radius of the ring", GH_ParamAccess.item, 3);
pManager.AddNumberParameter("r2", "r2", "radius of the tube", GH_ParamAccess.item, 1);
pManager.AddIntegerParameter("ringN", "rN", "segments of the ring", GH_ParamAccess.item, 6);
pManager.AddIntegerParameter("tubeN", "tN", "segments of the tube", GH_ParamAccess.item, 6);
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddGenericParameter("Torus", "Torus", "a Torus MolaMesh", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
double r1 = 3;
double r2 = 1;
int n1 = 6;
int n2 = 6;
DA.GetData(0, ref r1);
DA.GetData(1, ref r2);
DA.GetData(2, ref n1);
DA.GetData(3, ref n2);
MolaMesh mMesh = MeshFactory.CreateTorus((float)r1, (float)r2, n1, n2);
DA.SetData(0, mMesh);
}
protected override System.Drawing.Bitmap Icon
{
get
{
return Properties.Resources.torus;
}
}
public override Guid ComponentGuid
{
get { return new Guid("866bc903-1716-4f74-a449-f91578e95e97"); }
}
}
}