-
Notifications
You must be signed in to change notification settings - Fork 11
/
GeometryWobblySurface.cs
73 lines (66 loc) · 2.76 KB
/
GeometryWobblySurface.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
73
using System;
using System.Collections.Generic;
using Dynamo.Graph.Nodes;
using ProtoCore.AST.AssociativeAST;
using NodeModelsEssentials.Functions;
using Autodesk.DesignScript.Geometry;
using System.Linq;
using Newtonsoft.Json;
namespace NodeModelsEssentials
{
// <summary>
// Given some size parameters, returns a lofted surface with random bumps.
// </summary>
[NodeName("Geometry.WobblySurface")]
[NodeDescription("Given some size parameters, returns a lofted surface with random bumps.")]
[NodeCategory("NodeModelsEssentials")]
[InPortNames("baseX", "baseY", "baseZ", "width", "length", "maxHeight", "uCount", "vCount")]
[InPortTypes("double", "double", "double", "double", "double", "double", "int", "int")]
[InPortDescriptions("baseX", "baseY", "baseZ", "width", "length", "maxHeight", "uCount", "vCount")]
[OutPortNames("Surface")]
[OutPortTypes("Surface")]
[OutPortDescriptions("Lofted surface with random bumps.")]
[IsDesignScriptCompatible]
public class WobblySurface : NodeModel
{
[JsonConstructor]
private WobblySurface(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
{
}
public WobblySurface()
{
RegisterAllPorts();
}
public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAsNodes)
{
if (
!InPorts[0].Connectors.Any() ||
!InPorts[1].Connectors.Any() ||
!InPorts[2].Connectors.Any() ||
!InPorts[3].Connectors.Any() ||
!InPorts[4].Connectors.Any() ||
!InPorts[5].Connectors.Any() ||
!InPorts[6].Connectors.Any() ||
!InPorts[7].Connectors.Any()
)
{
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), AstFactory.BuildNullNode()) };
}
var functionCall =
AstFactory.BuildFunctionCall(
new Func<double, double, double, double, double, double, int, int, Surface>(NodeModelsEssentialsFunctions.WobblySurface),
new List<AssociativeNode> {
inputAsNodes[0],
inputAsNodes[1],
inputAsNodes[2],
inputAsNodes[3],
inputAsNodes[4],
inputAsNodes[5],
inputAsNodes[6],
inputAsNodes[7],
});
// Return an assigment of the generated Ast function call to output node 0
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), functionCall) };
}
}
}