Esempio n. 1
0
File: Map.cs Progetto: remy22/dx11
        private Corner MakeCorner(Vector2? p)
        {
            if (p == null) {
                return null;
            }
            var point = p.Value;
            int bucket;

            for (bucket = (int)point.X-1; bucket < (int)point.X + 1; bucket++) {
                if ( !_cornerMap.ContainsKey(bucket)) continue;
                foreach ( var q in _cornerMap[bucket]) {
                    var dx = point.X - q.Point.X;
                    var dy = point.Y - q.Point.Y;
                    if (dx*dx + dy*dy < 1e-6) {
                        return q;
                    }
                }
            }
            bucket = (int) point.X;
            if (!_cornerMap.ContainsKey(bucket) ) {
                _cornerMap[bucket] = new List<Corner>();
            }
            var c = new Corner {
                Index = _corners.Count,
                Point = point,
                Border = (Equals(point.X, 0.0f) || Equals(point.X, _size) || Equals(point.Y, 0.0f) || Equals(point.Y, _size)),
                Touches = new List<Center>(),
                Protrudes = new List<Edge>(),
                Adjacent = new List<Corner>()
            };

            _corners.Add(c);
            _cornerMap[bucket].Add(c);
            return c;
        }
Esempio n. 2
0
File: Map.cs Progetto: remy22/dx11
 private static Edge LookupEdgeFromCorner(Corner q, Corner s)
 {
     return q.Protrudes.FirstOrDefault(edge => edge.V0 == s || edge.V1 == s);
 }
Esempio n. 3
0
File: Map.cs Progetto: remy22/dx11
 private static void AddToCornersList(IList<Corner> v, Corner x)
 {
     if ( x != null && v.IndexOf(x) < 0) v.Add(x);
 }
Esempio n. 4
0
        private Corner MakeCorner(PointF p) {
            if (p == InvalidPoint) return null;
            int bucket;
            for (bucket = (int)p.X - 1; bucket < (int)p.X + 1; bucket++) {
                if (!_cornerMap.ContainsKey(bucket)) {
                    continue;
                }
                foreach (var q in _cornerMap[bucket]) {
                    var dx = p.X - q.Point.X;
                    var dy = p.Y - q.Point.Y;
                    if (dx * dx + dy * dy < 1e-6) {
                        return q;
                    }
                }
            }
            bucket = (int)p.X;
            if (!_cornerMap.ContainsKey(bucket)) {
                _cornerMap[bucket] = new List<Corner>();
            }
            var c = new Corner {
                Index = Corners.Count,
                Point = p,
                Border = (p.X <= 0 || p.X >= _graph.Width || p.Y <= 0 || p.Y >= _graph.Height)
            };
            Corners.Add(c);
            _cornerMap[bucket].Add(c);
            return c;

        }
Esempio n. 5
0
 private static void AddToCornerList(ICollection<Corner> v, Corner corner) {
     if (corner != null && !v.Contains(corner)) {
         v.Add(corner);
     }
 }
Esempio n. 6
0
 private Edge1 LookupEdgeFromCorner(Corner q, Corner s) {
     foreach (var edge in q.Protrudes) {
         if (edge.V0 == s || edge.V1 == s) return edge;
     }
     return null;
 }