コード例 #1
0
        public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile)
        {
            List <Point3d> points = new List <Point3d>()
            {
                new Point3d(lowX / 2 + highX / 2, lowY / 2 + highY / 2, Depth),
                new Point3d(lowX, lowY / 2 + highY / 2, Depth),
                new Point3d(lowX, highY, Depth),
                new Point3d(highX, highY, Depth),
                new Point3d(highX, lowY, Depth),
                new Point3d(lowX, lowY, Depth),
                new Point3d(lowX, lowY + highY / 4 - lowY / 4, Depth),
            };
            List <double> bulges = new List <double>()
            {
                0, 0, 0, 0, 0, 0, 0
            };

            Machinings.Routing route = new Machinings.Routing();
            route.Bulges   = bulges;
            route.Points   = points;
            route.ToolComp = ToolComp.Left;
            route.Part     = this.Part;
            route.OnFace5  = this.OnFace5;
            route.ToolName = this.ToolName;

            Part.Routings.Add(route);

            //TODO:不知道刀的大小,如何生成Pocket的路径?
            //可能需要在分析时再来生成路径,晕死
            if (IsPocket)
            {
                PocketMachining(toolFile);
            }
        }
コード例 #2
0
        public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile)
        {
            List<Point3d> points = new List<Point3d>()
                {
                    new Point3d(lowX/2+highX/2,lowY/2+highY/2,Depth),
                    new Point3d(lowX,lowY/2+highY/2,Depth),
                    new Point3d(lowX,highY,Depth),
                    new Point3d(highX,highY,Depth),
                    new Point3d(highX,lowY,Depth),
                    new Point3d(lowX,lowY,Depth),
                    new Point3d(lowX,lowY+highY/4-lowY/4,Depth),
                };
            List<double> bulges = new List<double>() { 0, 0, 0, 0, 0, 0, 0 };
            Machinings.Routing route = new Machinings.Routing();
            route.Bulges = bulges;
            route.Points = points;
            route.ToolComp = ToolComp.Left;
            route.Part = this.Part;
            route.OnFace5 = this.OnFace5;
            route.ToolName = this.ToolName;

            Part.Routings.Add(route);

            //TODO:不知道刀的大小,如何生成Pocket的路径?
            //可能需要在分析时再来生成路径,晕死
            if (IsPocket)
            {
                PocketMachining(toolFile);
            }
        }
コード例 #3
0
        private void PocketMachining(Entities.ToolFile toolFile)
        {
            List <Point3d> points = new List <Point3d>();
            List <double>  bulges = new List <double>();

            double diameter = toolFile.GetRouteToolByName(this.ToolName).Diameter;
            int    row      = (int)System.Math.Ceiling(System.Math.Abs(StartX - EndX) / diameter) - 1;

            double mod = System.Math.Abs(StartX - EndX) % diameter;

            for (int i = 0; i < row; i++)
            {
                if (i != row - 1)
                {
                    AddLineToPocket(points, bulges, diameter, i);
                }
                else
                {
                    if (mod == 0)//如果是整数行
                    {
                        AddLineToPocket(points, bulges, diameter, i);
                    }
                    else
                    {
                        if (i % 2 == 0)//整除2,表明为基数列
                        {
                            points.Add(new Point3d(lowX + diameter * (i - 1) + diameter * mod / diameter, lowY + diameter, Depth));
                            points.Add(new Point3d(lowX + diameter * (i - 1) + diameter * mod / diameter, highY - diameter, Depth));
                            bulges.Add(0);
                            bulges.Add(0);
                        }
                        else
                        {
                            points.Add(new Point3d(lowX + diameter * (i - 1) + diameter * mod / diameter, highY - diameter, Depth));
                            points.Add(new Point3d(lowX + diameter * (i - 1) + diameter * mod / diameter, lowY + diameter, Depth));
                            bulges.Add(0);
                            bulges.Add(0);
                        }
                    }
                }
            }

            Machinings.Routing route = new Machinings.Routing();
            route.Bulges   = bulges;
            route.Points   = points;
            route.ToolComp = ToolComp.Left;
            route.Part     = this.Part;
            route.OnFace5  = this.OnFace5;
            route.ToolName = this.ToolName;

            Part.Routings.Add(route);
        }
