Exemple #1
0
 private Corner MakeCorner(Vector point)
 {
     if (point == null) {
         return null;
     }
     int bucket;
     for (bucket = (int) point.X - 1; bucket <= (int) point.X + 1; bucket++) {
         foreach (Corner possibleCorner in (ArrayList) _cornerMap[bucket]) {
             var dx = point.X - possibleCorner.location.X;
             var dy = point.Y - possibleCorner.location.Y;
             if (dx * dx + dy * dy < 1E-6) {
                 return possibleCorner;
             }
         }
     }
     bucket = (int) point.X;
     if (_cornerMap[bucket] == null) {
         _cornerMap[bucket] = new ArrayList();
     }
     var corner = new Corner {
         index = _corners.Count,
         location = point,
         mapBorder =
             (Math.Abs(point.X) < 1E-6 || Math.Abs(point.X - _size) < 1E-6 || Math.Abs(point.Y) < 1E-6 ||
              Math.Abs(point.Y - _size) < 1E-6),
         touches = new HashSet<Center>(),
         protrudes = new HashSet<Edge>(),
         adjacent = new HashSet<Corner>()
     };
     _corners.Add(corner);
     _cornerMap[bucket] = corner;
     return corner;
 }
Exemple #2
0
 private void AddToCornerList(Corner corner, HashSet<Corner> corners)
 {
     if (corner != null && !corners.Contains(corner)) {
         corners.Add(corner);
     }
 }