コード例 #1
0
 public void Rewind(uint path_id)
 {
     m_source.Rewind(path_id);
     m_last_x = 0.0;
     m_last_y = 0.0;
     m_curve3.reset();
     m_curve4.Reset();
 }
コード例 #2
0
        public void MakeVxs(VertexStoreSnap vsnap, VertexStore vxs)
        {
            m_curve3.Reset();
            m_curve4.Reset();
            var            snapIter = vsnap.GetVertexSnapIter();
            CurvePointMode latestCurveMode = CurvePointMode.NotCurve;
            double         x, y;
            VertexCmd      cmd;

            VectorMath.Vector2 c3p2      = new VectorMath.Vector2();
            VectorMath.Vector2 c4p2      = new VectorMath.Vector2();
            VectorMath.Vector2 c4p3      = new VectorMath.Vector2();
            double             lastX     = 0;
            double             lasty     = 0;
            double             lastMoveX = 0;
            double             lastMoveY = 0;

            do
            {
                //this vertex
                cmd = snapIter.GetNextVertex(out x, out y);
                switch (cmd)
                {
                case VertexCmd.P2c:
                {
                    switch (latestCurveMode)
                    {
                    case CurvePointMode.P2:
                    {
                    }
                    break;

                    case CurvePointMode.P3:
                    {
                    }
                    break;

                    case CurvePointMode.NotCurve:
                    {
                        c3p2.x = x;
                        c3p2.y = y;
                    }
                    break;

                    default:
                    {
                    }
                    break;
                    }
                    latestCurveMode = CurvePointMode.P2;
                }
                break;

                case VertexCmd.P3c:
                {
                    //this is p3c
                    switch (latestCurveMode)
                    {
                    case CurvePointMode.P2:
                    {
                        c3p2.x = x;
                        c3p2.y = y;
                    }
                    break;

                    case CurvePointMode.P3:
                    {
                        // vxs.AddVertex(x, y, cmd);
                        c4p3.x = x;
                        c4p3.y = y;
                        //m_curve4.MakeLines(vxs,
                        //    lastX, lasty,
                        //    c3p2.X, c3p2.Y,
                        //    c4p2.x, c4p2.y,
                        //    x, y);

                        // vxs.AddVertex(x, y, cmd);
                    }
                    break;

                    case CurvePointMode.NotCurve:
                    {
                        c4p2.x = x;
                        c4p2.y = y;
                    }
                    break;
                    }
                    latestCurveMode = CurvePointMode.P3;
                }
                break;

                case VertexCmd.LineTo:
                {
                    switch (latestCurveMode)
                    {
                    case CurvePointMode.P2:
                    {
                        m_curve3.MakeLines(vxs,
                                           lastX,
                                           lasty,
                                           c3p2.X,
                                           c3p2.Y,
                                           x,
                                           y);
                    }
                    break;

                    case CurvePointMode.P3:
                    {
                        //from curve4
                        // vxs.AddVertex(x, y, cmd);
                        m_curve4.MakeLines(vxs,
                                           lastX, lasty,
                                           c4p2.x, c4p2.y,
                                           c4p3.x, c4p3.y,
                                           x, y);
                    }
                    break;

                    default:
                    {
                        vxs.AddVertex(x, y, cmd);
                    }
                    break;
                    }
                    //-----------
                    latestCurveMode = CurvePointMode.NotCurve;
                    lastX           = x;
                    lasty           = y;
                    //-----------
                }
                break;

                case VertexCmd.MoveTo:
                {
                    //move to, and end command
                    vxs.AddVertex(x, y, cmd);
                    //-----------
                    latestCurveMode = CurvePointMode.NotCurve;
                    lastMoveX       = lastX = x;
                    lastMoveY       = lasty = y;
                    //-----------
                }
                break;

                case VertexCmd.Close:
                case VertexCmd.CloseAndEndFigure:
                {
                    latestCurveMode = CurvePointMode.NotCurve;
                    vxs.AddVertex(x, y, cmd);
                    //move to begin
                    lastX = lastMoveX;
                    lasty = lastMoveY;
                }
                break;

                default:
                {
                    //move to, and end command
                    vxs.AddVertex(x, y, cmd);
                    //-----------
                    latestCurveMode = CurvePointMode.NotCurve;
                    lastX           = x;
                    lasty           = y;
                    //-----------
                }
                break;
                }
            } while (cmd != VertexCmd.NoMore);
        }