AddChild() private method

private AddChild ( PolyNode Child ) : void
Child PolyNode
return void
Exemplo n.º 1
0
        public void AddPath(List <IntPoint> path, JoinType joinType, EndType endType)
        {
            int num = path.Count - 1;

            if (num >= 0)
            {
                PolyNode polyNode = new PolyNode();
                polyNode.m_jointype = joinType;
                polyNode.m_endtype  = endType;
                if (endType == EndType.etClosedLine || endType == EndType.etClosedPolygon)
                {
                    while (num > 0 && path[0] == path[num])
                    {
                        num--;
                    }
                }
                polyNode.m_polygon.Capacity = num + 1;
                polyNode.m_polygon.Add(path[0]);
                int num2 = 0;
                int num3 = 0;
                for (int i = 1; i <= num; i++)
                {
                    if (polyNode.m_polygon[num2] != path[i])
                    {
                        num2++;
                        polyNode.m_polygon.Add(path[i]);
                        if (path[i].Y > polyNode.m_polygon[num3].Y || (path[i].Y == polyNode.m_polygon[num3].Y && path[i].X < polyNode.m_polygon[num3].X))
                        {
                            num3 = num2;
                        }
                    }
                }
                if (endType != 0 || num2 >= 2)
                {
                    m_polyNodes.AddChild(polyNode);
                    if (endType == EndType.etClosedPolygon)
                    {
                        if (m_lowest.X < 0)
                        {
                            m_lowest = new IntPoint(m_polyNodes.ChildCount - 1, num3);
                        }
                        else
                        {
                            IntPoint intPoint = m_polyNodes.Childs[(int)m_lowest.X].m_polygon[(int)m_lowest.Y];
                            if (polyNode.m_polygon[num3].Y > intPoint.Y || (polyNode.m_polygon[num3].Y == intPoint.Y && polyNode.m_polygon[num3].X < intPoint.X))
                            {
                                m_lowest = new IntPoint(m_polyNodes.ChildCount - 1, num3);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        //------------------------------------------------------------------------------

        public void AddPath(List <IntPoint> path, JoinType joinType, EndType endType)
        {
            int highI = path.Count - 1;

            if (highI < 0)
            {
                return;
            }
            PolyNode newNode = new PolyNode();

            newNode.m_jointype = joinType;
            newNode.m_endtype  = endType;

            //strip duplicate points from path and also get index to the lowest point ...
            if (endType == EndType.etClosedLine || endType == EndType.etClosedPolygon)
            {
                while (highI > 0 && path[0] == path[highI])
                {
                    highI--;
                }
            }
            newNode.m_polygon.Capacity = highI + 1;
            newNode.m_polygon.Add(path[0]);
            int j = 0, k = 0;

            for (int i = 1; i <= highI; i++)
            {
                if (newNode.m_polygon[j] != path[i])
                {
                    j++;
                    newNode.m_polygon.Add(path[i]);
                    if (path[i].Y > newNode.m_polygon[k].Y ||
                        (path[i].Y == newNode.m_polygon[k].Y &&
                         path[i].X < newNode.m_polygon[k].X))
                    {
                        k = j;
                    }
                }
            }
            if (endType == EndType.etClosedPolygon && j < 2)
            {
                return;
            }

            m_polyNodes.AddChild(newNode);

            //if this path's lowest pt is lower than all the others then update m_lowest
            if (endType != EndType.etClosedPolygon)
            {
                return;
            }
            if (m_lowest.X < 0)
            {
                m_lowest = new IntPoint(m_polyNodes.ChildCount - 1, k);
            }
            else
            {
                IntPoint ip = m_polyNodes.Childs[(int)m_lowest.X].m_polygon[(int)m_lowest.Y];
                if (newNode.m_polygon[k].Y > ip.Y ||
                    (newNode.m_polygon[k].Y == ip.Y &&
                     newNode.m_polygon[k].X < ip.X))
                {
                    m_lowest = new IntPoint(m_polyNodes.ChildCount - 1, k);
                }
            }
        }
Exemplo n.º 3
0
        public void AddPath(List <IntPoint> path, JoinType joinType, EndType endType)
        {
            int num = path.Count - 1;

            if (num < 0)
            {
                return;
            }
            PolyNode polyNode = new PolyNode();

            polyNode.m_jointype = joinType;
            polyNode.m_endtype  = endType;
            if (endType == EndType.etClosedLine || endType == EndType.etClosedPolygon)
            {
                while (num > 0 && path[0] == path[num])
                {
                    num--;
                }
            }
            polyNode.m_polygon.Capacity = num + 1;
            polyNode.m_polygon.Add(path[0]);
            int num2 = 0;
            int num3 = 0;

            for (int i = 1; i <= num; i++)
            {
                if (!(polyNode.m_polygon[num2] != path[i]))
                {
                    continue;
                }
                num2++;
                polyNode.m_polygon.Add(path[i]);
                IntPoint intPoint  = path[i];
                long     y         = intPoint.Y;
                IntPoint intPoint2 = polyNode.m_polygon[num3];
                if (y <= intPoint2.Y)
                {
                    IntPoint intPoint3 = path[i];
                    long     y2        = intPoint3.Y;
                    IntPoint intPoint4 = polyNode.m_polygon[num3];
                    if (y2 != intPoint4.Y)
                    {
                        continue;
                    }
                    IntPoint intPoint5 = path[i];
                    long     x         = intPoint5.X;
                    IntPoint intPoint6 = polyNode.m_polygon[num3];
                    if (x >= intPoint6.X)
                    {
                        continue;
                    }
                }
                num3 = num2;
            }
            if ((endType == EndType.etClosedPolygon && num2 < 2) || (endType != 0 && num2 < 0))
            {
                return;
            }
            m_polyNodes.AddChild(polyNode);
            if (endType != 0)
            {
                return;
            }
            if (m_lowest.X < 0)
            {
                m_lowest = new IntPoint(0L, num3);
                return;
            }
            IntPoint intPoint7 = m_polyNodes.Childs[(int)m_lowest.X].m_polygon[(int)m_lowest.Y];
            IntPoint intPoint8 = polyNode.m_polygon[num3];

            if (intPoint8.Y <= intPoint7.Y)
            {
                IntPoint intPoint9 = polyNode.m_polygon[num3];
                if (intPoint9.Y != intPoint7.Y)
                {
                    return;
                }
                IntPoint intPoint10 = polyNode.m_polygon[num3];
                if (intPoint10.X >= intPoint7.X)
                {
                    return;
                }
            }
            m_lowest = new IntPoint(m_polyNodes.ChildCount - 1, num3);
        }