Exemple #1
0
        public static SVGElementArray path(string URL)
        {
            //attributes to look for from a path
            SVGElementArray       pathElements    = new SVGElementArray();
            List <attributeArray> attributeValues = new List <attributeArray>();

            readSVG.getElements(allElementAttributes.path, "path", URL, ref attributeValues);
            if (attributeValues.Count > 0)
            {
                //seporate the attributes that are more than the attribute list
                //these are the transformMatricieStrings
                for (int elementNum = 0; elementNum < attributeValues.Count; elementNum++)
                {
                    //convert dVals and points to SVGelementArrays
                }
                for (int elementNum = 0; elementNum < attributeValues.Count; elementNum++)
                {
                    SVGElementArray moreElements = processPath.path(attributeValues[elementNum]);
                    //copy onto pathElements
                    for (int pathElementNum = 0; pathElementNum < moreElements.SVGelement.Count; pathElementNum++)
                    {
                        pathElements.SVGelement.Add(moreElements.SVGelement[pathElementNum]);
                    }
                }
                return(pathElements);
            }
            else
            {
                return(new SVGElementArray());
            }
        }
Exemple #2
0
 static void copyOver(SVGElementArray elementsToAdd, ref SVGElementArray original)
 {
     for (int elementNum = 0; elementNum < elementsToAdd.SVGelement.Count; elementNum++)
     {
         original.SVGelement.Add(elementsToAdd.SVGelement[elementNum]);
     }
 }
Exemple #3
0
        public static SVGElementArray polyline(string URL)
        {
            //attributes to look for from a polyline
            List <attributeArray> attributeValues = new List <attributeArray>();

            readSVG.getElements(allElementAttributes.polyline, "polyline", URL, ref attributeValues);
            if (attributeValues.Count > 0)
            {
                SVGElementArray polylines = new SVGElementArray();
                //seporate the attributes that are more than the attribute list
                //these are the transformMatricieStrings
                for (int elementNum = 0; elementNum < attributeValues.Count; elementNum++)
                {
                    string[] matricies     = new string[0];
                    int      numTransforms = attributeValues[elementNum].atributes.Count
                                             - allElementAttributes.polyline.Count();
                    //seporate the transform matricies from the other attributes
                    for (int transformNum = 0; transformNum < numTransforms; transformNum++)
                    {
                        Array.Resize(ref matricies, matricies.Length + 1);
                        matricies[transformNum] = attributeValues[elementNum].atributes
                                                  [allElementAttributes.polyline.Count() + transformNum];
                    }
                    //convert points string to points
                    point[]  seporatePointVals = new point[0];
                    string[] seporatePoints    = attributeValues[elementNum].atributes[0].Split(new char[2] {
                        ' ', ','
                    });
                    int rem = 0;
                    Math.DivRem(seporatePoints.Length, 2, out rem);
                    if (rem == 0)
                    {
                        for (int pointNum = 0; pointNum < seporatePoints.Length; pointNum += 2)
                        {
                            Array.Resize(ref seporatePointVals, seporatePointVals.Length + 1);
                            seporatePointVals[pointNum / 2].x = double.Parse(seporatePoints[pointNum]);
                            seporatePointVals[pointNum / 2].y = double.Parse(seporatePoints[pointNum + 1]);
                        }
                    }
                    //convert polyline points to SVGlines
                    SVGElementArray somePolylines = polylineToQuadLine(seporatePointVals, matricies, false);
                    for (int SVGelement = 0; SVGelement < somePolylines.SVGelement.Count; SVGelement++)
                    {
                        polylines.SVGelement.Add(somePolylines.SVGelement[SVGelement]);
                    }
                }
                return(polylines);
            }
            else
            {
                return(new SVGElementArray());
            }
        }
