Esempio n. 1
0
        /// <summary>
        /// 將檔案從V1版本轉成V2版本
        /// </summary>
        /// <param name="saveobj"></param>
        /// <returns></returns>
        public static SaveResultV2 Convert(SaveResultV1 saveobj, DcmInfo info)
        {
            SaveResultV2 Result = new SaveResultV2(saveobj.FileName);

            Result.SaveTime  = DateTime.Now;
            Result.KeyPoints = new List <Nullable <Point> >();
            #region 處理塑膠管
            Result.KeyPoints.AddRange(SaveResultV1.PointConvert(info.Width, info.Height, saveobj.tube));
            //foreach (Point p in saveobj.tube)
            //{
            //    Result.KeyPoints.Add(p);
            //}
            #endregion
            #region 處理氣管分岔
            foreach (List <Point> LP in saveobj.bifurcation)
            {
                Result.KeyPoints.AddRange(SaveResultV1.PointConvert(info.Width, info.Height, LP));
                //foreach (Point p in LP)
                //{
                //    Result.KeyPoints.Add(p);
                //}
            }
            #endregion
            //巡迴KetPoint後如果點數沒有等於4+3+3+3=13,就代表點數不完整,則遺棄所有的點
            if (Result.KeyPoints.Count != 13)
            {
                Result.KeyPoints = new List <Nullable <Point> >();
            }
            return(Result);
        }
Esempio n. 2
0
 public static SaveResultV2 ReadFromFile(string FilePath, DcmInfo info)
 {
     if (Func.CheckFileExist(FilePath))
     {
         string JsonStr = Func.ReadText(FilePath);
         return(ReadFromString(JsonStr, info));
     }
     else
     {
         throw new IOException("File Not Find");
     }
 }
Esempio n. 3
0
        public static SaveResultV2 ReadFromString(string JsonStr, DcmInfo info)
        {
            SaveResultV2 item;

            if (SaveResultV2.IsVersion2(JsonStr))
            {
                item = JsonConvert.DeserializeObject <SaveResultV2>(JsonStr);
            }
            else
            {
                SaveResultV1 item_old = SaveResultV1.ConvertSaveFile(JsonStr);
                item = SaveResultV2.Convert(item_old, info);
            }
            return(item);
        }
Esempio n. 4
0
        /// <summary>
        /// 抓出dcm的細節資料
        /// </summary>
        /// <param name="DcmPath"></param>
        public static DcmInfo DcmDetailData(string DcmPath)
        {
            DicomImage dcmimage = new DicomImage(DcmPath);
            string     Spacing  = "";

            try
            {
                Spacing = dcmimage.Dataset.GetValue <string>(DicomTag.PixelSpacing, 0);
            }
            catch
            {
                Spacing = "0.139";
            }
            DcmInfo info = new DcmInfo()
            {
                Height = dcmimage.Height,
                Width  = dcmimage.Width,
                scale  = Convert.ToDouble(Spacing)
            };

            return(info);
        }