/// <summary> /// This method identifies clusters of points which are separated from others /// by a configurable distance. /// /// Once separate clusters have been identified, they maintain their coherence even /// if the clusters move to overlap each other. /// </summary> /// <param name="resultList"></param> /// <returns></returns> public bool SeparateClusters(List <SpanningTree> resultList) { float maxClusteringEdgeLength = MultiselectEventSystem.current.MaxTouchClusterDistancePixels; float sqrMaxClusteringEdgeLength = maxClusteringEdgeLength * maxClusteringEdgeLength; // Need to be able to associate active touch with correct split cluster int currentClusterActiveTouchId = GetActiveTouchId(); _splitList.Clear(); _splitList.Add(Root); SplitClusters(Root, sqrMaxClusteringEdgeLength); if (_splitList.Count == 1) { resultList.Add(this); return(false); } // Clusters were split off. Create the result list. foreach (var node in _splitList) { _tempTouchPoints.Clear(); CollectTouchesInTree(node, _tempTouchPoints); var newTree = SpanningTreePool.Get(); newTree.SetTouchList(_tempTouchPoints); // migrate the ClusterID and ActiveTouchPoint if applicable newTree.ClusterId = newTree.ContainsTouchId(currentClusterActiveTouchId) ? ClusterId : GetNextClusterId(); newTree.SetTouchAsActiveIfPresent(currentClusterActiveTouchId); resultList.Add(newTree); } return(true); }
public static SpanningTree Get() { return(SpanningTreePool.Get()); }
public void Dispose() { SpanningTreePool.Release(this); }