Exemple #4
0
        public static SVGElementArray line(string URL)
        {
            //attributes to look for from a line
            SVGElementArray       lines           = new SVGElementArray();
            List <attributeArray> attributeValues = new List <attributeArray>();

            readSVG.getElements(allElementAttributes.line, "line", URL, ref attributeValues);
            if (attributeValues.Count > 0)
            {
                //seporate the attributes that are more than the attribute list
                //these are the transformMatricieStrings
                for (int elementNum = 0; elementNum < attributeValues.Count; elementNum++)
                {
                    string[] matricies     = new string[0];
                    int      numTransforms = attributeValues[elementNum].atributes.Count
                                             - allElementAttributes.line.Count();
                    //seporate the transform matricies from the other attributes
                    for (int transformNum = 0; transformNum < numTransforms; transformNum++)
                    {
                        Array.Resize(ref matricies, matricies.Length + 1);
                        matricies[transformNum] = attributeValues[elementNum].atributes
                                                  [allElementAttributes.line.Count() + transformNum];
                    }

                    //convert lineangle points to SVGline
                    double lineX1 = double.Parse(attributeValues[elementNum].atributes[0]);
                    double lineY1 = double.Parse(attributeValues[elementNum].atributes[1]);
                    double lineX2 = double.Parse(attributeValues[elementNum].atributes[2]);
                    double lineY2 = double.Parse(attributeValues[elementNum].atributes[3]);

                    point start = new point();
                    point end   = new point();

                    start.x = lineX1;
                    start.y = lineY1;
                    end.x   = lineX2;
                    end.y   = lineY2;

                    QuadCode quadCode = new QuadCode();
                    lines.SVGelement.Add(quadCode.addLine(start, end, matricies));
                }
                return(lines);
            }
            else
            {
                return(new SVGElementArray());
            }
        }
Exemple #5
0
        public static SVGElementArray polylineToQuadLine(point[] points, string[] matricies, bool closedFigure)
        {
            //add two lines for every two points
            var             quadCode = new QuadCode();
            SVGElementArray lines    = new SVGElementArray();

            for (int pointNum = 1; pointNum < points.Length; pointNum++)
            {
                lines.SVGelement.Add(quadCode.addLine(points[pointNum - 1], points[pointNum], matricies));
            }
            //draw a line closing the start and end points
            if (closedFigure)
            {
                lines.SVGelement.Add(quadCode.addLine(points[0], points[points.Length - 1], matricies));
            }
            return(lines);
        }
Exemple #6
0
        private void openButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.FileName         = "";
            openFileDialog1.InitialDirectory = "C:\\Users\\" + Environment.UserName + "\\";
            DialogResult result = openFileDialog1.ShowDialog();

            if (result != DialogResult.Cancel)
            {
                elements = loadSVG.getElements(openFileDialog1.FileName);/*
                                                                          * using (StreamReader sr = File.OpenText(openFileDialog1.FileName))
                                                                          * {
                                                                          * string s = "";
                                                                          * while ((s = sr.ReadLine()) != null)
                                                                          * {
                                                                          * viewer.DocumentText += s;
                                                                          * }
                                                                          * }*/
                string doc = "<!DOCTYPE html> <html> <body> " + "hello <svg width=\""
                             /*+(viewer.Width-5).ToString()*/ + "250\" height=\""
                             /*+(viewer.Height-5).ToString()*/ + "250\" >";
                foreach (SVGelement element in elements.SVGelement)
                {
                    doc += svgify(element);
                }
                doc += "</svg>" + " </body> </html>";

                /*
                 * using (FileStream fs = File.Create("C:\\\\bin\\CookieWareCookies"))
                 * {
                 *  Byte[] info =
                 *      new UTF8Encoding(true).GetBytes("This is some text in the file.");
                 *
                 *  // Add some information to the file.
                 *  fs.Write(info, 0, info.Length);
                 * }*/
                //viewer.Navigate("");
                viewer.Visible = true;
                slideSpeed     = .5;
                acceleration   = 1.15;
                animationTimer.Start();
            }
        }
