Пример #1
0
 private Point3d CreatePoint3d(_Point myPoint)
 {
     return(new Point3d(myPoint.X, myPoint.Y, myPoint.Z));
 }
Пример #2
0
        private void GetLayerContour()
        {
            List <GcodeLine> gcodeInLayer = GcodeLine.ConvertFormart(layerNr, gcodeStringInLayer);

            int gcodeLineNr = gcodeInLayer.Count - 1;

            for (int c = 0; c < gcodeLineNr; c++)
            {
                //  current line contains E         ->  need current point
                //      next line contains E        ->  current point is not the last point of current curve
                //      next line doesn't contain E ->  current point is the last point of current curve

                //  current line doesn't contains E ->  must check the next point
                //      next line contains E        ->  current point is the first point of current curve
                //      next line doesn't contain E ->  current point can be skipped.


                if (gcodeInLayer[c].EnableE)    // exists extrude(E) in current gcode line
                {
                    _Point currentPoint = new _Point
                    {
                        PointID = pointCounter,
                        X       = gcodeInLayer[c].X,
                        Y       = gcodeInLayer[c].Y,
                        Z       = z
                    };
                    points.Add(currentPoint);

                    if (pointCounter == 0)
                    {
                        //Console.WriteLine("\n\tCurve " + curveCounter + "\t--------------------------------------------------");
                    }
                    //Console.WriteLine("\t\tP" + pointCounter + "\tX = " + points[pointCounter].X + "\t Y = " + points[pointCounter].Y + "\t Z = " + points[pointCounter].Z);

                    if (gcodeInLayer[c + 1].EnableE)  // check the next line
                    {
                        pointCounter++;
                    }
                    else
                    {
                        _Curve currentCurve = new _Curve
                        {
                            CurveID = curveCounter,
                            Points  = points
                        };
                        curves.Add(currentCurve);

                        pointCounter = 0;
                        points       = new List <_Point>();

                        curveCounter++;
                    }
                }
                else if (gcodeInLayer[c + 1].EnableE)
                {
                    _Point currentPoint = new _Point
                    {
                        PointID = pointCounter,
                        X       = gcodeInLayer[c].X,
                        Y       = gcodeInLayer[c].Y,
                        Z       = z
                    };
                    points.Add(currentPoint);

                    if (pointCounter == 0)
                    {
                        //Console.WriteLine("\n\tCurve " + curveCounter + "\t--------------------------------------------------");
                    }
                    //Console.WriteLine("\t\tP" + pointCounter + "\tX = " + points[pointCounter].X + "\t Y = " + points[pointCounter].Y + "\t Z = " + points[pointCounter].Z);
                    pointCounter++;
                }
            }

            if (gcodeInLayer[gcodeLineNr].EnableE)   // check the last line
            {
                _Point currentPoint = new _Point
                {
                    PointID = pointCounter,
                    X       = gcodeInLayer[gcodeLineNr].X,
                    Y       = gcodeInLayer[gcodeLineNr].Y,
                    Z       = z
                };
                points.Add(currentPoint);

                if (pointCounter == 0)
                {
                    //Console.WriteLine("\n\tCurve " + curveCounter + "\t--------------------------------------------------");
                }
                //Console.WriteLine("\t\tP" + pointCounter + "\tX = " + points[pointCounter].X + "\t Y = " + points[pointCounter].Y + "\t Z = " + points[pointCounter].Z);

                _Curve currentCurve = new _Curve
                {
                    CurveID = curveCounter,
                    Points  = points
                };
                curves.Add(currentCurve);
            }

            myContour.LayerID = layerNr;
            myContour.Curves  = curves;
        }