Beispiel #1
0
        protected bool Add(TriangulationPoint p, int idx, bool constrainToBounds)
        {
            if (p == null)
            {
                return(false);
            }

            if (constrainToBounds)
            {
                ConstrainPointToBounds(p);
            }

            // if we already have an instance of the point, then don't bother inserting it again as duplicate points
            // will actually cause some real problems later on.   Still return true though to indicate that the point
            // is successfully "added"
            if (_pointMap.ContainsKey(p.VertexCode))
            {
                return(true);
            }
            _pointMap.Add(p.VertexCode, p);

            if (idx < 0)
            {
                MPoints.Add(p);
            }
            else
            {
                MPoints.Insert(idx, p);
            }

            return(true);
        }
Beispiel #2
0
        protected override void Add(Point2D p, int idx, bool bCalcWindingOrderAndEpsilon)
        {
            TriangulationPoint pt;

            if (p is TriangulationPoint)
            {
                pt = p as TriangulationPoint;
            }
            else
            {
                pt = new TriangulationPoint(p.X, p.Y);
            }
            if (idx < 0)
            {
                MPoints.Add(pt);
            }
            else
            {
                MPoints.Insert(idx, pt);
            }
            BoundingBox = BoundingBox.AddPoint(pt);
            if (bCalcWindingOrderAndEpsilon)
            {
                if (WindingOrder == WindingOrderType.Unknown)
                {
                    WindingOrder = CalculateWindingOrder();
                }
                Epsilon = CalculateEpsilon();
            }
        }
Beispiel #3
0
        protected override void AddRange(IEnumerator <Point2D> iter, WindingOrderType windingOrder)
        {
            if (iter == null)
            {
                return;
            }

            if (WindingOrder == WindingOrderType.Unknown && Count == 0)
            {
                WindingOrder = windingOrder;
            }
            bool bReverseReadOrder = (WindingOrder != WindingOrderType.Unknown) && (windingOrder != WindingOrderType.Unknown) && (WindingOrder != windingOrder);
            bool bAddedFirst       = true;
            int  startCount        = MPoints.Count;

            iter.Reset();
            while (iter.MoveNext())
            {
                TriangulationPoint pt;
                if (iter.Current is TriangulationPoint)
                {
                    pt = iter.Current as TriangulationPoint;
                }
                else
                {
                    pt = new TriangulationPoint(iter.Current.X, iter.Current.Y);
                }
                if (!bAddedFirst)
                {
                    bAddedFirst = true;
                    MPoints.Add(pt);
                }
                else if (bReverseReadOrder)
                {
                    MPoints.Insert(startCount, pt);
                }
                else
                {
                    MPoints.Add(pt);
                }
                BoundingBox = BoundingBox.AddPoint(iter.Current);
            }
            if (WindingOrder == WindingOrderType.Unknown && windingOrder == WindingOrderType.Unknown)
            {
                WindingOrder = CalculateWindingOrder();
            }
            Epsilon = CalculateEpsilon();
        }