Exemple #7
0
        public static SVGElementArray circle(string URL)
        {
            //attributes to look for from a circle
            SVGElementArray       circles         = new SVGElementArray();
            List <attributeArray> attributeValues = new List <attributeArray>();

            readSVG.getElements(allElementAttributes.circle, "circle", URL, ref attributeValues);
            if (attributeValues.Count > 0)
            {
                //seporate the attributes that are more than the attribute list
                //these are the transformMatricieStrings
                for (int elementNum = 0; elementNum < attributeValues.Count; elementNum++)
                {
                    string[] matricies     = new string[0];
                    int      numTransforms = attributeValues[elementNum].atributes.Count
                                             - allElementAttributes.circle.Count();
                    //seporate the transform matricies from the other attributes
                    for (int transformNum = 0; transformNum < numTransforms; transformNum++)
                    {
                        Array.Resize(ref matricies, matricies.Length + 1);
                        matricies[transformNum] = attributeValues[elementNum].atributes
                                                  [allElementAttributes.circle.Count() + transformNum];
                    }

                    //convert circle to SVGellipse
                    point center = new point();
                    point radius = new point();

                    center.x = double.Parse(attributeValues[elementNum].atributes[0]);
                    center.y = double.Parse(attributeValues[elementNum].atributes[1]);
                    radius.x = double.Parse(attributeValues[elementNum].atributes[2]);
                    radius.y = radius.x;

                    QuadCode quadCode = new QuadCode();
                    circles.SVGelement.Add(quadCode.addEllipse(center, radius, matricies));
                }
                return(circles);
            }
            else
            {
                return(new SVGElementArray());
            }
        }
Exemple #8
0
        /* This is where the SVG file elements get loaded into Cookie Cutter Control Software.
         * After being processed with attributes, the elements are converted into an SVGelement
         * array. Then Processor.shortPath returns the shortest possible distance between all the
         * SVGelements, which is stored into memory while being sent over in one instruction at a
         * time to the Cookie Cutter. On the client side, the Arduino waits to get a go command,
         * after which, it moves along a path given to it by this program. Once the servo motors
         * move to the desired location, the client sends a completed signal back to the control
         * software. This process is repeated until all the SVGelements have been cut out. */
        public static SVGElementArray getElements(string URL)
        {
            SVGElementArray allElements = new SVGElementArray();

            /* process elements by getting their attribute values and
            *  running their attributes though their appropriate void */

            allElements = Quadify.path(URL);

            /* Quadify path converts a path's d's and poinits into SVGelements.
             *  It supports lines, ellipses, arcto's, cubic, & quadradic curves */

            copyOver(Quadify.rect(URL), ref allElements);

            /* Quadify rect takes the rectangle transforms and combines the rectangles into
             * one matrix and then creates SVGlines based on their deminsional attributes */

            copyOver(Quadify.line(URL), ref allElements);

            /* Quadify line takes the x1, y1, x2, & y2 values of an XML SVG line and after
             * mulitplying out the matricies, creates a new SVGline */

            copyOver(Quadify.polygon(URL), ref allElements);
            copyOver(Quadify.polyline(URL), ref allElements);

            /* Polygon and polyline take in a series of points from polyline
             * or polygon element and process them into an SVGElement array */

            copyOver(Quadify.circle(URL), ref allElements);
            copyOver(Quadify.ellipse(URL), ref allElements);

            /* Quadify circle and polygon are relativly simple; These functions parse the
             * radius and center locations of an ellipse or circle to make an SVGellise*/

            allElements = Processer.shortPath(allElements);
            /* Processor.shortPath finds the shortest possible path connecting all the elements */
            return(allElements);
        }