コード例 #4
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            //得到当前面的关联面
            AssociatedPartFaceList = base.FindAssociatedFacesOneTime(AssociatedDist, Penetration);

            //当前的face
            var currentFace = this.Part.GetPartFaceByNumber(this.FaceNumber);

            foreach (var f in AssociatedPartFaceList)
            {
                //得到一个转换矩阵,将
                var matrix = Matrix3d.AlignCoordinateSystem(f.Part.MovedMPPoint,
                                                            f.Part.MovedMPXAxis,
                                                            f.Part.MovedMPYAxis,
                                                            f.Part.MovedMPZAxis,
                                                            Point3d.Origin,
                                                            Vector3d.XAxis,
                                                            Vector3d.YAxis,
                                                            Vector3d.ZAxis);

                //将关联面的两个点作为铣型的起始
                var pt1 = currentFace.Point1.TransformBy(matrix);
                var pt2 = currentFace.Point4.TransformBy(matrix);


                //TODO:需要考虑的事情
                //1、LeadIn和LeadOut
                //2、铣型的方向
                //3、double/triple pass
                //4、刀补的方向如何偏移
                //5、宽度的方向如何偏移


                List <Point3d> points = new List <Point3d>()
                {
                    pt1, pt2
                };
                List <double> bulges = new List <double>()
                {
                    0, 0
                };
                Machinings.Routing route = new Machinings.Routing();
                route.Bulges   = bulges;
                route.Points   = points;
                route.ToolComp = ToolComp.None;
                route.Part     = f.Part;
                route.OnFace5  = (f.FaceNumber == 5) ? true : false;
                route.ToolName = this.ToolName;

                f.Part.Routings.Add(route);
            }
        }
コード例 #5
0
        public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile)
        {
            Point3d pt1 = new Point3d(PosStartX, PosStartY, StartDepth);
            Point3d pt2 = new Point3d(PosEndX, PosEndY, EndDepth);
            List<Point3d> points = new List<Point3d>() { pt1, pt2 };
            List<double> bulges = new List<double>() { 0, 0 };
            Machinings.Routing route = new Machinings.Routing();
            route.Bulges = bulges;
            route.Points = points;
            route.ToolComp = this.ToolComp;
            route.Part = this.Part;
            route.OnFace5 = (this.FaceNumber == 5) ? true : false;
            route.ToolName = this.ToolName;

            Part.Routings.Add(route);
        }
コード例 #6
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            //得到当前面的关联面
            AssociatedPartFaceList = base.FindAssociatedFacesOneTime(AssociatedDist, Penetration);

            //当前的face
            var currentFace = this.Part.GetPartFaceByNumber(this.FaceNumber);

            foreach (var f in AssociatedPartFaceList)
            {
                //得到一个转换矩阵,将
                var matrix = Matrix3d.AlignCoordinateSystem(f.Part.MovedMPPoint,
                                                            f.Part.MovedMPXAxis,
                                                            f.Part.MovedMPYAxis,
                                                            f.Part.MovedMPZAxis,
                                                            Point3d.Origin,
                                                            Vector3d.XAxis,
                                                            Vector3d.YAxis,
                                                            Vector3d.ZAxis);

                //将关联面的两个点作为铣型的起始
                var pt1 = currentFace.Point1.TransformBy(matrix);
                var pt2 = currentFace.Point4.TransformBy(matrix);


                //TODO:需要考虑的事情
                //1、LeadIn和LeadOut
                //2、铣型的方向
                //3、double/triple pass
                //4、刀补的方向如何偏移
                //5、宽度的方向如何偏移


                List<Point3d> points = new List<Point3d>() { pt1, pt2 };
                List<double> bulges = new List<double>() { 0, 0 };
                Machinings.Routing route = new Machinings.Routing();
                route.Bulges = bulges;
                route.Points = points;
                route.ToolComp = ToolComp.None;
                route.Part = f.Part;
                route.OnFace5 = (f.FaceNumber == 5) ? true : false;
                route.ToolName = this.ToolName;

                f.Part.Routings.Add(route);
            }
        }
コード例 #7
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            //if (!toolFile.Tools.Any(it => it.ToolName == this.ToolName))
            //{
            //    this.writeError("未在刀具文件中找到铣刀:" + this.ToolName, false);
            //    return;
            //}

            Machinings.Routing route = new Machinings.Routing();
            route.ToolName = this.ToolName;
            route.ToolComp = this.ToolComp;
            route.Points   = this.Points;
            route.Bulges   = this.Bulges;
            //route.FeedSpeeds;
            route.OnFace5 = this.OnFace5;
            route.Part    = this.Part;

            Part.Routings.Add(route);
        }
コード例 #8
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            double diameter = toolFile.GetRouteToolByName(this.ToolName).Diameter;

            if (diameter >= Radius)
            {
                throw new Exception("不支持加工圆半径小于铣刀半径的情况");
            }

            double smallRadius = (Radius < 12.7) ? Radius : 12.7;//TODO:MV里这是一个定制,如果大于大员的半径,就用大圆的半径

            List <Point3d> points = new List <Point3d>();
            List <double>  bulges = new List <double>();

            points.Add(new Point3d(StartX - Radius + smallRadius, StartY + smallRadius, 0));//下刀深度为0
            points.Add(new Point3d(StartX - Radius, StartY, Depth));
            points.Add(new Point3d(StartX, StartY - Radius, Depth));
            points.Add(new Point3d(StartX + Radius, StartY, Depth));
            points.Add(new Point3d(StartX, StartY + Radius, Depth));
            points.Add(new Point3d(StartX - Radius, StartY, Depth));
            points.Add(new Point3d(StartX - Radius + smallRadius, StartY - smallRadius, 0));
            bulges.AddRange(new double[] { -0.414214, -0.414214, -0.414214, -0.414214, -0.414214, -0.414214, -0.414214 });

            Machinings.Routing route = new Machinings.Routing();
            route.Bulges   = bulges;
            route.Points   = points;
            route.ToolComp = ToolComp.Left;
            route.Part     = this.Part;
            route.OnFace5  = this.OnFace5;
            route.ToolName = this.ToolName;

            Part.Routings.Add(route);

            if (IsPocket)
            {
                //TODO:这个未完成
                PocketMachining(diameter);
            }
        }
