private void MakeClumps()
        {
            // Accumulate overlapping rectangular groups and obstacles.
            foreach (var group in obstacleTree.GetAllGroups().Where(group => group.IsRectangle))
            {
                var groupClump = new SuperClump();
                groupClump.Insert(group);
                this.mapObstacleToSuperClump[group] = groupClump;

                var localGroup = group;
                foreach (var candidate in obstacleTree.Root.AllHitItems(
                                        group.PaddedBoundingBox,
                                        cand => cand.IsRectangle && ObstaclesOverlap(localGroup, cand)))
                {
                    SuperClump candClump;
                    if (this.mapObstacleToSuperClump.TryGetValue(candidate, out candClump) && (candClump != groupClump)) {
                        groupClump = JoinSuperClumps(groupClump, group, candClump);
                        continue;
                    }
                    AddObstacleToSuperClump(groupClump, candidate);
                    if (candidate.Clump != null) 
                    {
                        foreach (var sibling in candidate.Clump)
                        {
                            AddObstacleToSuperClump(groupClump, sibling);
                        }
                    }
                }
            }

            foreach (var superClump in this.mapObstacleToSuperClump.Values) 
            {
                superClump.CalculateHierarchy();
            }
        }
        private SuperClump JoinSuperClumps(SuperClump obsClump, Obstacle group, SuperClump candClump) {
            foreach (var clumpee in obsClump.Obstacles)
            {
                candClump.Insert(clumpee);
                this.mapObstacleToSuperClump[clumpee] = candClump;
            }

            obsClump = candClump;
            this.mapObstacleToSuperClump[group] = obsClump;
            return obsClump;
        }
        private SuperClump JoinSuperClumps(SuperClump obsClump, Obstacle group, SuperClump candClump)
        {
            foreach (var clumpee in obsClump.Obstacles)
            {
                candClump.Insert(clumpee);
                this.mapObstacleToSuperClump[clumpee] = candClump;
            }

            obsClump = candClump;
            this.mapObstacleToSuperClump[group] = obsClump;
            return(obsClump);
        }
        private void MakeClumps()
        {
            // Accumulate overlapping rectangular groups and obstacles.
            foreach (var group in obstacleTree.GetAllGroups().Where(group => group.IsRectangle))
            {
                var groupClump = new SuperClump();
                groupClump.Insert(group);
                this.mapObstacleToSuperClump[group] = groupClump;

                var localGroup = group;
                foreach (var candidate in obstacleTree.Root.AllHitItems(
                             group.PaddedBoundingBox,
                             cand => cand.IsRectangle && ObstaclesOverlap(localGroup, cand)))
                {
                    SuperClump candClump;
                    if (this.mapObstacleToSuperClump.TryGetValue(candidate, out candClump) && (candClump != groupClump))
                    {
                        groupClump = JoinSuperClumps(groupClump, group, candClump);
                        continue;
                    }
                    AddObstacleToSuperClump(groupClump, candidate);
                    if (candidate.Clump != null)
                    {
                        foreach (var sibling in candidate.Clump)
                        {
                            AddObstacleToSuperClump(groupClump, sibling);
                        }
                    }
                }
            }

            foreach (var superClump in this.mapObstacleToSuperClump.Values)
            {
                superClump.CalculateHierarchy();
            }
        }
 private void AddObstacleToSuperClump(SuperClump groupClump, Obstacle candidate)
 {
     groupClump.Insert(candidate);
     this.mapObstacleToSuperClump[candidate] = groupClump;
 }
 private void AddObstacleToSuperClump(SuperClump groupClump, Obstacle candidate) {
     groupClump.Insert(candidate);
     this.mapObstacleToSuperClump[candidate] = groupClump;
 }