Exemple #9
0
        public static SVGElementArray rect(string URL)
        {
            //attributes to look for from a rect
            List <attributeArray> attributeValues = new List <attributeArray>();

            readSVG.getElements(allElementAttributes.rect, "rect", URL, ref attributeValues);
            if (attributeValues.Count > 0)
            {
                SVGElementArray polylines = new SVGElementArray();
                //seporate the attributes that are more than the attribute list
                //these are the transformMatricieStrings
                for (int elementNum = 0; elementNum < attributeValues.Count; elementNum++)
                {
                    string[] matricies     = new string[0];
                    int      numTransforms = attributeValues[elementNum].atributes.Count
                                             - allElementAttributes.rect.Count();
                    //seporate the transform matricies from the other attributes
                    for (int transformNum = 0; transformNum < numTransforms; transformNum++)
                    {
                        Array.Resize(ref matricies, matricies.Length + 1);
                        matricies[transformNum] = attributeValues[elementNum].atributes
                                                  [allElementAttributes.rect.Count() + transformNum];
                    }

                    //convert rectangle points to SVGline
                    double rectX;
                    rectX = double.Parse(attributeValues[elementNum].atributes[0]);
                    double rectY;
                    rectY = double.Parse(attributeValues[elementNum].atributes[1]);
                    double rectWidth;
                    rectWidth = double.Parse(attributeValues[elementNum].atributes[2]);
                    double rectHeight;
                    rectHeight = double.Parse(attributeValues[elementNum].atributes[3]);

                    point topLeft     = new point();
                    point topRight    = new point();
                    point bottomRight = new point();
                    point bottomLeft  = new point();

                    topLeft.x     = rectX;
                    topLeft.y     = rectY;
                    topRight.x    = rectX + rectWidth;
                    topRight.y    = rectY;
                    bottomRight.x = rectX + rectWidth;
                    bottomRight.y = rectY + rectHeight;
                    bottomLeft.x  = rectX;
                    bottomLeft.y  = rectY + rectHeight;

                    SVGElementArray singleRectangle = new SVGElementArray();
                    singleRectangle = polylineToQuadLine(new point[4] {
                        topLeft, topRight, bottomRight, bottomLeft
                    }, matricies, true);

                    polylines.SVGelement.Add(singleRectangle.SVGelement[0]);  //add the single rectangle to the polyline array
                    polylines.SVGelement.Add(singleRectangle.SVGelement[1]);  //add the single rectangle to the polyline array
                    polylines.SVGelement.Add(singleRectangle.SVGelement[2]);  //add the single rectangle to the polyline array
                    polylines.SVGelement.Add(singleRectangle.SVGelement[3]);  //add the single rectangle to the polyline array
                }
                return(polylines);
            }
            else
            {
                return(new SVGElementArray());
            }
        }
