CreateJoin() публичный Метод

public CreateJoin ( VertexStore output, VertexDistance v0, VertexDistance v1, VertexDistance v2, double len1, double len2 ) : void
output VertexStore
v0 VertexDistance
v1 VertexDistance
v2 VertexDistance
len1 double
len2 double
Результат void
Пример #1
0
        VertexCmd GetNextVertex(out double x, out double y)
        {
            x = 0; y = 0;
            VertexCmd cmd = VertexCmd.LineTo;

            do
            {
                switch (m_status)
                {
                case Status.Init:
                    this.Rewind();
                    goto case Status.Ready;

                case Status.Ready:

                    if (multipartVertexDistanceList.CurrentRangeLen < 2 + (m_closed ? 1 : 0))
                    {
                        cmd = VertexCmd.NoMore;
                        break;
                    }
                    m_status     = m_closed ? Status.Outline1 : Status.Cap1;
                    cmd          = VertexCmd.MoveTo;
                    m_src_vertex = 0;
                    m_out_vertex = 0;
                    break;

                case Status.CloseFirst:
                    m_status = Status.Outline2;
                    cmd      = VertexCmd.MoveTo;
                    goto case Status.Outline2;

                case Status.Cap1:
                {
                    Vertex2d v0, v1;

                    multipartVertexDistanceList.GetFirst2(out v0, out v1);
                    m_stroker.CreateCap(
                        m_out_vertices,
                        v0,
                        v1,
                        v0.CalLen(v1));

                    m_src_vertex  = 1;
                    m_prev_status = Status.Outline1;
                    m_status      = Status.OutVertices;
                    m_out_vertex  = 0;
                }
                break;

                case Status.Cap2:
                {
                    Vertex2d beforeLast, last;
                    multipartVertexDistanceList.GetLast2(out beforeLast, out last);
                    m_stroker.CreateCap(m_out_vertices,
                                        last,
                                        beforeLast,
                                        beforeLast.CalLen(last));
                    m_prev_status = Status.Outline2;
                    m_status      = Status.OutVertices;
                    m_out_vertex  = 0;
                }
                break;

                case Status.Outline1:
                {
                    if (m_closed)
                    {
                        if (m_src_vertex >= multipartVertexDistanceList.CurrentRangeLen)
                        {
                            m_prev_status = Status.CloseFirst;
                            m_status      = Status.EndPoly1;
                            break;
                        }
                    }
                    else
                    {
                        if (m_src_vertex >= multipartVertexDistanceList.CurrentRangeLen - 1)
                        {
                            m_status = Status.Cap2;
                            break;
                        }
                    }

                    Vertex2d prev, cur, next;
                    multipartVertexDistanceList.GetTripleVertices(m_src_vertex,
                                                                  out prev,
                                                                  out cur,
                                                                  out next);
                    //check if we should join or not ?

                    //don't join it
                    m_stroker.CreateJoin(m_out_vertices,
                                         prev,
                                         cur,
                                         next,
                                         prev.CalLen(cur),
                                         cur.CalLen(next));

                    ++m_src_vertex;
                    m_prev_status = m_status;
                    m_status      = Status.OutVertices;
                    m_out_vertex  = 0;
                }
                break;

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

                    --m_src_vertex;

                    Vertex2d prev, cur, next;
                    multipartVertexDistanceList.GetTripleVertices(m_src_vertex,
                                                                  out prev,
                                                                  out cur,
                                                                  out next);

                    m_stroker.CreateJoin(m_out_vertices,
                                         next,
                                         cur,
                                         prev,
                                         cur.CalLen(next),
                                         prev.CalLen(cur));
                    m_prev_status = m_status;
                    m_status      = Status.OutVertices;
                    m_out_vertex  = 0;
                }
                break;

                case Status.OutVertices:
                    if (m_out_vertex >= m_out_vertices.Count)
                    {
                        m_status = m_prev_status;
                    }
                    else
                    {
                        m_out_vertices.GetVertex(m_out_vertex++, out x, out y);
                        return(cmd);
                    }
                    break;

                case Status.EndPoly1:
                    m_status = m_prev_status;
                    x        = (int)EndVertexOrientation.CCW;
                    y        = 0;
                    return(VertexCmd.Close);

                case Status.EndPoly2:
                    m_status = m_prev_status;
                    x        = (int)EndVertexOrientation.CW;
                    y        = 0;
                    return(VertexCmd.Close);

                case Status.Stop:
                    cmd = VertexCmd.NoMore;
                    break;
                }
            } while (!VertexHelper.IsEmpty(cmd));
            return(cmd);
        }