コード例 #9
0
        public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile)
        {
            Point3d        pt1    = new Point3d(PosStartX, PosStartY, StartDepth);
            Point3d        pt2    = new Point3d(PosEndX, PosEndY, EndDepth);
            List <Point3d> points = new List <Point3d>()
            {
                pt1, pt2
            };
            List <double> bulges = new List <double>()
            {
                0, 0
            };

            Machinings.Routing route = new Machinings.Routing();
            route.Bulges   = bulges;
            route.Points   = points;
            route.ToolComp = this.ToolComp;
            route.Part     = this.Part;
            route.OnFace5  = (this.FaceNumber == 5) ? true : false;
            route.ToolName = this.ToolName;

            Part.Routings.Add(route);
        }
コード例 #10
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            double diameter = toolFile.GetRouteToolByName(this.ToolName).Diameter;
            if (diameter >= Radius)
                throw new Exception("不支持加工圆半径小于铣刀半径的情况");

            double smallRadius = (Radius < 12.7) ? Radius : 12.7;//TODO:MV里这是一个定制,如果大于大员的半径,就用大圆的半径

            List<Point3d> points = new List<Point3d>();
            List<double> bulges = new List<double>();

            points.Add(new Point3d(StartX - Radius + smallRadius, StartY + smallRadius, 0));//下刀深度为0
            points.Add(new Point3d(StartX - Radius, StartY, Depth));
            points.Add(new Point3d(StartX, StartY - Radius, Depth));
            points.Add(new Point3d(StartX + Radius, StartY, Depth));
            points.Add(new Point3d(StartX, StartY + Radius, Depth));
            points.Add(new Point3d(StartX - Radius, StartY, Depth));
            points.Add(new Point3d(StartX - Radius + smallRadius, StartY - smallRadius, 0));
            bulges.AddRange(new double[] { -0.414214, -0.414214, -0.414214, -0.414214, -0.414214, -0.414214, -0.414214 });

            Machinings.Routing route = new Machinings.Routing();
            route.Bulges = bulges;
            route.Points = points;
            route.ToolComp = ToolComp.Left;
            route.Part = this.Part;
            route.OnFace5 = this.OnFace5;
            route.ToolName = this.ToolName;

            Part.Routings.Add(route);

            if (IsPocket)
            {
                //TODO:这个未完成
                PocketMachining(diameter);
            }
        }
コード例 #11
0
        public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile)
        {
            //先以当前点为坐标系,建立两点坐标
            double  xydist   = System.Math.Sqrt(DistX * DistX + DistY * DistY);
            double  cos      = DistX / xydist;
            double  sin      = DistY / xydist;
            Point3d firstPt  = new Point3d(DistX + LeadIn * cos, -LeadIn * sin, Depth);
            Point3d secondPt = new Point3d(-LeadIn * cos, DistY + LeadIn * sin, Depth);

            //把两点坐标,转换为世界坐标,再转为MP坐标系
            Point3d  pt      = Part.GetPartPointByNumber(EdgeNumber.ToString());
            Matrix3d matrix1 = Matrix3d.AlignCoordinateSystem(
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis,
                pt,
                (Part.MachinePoint.IsRotated) ? this.GetPointYAxis(EdgeNumber) : this.GetPointXAxis(EdgeNumber),
                (Part.MachinePoint.IsRotated) ? this.GetPointXAxis(EdgeNumber) : this.GetPointYAxis(EdgeNumber),
                Vector3d.ZAxis);
            Matrix3d matrix2 = Matrix3d.AlignCoordinateSystem(
                Part.MPPoint,
                Part.MPXAxis,
                Part.MPYAxis,
                Part.MPZAxis,
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis);

            firstPt  = firstPt.TransformBy(matrix1).TransformBy(matrix2);
            secondPt = secondPt.TransformBy(matrix1).TransformBy(matrix2);

            ToolComp comp = ToolComp.None;

            if (firstPt.X >= secondPt.X && firstPt.Y >= secondPt.Y)
            {
                comp = ToolComp.Left;
            }
            else if (firstPt.X >= secondPt.X && firstPt.Y < secondPt.Y)
            {
                comp = ToolComp.Right;
            }
            else if (firstPt.X < secondPt.X && firstPt.Y < secondPt.Y)
            {
                comp = ToolComp.Left;
            }
            else if (firstPt.X < secondPt.X && firstPt.Y >= secondPt.Y)
            {
                comp = ToolComp.Right;
            }

            List <Point3d> points = new List <Point3d>()
            {
                firstPt, secondPt
            };

            Machinings.Routing route = new Machinings.Routing();
            route.ToolName = ToolName;
            route.Points   = points;
            route.Part     = Part;
            route.ToolComp = comp;
            route.Bulges   = (new double[] { 0, 0 }).ToList();
            if (FaceNumber == 5)
            {
                route.OnFace5 = true;
            }
            else
            {
                route.OnFace5 = false;
            }

            Part.Routings.Add(route);
        }
