123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- using AI.Common;
- using AutoEFCalculationLib;
- using Vinno.AI.AutoEFDiagnosisSDK.Enums;
- using Vinno.AI.AutoEFDiagnosisSDK.Models;
- using Vinno.AI.CommonSDK.Models;
- using Vinno.AI.Service.Common.Tools;
- namespace Vinno.AI.AutoEFDiagnosisService.Tools
- {
- internal static class AIConvertHelper
- {
- internal static AILVVolumeCalcResult ConvertLVVolumeCalcResultToAILVVolumeCalcResult(LVVolumeCalcResult lvVolumeCalcResult)
- {
- AIPoint2D[] contours;
- if (lvVolumeCalcResult.Contours == null)
- {
- contours = null;
- }
- else
- {
- var contoursLength = lvVolumeCalcResult.Contours.Length;
- contours = new AIPoint2D[lvVolumeCalcResult.Contours.Length];
- for (int i = 0; i < contoursLength; i++)
- {
- contours[i] = AICommonServiceConvertHelper.ConvertPoint2DToAIPoint2D(lvVolumeCalcResult.Contours[i]);
- }
- }
- var measureMarks = ConvertLVVolumeMeasureMarksToAILVVolumeMeasureMarks(lvVolumeCalcResult.MeasureMarks);
- var aiImageSize = ConvertImgSizeToAIImgSize(lvVolumeCalcResult.OrImgSize);
- return new AILVVolumeCalcResult(contours, lvVolumeCalcResult.Volume, lvVolumeCalcResult.Score, measureMarks, aiImageSize);
- }
- private static AIImgSize ConvertImgSizeToAIImgSize(ImgSize orImgSize)
- {
- return new AIImgSize(orImgSize.ImgWidth, orImgSize.ImgHeight);
- }
- private static AILVVolumeMeasureMarks ConvertLVVolumeMeasureMarksToAILVVolumeMeasureMarks(LVVolumeMeasureMarks measureMarks)
- {
- var apexPoint = AICommonServiceConvertHelper.ConvertPoint2DToAIPoint2D(measureMarks.ApexPoint);
- AIPoint2D[] endPoints;
- if (measureMarks.EndPoints == null)
- {
- endPoints = null;
- }
- else
- {
- var endPointsLength = measureMarks.EndPoints.Length;
- endPoints = new AIPoint2D[endPointsLength];
- for (int i = 0; i < endPointsLength; i++)
- {
- endPoints[i] = AICommonServiceConvertHelper.ConvertPoint2DToAIPoint2D(measureMarks.EndPoints[i]);
- }
- }
- AIPoint2D[] slicePoints;
- if (measureMarks.SlicePoints == null)
- {
- slicePoints = null;
- }
- else
- {
- var slicePointsLength = measureMarks.SlicePoints.Length;
- slicePoints = new AIPoint2D[slicePointsLength];
- for (int i = 0; i < slicePointsLength; i++)
- {
- slicePoints[i] = AICommonServiceConvertHelper.ConvertPoint2DToAIPoint2D(measureMarks.SlicePoints[i]);
- }
- }
- AIPoint2D[] controlPoints;
- if (measureMarks.ControlPoints == null)
- {
- controlPoints = null;
- }
- else
- {
- var controlPointsLength = measureMarks.ControlPoints.Length;
- controlPoints = new AIPoint2D[controlPointsLength];
- for (int i = 0; i < controlPointsLength; i++)
- {
- controlPoints[i] = AICommonServiceConvertHelper.ConvertPoint2DToAIPoint2D(measureMarks.ControlPoints[i]);
- }
- }
- return new AILVVolumeMeasureMarks(apexPoint, endPoints, slicePoints, controlPoints);
- }
- internal static AIEDESDetectResult ConvertEDESDetectResultToAIEDESDetectResult(EDESDetectResult edESDetectResult)
- {
- var aiLVVolume = ConvertLVVolumeCalcResultToAILVVolumeCalcResult(edESDetectResult.LVVolume);
- return new AIEDESDetectResult((AIEnumFrameType)edESDetectResult.FrameType, aiLVVolume);
- }
- internal static LVVolumeCalcResult ConvertAILVVolumeCalcResultToLVVolumeCalcResult(AILVVolumeCalcResult aiLVVolumeCalcResult)
- {
- if (aiLVVolumeCalcResult == null)
- {
- return default(LVVolumeCalcResult);
- }
- Point2D[] contours;
- if (aiLVVolumeCalcResult.Contours == null)
- {
- contours = null;
- }
- else
- {
- var contoursLength = aiLVVolumeCalcResult.Contours.Length;
- contours = new Point2D[aiLVVolumeCalcResult.Contours.Length];
- for (int i = 0; i < contoursLength; i++)
- {
- contours[i] = AICommonServiceConvertHelper.ConvertAIPoint2DToPoint2D(aiLVVolumeCalcResult.Contours[i]);
- }
- }
- var measureMarks = ConvertAILVVolumeMeasureMarksToLVVolumeMeasureMarks(aiLVVolumeCalcResult.MeasureMarks);
- var imageSize = ConvertAIImgSizeToImgSize(aiLVVolumeCalcResult.OrImgSize);
- return new LVVolumeCalcResult(contours, aiLVVolumeCalcResult.Volume, aiLVVolumeCalcResult.Score, measureMarks, imageSize);
- }
- private static LVVolumeMeasureMarks ConvertAILVVolumeMeasureMarksToLVVolumeMeasureMarks(AILVVolumeMeasureMarks measureMarks)
- {
- if (measureMarks == null)
- {
- return default(LVVolumeMeasureMarks);
- }
- var apexPoint = AICommonServiceConvertHelper.ConvertAIPoint2DToPoint2D(measureMarks.ApexPoint);
- Point2D[] endPoints;
- if (measureMarks.EndPoints == null)
- {
- endPoints = null;
- }
- else
- {
- var endPointsLength = measureMarks.EndPoints.Length;
- endPoints = new Point2D[endPointsLength];
- for (int i = 0; i < endPointsLength; i++)
- {
- endPoints[i] = AICommonServiceConvertHelper.ConvertAIPoint2DToPoint2D(measureMarks.EndPoints[i]);
- }
- }
- Point2D[] slicePoints;
- if (measureMarks.SlicePoints == null)
- {
- slicePoints = null;
- }
- else
- {
- var slicePointsLength = measureMarks.SlicePoints.Length;
- slicePoints = new Point2D[slicePointsLength];
- for (int i = 0; i < slicePointsLength; i++)
- {
- slicePoints[i] = AICommonServiceConvertHelper.ConvertAIPoint2DToPoint2D(measureMarks.SlicePoints[i]);
- }
- }
- Point2D[] controlPoints;
- if (measureMarks.ControlPoints == null)
- {
- controlPoints = null;
- }
- else
- {
- var controlPointsLength = measureMarks.ControlPoints.Length;
- controlPoints = new Point2D[controlPointsLength];
- for (int i = 0; i < controlPointsLength; i++)
- {
- controlPoints[i] = AICommonServiceConvertHelper.ConvertAIPoint2DToPoint2D(measureMarks.ControlPoints[i]);
- }
- }
- return new LVVolumeMeasureMarks(apexPoint, endPoints, slicePoints, controlPoints);
- }
- private static ImgSize ConvertAIImgSizeToImgSize(AIImgSize orImgSize)
- {
- if (orImgSize == null)
- {
- return default(ImgSize);
- }
- return new ImgSize(orImgSize.ImgWidth, orImgSize.ImgHeight);
- }
- }
- }
|