/// <summary>
        /// 用指定Matrix校准List<List<Entity_Data>>数据,0 - 原点起始,1 - Mark校准,2 - 指定点起始
        /// </summary>
        /// <param name="List_Datas"></param>
        /// <param name="Matrices"></param>
        /// <param name="Flag"></param>
        /// <returns></returns>
        public List <List <Entity_Data> > CalDataByMatrix(List <List <Entity_Data> > List_Datas, Affinity_Matrix Matrices, int Flag)
        {
            //建立变量
            List <List <Entity_Data> > Result    = new List <List <Entity_Data> >();
            List <Entity_Data>         Temp_List = new List <Entity_Data>();
            Entity_Data Temp_Data = new Entity_Data();

            foreach (var entity_Datas in List_Datas)
            {
                foreach (var O in entity_Datas)
                {
                    //先清空
                    Temp_Data.Empty();
                    //后赋值
                    Temp_Data = new Entity_Data(O);
                    //加工起始位置选择
                    switch (Flag)
                    {
                    case 0:    //原点起始加工
                        //起点计算
                        Temp_Data.Start_x = O.Start_x - Program.SystemContainer.SysPara.Rtc_Org.X;
                        Temp_Data.Start_y = O.Start_y - Program.SystemContainer.SysPara.Rtc_Org.Y;
                        //终点计算
                        Temp_Data.End_x = O.End_x - Program.SystemContainer.SysPara.Rtc_Org.X;
                        Temp_Data.End_y = O.End_y - Program.SystemContainer.SysPara.Rtc_Org.Y;
                        //圆心计算
                        if (Temp_Data.Type == 1)
                        {
                            break;
                        }
                        Temp_Data.Center_x = O.Center_x - Program.SystemContainer.SysPara.Rtc_Org.X;
                        Temp_Data.Center_y = O.Center_y - Program.SystemContainer.SysPara.Rtc_Org.Y;
                        break;

                    case 1:    //Mark矫正
                        //sin取正  (当前坐标系采用) 已验证
                        //起点计算
                        Temp_Data.Start_x = O.Start_x * Matrices.Stretch_X + O.Start_y * Matrices.Distortion_X + Matrices.Delta_X - Program.SystemContainer.SysPara.Rtc_Org.X;
                        Temp_Data.Start_y = O.Start_y * Matrices.Stretch_Y + O.Start_x * Matrices.Distortion_Y + Matrices.Delta_Y - Program.SystemContainer.SysPara.Rtc_Org.Y;
                        //终点计算
                        Temp_Data.End_x = O.End_x * Matrices.Stretch_X + O.End_y * Matrices.Distortion_X + Matrices.Delta_X - Program.SystemContainer.SysPara.Rtc_Org.X;
                        Temp_Data.End_y = O.End_y * Matrices.Stretch_Y + O.End_x * Matrices.Distortion_Y + Matrices.Delta_Y - Program.SystemContainer.SysPara.Rtc_Org.Y;
                        //圆心计算
                        if (Temp_Data.Type == 1)
                        {
                            break;
                        }
                        Temp_Data.Center_x = O.Center_x * Matrices.Stretch_X + O.Center_y * Matrices.Distortion_X + Matrices.Delta_X - Program.SystemContainer.SysPara.Rtc_Org.X;
                        Temp_Data.Center_y = O.Center_y * Matrices.Stretch_Y + O.Center_x * Matrices.Distortion_Y + Matrices.Delta_Y - Program.SystemContainer.SysPara.Rtc_Org.Y;
                        break;

                    case 2:    //指定点加工
                        //起点计算
                        Temp_Data.Start_x = O.Start_x - Program.SystemContainer.SysPara.Rtc_Org.X + Program.SystemContainer.SysPara.ResignationPoint.X;
                        Temp_Data.Start_y = O.Start_y - Program.SystemContainer.SysPara.Rtc_Org.Y + Program.SystemContainer.SysPara.ResignationPoint.Y;
                        //终点计算
                        Temp_Data.End_x = O.End_x - Program.SystemContainer.SysPara.Rtc_Org.X + Program.SystemContainer.SysPara.ResignationPoint.X;
                        Temp_Data.End_y = O.End_y - Program.SystemContainer.SysPara.Rtc_Org.Y + Program.SystemContainer.SysPara.ResignationPoint.Y;
                        //圆心计算
                        if (Temp_Data.Type == 1)
                        {
                            break;
                        }
                        Temp_Data.Center_x = O.Center_x - Program.SystemContainer.SysPara.Rtc_Org.X + Program.SystemContainer.SysPara.ResignationPoint.X;
                        Temp_Data.Center_y = O.Center_y - Program.SystemContainer.SysPara.Rtc_Org.Y + Program.SystemContainer.SysPara.ResignationPoint.Y;
                        break;

                    default:
                        break;
                    }
                    //追加数据至Temp_List
                    Temp_List.Add(new Entity_Data(Temp_Data));
                    //清空Temp_Data
                    Temp_Data.Empty();
                }
                //追加至结果数据
                Result.Add(new List <Entity_Data>(Temp_List));
                //清空数据
                Temp_List.Clear();
            }
            return(Result);
        }
        /// <summary>
        /// 用指定Matrix校准List<List<Entity_Data>>数据,True - 校准,False - 不校准
        /// </summary>
        /// <param name="List_Datas"></param>
        /// <param name="Matrices"></param>
        /// <param name="Flag"></param>
        /// <returns></returns>
        public List <Entity_Data> CalDataByMatrix(List <Entity_Data> List_Datas, Affinity_Matrix Matrices, int Flag)
        {
            //建立变量
            List <Entity_Data> Result    = new List <Entity_Data>();
            Entity_Data        Temp_Data = new Entity_Data();

            //处理数据
            foreach (var O in List_Datas)
            {
                //先清空
                Temp_Data.Empty();
                //后赋值
                Temp_Data = new Entity_Data(O);
                switch (Flag)
                {
                case 0:    //原点起始
                    //起点计算
                    Temp_Data.Start_x = O.Start_x - Program.SystemContainer.SysPara.Rtc_Org.X;
                    Temp_Data.Start_y = O.Start_y - Program.SystemContainer.SysPara.Rtc_Org.Y;
                    //终点计算
                    Temp_Data.End_x = O.End_x - Program.SystemContainer.SysPara.Rtc_Org.X;
                    Temp_Data.End_y = O.End_y - Program.SystemContainer.SysPara.Rtc_Org.Y;
                    //圆心计算
                    Temp_Data.Center_x = O.Center_x - Program.SystemContainer.SysPara.Rtc_Org.X;
                    Temp_Data.Center_y = O.Center_y - Program.SystemContainer.SysPara.Rtc_Org.Y;
                    break;

                case 1:    //Mark矫正
                    //起点计算
                    Temp_Data.Start_x = O.Start_x * Matrices.Stretch_X + O.Start_y * Matrices.Distortion_X + Matrices.Delta_X - Program.SystemContainer.SysPara.Rtc_Org.X;
                    Temp_Data.Start_y = O.Start_y * Matrices.Stretch_Y + O.Start_x * Matrices.Distortion_Y + Matrices.Delta_Y - Program.SystemContainer.SysPara.Rtc_Org.Y;
                    //终点计算
                    Temp_Data.End_x = O.End_x * Matrices.Stretch_X + O.End_y * Matrices.Distortion_X + Matrices.Delta_X - Program.SystemContainer.SysPara.Rtc_Org.X;
                    Temp_Data.End_y = O.End_y * Matrices.Stretch_Y + O.End_x * Matrices.Distortion_Y + Matrices.Delta_Y - Program.SystemContainer.SysPara.Rtc_Org.Y;
                    //圆心计算
                    Temp_Data.Center_x = O.Center_x * Matrices.Stretch_X + O.Center_y * Matrices.Distortion_X + Matrices.Delta_X - Program.SystemContainer.SysPara.Rtc_Org.X;
                    Temp_Data.Center_y = O.Center_y * Matrices.Stretch_Y + O.Center_x * Matrices.Distortion_Y + Matrices.Delta_Y - Program.SystemContainer.SysPara.Rtc_Org.Y;
                    break;

                case 2:    //指定点起始
                    //起点计算
                    Temp_Data.Start_x = O.Start_x - Program.SystemContainer.SysPara.Rtc_Org.X + Program.SystemContainer.SysPara.ResignationPoint.X;
                    Temp_Data.Start_y = O.Start_y - Program.SystemContainer.SysPara.Rtc_Org.Y + Program.SystemContainer.SysPara.ResignationPoint.Y;
                    //终点计算
                    Temp_Data.End_x = O.End_x - Program.SystemContainer.SysPara.Rtc_Org.X + Program.SystemContainer.SysPara.ResignationPoint.X;
                    Temp_Data.End_y = O.End_y - Program.SystemContainer.SysPara.Rtc_Org.Y + Program.SystemContainer.SysPara.ResignationPoint.Y;
                    //圆心计算
                    Temp_Data.Center_x = O.Center_x - Program.SystemContainer.SysPara.Rtc_Org.X + Program.SystemContainer.SysPara.ResignationPoint.X;
                    Temp_Data.Center_y = O.Center_y - Program.SystemContainer.SysPara.Rtc_Org.Y + Program.SystemContainer.SysPara.ResignationPoint.Y;
                    break;

                default:
                    break;
                }
                //追加数据至Temp_List
                Result.Add(new Entity_Data(Temp_Data));
                //清空Temp_Data
                Temp_Data.Empty();
            }
            //返回结果
            return(Result);
        }