コード例 #12
0
        public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile)
        {
            //指令根据板件的1-4个边进行定位
            //需要根据面的方位来生成加工的位置
            //幸运的是,不需要经过太多的坐标转换

            List <Point3d> Points = new List <Point3d>();
            ToolComp       comp   = ToolComp.None;

            if (EdgeNumber == 1)
            {
                Point3d firstPt  = new Point3d(StartX, -LeadIn, Depth);
                Point3d secondPt = new Point3d(StartX, StartY, Depth);
                Point3d thirdPt  = new Point3d(EndX, EndY, Depth);
                Point3d forthPt  = new Point3d(EndX, -LeadIn, Depth);
                Points.Add(firstPt);
                Points.Add(secondPt);
                Points.Add(thirdPt);
                Points.Add(forthPt);

                comp = ToolComp.Left;

                Machinings.Routing route = new Machinings.Routing();
                route.ToolName = ToolName;
                route.Points   = Points;
                route.Part     = Part;
                route.ToolComp = comp;
                route.Bulges   = (new double[] { 0, 0, 0, 0 }).ToList();
                if (FaceNumber == 5)
                {
                    route.OnFace5 = true;
                }
                else
                {
                    route.OnFace5 = false;
                }

                Part.Routings.Add(route);
            }
            else if (EdgeNumber == 2)
            {
                //double pl = (Part.MachinePoint.IsRotated) ? Part.Width : Part.Length;
                double  pw       = (!Part.MachinePoint.IsRotated) ? Part.Width : Part.Length;
                Point3d firstPt  = new Point3d(StartX, pw + LeadIn, Depth);
                Point3d secondPt = new Point3d(StartX, pw - StartY, Depth);
                Point3d thirdPt  = new Point3d(EndX, pw - EndY, Depth);
                Point3d forthPt  = new Point3d(EndX, pw + LeadIn, Depth);
                Points.Add(firstPt);
                Points.Add(secondPt);
                Points.Add(thirdPt);
                Points.Add(forthPt);

                comp = ToolComp.Right;

                Machinings.Routing route = new Machinings.Routing();
                route.ToolName = ToolName;
                route.Points   = Points;
                route.Part     = Part;
                route.ToolComp = comp;
                route.Bulges   = (new double[] { 0, 0, 0, 0 }).ToList();
                if (FaceNumber == 5)
                {
                    route.OnFace5 = true;
                }
                else
                {
                    route.OnFace5 = false;
                }

                Part.Routings.Add(route);
            }
            else if (EdgeNumber == 3)
            {
                //double pl = (Part.MachinePoint.IsRotated) ? Part.Width : Part.Length;
                //double pw = (!Part.MachinePoint.IsRotated) ? Part.Width : Part.Length;
                Point3d firstPt  = new Point3d(-LeadIn, StartY, Depth);
                Point3d secondPt = new Point3d(StartX, StartY, Depth);
                Point3d thirdPt  = new Point3d(EndX, EndY, Depth);
                Point3d forthPt  = new Point3d(-LeadIn, EndY, Depth);
                Points.Add(firstPt);
                Points.Add(secondPt);
                Points.Add(thirdPt);
                Points.Add(forthPt);

                comp = ToolComp.Right;

                Machinings.Routing route = new Machinings.Routing();
                route.ToolName = ToolName;
                route.Points   = Points;
                route.Part     = Part;
                route.ToolComp = comp;
                route.Bulges   = (new double[] { 0, 0, 0, 0 }).ToList();
                if (FaceNumber == 5)
                {
                    route.OnFace5 = true;
                }
                else
                {
                    route.OnFace5 = false;
                }

                Part.Routings.Add(route);
            }
            else if (EdgeNumber == 4)
            {
                double pl = (Part.MachinePoint.IsRotated) ? Part.Width : Part.Length;
                //double pw = (!Part.MachinePoint.IsRotated) ? Part.Width : Part.Length;
                Point3d firstPt  = new Point3d(pl + LeadIn, StartY, Depth);
                Point3d secondPt = new Point3d(pl - StartX, StartY, Depth);
                Point3d thirdPt  = new Point3d(pl - EndX, EndY, Depth);
                Point3d forthPt  = new Point3d(pl + LeadIn, EndY, Depth);
                Points.Add(firstPt);
                Points.Add(secondPt);
                Points.Add(thirdPt);
                Points.Add(forthPt);

                comp = ToolComp.Left;

                Machinings.Routing route = new Machinings.Routing();
                route.ToolName = ToolName;
                route.Points   = Points;
                route.Part     = Part;
                route.ToolComp = comp;
                route.Bulges   = (new double[] { 0, 0, 0, 0 }).ToList();
                if (FaceNumber == 5)
                {
                    route.OnFace5 = true;
                }
                else
                {
                    route.OnFace5 = false;
                }

                Part.Routings.Add(route);
            }
        }
