示例#1
0
        public bool Equals(Multipoint <T> other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (_points.Count != other._points.Count)
            {
                return(false);
            }

            for (int i = 0; i < _points.Count; i++)
            {
                if (!_points[i].Equals(other._points[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
示例#2
0
        public static Multipoint <TP> CreateEmpty <TP>(int capacity = 0) where TP : IPnt
        {
            var result = new Multipoint <TP>(capacity);

            result.SetEmpty();

            return(result);
        }
示例#3
0
        public static bool AreMultipointsEqualXY([NotNull] Multipoint <IPnt> multipoint1,
                                                 [NotNull] Multipoint <IPnt> multipoint2,
                                                 double tolerance)
        {
            if (ReferenceEquals(multipoint1, multipoint2))
            {
                return(true);
            }

            if (!AreBoundsEqual(multipoint1, multipoint2, tolerance))
            {
                return(false);
            }

            HashSet <int> foundIndexes = new HashSet <int>();

            foreach (IPnt point in multipoint1.GetPoints())
            {
                bool anyFound = false;
                foreach (int foundIdx in
                         multipoint2.FindPointIndexes(point, tolerance, true))
                {
                    anyFound = true;

                    foundIndexes.Add(foundIdx);
                }

                if (!anyFound)
                {
                    return(false);
                }
            }

            // Check if all points have been found at some point:
            for (int i = 0; i < multipoint2.PointCount; i++)
            {
                if (!foundIndexes.Contains(i))
                {
                    return(false);
                }
            }

            return(true);
        }