/// <summary> /// Generate nodes at the ends of the paths in this collection. /// It is not necessary for the geometry to be part of a Model for this /// function, nor will any newly created nodes be added automatically /// to the current model - this should be done subsequently if necessary. /// </summary> /// <typeparam name="TPath"></typeparam> /// <param name="paths"></param> /// <param name="refreshNodes">Refresh nodes by removing any existing ones before beginning</param> /// <returns></returns> public static NodeCollection GenerateNetworkPathNodes <TPath>(this IList <TPath> paths, NodeGenerationParameters gParams, bool refreshNodes = false) where TPath : IWidePath { var nodes = new NodeCollection(); foreach (TPath path in paths) { if (refreshNodes) { if (path.Spine?.Start != null) { path.Spine.Start.Node = null; } if (path.Spine?.End != null) { path.Spine.End.Node = null; } } else { Node sNode = path.Spine?.Start?.Node; if (sNode != null && !nodes.Contains(sNode.GUID)) { nodes.Add(sNode); } Node eNode = path.Spine?.End?.Node; if (eNode != null && !nodes.Contains(eNode.GUID)) { nodes.Add(eNode); } } } var tree = new NodeDDTree(nodes); foreach (TPath path in paths) { path.Spine?.Start.GenerateNode(gParams, nodes, tree); path.Spine?.End.GenerateNode(gParams, nodes, tree); } return(nodes); }
public override bool Execute(ExecutionInfo exInfo = null) { MergedNodes = new NodeCollection(); NodeDDTree tree = new NodeDDTree(Nodes); var nodeSets = tree.CoincidentNodes(Nodes, Tolerance); foreach (var nodeSet in nodeSets) { if (nodeSet.Count > 1) { MergedNodes.Add(nodeSet.Merge()); } else { MergedNodes.Add(nodeSet[0]); } } return(true); }
/// <summary> /// Generate nodes for this element's vertices, if they do not already posess them /// them. This override of the GenerateNodes function does not require the element /// to be part of a Model. /// </summary> /// <param name="options">The node generation options</param> public virtual void GenerateNodes(NodeGenerationParameters options, NodeCollection nodes, NodeDDTree nodeTree) { VertexGeometry geometry = GetGeometry(); foreach (Vertex v in geometry.Vertices) { v.GenerateNode(options, nodes, nodeTree); } }
protected override void SetItem(int index, Node item) { base.SetItem(index, item); _SpatialTree = null; }
/// <summary> /// Generate a node at this vertex, if it does not already posess one. /// This override can be used to generate nodes independent of a full model/element system. /// </summary> /// <param name="options"></param> public void GenerateNode(NodeGenerationParameters options, NodeCollection nodes, NodeDDTree nodeTree) { if (Node == null) { Node = nodeTree.NearestTo(Position, options.ConnectionTolerance); if (Node == null) { Node = new Node(Position); } } if (!nodes.Contains(Node.GUID)) { nodes.Add(Node); nodeTree.Add(Node); } }