コード例 #13
0
        public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile)
        {
            //先以当前点为坐标系,建立两点坐标
            double xydist = System.Math.Sqrt(DistX * DistX + DistY * DistY);
            double cos = DistX / xydist;
            double sin = DistY / xydist;
            Point3d firstPt = new Point3d(DistX + LeadIn * cos, -LeadIn * sin, Depth);
            Point3d secondPt = new Point3d(-LeadIn * cos, DistY + LeadIn * sin, Depth);

            //把两点坐标,转换为世界坐标,再转为MP坐标系
            Point3d pt = Part.GetPartPointByNumber(EdgeNumber.ToString());
            Matrix3d matrix1 = Matrix3d.AlignCoordinateSystem(
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis,
                pt,
                (Part.MachinePoint.IsRotated) ? this.GetPointYAxis(EdgeNumber) : this.GetPointXAxis(EdgeNumber),
                (Part.MachinePoint.IsRotated) ? this.GetPointXAxis(EdgeNumber) : this.GetPointYAxis(EdgeNumber),
                Vector3d.ZAxis);
            Matrix3d matrix2 = Matrix3d.AlignCoordinateSystem(
                Part.MPPoint,
                Part.MPXAxis,
                Part.MPYAxis,
                Part.MPZAxis,
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis);

            firstPt = firstPt.TransformBy(matrix1).TransformBy(matrix2);
            secondPt = secondPt.TransformBy(matrix1).TransformBy(matrix2);

            ToolComp comp = ToolComp.None;

            if (firstPt.X >= secondPt.X && firstPt.Y >= secondPt.Y)
                comp = ToolComp.Left;
            else if (firstPt.X >= secondPt.X && firstPt.Y < secondPt.Y)
                comp = ToolComp.Right;
            else if (firstPt.X < secondPt.X && firstPt.Y < secondPt.Y)
                comp = ToolComp.Left;
            else if (firstPt.X < secondPt.X && firstPt.Y >= secondPt.Y)
                comp = ToolComp.Right;

            List<Point3d> points = new List<Point3d>() { firstPt, secondPt };

            Machinings.Routing route = new Machinings.Routing();
            route.ToolName = ToolName;
            route.Points = points;
            route.Part = Part;
            route.ToolComp = comp;
            route.Bulges = (new double[] { 0, 0 }).ToList();
            if (FaceNumber == 5) route.OnFace5 = true;
            else route.OnFace5 = false;

            Part.Routings.Add(route);
        }
コード例 #14
0
        public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile)
        {
            //由于这个指令是指定了板件的1-8个点进行定位的,所以要把空间的绝对坐标换算回机加工原点的相对坐标
            //matrix1负责把所在点的坐标转换为板件中心的坐标
            //matrix2负责把板件中心的坐标,再转换为MP中心的坐标
            Point3d  pt      = Part.GetPartPointByNumber(EdgeNumber.ToString());
            Matrix3d matrix1 = Matrix3d.AlignCoordinateSystem(
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis,
                pt,
                (Part.MachinePoint.IsRotated) ? this.GetPointYAxis(EdgeNumber) : this.GetPointXAxis(EdgeNumber),
                (Part.MachinePoint.IsRotated) ? this.GetPointXAxis(EdgeNumber) : this.GetPointYAxis(EdgeNumber),
                Vector3d.ZAxis);
            Matrix3d matrix2 = Matrix3d.AlignCoordinateSystem(
                Part.MPPoint,
                Part.MPXAxis,
                Part.MPYAxis,
                Part.MPZAxis,
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis);

            //板件如果旋转,则生成的坐标点是不一样的
            List <Point3d> Points   = new List <Point3d>();
            Point3d        firstPt  = new Point3d(XDist, -LeadIn, Depth);
            Point3d        secondPt = new Point3d(XDist, YDist, Depth);
            Point3d        thirdPt  = new Point3d(-LeadIn, YDist, Depth);

            firstPt  = firstPt.TransformBy(matrix1).TransformBy(matrix2);
            secondPt = secondPt.TransformBy(matrix1).TransformBy(matrix2);
            thirdPt  = thirdPt.TransformBy(matrix1).TransformBy(matrix2);
            Points.Add(new Point3d(firstPt.X, firstPt.Y, Depth));
            Points.Add(new Point3d(secondPt.X, secondPt.Y, Depth));
            Points.Add(new Point3d(thirdPt.X, thirdPt.Y, Depth));

            //判断刀补的方向
            ToolComp comp = ToolComp.None;

            if (firstPt.X >= thirdPt.X && firstPt.Y >= thirdPt.Y)
            {
                comp = ToolComp.Left;
            }
            else if (firstPt.X >= thirdPt.X && firstPt.Y < thirdPt.Y)
            {
                comp = ToolComp.Right;
            }
            else if (firstPt.X < thirdPt.X && firstPt.Y < thirdPt.Y)
            {
                comp = ToolComp.Left;
            }
            else if (firstPt.X < thirdPt.X && firstPt.Y >= thirdPt.Y)
            {
                comp = ToolComp.Right;
            }

            Machinings.Routing route = new Machinings.Routing();
            route.ToolName = ToolName;
            route.Points   = Points;
            route.Part     = Part;
            route.ToolComp = comp;
            route.Bulges   = (new double[] { 0, 0, 0 }).ToList();
            if (FaceNumber == 5)
            {
                route.OnFace5 = true;
            }
            else
            {
                route.OnFace5 = false;
            }

            Part.Routings.Add(route);
        }