Пример #2
0
        VertexCmd GetNextVertex(ref double x, ref double y)
        {
            VertexCmd cmd = VertexCmd.LineTo;

            while (!VertexHelper.IsEmpty(cmd))
            {
                switch (m_status)
                {
                case StrokeMath.Status.Init:
                    this.Rewind();
                    goto case StrokeMath.Status.Ready;

                case StrokeMath.Status.Ready:

                    if (vertexDistanceList.Count < 2 + (m_closed ? 1 : 0))
                    {
                        cmd = VertexCmd.Stop;
                        break;
                    }
                    m_status     = m_closed ? StrokeMath.Status.Outline1 : StrokeMath.Status.Cap1;
                    cmd          = VertexCmd.MoveTo;
                    m_src_vertex = 0;
                    m_out_vertex = 0;
                    break;

                case StrokeMath.Status.Cap1:
                    m_stroker.CreateCap(
                        m_out_vertices,
                        vertexDistanceList[0],
                        vertexDistanceList[1],
                        vertexDistanceList[0].dist);

                    m_src_vertex  = 1;
                    m_prev_status = StrokeMath.Status.Outline1;
                    m_status      = StrokeMath.Status.OutVertices;
                    m_out_vertex  = 0;
                    break;

                case StrokeMath.Status.Cap2:
                    m_stroker.CreateCap(m_out_vertices,
                                        vertexDistanceList[vertexDistanceList.Count - 1],
                                        vertexDistanceList[vertexDistanceList.Count - 2],
                                        vertexDistanceList[vertexDistanceList.Count - 2].dist);
                    m_prev_status = StrokeMath.Status.Outline2;
                    m_status      = StrokeMath.Status.OutVertices;
                    m_out_vertex  = 0;
                    break;

                case StrokeMath.Status.Outline1:
                    if (m_closed)
                    {
                        if (m_src_vertex >= vertexDistanceList.Count)
                        {
                            m_prev_status = StrokeMath.Status.CloseFirst;
                            m_status      = StrokeMath.Status.EndPoly1;
                            break;
                        }
                    }
                    else
                    {
                        if (m_src_vertex >= vertexDistanceList.Count - 1)
                        {
                            m_status = StrokeMath.Status.Cap2;
                            break;
                        }
                    }

                    m_stroker.CreateJoin(m_out_vertices,
                                         vertexDistanceList.prev(m_src_vertex),
                                         vertexDistanceList.curr(m_src_vertex),
                                         vertexDistanceList.next(m_src_vertex),
                                         vertexDistanceList.prev(m_src_vertex).dist,
                                         vertexDistanceList.curr(m_src_vertex).dist);
                    ++m_src_vertex;
                    m_prev_status = m_status;
                    m_status      = StrokeMath.Status.OutVertices;
                    m_out_vertex  = 0;
                    break;

                case StrokeMath.Status.CloseFirst:
                    m_status = StrokeMath.Status.Outline2;
                    cmd      = VertexCmd.MoveTo;
                    goto case StrokeMath.Status.Outline2;

                case StrokeMath.Status.Outline2:

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

                    --m_src_vertex;
                    m_stroker.CreateJoin(m_out_vertices,
                                         vertexDistanceList.next(m_src_vertex),
                                         vertexDistanceList.curr(m_src_vertex),
                                         vertexDistanceList.prev(m_src_vertex),
                                         vertexDistanceList.curr(m_src_vertex).dist,
                                         vertexDistanceList.prev(m_src_vertex).dist);

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

                case StrokeMath.Status.OutVertices:
                    if (m_out_vertex >= m_out_vertices.Count)
                    {
                        m_status = m_prev_status;
                    }
                    else
                    {
                        m_out_vertices.GetVertex(m_out_vertex++, out x, out y);
                        //Vector2 c = m_out_vertices[(int)m_out_vertex++];
                        //x = c.x;
                        //y = c.y;
                        return(cmd);
                    }
                    break;

                case StrokeMath.Status.EndPoly1:
                    m_status = m_prev_status;
                    x        = (int)EndVertexOrientation.CCW;
                    return(VertexCmd.EndAndCloseFigure);

                case StrokeMath.Status.EndPoly2:
                    m_status = m_prev_status;
                    x        = (int)EndVertexOrientation.CW;
                    return(VertexCmd.EndAndCloseFigure);


                case StrokeMath.Status.Stop:
                    cmd = VertexCmd.Stop;
                    break;
                }
            }
            return(cmd);
        }