Exemple #10
0
        public static SVGElementArray path(attributeArray attributeValues)
        {
            //0 = d's : 1 = points
            //takes in d and points to make an SVGElementArray

            //!!ADD SUPPORT FOR POINTS TO POLYLINE CONVERSION!!

            SVGElementArray returnElements = new SVGElementArray();
            List <char>     allCMD         = new List <char>();

            //transforming
            string[] matricies     = new string[0];
            int      numTransforms = attributeValues.atributes.Count
                                     - allElementAttributes.path.Count();

            //seporate the transform matricies from the other attributes
            for (int transformNum = 0; transformNum < numTransforms; transformNum++)
            {
                Array.Resize(ref matricies, matricies.Length + 1);
                matricies[transformNum] = attributeValues.atributes
                                          [allElementAttributes.path.Count() + transformNum];
            }
            transformMatrix finalMatrix = transform.combineMatricies(matricies);
            string          dVal        = attributeValues.atributes[0];

            string[] seporateDVals = dVal.Split(new char[2] {
                ' ', ','
            });
            char         CMD           = ' ';
            point        handle0       = new point();
            point        handle1       = new point();
            point        startPoint    = new point();
            point        currentPoint  = new point();
            point        previousPoint = new point();
            QuadCode     quadCode      = new QuadCode();
            List <point> moveTos       = new List <point>();

            //going through the loop
            for (int dValIndex = 0; dValIndex < seporateDVals.Length - 1; dValIndex++)
            {
                //look for a cmd
                char firstChar = seporateDVals[dValIndex][0];
                if (char.IsLetter(firstChar) == true)
                {
                    CMD = firstChar;
                    if (seporateDVals[dValIndex].Length > 1)
                    {
                        seporateDVals[dValIndex] = seporateDVals[dValIndex].Substring(1);
                    }
                    else
                    {
                        dValIndex++;
                    }
                    allCMD.Add(CMD);
                }
                double firstVal = double.Parse(seporateDVals[dValIndex]);
                switch (CMD)
                {
                case 'M':     //move to point absolute
                    startPoint.x = firstVal;
                    dValIndex++;
                    startPoint.y = double.Parse(seporateDVals[dValIndex]);
                    currentPoint = startPoint;
                    moveTos.Add(startPoint);
                    break;

                case 'm':     //move to point relative
                    startPoint.x = currentPoint.x + firstVal;
                    dValIndex++;
                    startPoint.y = currentPoint.y + double.Parse(seporateDVals[dValIndex]);
                    currentPoint = startPoint;
                    moveTos.Add(startPoint);
                    break;

                case 'L':     //line to point absolute
                    currentPoint.x = firstVal;
                    dValIndex++;
                    currentPoint.y = double.Parse(seporateDVals[dValIndex]);
                    returnElements.SVGelement.Add(quadCode.addLine(previousPoint, currentPoint, matricies));
                    break;

                case 'l':     //line to point relative
                    currentPoint.x += firstVal;
                    dValIndex++;
                    currentPoint.y += double.Parse(seporateDVals[dValIndex]);
                    returnElements.SVGelement.Add(quadCode.addLine(previousPoint, currentPoint, matricies));
                    break;

                case 'H':     //horizontal line absolute
                    currentPoint.x = firstVal;
                    currentPoint.y = 0;
                    returnElements.SVGelement.Add(quadCode.addLine(previousPoint, currentPoint, matricies));
                    break;

                case 'h':     //horizontal line relative
                    currentPoint.x += firstVal;
                    returnElements.SVGelement.Add(quadCode.addLine(previousPoint, currentPoint, matricies));
                    break;

                case 'V':     //vertical line absolute
                    currentPoint.x = 0;
                    currentPoint.y = firstVal;
                    returnElements.SVGelement.Add(quadCode.addLine(previousPoint, currentPoint, matricies));
                    break;

                case 'v':     //vertical line relative
                    currentPoint.y += firstVal;
                    returnElements.SVGelement.Add(quadCode.addLine(previousPoint, currentPoint, matricies));
                    break;

                case 'C':     // Cubic bezier curve absolute
                case 'S':
                    handle0.x = firstVal;
                    dValIndex++;
                    handle0.y = double.Parse(seporateDVals[dValIndex]);
                    dValIndex++;
                    handle1.x = double.Parse(seporateDVals[dValIndex]);
                    dValIndex++;
                    handle1.y = double.Parse(seporateDVals[dValIndex]);
                    dValIndex++;
                    currentPoint.x = double.Parse(seporateDVals[dValIndex]);
                    dValIndex++;
                    currentPoint.y = double.Parse(seporateDVals[dValIndex]);
                    returnElements.SVGelement.Add(quadCode.addCurve(previousPoint, handle0, handle1, currentPoint, matricies));
                    break;

                case 'c':     // Cubic bezier curve relative
                case 's':
                    handle0.x = previousPoint.x + firstVal;
                    dValIndex++;
                    handle0.y = previousPoint.y + double.Parse(seporateDVals[dValIndex]);
                    dValIndex++;
                    handle1.x = previousPoint.x + double.Parse(seporateDVals[dValIndex]);
                    dValIndex++;
                    handle1.y = previousPoint.y + double.Parse(seporateDVals[dValIndex]);
                    dValIndex++;
                    currentPoint.x += double.Parse(seporateDVals[dValIndex]);
                    dValIndex++;
                    currentPoint.y += double.Parse(seporateDVals[dValIndex]);
                    returnElements.SVGelement.Add(quadCode.addCurve(previousPoint, handle0, handle1, currentPoint, matricies));
                    break;

                case 'Q':     // Cubic bezier curve absolute
                case 'T':
                    handle0.x = firstVal;
                    dValIndex++;
                    handle0.y = double.Parse(seporateDVals[dValIndex]);
                    dValIndex++;
                    currentPoint.x = double.Parse(seporateDVals[dValIndex]);
                    dValIndex++;
                    currentPoint.y = double.Parse(seporateDVals[dValIndex]);
                    returnElements.SVGelement.Add(quadCode.addCurve(previousPoint, handle0, handle0, currentPoint, matricies));
                    break;

                case 'q':     // Cubic bezier curve relative
                case 't':
                    handle0.x = previousPoint.x + firstVal;
                    dValIndex++;
                    handle0.y = previousPoint.y + double.Parse(seporateDVals[dValIndex]);
                    dValIndex++;
                    currentPoint.x += double.Parse(seporateDVals[dValIndex]);
                    dValIndex++;
                    currentPoint.y += double.Parse(seporateDVals[dValIndex]);
                    returnElements.SVGelement.Add(quadCode.addCurve(previousPoint, handle0, handle0, currentPoint, matricies));
                    break;

                case 'A':     //Arcto absolute
                    //????????????????????
                    break;

                case 'a':     //Arcto relative
                    //????????????????????
                    break;

                case 'Z':     //closing line to start point
                case 'z':
                    returnElements.SVGelement.Add(quadCode.addLine(startPoint, currentPoint, matricies));
                    break;
                }
                previousPoint = currentPoint;
            }
            if (allCMD.Count == 2)
            {
                if (allCMD[0].ToString().ToUpper() == "M" & allCMD[1].ToString().ToUpper() == "Z")
                {
                    return(Quadify.polylineToQuadLine(moveTos.ToArray(), matricies, true));
                }
            }
            else if (allCMD.Count == 1)
            {
                if (allCMD[0].ToString().ToUpper() == "M")
                {
                    return(Quadify.polylineToQuadLine(moveTos.ToArray(), matricies, true));
                }
            }
            return(returnElements);
        }