コード例 #15
0
        public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile)
        {
            //由于这个指令是指定了板件的1-8个点进行定位的,所以要把空间的绝对坐标换算回机加工原点的相对坐标 
            //matrix1负责把所在点的坐标转换为板件中心的坐标
            //matrix2负责把板件中心的坐标,再转换为MP中心的坐标
            Point3d pt = Part.GetPartPointByNumber(EdgeNumber.ToString());
            Matrix3d matrix1 = Matrix3d.AlignCoordinateSystem(
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis,
                pt,
                (Part.MachinePoint.IsRotated) ? this.GetPointYAxis(EdgeNumber) : this.GetPointXAxis(EdgeNumber),
                (Part.MachinePoint.IsRotated) ? this.GetPointXAxis(EdgeNumber) : this.GetPointYAxis(EdgeNumber),
                Vector3d.ZAxis);
            Matrix3d matrix2 = Matrix3d.AlignCoordinateSystem(
                Part.MPPoint,
                Part.MPXAxis,
                Part.MPYAxis,
                Part.MPZAxis,
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis);

            if (LeadIn > 0)
            {
                double rRadius = LeadIn;
                Point3d firstPt = new Point3d(Radius + rRadius, -rRadius, Depth);
                Point3d secondPt = new Point3d(Radius, 0, Depth);
                Point3d thirdPt = new Point3d(0, Radius, Depth);
                Point3d forthPt = new Point3d(-rRadius, Radius + rRadius, Depth);

                firstPt = firstPt.TransformBy(matrix1).TransformBy(matrix2);
                secondPt = secondPt.TransformBy(matrix1).TransformBy(matrix2);
                thirdPt = thirdPt.TransformBy(matrix1).TransformBy(matrix2);
                forthPt = forthPt.TransformBy(matrix1).TransformBy(matrix2);

                double firstBulge = -0.414214;
                ToolComp comp = ToolComp.None;

                if (firstPt.X >= thirdPt.X && firstPt.Y >= thirdPt.Y)
                {
                    comp = ToolComp.Left;
                    firstBulge *= -1;
                }
                else if (firstPt.X >= thirdPt.X && firstPt.Y < thirdPt.Y)
                {
                    comp = ToolComp.Right;
                }
                else if (firstPt.X < thirdPt.X && firstPt.Y < thirdPt.Y)
                {
                    comp = ToolComp.Left;
                    firstBulge *= -1;
                }
                else if (firstPt.X < thirdPt.X && firstPt.Y >= thirdPt.Y)
                {
                    comp = ToolComp.Right;
                }

                Machinings.Routing route = new Machinings.Routing();
                route.ToolName = ToolName;
                route.Points = new List<Point3d>() { firstPt, secondPt, thirdPt, forthPt };
                route.Part = Part;
                route.ToolComp = comp;
                route.Bulges = (new double[] { firstBulge, -firstBulge, firstBulge, 0 }).ToList();
                if (FaceNumber == 5) route.OnFace5 = true;
                else route.OnFace5 = false;

                Part.Routings.Add(route);
            }
        }
