コード例 #1
0
        //重写ToMachining方法,将Token转换为Machining
        public override void ToMachining(double AssociatedDist, Entities.ToolFile toolFile)
        {
            //step1 查找关联的板件
            //step2 建立一个临时的水平孔列表,把孔位坐标转换为水平机加工
            //setp3 把关联的垂直钻添加到关联的板件
            FindAssociatedFaces(AssociatedDist);

            PartFace pf = this.Part.GetPartFaceByNumber(FaceNumber);

            if (pf.AssociatedPartFaces.Count != 0)//数量不为0,说明有关联的板件
            {
                List<HDrilling> TempHDrills = new List<HDrilling>();

                if (this.EdgeBoreDepth > 0 && this.EdgeBoreDiameter > 0)
                {
                    foreach (double d in this.PointsPosition)//遍历所欲的孔位坐标
                    {
                        HDrilling hdrill = new HDrilling(this.FaceNumber, this.EdgeBoreDiameter, this.EdgeBoreDepth, d, this.ZValue, Part);
                        TempHDrills.Add(hdrill);
                    }
                }

                if (this.FaceBoreDepth > 0 && this.FaceBoreDiameter > 0)
                {
                    foreach (PartFace f in pf.AssociatedPartFaces)
                    {
                        if (!f.IsHorizontalFace)//如果关联的面是面5或面6
                        {
                            foreach (var hdrill in TempHDrills)
                            {
                                Point3d holeposition = hdrill.GetBorePosition();
                                holeposition = holeposition.TransformBy(Matrix3d.AlignCoordinateSystem(new Point3d(), 
                                                                                                       Vector3d.XAxis, 
                                                                                                       Vector3d.YAxis, 
                                                                                                       Vector3d.ZAxis, 
                                                                                                       hdrill.Part.MPPoint, 
                                                                                                       hdrill.Part.MPXAxis,
                                                                                                       hdrill.Part.MPYAxis,
                                                                                                       hdrill.Part.MPZAxis));
                                holeposition = Math.MathHelper.GetRotatedAndMovedPoint(holeposition, Part.TXRotation, Part.YRotation, Part.ZRotation, Part.CenterVector);
                                holeposition = holeposition.TransformBy(Matrix3d.AlignCoordinateSystem(f.Part.MovedMPPoint, 
                                                                                                       f.Part.MovedMPXAxis,
                                                                                                       f.Part.MovedMPYAxis, 
                                                                                                       f.Part.MovedMPZAxis,
                                                                                                       new Point3d(),
                                                                                                       Vector3d.XAxis,
                                                                                                       Vector3d.YAxis, 
                                                                                                       Vector3d.ZAxis));
                                double dimx = holeposition.X;
                                double dimy = holeposition.Y;

                                VDrilling vdrill = new VDrilling(f.FaceNumber, dimx, dimy, this.FaceBoreDiameter, this.FaceBoreDepth, f.Part);
                                f.Part.VDrillings.Add(vdrill);
                            }
                        }
                        else//TODO:如果关联的面是水平面
                        {

                        }
                    }
                }

                this.Part.HDrillings.AddRange(TempHDrills);

            }
        }
コード例 #2
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            FindAssociatedFaces(AssociatedDist + this.GapDist);

            PartFace pf = this.Part.GetPartFaceByNumber(FaceNumber);

            if (pf.AssociatedPartFaces.Count != 0)//数量不为0,说明有关联的板件
            {
                double totolDist = DistToBottom + DistToTop;
                int number = (int)(totolDist / DistBetweenTwoHoles);
                for (int i = 0; i < number; i++)
                {
                    foreach (PartFace f in pf.AssociatedPartFaces)
                    {
                        if (f.IsHorizontalFace)//不对水平面处理
                            continue;


                        //TODO:关于生成的孔的排列
                        /*
                         * 1、无论层板如何旋转,计算上下时总是按未位移旋转时的下平面为基准
                         * 2、排列时,无论本身如何旋转,在加工板件上总是竖直平行于板件的一边
                         * 3、平行的难点:是平行于长边,还是平行于短边?
                         * 
                         */


                        double firstPointX = GetFirstPointX();
                        double firstPointY = GetFirstPointY();
                        double firstPointZ = DistToBottom - i * DistBetweenTwoHoles;
                        //firstPointZ = -Part.Thickness - DistToBottom + i * DistBetweenTwoHoles;
                        Point3d holeposition = new Point3d(firstPointX, firstPointY, firstPointZ);

                        holeposition = holeposition.TransformBy(Matrix3d.AlignCoordinateSystem(new Point3d(),
                                                                                                           Vector3d.XAxis,
                                                                                                           Vector3d.YAxis,
                                                                                                           Vector3d.ZAxis,
                                                                                                           Part.MPPoint,
                                                                                                           Part.MPXAxis,
                                                                                                           Part.MPYAxis,
                                                                                                           Part.MPZAxis));
                        holeposition = Math.MathHelper.GetRotatedAndMovedPoint(holeposition, Part.TXRotation, Part.YRotation, Part.ZRotation, Part.CenterVector);
                        holeposition = holeposition.TransformBy(Matrix3d.AlignCoordinateSystem(f.Part.MovedMPPoint,
                                                                                               f.Part.MovedMPXAxis,
                                                                                               f.Part.MovedMPYAxis,
                                                                                               f.Part.MovedMPZAxis,
                                                                                               new Point3d(),
                                                                                               Vector3d.XAxis,
                                                                                               Vector3d.YAxis,
                                                                                               Vector3d.ZAxis));
                        double dimx = holeposition.X;
                        double dimy = holeposition.Y;

                        VDrilling vdrill = new VDrilling(f.FaceNumber, dimx, dimy, this.FaceHoleDiameter, this.FaceHoleDepth, f.Part);
                        f.Part.VDrillings.Add(vdrill);
                    }
                }
            }
        }