Exemple #11
0
 public void sendElements(ref SVGElementArray elements, string portName)
 {
     //create serial object here and event handler in this class
     if (serialClass.loadSerial(portName) == true)
     {
         serialClass.write("D"); //change this to "C" at release
         //start sending over instructions
         for (int elementNum = 0; elementNum < elements.SVGelement.Count; elementNum++)
         {
             while (serialClass.newVal == false)
             {
             }
             serialClass.newVal = false;
             if (elements.SVGelement[elementNum] is SVGline)
             {
                 serialClass.write("l");
                 SVGline line = (SVGline)elements.SVGelement[elementNum];
                 serialClass.log(line.start.x,
                                 line.start.y,
                                 line.end.x,
                                 line.end.y);
             }
             if (elements.SVGelement[elementNum] is SVGcurve)
             {
                 serialClass.write("c");
                 SVGcurve curve = (SVGcurve)elements.SVGelement[elementNum];
                 serialClass.log(curve.point1.x,
                                 curve.point1.y,
                                 curve.point2.x,
                                 curve.point2.y,
                                 curve.transform.a,
                                 curve.transform.b,
                                 curve.transform.c,
                                 curve.transform.d,
                                 curve.transform.e,
                                 curve.transform.f,
                                 curve.handle1.x,
                                 curve.handle1.y,
                                 curve.handle2.x,
                                 curve.handle2.y);
             }
             if (elements.SVGelement[elementNum] is SVGellipse)
             {
                 serialClass.write("e");
                 SVGellipse ellipse = (SVGellipse)elements.SVGelement[elementNum];
                 serialClass.log(ellipse.center.x,
                                 ellipse.center.y,
                                 ellipse.radius.x,
                                 ellipse.radius.y,
                                 ellipse.transform.a,
                                 ellipse.transform.b,
                                 ellipse.transform.c,
                                 ellipse.transform.d,
                                 ellipse.transform.e,
                                 ellipse.transform.f,
                                 0, 359.99999); //add code later to find the quickest route
             }
         }
     }
     else
     {
         MessageBox.Show("No Cookie Cutter found");
     }
 }
