Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
 public static SpanningTree Get()
 {
     return(SpanningTreePool.Get());
 }
Esempio n. 3
0
 public void Dispose()
 {
     SpanningTreePool.Release(this);
 }