public void CanCopyAndPasteAllNodesOnRevit(NodeModelSearchElement searchElement) { var model = ViewModel.Model; searchElement.ProduceNode(); // puts the node into the current workspace var node = AllNodes.FirstOrDefault(); DynamoSelection.Instance.ClearSelection(); DynamoSelection.Instance.Selection.Add(node); Assert.AreEqual(1, DynamoSelection.Instance.Selection.Count); Assert.DoesNotThrow(() => model.Copy(), string.Format("Could not copy node : {0}", node.GetType())); Assert.DoesNotThrow(() => model.Paste(), string.Format("Could not paste node : {0}", node.GetType())); model.ClearCurrentWorkspace(); }
/// <summary> /// Initializes the solver so that the optimization can be run. /// </summary> /// <exception cref="GraphNotConnectedException"> /// If not all target nodes are connected to the start node. /// </exception> public virtual void Initialize() { BuildSearchGraph(); // Use SteinerPreprocessor for search space reduction. SearchSpace = AllNodes.ToList(); var variableTargetNodes = SearchSpace.Where(IsVariableTargetNode); var preProc = new SteinerPreprocessor(SearchSpace, TargetNodes, StartNode, variableTargetNodes); var result = preProc.ReduceSearchSpace(); TargetNodes = result.FixedTargetNodes; var remainingNodes = result.RemainingNodes; SearchSpace = remainingNodes.Except(TargetNodes).ToList(); Distances = result.DistanceLookup; ShortestPaths = result.ShortestPathLookup; StartNode = result.StartNode; // SkillNode-Ids of the remaining search space may represent more than one node. This // information needs to be saved. var expansionDict = new IReadOnlyCollection <ushort> [ushort.MaxValue]; foreach (var node in remainingNodes) { expansionDict[node.Id] = node.Nodes; } var inExpansion = new HashSet <ushort>(remainingNodes.SelectMany(n => n.Nodes)); // Add the remaining nodes as single (unmerged) ones. foreach (var node in AllNodes) { if (!inExpansion.Contains(node.Id)) { expansionDict[node.Id] = new[] { node.Id }; } } NodeExpansionDictionary = expansionDict; // The hidden root node and ascendancy nodes do not count for the total node count. UncountedNodes = 1 + StartNode.Nodes.Count(n => SkillTree.Skillnodes[n].IsAscendancyNode); Debug.WriteLine("Search space dimension: " + SearchSpace.Count); Debug.WriteLine("Target node count: " + TargetNodes.Count); IsInitialized = true; }
public virtual void GatherDefs() { Workspaces.Document item = Item; string ffn = item.FullPath; IGrammarDescription gd = GrammarDescriptionFactory.Create(ffn); if (gd == null) { throw new Exception(); } for (int classification = 0; classification < gd.IdentifyDefinition.Count; ++classification) { Func <IGrammarDescription, Dictionary <IParseTree, IList <CombinedScopeSymbol> >, IParseTree, bool> fun = gd.IdentifyDefinition[classification]; if (fun == null) { continue; } IEnumerable <IParseTree> it = AllNodes.Where(t => fun(gd, Attributes, t)); foreach (IParseTree t in it) { TerminalNodeImpl x = (t as TerminalNodeImpl); if (x == null) { continue; } if (x.Symbol == null) { continue; } try { Defs.Add(x, classification); Tags.Add(x, classification); } catch (ArgumentException) { // Duplicate } } } }
public List <Node> FindPath(NodePosition start, NodePosition end) { if (!IsInitialized) { throw new Exception("First you need to Initialize the grid."); } try { var startNode = AllNodes.GetValue(start.X, start.Y) as Node; var endNode = AllNodes.GetValue(end.X, end.Y) as Node; return(FindPath(startNode, endNode)); } catch (IndexOutOfRangeException error) { Console.WriteLine(error); throw; } catch (Exception ex) { Console.WriteLine(ex); throw; } }
void DrawWindows(EditorWindow editor) { foreach (var node in AllNodes.OrderBy(n => n.Position.y)) { node.DrawGUI(); } if (NextMouseMode != null) { CurrentMouseMode?.End(Event.current.mousePosition); CurrentMouseMode = NextMouseMode; NextMouseMode = null; CurrentMouseMode?.Start(Event.current.mousePosition); } if (CurrentMouseMode == null) { NextMouseMode = new NormalMode(this); } if (CurrentMouseMode != null) { CurrentMouseMode.Update(Event.current.mousePosition); } // Rect test = new Rect(DrawRect); // test.center += PannedOffset; // GUI.color = Color.red; // GUI.Box(test, GUIContent.none); // GUI.color = Color.blue; // Rect koza = new Rect(PhysicalRect); // GUI.Box(koza, GUIContent.none); // GUI.color = Color.white; //if (Event.current.type == EventType.MouseMove //|| (Event.current.type == EventType.Ignore && Event.current.rawType == EventType.MouseMove)) { //if (DrawRect.Contains(Event.current.mousePosition)) // DrawPos(Event.current.mousePosition); // // WantsRepaint = true; } }
public void StartTerminationDetection() { DetectingTermination = true; Task.Run(() => { while (DetectingTermination) { Thread.Sleep(100); lock (AllNodesLock) { if (AllNodes.All(n => n.IsValid() && DateTime.Now.Subtract(n.LastReceivedMessageTime) > TimeSpan.FromMilliseconds(400))) { OnTerminated(); DetectingTermination = false; } } } }); }
public virtual void GatherErrors() { Workspaces.Document item = Item; string ffn = item.FullPath; IGrammarDescription gd = GrammarDescriptionFactory.Create(ffn); if (gd == null) { throw new Exception(); } { IEnumerable <IParseTree> it = AllNodes.Where(t => t as Antlr4.Runtime.Tree.ErrorNodeImpl != null); foreach (IParseTree t in it) { Errors.Add(t); } } }
public void DFS() { //reset all nodes to not visited foreach (var n in AllNodes) { n.Value.isVisited = false; n.Value.ChangeNodeColor(Visuals.Colors.Black); n.Value.HideNode(); } foreach (var e in AllEdges) { e.Value.HideEdge(); e.Value.HideEdge(); e.Value.ChangeEdgeColor(Visuals.Colors.Black); } var node = AllNodes.First().Value; StartCoroutine(DepthFirstSearchNodeVisit(node)); }
public void AddNode(Node node) { if (AllNodes.Contains(node)) { return; } AllNodes.Add(node); if (!DirectContingents.ContainsKey(node)) { DirectContingents.Add(node, new List <Node>()); } if (!DirectDependents.ContainsKey(node)) { DirectDependents.Add(node, new List <Node>()); } }
public void SelectionButtonShouldBeDisabledAfterOpeningNewDocument() { string filePath = Path.Combine(workingDirectory, @".\Bugs\MAGN_7251.dyn"); string testPath = Path.GetFullPath(filePath); ViewModel.OpenCommand.Execute(testPath); AssertNoDummyNodes(); RunCurrentModel(); var node = AllNodes.OfType <DSModelElementSelection>().ElementAt(0); node.RevitDynamoModel = Model as RevitDynamoModel; Assert.IsTrue(node.CanSelect); string newRfaFilePath = Path.Combine(workingDirectory, "modelLines.rfa"); DocumentManager.Instance.CurrentUIApplication.OpenAndActivateDocument(newRfaFilePath); node = AllNodes.OfType <DSModelElementSelection>().ElementAt(0); Assert.IsFalse(node.CanSelect); }
public void ClearNodes() { CtrlPressed = false; CurrentMouseMode?.End(Event.current?.mousePosition ?? Vector2.zero); CurrentMouseMode = null; OnDeleteNode.Clear(); OnSelectNode.Clear(); OnDeleteNode.Clear(); SelectedNodes.Clear(); foreach (var node in AllNodes) { node.OnDestroy(); } AllNodes.Clear(); }
public static bool SetEdge(NodeHandle a, NodeHandle b, bool value) { long d = (long)((ulong)b & handleMask) - (long)((ulong)a & handleMask); if (!whichEdgeBit.ContainsKey(d)) { return(false); } var mask = (NodeEdges)(1ul << whichEdgeBit[d]); if (value) { AllNodes.AddOrUpdate(a, mask, (k, oldValue) => oldValue | mask); } else { AllNodes.AddOrUpdate(a, 0, (k, oldValue) => oldValue & ~mask); } return(true); }
private void CreateTree(List <HATNode <T> > nodes) { if (nodes.Count <= 1) { Root = nodes[0]; return; } else { List <HATNode <T> > AllNodesTemp = new List <HATNode <T> >(); for (int i = 0; i < nodes.Count; i = i + 2) { HATNode <T> parent = new HATNode <T>(); parent.Left = nodes[i]; if (i + 1 < nodes.Count) { parent.Right = nodes[i + 1]; } parent.IsBlockNode = false; parent.FileBlockIndex = -1; parent.Version = 0; if (i + 1 < nodes.Count) { parent.Hash = Utility.ComputeHashAsString(nodes[i].Hash + nodes[i + 1].Hash); } else { parent.Hash = Utility.ComputeHashAsString(nodes[i].Hash); } AllNodes.Add(parent); AllNodesTemp.Add(parent); } CreateTree(AllNodesTemp); } }
public void CreateTree(List <FileBlock> fileBlocks) { fileBlocks = fileBlocks.OrderBy(x => x.Index).ToList(); for (int i = 0; i < fileBlocks.Count; i = i + 2) { MerkleTreeNode left = new MerkleTreeNode(); left.Hash = fileBlocks[i].ContentHash; left.IsBlockNode = true; left.Index = i; MerkleTreeNode right = new MerkleTreeNode(); if (i + 1 < fileBlocks.Count) { right.Hash = fileBlocks[i + 1].ContentHash; right.IsBlockNode = true; right.Index = i + 1; } MerkleTreeNode parent = new MerkleTreeNode(); parent.Left = left; parent.Right = right; parent.IsBlockNode = false; parent.Index = -1; if (i + 1 < fileBlocks.Count) { parent.Hash = Utility.ComputeHashAsString(left.Hash + right.Hash); } else { parent.Hash = Utility.ComputeHashAsString(left.Hash); } AllNodes.Add(parent); } CreateTree(); }
public async Task <PosNode> AddAsync(PosNode node) { if (!AllNodes.ContainsKey(node.AccountID)) { AllNodes.Add(node.AccountID, node); } else { AllNodes[node.AccountID].IP = node.IP; // support for dynamic IP address } node.LastStaking = DateTime.Now; // lookup balance var block = await BlockChain.Singleton.FindLatestBlockAsync(node.AccountID); if (block != null && block.Balances != null && block.Balances.ContainsKey(LyraGlobal.LYRATICKERCODE)) { node.Balance = block.Balances[LyraGlobal.LYRATICKERCODE]; } return(node); }
private void RemoveFromOpen(Node node, bool inner, bool onlyCurrent) { if (inner) { node.Remove(); } if (!onlyCurrent) { AllNodes.Remove(node); for (int i = 0; i < node.Nodes.Count; i++) { RemoveFromOpen(node.Nodes[i], false, onlyCurrent); } } else { for (int i = 0; i < node.Nodes.Count; i++) { node.Nodes[i].Release(); } AllNodes.Remove(node); } }
static void Main(string[] args) { N = 17; #region nodepop Node n0 = new Node(0); Node n1 = new Node(0); Node n2 = new Node(0); Node n3 = new Node(0); Node n4 = new Node(0); Node n5 = new Node(0); Node n6 = new Node(0); Node n7 = new Node(0); Node n8 = new Node(0); Node n9 = new Node(0); Node n10 = new Node(0); Node n11 = new Node(0); Node n12 = new Node(0); Node n13 = new Node(0); Node n14 = new Node(0); Node n15 = new Node(0); Node n16 = new Node(0); Node n17 = new Node(0); n0.Connections.Add(4); n0.Connections.Add(8); n0.Connections.Add(13); n0.Connections.Add(14); n1.Connections.Add(5); n2.Connections.Add(9); n2.Connections.Add(15); n3.Connections.Add(9); n4.Connections.Add(0); n4.Connections.Add(8); n5.Connections.Add(1); n5.Connections.Add(16); n5.Connections.Add(17); n6.Connections.Add(7); n6.Connections.Add(11); n7.Connections.Add(6); n7.Connections.Add(11); n8.Connections.Add(0); n8.Connections.Add(4); n8.Connections.Add(14); n9.Connections.Add(2); n9.Connections.Add(3); n9.Connections.Add(15); n10.Connections.Add(15); n11.Connections.Add(6); n11.Connections.Add(7); n13.Connections.Add(0); n13.Connections.Add(14); n14.Connections.Add(0); n14.Connections.Add(8); n14.Connections.Add(13); n15.Connections.Add(2); n15.Connections.Add(9); n15.Connections.Add(10); n16.Connections.Add(5); n17.Connections.Add(5); AllNodes.Add(n0); AllNodes.Add(n1); AllNodes.Add(n2); AllNodes.Add(n3); AllNodes.Add(n4); AllNodes.Add(n5); AllNodes.Add(n6); AllNodes.Add(n7); AllNodes.Add(n8); AllNodes.Add(n9); AllNodes.Add(n10); AllNodes.Add(n11); AllNodes.Add(n12); AllNodes.Add(n13); AllNodes.Add(n14); AllNodes.Add(n15); AllNodes.Add(n16); AllNodes.Add(n17); #endregion nodepop for (int i = 0; i < Visited.Length; i++) { Visited[i] = false; Console.Write($"{i} false "); } for (int i = 0; i < 18; i++) { Result.Add(i, new List <int>()); } FindComponents(); }
void CheckInput() { if (Input.touchCount == 1) { Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { heldDowntimer = Time.time; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100.0f)) { if (hit.transform.tag == "Nodes" || hit.transform.tag == "HorizontalTouchMove" || hit.transform.tag == "VerticalMovers") { //transform.GetChild(0).GetComponent<Highlight>().isVisible = false; destinationNode = hit.transform.GetComponent <Node>(); } } } else if (touch.phase == TouchPhase.Ended) { heldDowntimer = Time.time - heldDowntimer; if (heldDowntimer < 0.16f && destinationNode) { TouchDecal.AddTouchAnimation(destinationNode.transform); List <Node> tempPath = AllNodes.AStar(currentNode, destinationNode); //Edge cases if (tempPath.Count > 0 && tempPath[0].isOccupied) { if (isMoving) { //Occupancy set by the player if (tempPath[0] != pathToDestination[0]) { Node onlyRemainingNode = pathToDestination[0]; pathToDestination.Clear(); pathToDestination.Add(onlyRemainingNode); return; } } else { destinationNode = null; return; } } //If already moving, adjust if (pathToDestination.Count > 0) { if (pathToDestination[0] != tempPath[0]) { tempPath.Insert(0, currentNode); tempPath.Insert(0, pathToDestination[0]); } } //Set occupancy pathToDestination = tempPath; if (pathToDestination.Count > 0) { if (!isMoving) { currentNode.isOccupied = false; isMoving = true; } pathToDestination[0].isOccupied = true; } } else { destinationNode = null; } } } }
/// <summary> /// Gets the typed enumerator for this class /// </summary> /// <returns>the typed enumerator</returns> public IEnumerator <Method> GetEnumerator() { return(AllNodes.GetEnumerator()); }
public virtual void GatherRefs() { Workspaces.Document item = Item; string ffn = item.FullPath; IGrammarDescription gd = GrammarDescriptionFactory.Create(ffn); if (gd == null) { throw new Exception(); } for (int classification = 0; classification < gd.Identify.Count; ++classification) { Func <IGrammarDescription, Dictionary <IParseTree, IList <CombinedScopeSymbol> >, IParseTree, bool> fun = gd.Identify[classification]; if (fun == null) { continue; } IEnumerable <IParseTree> it = AllNodes.Where(t => fun(gd, Attributes, t)); foreach (IParseTree t in it) { TerminalNodeImpl x = (t as TerminalNodeImpl); if (x == null) { continue; } if (x.Symbol == null) { continue; } try { Attributes.TryGetValue(x, out IList <CombinedScopeSymbol> attr_list); if (attr_list == null) { continue; } foreach (CombinedScopeSymbol attr in attr_list) { Tags.Add(x, classification); if (attr == null) { continue; } ISymbol sym = attr as Symtab.ISymbol; if (sym == null) { continue; } ISymbol def = sym.resolve(); if (def != null && def.file != null && def.file != "" && def.file != ffn) { Workspaces.Document def_item = Workspaces.Workspace.Instance.FindDocument(def.file); ParserDetails def_pd = ParserDetailsFactory.Create(def_item); def_pd.PropagateChangesTo.Add(ffn); } Refs.Add(x, classification); } } catch (ArgumentException) { // Duplicate } } } }
public static uint Clearance(NodeHandle a) => Clearance(AllNodes.Get(a));
protected override void BeginVisit(INode node) { AllNodes.add(node); NodesByType.add(node.typeName(), node); }
/// <summary> /// Gets the enumerator for this class /// </summary> /// <returns>the enumerator</returns> IEnumerator IEnumerable.GetEnumerator() { return(AllNodes.GetEnumerator()); }
/// <summary> /// Yield all neighbors connected to the given node. /// </summary> public static IEnumerable <NodeHandle> Edges(NodeHandle a) => Edges(a, AllNodes.Get(a));
public static bool HasFlag(NodeHandle n, NodeEdges flag) => (AllNodes.Get(n) & flag) != 0;
public override int GetHashCode() { return(2 * Name.GetHashCode() + 3 * AllNodes.GetHashCode()); }
/// <summary> /// Find node with word. Returns null if nothing found. /// </summary> /// <param name="word">Word to try and find</param> /// <returns>Found node</returns> public WordMapNode FindNode(string word) { return(AllNodes.Find(x => x.Word == word)); }
public static void SetEdges(NodeHandle a, NodeEdges e) => AllNodes.Set(a, e);
public static NodeEdges GetEdges(NodeHandle a) => AllNodes.Get(a);
public static void IsCover(NodeHandle a, bool value) => AllNodes.AddOrUpdate(a, value ? NodeEdges.IsCover : 0, (key, e) => IsCover(e, value));