//加载 public void LoadXML(string xmlPath) { /* * await Task.Run(() => * { * while (htWindow.HTWindow.HalconWindow.Handle == (IntPtr)0xffffffffffffffff) * { * Thread.Sleep(500); * } * }); */ try { XElement root = XElement.Load(xmlPath); XElement bondMeasureParameterNode = root.Element("BondMeasureParameter"); XElement bond1AutoRegionsParameterNode = root.Element("Bond1AutoRegionsParameter");//自动 if (bondMeasureParameterNode == null) { return; } XMLHelper.ReadParameters(bondMeasureParameterNode, bondMeasureParameter); XMLHelper.ReadParameters(bond1AutoRegionsParameterNode, bond1AutoRegionsParameter);//自动 (createBondMeasureModel as CreateBondMeasureModel).LoadReferenceData(); XMLHelper.ReadRegion(root, bondModelUserRegions, "BondModelUserRegions", 0, 0, true); //XMLHelper.ReadRegion(root, BondVerifyUserRegions, "BondVerifyUserRegions", bondMeasureParameter.DieImageRowOffset, bondMeasureParameter.DieImageColumnOffset); XMLHelper.ReadRegion(root, PadUserRegions, "PadUserRegions", bondMeasureParameter.DieImageRowOffset, bondMeasureParameter.DieImageColumnOffset, false, false, false, false, true); // XElement BondVerifyModelParaNode = root.Element("BondVerifyModelPara"); XMLHelper.ReadParameters(BondVerifyModelParaNode, bondVerifyModelPara); // 兼容老产品打开参数不保留 2021-0105 by wj if (PadUserRegions.Count() != 0) { //add by wj 2021-01-05 string regionPathName; string regionName = "Pad_Regions"; regionPathName = $"\\{regionName}.reg"; HOperatorSet.ReadRegion(out HObject freeRegion, $"{ModelsBondDirectory}\\{ regionPathName}"); //更新PadUserRegions for (int i = 0; i < PadUserRegions.Count; i++) { //检测区域内通道值设置 if (PadUserRegions.ElementAt(i).ChannelNames.Count() == 0) { PadUserRegions.ElementAt(i).ChannelNames = bondMeasureParameter.ChannelNames; } if (PadUserRegions[i].RegionType == RegionType.Region) { HOperatorSet.SelectObj(freeRegion, out HObject padFreeRegion, i + 1); PadUserRegions[i].CalculateRegion = padFreeRegion; HOperatorSet.MoveRegion(padFreeRegion, out HObject _padFreeRegion, -bondMeasureParameter.DieImageRowOffset, -bondMeasureParameter.DieImageColumnOffset); PadUserRegions[i].DisplayRegion = _padFreeRegion; } } } XMLHelper.ReadRegion(root, Bond2UserRegion, "Bond2UserRegion", 0, 0, true); XMLHelper.ReadRegion(root, Bond2UserRegionDiff, "Bond2UserRegionDiff", 0, 0, true); XMLHelper.ReadRegion(root, RotateLineUserRegion, "RotateLineUserRegion", 0, 0, true); XElement BondMeasureVerifyParameterNode = root.Element("BondMeasureVerifyParameter"); XMLHelper.ReadParameters(BondMeasureVerifyParameterNode, bondMeasureVerifyParameter); (createBondMeasureModel as CreateBondMeasureModel).Initial(); bondWireRegionGroups.Clear(); XElement bondWireGroupNode = root.Element("BondWireGroups"); if (bondWireGroupNode == null) { return; } //自动生成焊点区域部分 foreach (var groupNode in bondWireGroupNode.Elements("BondWireGroup")) { BondWireRegionGroup group = new BondWireRegionGroup(); group.Bond2UserRegion = UserRegion.FromXElement(groupNode.Element("Bond2Region"), false); group.WireUserRegion = UserRegion.FromXElement(groupNode.Element("WireRegion"), false); //XMLHelper.ReadParameters(groupNode, group.Parameter); bondWireRegionGroups.Add(group); group.Index = bondWireRegionGroups.Count; group.Bond2_BallNums = int.Parse(groupNode.Attribute("Bond2Numbers")?.Value); } (createAutoBondMeasureModel as CreateAutoBondMeasureModel).GroupsCount = bondWireRegionGroups.Count; } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); return; } }
public void SaveXML() { try { Directory.GetFiles(ModelsBondDirectory).ToList().ForEach(File.Delete); XElement root = new XElement("Recipe"); XMLHelper.AddIdentifier(root, IdentifyString); XElement bondMeasureParameterNode = new XElement("BondMeasureParameter"); XElement bond1AutoRegionsParameterNode = new XElement("Bond1AutoRegionsParameter");//自动生成 XMLHelper.AddParameters(bondMeasureParameterNode, bondMeasureParameter, IdentifyString); if (bond1AutoRegionsParameter.RotatedImagePath == null) { // 1122 bond1AutoRegionsParameter.RotatedImagePath = ""; } XMLHelper.AddParameters(bond1AutoRegionsParameterNode, bond1AutoRegionsParameter, IdentifyString);//自动生成 XMLHelper.AddRegion(root, bondModelUserRegions, "BondModelUserRegions", true); //XMLHelper.AddRegion(root, BondVerifyUserRegions, "BondVerifyUserRegions");//自动生成焊点检测区域 // XMLHelper.AddRegion(root, PadUserRegions, "PadUserRegions", false, false, false, false, true);//xml中加载生成的焊盘区域 2021-01-05 XElement BondVerifyModelParaNode = new XElement("BondVerifyModelPara"); XMLHelper.AddParameters(BondVerifyModelParaNode, bondVerifyModelPara, IdentifyString); root.Add(BondVerifyModelParaNode); //保存批量设置的模板检测参数 //models下保存焊盘区域 HOperatorSet.WriteRegion(Algorithm.Region.ConcatRegion(PadUserRegions), ModelsBondDirectory + "Pad_Regions.reg"); //add by wj 2021-0105 XMLHelper.AddRegion(root, Bond2UserRegion, "Bond2UserRegion"); XMLHelper.AddRegion(root, Bond2UserRegionDiff, "Bond2UserRegionDiff"); XMLHelper.AddRegion(root, RotateLineUserRegion, "RotateLineUserRegion"); XElement BondMeasureVerifyParameterNode = new XElement("BondMeasureVerifyParameter"); XElement bondWireGroupNode = new XElement("BondWireGroups"); XMLHelper.AddParameters(BondMeasureVerifyParameterNode, bondMeasureVerifyParameter, IdentifyString); root.Add(bondMeasureParameterNode); root.Add(bond1AutoRegionsParameterNode);//自动生成 root.Add(BondMeasureVerifyParameterNode); //自动生成焊点区域部分 foreach (var group in bondWireRegionGroups) { XElement groupNode = new XElement("BondWireGroup"); groupNode.Add(new XAttribute("Index", group.Index.ToString())); groupNode.Add(new XAttribute("Bond2Numbers", group.Bond2_BallNums.ToString())); groupNode.Add(group.Bond2UserRegion?.ToXElement("Bond2Region")); groupNode.Add(group.WireUserRegion?.ToXElement("WireRegion")); bondWireGroupNode.Add(groupNode); } root.Add(bondWireGroupNode); root.Save(XmlPath); //if (bondMeasureParameter.ImageCountChannels == 1) //{ // HOperatorSet.WriteTuple(new HTuple(1), ModelsBondDirectory + "Image_Index.tup"); //} //else if (bondMeasureParameter.ImageCountChannels > 1) //{ // HOperatorSet.WriteTuple(bondMeasureVerifyParameter.ImageChannelIndex + 1, ModelsBondDirectory + "Image_Index.tup"); //} //HOperatorSet.WriteRegion(Algorithm.Region.ConcatRegion(BondVerifyUserRegions), ModelsBondDirectory + "Inspect_Regions.reg"); //HTuple bondOffsetFactor = new HTuple(); //HTuple bondOverSizeFactor = new HTuple(); //HTuple bondUnderSizeFactor = new HTuple(); //HTuple PreJudgeEnable = new HTuple(); //HTuple SegThreshGray = new HTuple(); //HTuple SegRegAreaFactor = new HTuple(); HTuple DistanceThreshold = new HTuple(); foreach (var item in bondModelUserRegions) { // //HOperatorSet.TupleConcat(bondOffsetFactor,item.BondMeasureVerifyParameterSet.BondOffsetFactor, out bondOffsetFactor); // HOperatorSet.TupleConcat(bondOverSizeFactor, item.BondMeasureVerifyParameterSet.BondOverSizeFactor, out bondOverSizeFactor); // HOperatorSet.TupleConcat(bondUnderSizeFactor, item.BondMeasureVerifyParameterSet.BondUnderSizeFactor, out bondUnderSizeFactor); // HOperatorSet.TupleConcat(PreJudgeEnable, item.BondMeasureVerifyParameterSet.PreJudgeEnable, out PreJudgeEnable); // HOperatorSet.TupleConcat(SegThreshGray, item.BondMeasureVerifyParameterSet.SegThreshGray, out SegThreshGray); // HOperatorSet.TupleConcat(SegRegAreaFactor, item.BondMeasureVerifyParameterSet.SegRegAreaFactor, out SegRegAreaFactor); HOperatorSet.TupleConcat(DistanceThreshold, item.BondMeasureModelParameter.DistanceThreshold, out DistanceThreshold); } //HOperatorSet.WriteTuple(bondOffsetFactor, $"{ModelsBondDirectory}BondOffsetFactor.tup"); //HOperatorSet.WriteTuple(bondOverSizeFactor, $"{ModelsBondDirectory}BondOverSizeFactor.tup"); //HOperatorSet.WriteTuple(bondUnderSizeFactor, $"{ModelsBondDirectory}BondUnderSizeFactor.tup"); //HOperatorSet.WriteTuple(PreJudgeEnable, $"{ModelsBondDirectory}PreJudgeEnable.tup"); //HOperatorSet.WriteTuple(SegThreshGray, $"{ModelsBondDirectory}SegThreshGray.tup"); //HOperatorSet.WriteTuple(SegRegAreaFactor, $"{ModelsBondDirectory}SegRegAreaFactor.tup"); HOperatorSet.WriteTuple(DistanceThreshold, $"{ModelsBondDirectory}MetrologyDistanceThreshold.tup"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } try { if (bondMeasureParameter.OnRecipesIndexs.Length > 0) { HOperatorSet.WriteTuple(bondMeasureParameter.OnRecipesIndexs[bondMeasureParameter.OnRecipesIndex], $"{ModelsBondDirectory}OnWhat.tup"); } } catch (Exception)//改 { MessageBox.Show("请选择\"焊点在\"位置!"); } try { if (bondMeasureModelObject.MetrologyHandle != null) { HOperatorSet.WriteMetrologyModel(bondMeasureModelObject.MetrologyHandle, $"{ModelsBondDirectory}" + "MetrologyHandle.mtr"); } else if (File.Exists($"{BondMeasureDirectory}MetrologyHandle.mtr")) { HOperatorSet.ReadMetrologyModel($"{BondMeasureDirectory}MetrologyHandle.mtr", out HTuple metrologyHandle); HOperatorSet.WriteMetrologyModel(metrologyHandle, $"{ModelsBondDirectory}" + "MetrologyHandle.mtr"); } HOperatorSet.WriteTuple(Algorithm.Region.MetrologyType(bondModelUserRegions), $"{ModelsBondDirectory}MetrologyType.tup"); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "模板句柄保存异常!"); } }
public override void SaveXML() { try { // 保留表面检测保存区域 0113 lw HObject ho_Frame_Region = null; if (File.Exists($"{ModelsRecipeDirectory}Frame_Region.reg")) { HOperatorSet.ReadRegion(out ho_Frame_Region, ModelsRecipeDirectory + "Frame_Region.reg"); } HObject ho_PegRack_Region = null; if (File.Exists($"{ModelsRecipeDirectory}PegRack_Region.reg")) { HOperatorSet.ReadRegion(out ho_PegRack_Region, ModelsRecipeDirectory + "PegRack_Region.reg"); } HObject ho_Bridge_Region = null; if (File.Exists($"{ModelsRecipeDirectory}Bridge_Region.reg")) { HOperatorSet.ReadRegion(out ho_Bridge_Region, ModelsRecipeDirectory + "Bridge_Region.reg"); } //Models删除文件 Directory.GetFiles(ModelsRecipeDirectory).ToList().ForEach(File.Delete); if (ho_Frame_Region != null) { HOperatorSet.WriteRegion(ho_Frame_Region, ModelsRecipeDirectory + "Frame_Region.reg"); ho_Frame_Region.Dispose(); } if (ho_PegRack_Region != null) { HOperatorSet.WriteRegion(ho_PegRack_Region, ModelsRecipeDirectory + "PegRack_Region.reg"); ho_PegRack_Region.Dispose(); } if (ho_Bridge_Region != null) { HOperatorSet.WriteRegion(ho_Bridge_Region, ModelsRecipeDirectory + "Bridge_Region.reg"); ho_Bridge_Region.Dispose(); } XElement root = new XElement("Recipe"); XElement goldenModelParameterNode = new XElement("GoldenModelParameter"); XElement frameLocateInspectParameterNode = new XElement("FrameLocateParameter"); XMLHelper.AddIdentifier(root, IdentifyString); XMLHelper.AddRegion(root, dieUserRegions, "Die_Regions"); //多框架区域保存 XElement matchRegionGroupsNode = new XElement("MatchRegionGroup"); foreach (var group in MatchRegionsGroups) { XElement matchRegionNode = new XElement("MatchRegion"); matchRegionNode.Add(new XAttribute("Index", group.Index.ToString())); XMLHelper.AddRegion(matchRegionNode, group.MatchUserRegions, "Region"); matchRegionGroupsNode.Add(matchRegionNode); } //框架区域保存 XMLHelper.AddRegion(root, FrameUserRegions, "Frame_Region"); XMLHelper.AddParameters(goldenModelParameterNode, goldenModelParameter, IdentifyString); XMLHelper.AddParameters(frameLocateInspectParameterNode, frameLocateInspectParameter, IdentifyString); root.Add(goldenModelParameterNode); root.Add(frameLocateInspectParameterNode); root.Add(matchRegionGroupsNode); root.Save(XmlPath); if (goldenModelParameter.ImageCountChannels == 1) { HOperatorSet.WriteTuple(new HTuple(1), ModelsRecipeDirectory + "Image_Index.tup"); } else if (goldenModelParameter.ImageCountChannels > 1) { //1121 HOperatorSet.WriteTuple(new HTuple(goldenModelParameter.ImageChannelIndex + 1), ModelsRecipeDirectory + "Image_Index.tup"); } if (goldenModelParameter.ModelType == 0) { HOperatorSet.WriteTuple(new HTuple("ncc"), $"{ModelsRecipeDirectory}Model_Type.tup"); } else if (goldenModelParameter.ModelType == 1) { HOperatorSet.WriteTuple(new HTuple("shape"), $"{ModelsRecipeDirectory}Model_Type.tup"); } } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); } //try //{ // if (File.Exists($"{RecipeDirectory}PosModel.dat")|| goldenModelObject.PosModelID != null) // { // if (goldenModelObject.PosModelID != null) // { // Algorithm.File.SaveModel(ModelsRecipeDirectory + "PosModel.dat", goldenModelParameter.ModelType, goldenModelObject.PosModelID); // } // else if (File.Exists($"{RecipeDirectory}PosModel.dat")) // { // HTuple PosModelId = Algorithm.File.ReadModel($"{RecipeDirectory}PosModel.dat", goldenModelParameter.ModelType); // Algorithm.File.SaveModel(ModelsRecipeDirectory + "PosModel.dat", goldenModelParameter.ModelType, PosModelId); // } // } // else // { // MessageBox.Show("请创建定位模板!"); // } //} //catch (System.Exception ex) //{ // MessageBox.Show(ex.ToString(),"保存模板错误!"); //} try { HOperatorSet.WriteTuple(frameLocateInspectParameter.AngleStart, FilePath.EnsureDirectoryExisted($"{ModelsRecipeDirectory}") + "AngleStart.tup"); HOperatorSet.WriteTuple(frameLocateInspectParameter.AngleExt, FilePath.EnsureDirectoryExisted($"{ModelsRecipeDirectory}") + "AngleExt.tup"); HOperatorSet.WriteTuple(frameLocateInspectParameter.MinMatchScore, FilePath.EnsureDirectoryExisted($"{ModelsRecipeDirectory}") + "MinMatchScore.tup"); HOperatorSet.WriteTuple(frameLocateInspectParameter.MatchNum, FilePath.EnsureDirectoryExisted($"{ModelsRecipeDirectory}") + "MatchNum.tup"); //HOperatorSet.WriteRegion(Algorithm.Region.Union1Region(matchUserRegions), ModelsRecipeDirectory + "Match_Region.reg"); HOperatorSet.GenEmptyObj(out HObject matchRegions); foreach (var item in MatchRegionsGroups) { // lw - 0115 每组区域应Union HOperatorSet.ConcatObj(Algorithm.Region.Union1Region(item.MatchUserRegions.Where(r => r.IsEnable)), matchRegions, out matchRegions); } HOperatorSet.WriteRegion(matchRegions, ModelsRecipeDirectory + "Match_Region.reg"); matchRegions.Dispose(); if (FrameUserRegions.Count > 0) { HOperatorSet.WriteRegion(FrameUserRegions[0].CalculateRegion, ModelsRecipeDirectory + "FrameRegion.reg"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } //保存模板 string[] ModelPathArr = goldenModelParameter.PosModelIdPath.Split(','); if (goldenModelObject.PosModelID == null && File.Exists(ModelPathArr[0])) { goldenModelObject.PosModelID = Algorithm.File.ReadModel(ModelPathArr, goldenModelParameter.ModelType); } else if (goldenModelObject.PosModelID == null) { MessageBox.Show("请先创建定位模板!"); return; } if (goldenModelObject.PosModelID.Length == 1) { string ModelsIDPath = $"{ModelsRecipeDirectory}PosModel.dat"; Algorithm.File.SaveModel(ModelsIDPath, goldenModelParameter.ModelType, goldenModelObject.PosModelID); } else if (goldenModelObject.PosModelID.Length > 1) { String[] ModelIdPathArry = new string[goldenModelObject.PosModelID.Length]; for (int i = 0; i < goldenModelParameter.PosModelIdPath.Split(',').Length; i++) { ModelIdPathArry[i] = $"{ModelsRecipeDirectory}PosModel_" + i + ".dat"; } Algorithm.File.SaveModel(ModelIdPathArry, goldenModelParameter.ModelType, goldenModelObject.PosModelID);// } else { MessageBox.Show("请先创建模板!"); } //try //{ // if (($"{RecipeDirectory}PosModel.dat").Contains("PosModel")) // { // if (goldenModelParameter.ModelIdPath.Split(',').Length == 1 && goldenModelParameter.ModelIdPath != "") // { // if (File.Exists($"{RecipeDirectory}PosModel.dat") || goldenModelObject.PosModelID != null) // { // if (goldenModelObject.PosModelID != null) // { // Algorithm.File.SaveModel(ModelsRecipeDirectory + "PosModel.dat", goldenModelParameter.ModelType, goldenModelObject.PosModelID); // } // else if (File.Exists($"{RecipeDirectory}PosModel.dat")) // { // HTuple PosModelId = Algorithm.File.ReadModel($"{RecipeDirectory}PosModel.dat", goldenModelParameter.ModelType); // Algorithm.File.SaveModel(ModelsRecipeDirectory + "PosModel.dat", goldenModelParameter.ModelType, PosModelId); // } // } // else // { // MessageBox.Show("请创建定位模板!"); // } // } // else // { // if (goldenModelObject.PosModelID != null) // { // String[] ModelIdPathArry = new string[goldenModelObject.PosModelID.TupleLength()]; // for (int i = 0; i < goldenModelObject.PosModelID.TupleLength(); i++) // { // ModelIdPathArry[i] = $"{ModelsRecipeDirectory}PosModel_" + i + ".dat"; // } // goldenModelParameter.ModelIdPath = String.Join(",", ModelIdPathArry); // Algorithm.File.SaveModel(ModelIdPathArry, goldenModelParameter.ModelType, goldenModelObject.PosModelID); // } // else if (File.Exists($"{RecipeDirectory}PosModel.dat")) // { // HTuple ModelId = Algorithm.File.ReadModel($"{RecipeDirectory}PosModel.dat".Split(','), goldenModelParameter.ModelType); // String[] ModelIdPathArry = new string[ModelId.TupleLength()]; // for (int i = 0; i < ModelId.TupleLength(); i++) // { // ModelIdPathArry[i] = $"{ModelsRecipeDirectory}PosModel_" + i + ".dat"; // } // Algorithm.File.SaveModel(ModelIdPathArry, goldenModelParameter.ModelType, ModelId); // } // } // } //} //catch (System.Exception ex) //{ // MessageBox.Show(ex.ToString()); //} }
//加载 public async void LoadXML(string xmlPath) //async { await Task.Run(() => { while (htWindow.HTWindow.HalconWindow.Handle == (IntPtr)0xffffffffffffffff) { Thread.Sleep(500); } }); try { XElement root = XElement.Load(xmlPath); XMLHelper.ReadParameters(root, iniParameters); DieUserRegions.Clear(); XMLHelper.ReadRegion(root, DieUserRegions, "Die_Regions", iniParameters.DieImageRowOffset, iniParameters.DieImageColumnOffset); if (iniParameters.ImageIndex == 0) { iniParameters.ImageIndex = 1; } if (!File.Exists($"{IniDirectory}ReferenceImage.tiff")) { MessageBox.Show("全局数据没有参考图像!"); return; } if (iniParameters.UserRegionForCutOutIndex == -1) { MessageBox.Show("全局数据没有参考Die!"); return; } if (!File.Exists(IniDirectory + "TrainningImagesDirectory.tup")) { MessageBox.Show("提示:训练图集文件不存在!"); } HOperatorSet.ReadTuple(IniDirectory + "TrainningImagesDirectory.tup", out HTuple TrainningImagesDirectoryTemp); //GoldenModelParameter.TrainningImagesDirectory = TrainningImagesDirectoryTemp; if (!Directory.Exists(TrainningImagesDirectoryTemp)) { MessageBox.Show("提示:训练图集不存在!"); } (createReference as CreateReference).LoadImage(); (createReference as CreateReference).SelectedUserRegion = DieUserRegions.Where(u => u.Index == (int)iniParameters.UserRegionForCutOutIndex).FirstOrDefault(); (createReference as CreateReference).DieCutOut(false); (createReference as CreateReference).Initial(); //1120 iniParameters.ChannelNames.Clear(); for (int i = 0; i < iniParameters.ImageCountChannels; i++) { ChannelName tmp_name = new ChannelName(); tmp_name.Name = (i + 1).ToString(); iniParameters.ChannelNames.Add(tmp_name); } (createReference as CreateReference).SwitchImageChannelIndex = iniParameters.ImageIndex - 1; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
//加载 public void LoadXML(string xmlPath)//async { //await Task.Run(() => //{ // while (htWindow.HTWindow.HalconWindow.Handle == (IntPtr)0xffffffffffffffff) // { // Thread.Sleep(500); // } //}); try { XElement root = XElement.Load(xmlPath); XElement cutRegionParameterNode = root.Element("CutRegionParameter"); if (cutRegionParameterNode == null) { return; } XMLHelper.ReadParameters(cutRegionParameterNode, CutRegionParameter); (createCutRegionModel as CreateCutRegionModel).LoadReferenceData(); //(createCutRegionModel as CreateCutRegionModel).LoadInspectCutRegions(); // add by wj //加载区域内检测参数 XElement AroundBondRegNode = root.Element("CutRegions"); if (AroundBondRegNode == null) { return; } XMLHelper.ReadRegion(AroundBondRegNode, OriRegionUserRegions, "CutReg", CutRegionParameter.DieImageRowOffset, CutRegionParameter.DieImageColumnOffset, false, false, false, false); foreach (var item in OriRegionUserRegions) { // 兼容老产品打开参数不保留 1223 lw if (item == null) { OriRegionUserRegions.Clear(); break; } if (item.RegionType == RegionType.Region) { HOperatorSet.ReadRegion(out HObject freeRegion, $"{ProductDirctory}\\{ item.RegionPath}"); item.DisplayRegion = freeRegion; item.CalculateRegion = freeRegion; } } (createCutRegionModel as CreateCutRegionModel).LoadDilationParameters(); /* * HOperatorSet.ReadTuple($"{ModelsDirectory}CutRegionParameters.tup",out cutRegionParameters); * HOperatorSet.ReadTuple($"{ModelsDirectory}CutRegionRecipeNames.tup", out CutRegionRecipeNames); * HOperatorSet.ReadRegion(out HObject CutDisplayRegions, $"{ModelsDirectory}CutDisplayRegions.reg"); * HOperatorSet.ReadRegion(out HObject CutRegions, $"{ModelsDirectory}CutRegions.reg"); * HOperatorSet.MoveRegion(CutDisplayRegions, out HObject DieCutDisplayRegion, -CutRegionParameter.DieImageRowOffset, -CutRegionParameter.DieImageColumnOffset);// * HOperatorSet.MoveRegion(CutRegions, out HObject DieCutRegion, -CutRegionParameter.DieImageRowOffset, -CutRegionParameter.DieImageColumnOffset);//calculation * CutDisplayRegions.CountObj(); * * for (int i = 1; i < CutRegionRecipeNames.TupleLength()+1; i++) * { * UserRegion userRegion = new UserRegion * { * DisplayRegion = DieCutDisplayRegion.SelectObj(i), * CalculateRegion = DieCutRegion.SelectObj(i), * RegionParameters = new double[1] { cutRegionParameters.TupleSelect(i-1)}, * RecipeNames = CutRegionRecipeNames.TupleSelect(i-1), * RegionType=RegionType.Dilation, * }; * if (userRegion == null) return; * userRegion.Index = CutRegionUserRegions.Count + 1; * CutRegionUserRegions.Add(userRegion); * } */ (createCutRegionModel as CreateCutRegionModel).Initial(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }