Beispiel #1
0
        public uint Vertex(ref T x, ref T y)
        {
            uint cmd = (uint)Path.Commands.LineTo;

            while (!Path.IsStop(cmd))
            {
                switch (m_status)
                {
                case Status.Initial:
                    Rewind(0);
                    goto case Status.Ready;

                case Status.Ready:
                    if (m_src_vertices.Size() < 2 + (m_closed != 0 ? 1 : 0))
                    {
                        cmd = (uint)Path.Commands.Stop;
                        break;
                    }
                    m_status     = (m_closed != 0) ? Status.Outline1 : Status.Cap1;
                    cmd          = (uint)Path.Commands.MoveTo;
                    m_src_vertex = 0;
                    m_out_vertex = 0;
                    break;

                case Status.Cap1:
                    m_stroker.CalcCap(m_out_vertices, m_src_vertices[0], m_src_vertices[1],
                                      m_src_vertices[0].Dist);
                    m_src_vertex  = 1;
                    m_prev_status = Status.Outline1;
                    m_status      = Status.OutVertices;
                    m_out_vertex  = 0;
                    break;

                case Status.Cap2:
                    m_stroker.CalcCap(m_out_vertices,
                                      m_src_vertices[m_src_vertices.Size() - 1],
                                      m_src_vertices[m_src_vertices.Size() - 2],
                                      m_src_vertices[m_src_vertices.Size() - 2].Dist);
                    m_prev_status = Status.Outline2;
                    m_status      = Status.OutVertices;
                    m_out_vertex  = 0;
                    break;

                case Status.Outline1:
                    if (m_closed != 0)
                    {
                        if (m_src_vertex >= m_src_vertices.Size())
                        {
                            m_prev_status = Status.CloseFirst;
                            m_status      = Status.EndPoly1;
                            break;
                        }
                    }
                    else
                    {
                        if (m_src_vertex >= m_src_vertices.Size() - 1)
                        {
                            m_status = Status.Cap2;
                            break;
                        }
                    }
                    m_stroker.CalcJoin(m_out_vertices,
                                       m_src_vertices.Prev(m_src_vertex),
                                       m_src_vertices.Curr(m_src_vertex),
                                       m_src_vertices.Next(m_src_vertex),
                                       m_src_vertices.Prev(m_src_vertex).Dist,
                                       m_src_vertices.Curr(m_src_vertex).Dist);
                    ++m_src_vertex;
                    m_prev_status = m_status;
                    m_status      = Status.OutVertices;
                    m_out_vertex  = 0;
                    break;

                case Status.CloseFirst:
                    m_status = Status.Outline2;
                    cmd      = (uint)Path.Commands.MoveTo;
                    goto case Status.Outline2;

                case Status.Outline2:
                    if (m_src_vertex <= (m_closed == 0 ? 1 : 0))
                    {
                        m_status      = Status.EndPoly2;
                        m_prev_status = Status.Stop;
                        break;
                    }

                    --m_src_vertex;
                    m_stroker.CalcJoin(m_out_vertices,
                                       m_src_vertices.Next(m_src_vertex),
                                       m_src_vertices.Curr(m_src_vertex),
                                       m_src_vertices.Prev(m_src_vertex),
                                       m_src_vertices.Curr(m_src_vertex).Dist,
                                       m_src_vertices.Prev(m_src_vertex).Dist);

                    m_prev_status = m_status;
                    m_status      = Status.OutVertices;
                    m_out_vertex  = 0;
                    break;

                case Status.OutVertices:
                    if (m_out_vertex >= m_out_vertices.Size())
                    {
                        m_status = m_prev_status;
                    }
                    else
                    {
                        IVector <T> c = m_out_vertices[(int)m_out_vertex++];
                        x = c[0];
                        y = c[1];
                        return(cmd);
                    }
                    break;

                case Status.EndPoly1:
                    m_status = m_prev_status;
                    return((uint)Path.Commands.EndPoly
                           | (uint)Path.Flags.Close
                           | (uint)Path.Flags.CCW);

                case Status.EndPoly2:
                    m_status = m_prev_status;
                    return((uint)Path.Commands.EndPoly
                           | (uint)Path.Flags.Close
                           | (uint)Path.Flags.CW);

                case Status.Stop:
                    cmd = (uint)Path.Commands.Stop;
                    break;
                }
            }
            return(cmd);
        }