Exemple #12
0
        public static SVGElementArray shortPath(SVGElementArray allElements)
        {
            //variables
            double          distance         = 0;
            double          previousDistance = 0;
            point           currentPoint     = new point();
            point           previousLocation = new point();
            SVGElementArray reOrdered        = new SVGElementArray();

            bool[] done = new bool[allElements.SVGelement.Count];
            List <processorPoint> points = new List <processorPoint>();

            //convert to points
            for (int elementNum = 0; elementNum < allElements.SVGelement.Count; elementNum++)
            {
                SVGelement element = allElements.SVGelement[elementNum];

                if (element is SVGellipse)
                {
                    SVGellipse ellipse = (SVGellipse)allElements.SVGelement[elementNum];
                    for (double angle = 0; angle <= 6.3; angle += 0.1)
                    {
                        point locAtAngle = new point();
                        locAtAngle.x = Math.Cos(angle) * ellipse.radius.x + ellipse.center.x;
                        locAtAngle.y = Math.Sin(angle) * ellipse.radius.y + ellipse.center.y;
                        points.Add(new processorPoint(locAtAngle, elementNum));
                    }
                    Array.Resize(ref done, done.Length + 63);
                }
                else if (element is SVGline)
                {
                    SVGline line = (SVGline)allElements.SVGelement[elementNum];
                    points.Add(new processorPoint(line.start, elementNum));
                    points.Add(new processorPoint(line.end, elementNum));
                    Array.Resize(ref done, done.Length + 2);
                }
                else if (element is SVGcurve)
                {
                    SVGcurve curve = (SVGcurve)allElements.SVGelement[elementNum];
                    points.Add(new processorPoint(curve.point1, elementNum));
                    points.Add(new processorPoint(curve.point2, elementNum));
                    Array.Resize(ref done, done.Length + 2);
                }
            }

            previousLocation.x = 0;
            previousLocation.y = 0;

            //find shortest distance
            for (int elementNum = 0; elementNum < allElements.SVGelement.Count; elementNum++)
            {
                int index = 0;
                previousDistance = double.MaxValue;
                for (int comparerIndex = 0; comparerIndex < points.Count; comparerIndex++)
                {
                    currentPoint.x = points[comparerIndex].loc.x;
                    currentPoint.y = points[comparerIndex].loc.y;
                    distance       = Math.Sqrt(Math.Pow((previousLocation.x - currentPoint.x), 2)
                                               + Math.Pow((previousLocation.y - currentPoint.y), 2));
                    if (distance < previousDistance & done[points[comparerIndex].index] == false)
                    {
                        previousDistance = distance;
                        index            = points[comparerIndex].index;
                    }
                }
                //after cycling through all points, assign the goal to have been  done
                done[index] = true;

                /* check which of the two points are closer
                 * pass out which point in particular was chosen
                 * then reorder with the closest point first */

                reOrdered.SVGelement.Add(allElements.SVGelement[index]);

                if (reOrdered.SVGelement[reOrdered.SVGelement.Count - 1] is SVGline)
                {
                    SVGline line     = (SVGline)reOrdered.SVGelement[reOrdered.SVGelement.Count - 1];
                    double  dToStart = Math.Sqrt(Math.Pow(previousLocation.x - line.start.x, 2) + Math.Pow(previousLocation.y - line.start.y, 2));
                    double  dToEnd   = Math.Sqrt(Math.Pow(previousLocation.x - line.end.x, 2) + Math.Pow(previousLocation.y - line.end.y, 2));
                    if (dToEnd < dToStart)
                    {
                        SVGline newLine = new SVGline(line.end, line.start);
                        reOrdered.SVGelement.RemoveAt(reOrdered.SVGelement.Count - 1);
                        reOrdered.SVGelement.Add(newLine);
                    }
                }

                if (reOrdered.SVGelement[reOrdered.SVGelement.Count - 1] is SVGcurve)
                {
                    SVGcurve curve    = (SVGcurve)reOrdered.SVGelement[reOrdered.SVGelement.Count - 1];
                    double   dToStart = Math.Sqrt(Math.Pow(previousLocation.x - curve.point1.x, 2) + Math.Pow(previousLocation.y - curve.point1.y, 2));
                    double   dToEnd   = Math.Sqrt(Math.Pow(previousLocation.x - curve.point2.x, 2) + Math.Pow(previousLocation.y - curve.point2.y, 2));
                    if (dToEnd < dToStart)
                    {
                        SVGcurve newCurve = new SVGcurve(curve.point2, curve.handle2, curve.handle1, curve.point1, curve.transform);
                        reOrdered.SVGelement.RemoveAt(reOrdered.SVGelement.Count - 1);
                        reOrdered.SVGelement.Add(newCurve);
                    }
                }

                if (reOrdered.SVGelement[reOrdered.SVGelement.Count - 1] is SVGellipse)
                {
                    SVGellipse ellipse = (SVGellipse)allElements.SVGelement[index];
                    reOrdered.SVGelement.RemoveAt(reOrdered.SVGelement.Count - 1);
                    reOrdered.SVGelement.Add(ellipse);
                }

                previousLocation = currentPoint;
            }
            return(reOrdered);
        }