コード例 #16
0
        private void PocketMachining(Entities.ToolFile toolFile)
        {
            List<Point3d> points = new List<Point3d>();
            List<double> bulges = new List<double>();

            double diameter = toolFile.GetRouteToolByName(this.ToolName).Diameter;
            int row = (int)System.Math.Ceiling(System.Math.Abs(StartX - EndX) / diameter) - 1;

            double mod = System.Math.Abs(StartX - EndX) % diameter;

            for (int i = 0; i < row; i++)
            {
                if (i != row - 1)
                {
                    AddLineToPocket(points, bulges, diameter, i);
                }
                else
                {
                    if (mod == 0)//如果是整数行
                        AddLineToPocket(points, bulges, diameter, i);
                    else
                    {
                        if (i % 2 == 0)//整除2,表明为基数列
                        {
                            points.Add(new Point3d(lowX + diameter * (i - 1) + diameter * mod / diameter, lowY + diameter, Depth));
                            points.Add(new Point3d(lowX + diameter * (i - 1) + diameter * mod / diameter, highY - diameter, Depth));
                            bulges.Add(0);
                            bulges.Add(0);
                        }
                        else
                        {
                            points.Add(new Point3d(lowX + diameter * (i - 1) + diameter * mod / diameter, highY - diameter, Depth));
                            points.Add(new Point3d(lowX + diameter * (i - 1) + diameter * mod / diameter, lowY + diameter, Depth));
                            bulges.Add(0);
                            bulges.Add(0);
                        }
                    }
                }
            }

            Machinings.Routing route = new Machinings.Routing();
            route.Bulges = bulges;
            route.Points = points;
            route.ToolComp = ToolComp.Left;
            route.Part = this.Part;
            route.OnFace5 = this.OnFace5;
            route.ToolName = this.ToolName;

            Part.Routings.Add(route);
        }
コード例 #17
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            //由于这个指令是指定了板件的1-8个点进行定位的,所以要把空间的绝对坐标换算回机加工原点的相对坐标
            //matrix1负责把所在点的坐标转换为板件中心的坐标
            //matrix2负责把板件中心的坐标,再转换为MP中心的坐标
            Point3d  pt      = Part.GetPartPointByNumber(EdgeNumber.ToString());
            Matrix3d matrix1 = Matrix3d.AlignCoordinateSystem(
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis,
                pt,
                (Part.MachinePoint.IsRotated) ? this.GetPointYAxis(EdgeNumber) : this.GetPointXAxis(EdgeNumber),
                (Part.MachinePoint.IsRotated) ? this.GetPointXAxis(EdgeNumber) : this.GetPointYAxis(EdgeNumber),
                Vector3d.ZAxis);
            Matrix3d matrix2 = Matrix3d.AlignCoordinateSystem(
                Part.MPPoint,
                Part.MPXAxis,
                Part.MPYAxis,
                Part.MPZAxis,
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis);

            if (LeadIn > 0)
            {
                double  rRadius  = LeadIn;
                Point3d firstPt  = new Point3d(Radius + rRadius, -rRadius, Depth);
                Point3d secondPt = new Point3d(Radius, 0, Depth);
                Point3d thirdPt  = new Point3d(0, Radius, Depth);
                Point3d forthPt  = new Point3d(-rRadius, Radius + rRadius, Depth);

                firstPt  = firstPt.TransformBy(matrix1).TransformBy(matrix2);
                secondPt = secondPt.TransformBy(matrix1).TransformBy(matrix2);
                thirdPt  = thirdPt.TransformBy(matrix1).TransformBy(matrix2);
                forthPt  = forthPt.TransformBy(matrix1).TransformBy(matrix2);

                double   firstBulge = -0.414214;
                ToolComp comp       = ToolComp.None;

                if (firstPt.X >= thirdPt.X && firstPt.Y >= thirdPt.Y)
                {
                    comp        = ToolComp.Left;
                    firstBulge *= -1;
                }
                else if (firstPt.X >= thirdPt.X && firstPt.Y < thirdPt.Y)
                {
                    comp = ToolComp.Right;
                }
                else if (firstPt.X < thirdPt.X && firstPt.Y < thirdPt.Y)
                {
                    comp        = ToolComp.Left;
                    firstBulge *= -1;
                }
                else if (firstPt.X < thirdPt.X && firstPt.Y >= thirdPt.Y)
                {
                    comp = ToolComp.Right;
                }

                Machinings.Routing route = new Machinings.Routing();
                route.ToolName = ToolName;
                route.Points   = new List <Point3d>()
                {
                    firstPt, secondPt, thirdPt, forthPt
                };
                route.Part     = Part;
                route.ToolComp = comp;
                route.Bulges   = (new double[] { 0, firstBulge, 0, 0 }).ToList();
                if (FaceNumber == 5)
                {
                    route.OnFace5 = true;
                }
                else
                {
                    route.OnFace5 = false;
                }

                Part.Routings.Add(route);
            }
        }
コード例 #18
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            //if (!toolFile.Tools.Any(it => it.ToolName == this.ToolName))
            //{
            //    this.writeError("未在刀具文件中找到铣刀:" + this.ToolName, false);
            //    return;
            //}

            Machinings.Routing route = new Machinings.Routing();
            route.ToolName = this.ToolName;
            route.ToolComp = this.ToolComp;
            route.Points = this.Points;
            route.Bulges = this.Bulges;
            //route.FeedSpeeds;
            route.OnFace5 = this.OnFace5;
            route.Part = this.Part;

            Part.Routings.Add(route);
        }