Esempio n. 3
0
        /// <summary>
        /// Mark定位 矫正偏转
        /// </summary>
        /// <param name="File_Entity_Datas"></param>
        /// <returns></returns>
        public bool CalibrateFileData(File_Entity_Data File_Entity_Datas)
        {
            Affinity_Matrix Matrix = new Affinity_Matrix();

            //重新梳理Mark信息
            if (MarkType == 1)                              // 1 - 整块板定位(取4角)
            {
                File_Entity_Datas.PlatformMarkInfo.Clear(); //清空平台Mark坐标
                foreach (var o in File_Entity_Datas.DxfMarkInfo)
                {
                    File_Entity_Datas.PlatformMarkInfo.Add(new Vector(o.X + File_Entity_Datas.Mark.X, o.Y + File_Entity_Datas.Mark.Y));
                }
            }
            else if (MarkType == 2)// 2 - 阵列文件定位(小分区取4角);
            {
                for (int i = 0; i < File_Entity_Datas.LayerSectionDatas.Count; i++)
                {
                    for (int j = 0; j < File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas.Count; j++)
                    {
                        File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].PlatformMarkInfo.Clear();//清空平台Mark坐标
                        foreach (var o in File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].DxfMarkInfo)
                        {
                            File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].PlatformMarkInfo.Add(new Vector(o.X + File_Entity_Datas.Mark.X, o.Y + File_Entity_Datas.Mark.Y));
                        }
                    }
                }
            }
            //计算偏转参数
            if (MarkType == 1)// 1 - 整块板定位(取4角)
            {
                //Mark点位数量异常
                if ((File_Entity_Datas.PlatformMarkInfo.Count < 3) || (File_Entity_Datas.DxfMarkInfo.Count < 3))
                {
                    MessageBox.Show("Mark定位点位数据异常!!!");
                    return(false);
                }
                //获取整图偏转参数
                Matrix = Calibration.Calibrate_Mark(File_Entity_Datas.DxfMarkInfo, File_Entity_Datas.PlatformMarkInfo);
                if (Matrix == null)
                {
                    return(false);               //Mark校准失败
                }
                //处理所有分区数据
                for (int i = 0; i < File_Entity_Datas.LayerSectionDatas.Count; i++)
                {
                    for (int j = 0; j < File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas.Count; j++)
                    {
                        File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].ArcLine    = DataResolve.CalDataByMatrix(File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].ArcLine, Matrix, true);
                        File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].Circle     = DataResolve.CalDataByMatrix(File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].Circle, Matrix, true);
                        File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].LWPolyline = DataResolve.CalDataByMatrix(File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].LWPolyline, Matrix, true);
                    }
                }
            }
            else if (MarkType == 2)// 2 - 每个小分区定位
            {
                //处理数据
                for (int i = 0; i < File_Entity_Datas.LayerSectionDatas.Count; i++)
                {
                    for (int j = 0; j < File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas.Count; j++)
                    {
                        //Mark点位数量异常
                        if ((File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].PlatformMarkInfo.Count < 3) || (File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].DxfMarkInfo.Count < 3))
                        {
                            MessageBox.Show("Mark定位点位数据异常!!!");
                            return(false);
                        }
                        //获取小分区偏转参数
                        Matrix = Calibration.Calibrate_Mark(File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].DxfMarkInfo, File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].PlatformMarkInfo);
                        if (Matrix == null)
                        {
                            return(false);               //Mark校准失败
                        }
                        //处理所有分区数据
                        File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].ArcLine    = DataResolve.CalDataByMatrix(File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].ArcLine, Matrix, true);
                        File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].Circle     = DataResolve.CalDataByMatrix(File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].Circle, Matrix, true);
                        File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].LWPolyline = DataResolve.CalDataByMatrix(File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].LWPolyline, Matrix, true);
                    }
                }
            }
            else//无Mark定位校准数据处理
            {
                //处理数据
                for (int i = 0; i < File_Entity_Datas.LayerSectionDatas.Count; i++)
                {
                    for (int j = 0; j < File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas.Count; j++)
                    {
                        File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].ArcLine    = DataResolve.CalDataByMatrix(File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].ArcLine, Matrix, false);
                        File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].Circle     = DataResolve.CalDataByMatrix(File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].Circle, Matrix, false);
                        File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].LWPolyline = DataResolve.CalDataByMatrix(File_Entity_Datas.LayerSectionDatas[i].SectionEntityDatas[j].LWPolyline, Matrix, false);
                    }
                }
            }
            //分区数据计算
            File_Entity_Datas = DataResolve.SeperateFileData(File_Entity_Datas);
            //返回
            return(true);
        }