-
Notifications
You must be signed in to change notification settings - Fork 11
/
GeometryUVPlanesOnSurface.cs
53 lines (48 loc) · 1.98 KB
/
GeometryUVPlanesOnSurface.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
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 a surface, returns a grid of UV tangent planes.
// </summary>
[NodeName("Geometry.UVPlanesOnSurface")]
[NodeDescription("Given a surface, returns a grid of UV tangent planes.")]
[NodeCategory("NodeModelsEssentials")]
[InPortNames("surface", "uCount", "vCount")]
[InPortTypes("Surface", "int", "int")]
[InPortDescriptions("Surface to evaluate", "Count u", "Count v")]
[OutPortNames("Surface")]
[OutPortTypes("Plane[][]")]
[OutPortDescriptions("UV tangent planes.")]
[IsDesignScriptCompatible]
public class UVPlanesOnSurface : NodeModel
{
[JsonConstructor]
private UVPlanesOnSurface(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
{
}
public UVPlanesOnSurface()
{
RegisterAllPorts();
}
public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAsNodes)
{
if (!InPorts[0].Connectors.Any() || !InPorts[1].Connectors.Any() || !InPorts[2].Connectors.Any())
{
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), AstFactory.BuildNullNode()) };
}
var functionCall =
AstFactory.BuildFunctionCall(
new Func<Surface, int ,int, List<List<Plane>>>(NodeModelsEssentialsFunctions.UVPlanesOnSurface),
new List<AssociativeNode> { inputAsNodes[0], inputAsNodes[1], inputAsNodes[2] });
// Return an assigment of the generated Ast function call to output node 0
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), functionCall) };
}
}
}