コード例 #19
0
        public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile)
        {
            //指令根据板件的1-4个边进行定位
            //需要根据面的方位来生成加工的位置
            //幸运的是,不需要经过太多的坐标转换

            List<Point3d> Points = new List<Point3d>();
            ToolComp comp = ToolComp.None;

            if (EdgeNumber == 1)
            {
                Point3d firstPt = new Point3d(StartX, -LeadIn, Depth);
                Point3d secondPt = new Point3d(StartX, StartY, Depth);
                Point3d thirdPt = new Point3d(EndX, EndY, Depth);
                Point3d forthPt = new Point3d(EndX, -LeadIn, Depth);
                Points.Add(firstPt);
                Points.Add(secondPt);
                Points.Add(thirdPt);
                Points.Add(forthPt);

                comp = ToolComp.Left;

                Machinings.Routing route = new Machinings.Routing();
                route.ToolName = ToolName;
                route.Points = Points;
                route.Part = Part;
                route.ToolComp = comp;
                route.Bulges = (new double[] { 0, 0, 0, 0 }).ToList();
                if (FaceNumber == 5) route.OnFace5 = true;
                else route.OnFace5 = false;

                Part.Routings.Add(route);
            }
            else if (EdgeNumber == 2)
            {
                //double pl = (Part.MachinePoint.IsRotated) ? Part.Width : Part.Length;
                double pw = (!Part.MachinePoint.IsRotated) ? Part.Width : Part.Length;
                Point3d firstPt = new Point3d(StartX, pw + LeadIn, Depth);
                Point3d secondPt = new Point3d(StartX, pw - StartY, Depth);
                Point3d thirdPt = new Point3d(EndX, pw - EndY, Depth);
                Point3d forthPt = new Point3d(EndX, pw + LeadIn, Depth);
                Points.Add(firstPt);
                Points.Add(secondPt);
                Points.Add(thirdPt);
                Points.Add(forthPt);

                comp = ToolComp.Right;

                Machinings.Routing route = new Machinings.Routing();
                route.ToolName = ToolName;
                route.Points = Points;
                route.Part = Part;
                route.ToolComp = comp;
                route.Bulges = (new double[] { 0, 0, 0, 0 }).ToList();
                if (FaceNumber == 5) route.OnFace5 = true;
                else route.OnFace5 = false;

                Part.Routings.Add(route);
            }
            else if (EdgeNumber == 3)
            {
                //double pl = (Part.MachinePoint.IsRotated) ? Part.Width : Part.Length;
                //double pw = (!Part.MachinePoint.IsRotated) ? Part.Width : Part.Length;
                Point3d firstPt = new Point3d(-LeadIn, StartY, Depth);
                Point3d secondPt = new Point3d(StartX, StartY, Depth);
                Point3d thirdPt = new Point3d(EndX, EndY, Depth);
                Point3d forthPt = new Point3d(-LeadIn, EndY, Depth);
                Points.Add(firstPt);
                Points.Add(secondPt);
                Points.Add(thirdPt);
                Points.Add(forthPt);

                comp = ToolComp.Right;

                Machinings.Routing route = new Machinings.Routing();
                route.ToolName = ToolName;
                route.Points = Points;
                route.Part = Part;
                route.ToolComp = comp;
                route.Bulges = (new double[] { 0, 0, 0, 0 }).ToList();
                if (FaceNumber == 5) route.OnFace5 = true;
                else route.OnFace5 = false;

                Part.Routings.Add(route);
            }
            else if (EdgeNumber == 4)
            {
                double pl = (Part.MachinePoint.IsRotated) ? Part.Width : Part.Length;
                //double pw = (!Part.MachinePoint.IsRotated) ? Part.Width : Part.Length;
                Point3d firstPt = new Point3d(pl + LeadIn, StartY, Depth);
                Point3d secondPt = new Point3d(pl - StartX, StartY, Depth);
                Point3d thirdPt = new Point3d(pl - EndX, EndY, Depth);
                Point3d forthPt = new Point3d(pl + LeadIn, EndY, Depth);
                Points.Add(firstPt);
                Points.Add(secondPt);
                Points.Add(thirdPt);
                Points.Add(forthPt);

                comp = ToolComp.Left;

                Machinings.Routing route = new Machinings.Routing();
                route.ToolName = ToolName;
                route.Points = Points;
                route.Part = Part;
                route.ToolComp = comp;
                route.Bulges = (new double[] { 0, 0, 0, 0 }).ToList();
                if (FaceNumber == 5) route.OnFace5 = true;
                else route.OnFace5 = false;

                Part.Routings.Add(route);
            }
        }