IsEmpty() public static method

public static IsEmpty ( VertexCmd c ) : bool
c VertexCmd
return bool
コード例 #1
0
ファイル: BoundingRect.cs プロジェクト: asmboom/HtmlRenderer
        //-----------------------------------------------------bounding_rect_single
        //template<class VertexSource, class CoordT>
        static bool GetBoundingRect(
            VertexStoreSnap vs,
            out int x1, out int y1,
            out int x2, out int y2)
        {
            double x_d = 0;
            double y_d = 0;

            int  x     = 0;
            int  y     = 0;
            bool first = true;

            x1 = 1;
            y1 = 1;
            x2 = 0;
            y2 = 0;

            var vsnapIter = vs.GetVertexSnapIter();

            VertexCmd PathAndFlags;

            while (!VertexHelper.IsEmpty(PathAndFlags = vsnapIter.GetNextVertex(out x_d, out y_d)))
            {
                x = (int)x_d;
                y = (int)y_d;
                if (VertexHelper.IsVertextCommand(PathAndFlags))
                {
                    if (first)
                    {
                        x1    = x;
                        y1    = y;
                        x2    = x;
                        y2    = y;
                        first = false;
                    }
                    else
                    {
                        if (x < x1)
                        {
                            x1 = x;
                        }
                        if (y < y1)
                        {
                            y1 = y;
                        }
                        if (x > x2)
                        {
                            x2 = x;
                        }
                        if (y > y2)
                        {
                            y2 = y;
                        }
                    }
                }
            }
            return(x1 <= x2 && y1 <= y2);
        }
コード例 #2
0
        static int ArrangeOrientations(VertexStore myvxs, int start, bool closewise)
        {
            while (start < myvxs.Count)
            {
                start = ArrangePolygonOrientation(myvxs, start, closewise);
                if (VertexHelper.IsEmpty(myvxs.GetCommand(start)))
                {
                    ++start;
                    break;
                }
            }

            return(start);
        }
コード例 #3
0
        public static VertexStore TransformToVxs(this Perspective perspecitveTx, VertexStoreSnap snap, VertexStore vxs)
        {
            var       vsnapIter = snap.GetVertexSnapIter();
            double    x, y;
            VertexCmd cmd;

            do
            {
                cmd = vsnapIter.GetNextVertex(out x, out y);
                perspecitveTx.Transform(ref x, ref y);
                vxs.AddVertex(x, y, cmd);
            } while (!VertexHelper.IsEmpty(cmd));
            return(vxs);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }