예제 #1
0
        /// <summary>
        /// Рез по кривой
        /// </summary>
        public void Cutting(Curve curve, int cuttingFeed, int smallFeed, Side engineSide = Side.None, double?angleC = null, double?angleA = null)
        {
            var point      = curve.GetClosestPoint(ToolPosition.Point);
            var calcAngleC = angleC == null;

            if (IsUpperTool) // && (angleA ?? AngleA).GetValueOrDefault() == 0)
            {
                var upperPoint = new Point3d(point.X, point.Y, ZSafety);
                if (!ToolPosition.Point.IsEqualTo(upperPoint))
                {
                    Move(upperPoint.X, upperPoint.Y, angleC: angleC ?? BuilderUtils.CalcToolAngle(curve, point, engineSide), angleA: angleA);
                }
            }
            else if (!(curve is Line) && calcAngleC)
            {
                angleC = BuilderUtils.CalcToolAngle(curve, point, engineSide);
            }

            GCommand(point.Z != ToolPosition.Point.Z ? CommandNames.Penetration : CommandNames.Transition, 1, point: point, angleC: angleC, angleA: angleA, feed: smallFeed);

            if (curve is Polyline polyline)
            {
                if (point == polyline.EndPoint)
                {
                    polyline.ReverseCurve();
                    engineSide = engineSide.Opposite();
                }
                for (int i = 1; i < polyline.NumberOfVertices; i++)
                {
                    point = polyline.GetPoint3dAt(i);
                    if (calcAngleC)
                    {
                        angleC = BuilderUtils.CalcToolAngle(polyline, point, engineSide);
                    }
                    if (polyline.GetSegmentType(i - 1) == SegmentType.Arc)
                    {
                        var arcSeg = polyline.GetArcSegment2dAt(i - 1);
                        GCommand(CommandNames.Cutting, arcSeg.IsClockWise ? 2 : 3, point: point, angleC: angleC, curve: polyline, feed: cuttingFeed, center: arcSeg.Center);
                    }
                    else
                    {
                        GCommand(CommandNames.Cutting, 1, point: point, angleC: angleC, curve: polyline, feed: cuttingFeed);
                    }
                }
            }
            else
            {
                var arc = curve as Arc;
                if (arc != null && calcAngleC)
                {
                    angleC += arc.TotalAngle.ToDeg() * (point == curve.StartPoint ? -1 : 1);
                }
                var gCode = curve is Line ? 1 : point == curve.StartPoint ? 2 : 3;
                GCommand(CommandNames.Cutting, gCode, point: curve.NextPoint(point), angleC: angleC, curve: curve, feed: cuttingFeed, center: arc?.Center.ToPoint2d());
            }
        }
예제 #2
0
        /// <summary>
        /// Рез по кривой
        /// </summary>
        public void Cutting(Curve curve, int cuttingFeed, int transitionFeed, Side engineSide = Side.None, double angleA = 0)
        {
            var point  = curve.GetClosestPoint(ToolLocation.Point);
            var angleC = ToolLocation.AngleC;

            if (!(curve is Line))
            {
                angleC = BuilderUtils.CalcToolAngle(curve, point, engineSide);
            }
            GCommand(point.Z != ToolLocation.Point.Z ? CommandNames.Penetration : CommandNames.Transition, 1, point: point, angleC: angleC, angleA: angleA, feed: transitionFeed);

            if (curve is Polyline polyline)
            {
                if (point == polyline.EndPoint)
                {
                    polyline.ReverseCurve();
                    engineSide = engineSide.Opposite();
                }
                for (int i = 1; i < polyline.NumberOfVertices; i++)
                {
                    point  = polyline.GetPoint3dAt(i);
                    angleC = BuilderUtils.CalcToolAngle(polyline, point, engineSide);
                    if (polyline.GetSegmentType(i - 1) == SegmentType.Arc)
                    {
                        var arcSeg = polyline.GetArcSegment2dAt(i - 1);
                        GCommand(CommandNames.Cutting, arcSeg.IsClockWise ? 2 : 3, point: point, angleC: angleC, curve: polyline, feed: cuttingFeed, center: arcSeg.Center);
                    }
                    else
                    {
                        GCommand(CommandNames.Cutting, 1, point: point, angleC: angleC, curve: polyline, feed: cuttingFeed);
                    }
                }
            }
            else
            {
                var arc = curve as Arc;
                if (arc != null)
                {
                    angleC += arc.TotalAngle.ToDeg() * (point == curve.StartPoint ? -1 : 1);
                }
                var gCode = curve is Line ? 1 : point == curve.StartPoint ? 2 : 3;
                GCommand(CommandNames.Cutting, gCode, point: curve.NextPoint(point), angleC: angleC, curve: curve, feed: cuttingFeed, center: arc?.Center.ToPoint2d());
            }
        }