private void ReadModel(int index) { //if (System.IO.File.Exists(string.Format("./Model/Model{0}.bmp", index + 1))) //{ // HOperatorSet.ReadImage(out MyModel[index].h_img,string.Format("./Model/Model{0}.bmp", index + 1)); //} //if (System.IO.File.Exists(string.Format("./Model/Model{0}.reg", index + 1))) //{ // HOperatorSet.ReadRegion(out MyModel[index].h_roi, string.Format("./Model/Model{0}.reg", index + 1)); //} //if (System.IO.File.Exists(string.Format("./Model/Model{0}.tup", index + 1))) //{ // HOperatorSet.ReadShapeModel(string.Format("./Model/Model{0}.tup", index + 1),out MyModel[index].hv_ModelID); //} //if (System.IO.File.Exists(string.Format("./Model/Model{0}.dxf", index + 1))) //{ // HTuple hv_DxfStatus = -1; // HOperatorSet.ReadContourXldDxf(out MyModel[index].ho_ShapeModel, string.Format("./Model/Model{0}.dxf", index + 1), new HTuple(), new HTuple(), out hv_DxfStatus); //} //if (MyModel[index].h_img != null && MyModel[index].h_roi != null && MyModel[index].hv_ModelID != -1 && MyModel[index].ho_ShapeModel!=null) //{ // HOperatorSet.AreaCenter(MyModel[index].h_roi, out MyModel[index].hv_Orgin_Angle, out MyModel[index].hv_Orgin_Row, out MyModel[index].hv_Orgin_Column); // MyModel[index].EffectiveFlag = true; //} //序列化 if (System.IO.File.Exists(string.Format("./Model/Model{0}.dat", index + 1))) { FileStream fs = new FileStream(string.Format("./Model/Model{0}.dat", index + 1), FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); SaveModelSerial tempRead = bf.Deserialize(fs) as SaveModelSerial; fs.Close(); MyModel[index].h_img = (HObject)tempRead.h_img; MyModel[index].h_roi = (HObject)tempRead.h_roi; MyModel[index].ho_ShapeModel = (HObject)tempRead.ho_ShapeModel; if (MyModel[index].h_img != null && MyModel[index].h_roi != null && MyModel[index].ho_ShapeModel != null) { HOperatorSet.AreaCenter(MyModel[index].h_roi, out MyModel[index].hv_Orgin_Angle, out MyModel[index].hv_Orgin_Row, out MyModel[index].hv_Orgin_Column); MyModel[index].EffectiveFlag = true; HObject hv_ImageReduced; HOperatorSet.ReduceDomain(MyModel[index].h_img, MyModel[index].h_roi, out hv_ImageReduced); HOperatorSet.CreateShapeModel(hv_ImageReduced, "auto", -0.39, 0.79, "auto", "auto", "use_polarity", "auto", "auto", out MyModel[index].hv_ModelID); } } }
private void WriteModel(int index) { //HOperatorSet.WriteImage(MyModel[index].h_img, "bmp", 0, string.Format("./Model/Model{0}.bmp", index + 1)); //HOperatorSet.WriteRegion(MyModel[index].h_roi, string.Format("./Model/Model{0}.reg", index + 1)); //HOperatorSet.WriteShapeModel(MyModel[index].hv_ModelID, string.Format("./Model/Model{0}.tup", index + 1)); //HOperatorSet.WriteContourXldDxf(MyModel[index].ho_ShapeModel, string.Format("./Model/Model{0}.dxf", index + 1)); //序列化 SaveModelSerial tempSave = new SaveModelSerial(); tempSave.h_img = MyModel[index].h_img; tempSave.h_roi = MyModel[index].h_roi; tempSave.ho_ShapeModel = MyModel[index].ho_ShapeModel; FileStream fs = new FileStream(string.Format("./Model/Model{0}.dat", index + 1), FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(fs, tempSave); fs.Close(); }