예제 #1
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        private static ArrayList PathToCurves(PathIterator pi)
        {
            ArrayList curves      = new ArrayList();
            int       windingRule = pi.GetWindingRule();
            // coords array is big enough for holding:
            //     coordinates returned from currentSegment (6)
            //     OR
            //         two subdivided quadratic curves (2+4+4=10)
            //         AND
            //             0-1 horizontal splitting parameters
            //             OR
            //             2 parametric equation derivative coefficients
            //     OR
            //         three subdivided cubic curves (2+6+6+6=20)
            //         AND
            //             0-2 horizontal splitting parameters
            //             OR
            //             3 parametric equation derivative coefficients
            var    coords = new int[23];
            double movx = 0, movy = 0;
            double curx = 0, cury = 0;

            while (!pi.IsDone())
            {
                double newx;
                double newy;
                switch (pi.CurrentSegment(coords))
                {
                case PathIterator.SEG_MOVETO:
                    Curve.InsertLine(curves, curx, cury, movx, movy);
                    curx = movx = coords[0];
                    cury = movy = coords[1];
                    Curve.InsertMove(curves, movx, movy);
                    break;

                case PathIterator.SEG_LINETO:
                    newx = coords[0];
                    newy = coords[1];
                    Curve.InsertLine(curves, curx, cury, newx, newy);
                    curx = newx;
                    cury = newy;
                    break;

                case PathIterator.SEG_QUADTO:
                {
                    newx = coords[2];
                    newy = coords[3];
                    var dblCoords = new double[coords.Length];
                    for (int i = 0; i < coords.Length; i++)
                    {
                        dblCoords[i] = coords[i];
                    }
                    Curve.InsertQuad(curves, curx, cury, dblCoords);
                    curx = newx;
                    cury = newy;
                }
                break;

                case PathIterator.SEG_CUBICTO:
                {
                    newx = coords[4];
                    newy = coords[5];
                    var dblCoords = new double[coords.Length];
                    for (int i = 0; i < coords.Length; i++)
                    {
                        dblCoords[i] = coords[i];
                    }
                    Curve.InsertCubic(curves, curx, cury, dblCoords);
                    curx = newx;
                    cury = newy;
                }
                break;

                case PathIterator.SEG_CLOSE:
                    Curve.InsertLine(curves, curx, cury, movx, movy);
                    curx = movx;
                    cury = movy;
                    break;
                }
                pi.Next();
            }
            Curve.InsertLine(curves, curx, cury, movx, movy);
            AreaOp op;

            if (windingRule == PathIterator.WIND_EVEN_ODD)
            {
                op = new AreaOp.EoWindOp();
            }
            else
            {
                op = new AreaOp.NzWindOp();
            }
            return(op.Calculate(curves, EmptyCurves));
        }
예제 #2
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 private static ArrayList PathToCurves(PathIterator pi)
 {
     ArrayList curves = new ArrayList();
     int windingRule = pi.GetWindingRule();
     // coords array is big enough for holding:
     //     coordinates returned from currentSegment (6)
     //     OR
     //         two subdivided quadratic curves (2+4+4=10)
     //         AND
     //             0-1 horizontal splitting parameters
     //             OR
     //             2 parametric equation derivative coefficients
     //     OR
     //         three subdivided cubic curves (2+6+6+6=20)
     //         AND
     //             0-2 horizontal splitting parameters
     //             OR
     //             3 parametric equation derivative coefficients
     var coords = new int[23];
     double movx = 0, movy = 0;
     double curx = 0, cury = 0;
     while (!pi.IsDone())
     {
         double newx;
         double newy;
         switch (pi.CurrentSegment(coords))
         {
             case PathIterator.SEG_MOVETO:
                 Curve.InsertLine(curves, curx, cury, movx, movy);
                 curx = movx = coords[0];
                 cury = movy = coords[1];
                 Curve.InsertMove(curves, movx, movy);
                 break;
             case PathIterator.SEG_LINETO:
                 newx = coords[0];
                 newy = coords[1];
                 Curve.InsertLine(curves, curx, cury, newx, newy);
                 curx = newx;
                 cury = newy;
                 break;
             case PathIterator.SEG_QUADTO:
                 {
                     newx = coords[2];
                     newy = coords[3];
                     var dblCoords = new double[coords.Length];
                     for (int i = 0; i < coords.Length; i++)
                     {
                         dblCoords[i] = coords[i];
                     }
                     Curve.InsertQuad(curves, curx, cury, dblCoords);
                     curx = newx;
                     cury = newy;
                 }
                 break;
             case PathIterator.SEG_CUBICTO:
                 {
                     newx = coords[4];
                     newy = coords[5];
                     var dblCoords = new double[coords.Length];
                     for (int i = 0; i < coords.Length; i++)
                     {
                         dblCoords[i] = coords[i];
                     }
                     Curve.InsertCubic(curves, curx, cury, dblCoords);
                     curx = newx;
                     cury = newy;
                 }
                 break;
             case PathIterator.SEG_CLOSE:
                 Curve.InsertLine(curves, curx, cury, movx, movy);
                 curx = movx;
                 cury = movy;
                 break;
         }
         pi.Next();
     }
     Curve.InsertLine(curves, curx, cury, movx, movy);
     AreaOp op;
     if (windingRule == PathIterator.WIND_EVEN_ODD)
     {
         op = new AreaOp.EoWindOp();
     }
     else
     {
         op = new AreaOp.NzWindOp();
     }
     return op.Calculate(curves, EmptyCurves);
 }