示例#1
0
        internal void TestDicomDecimalStringGetArray <T>()
        {
            var expected = new[] { 35.0m, 45.0m, 55.0m };
            var element  = new DicomDecimalString(DicomTag.MaterialThickness, expected);
            var actual   = element.Get <T[]>();

            Assert.Equal(expected.Select(i => (T)Convert.ChangeType(i, Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T), CultureInfo.InvariantCulture)), actual);
        }
示例#2
0
        internal void TestDicomDecimalStringGetItem <T>()
        {
            var expected = 45.0m;
            var element  = new DicomDecimalString(DicomTag.MaterialThickness, 35.0m, expected, 55.0m);
            var actual   = element.Get <T>(1);

            Assert.Equal((T)Convert.ChangeType(expected, Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T), CultureInfo.InvariantCulture), actual);
        }
示例#3
0
        public void DicomDecimalString_HasData_GetNullableReturnsDefinedNullable()
        {
            const int expected = -30;
            var       element  = new DicomDecimalString(DicomTag.ChannelOffset, expected);
            var       actual   = element.Get <int?>().Value;

            Assert.Equal(expected, actual);
        }
示例#4
0
        public void DicomDecimalString_WorksInCommaCulture()
        {
            var currentCulture = Thread.CurrentThread.CurrentCulture;

            try
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("de-DE");

                var decimals = new[] { 0.1m, 1e10m, -1m, 0, 3.141592656m };
                var element  = new DicomDecimalString(DicomTag.CumulativeMetersetWeight, decimals);
                Assert.Equal(decimals, element.Get <decimal[]>());
                Assert.Equal(decimals.Select(x => (double)x), element.Get <double[]>());
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = currentCulture;
            }
        }
示例#5
0
 private static void GetImageOrientationPatient(ImageData image, DicomDecimalString dicomOrientationPatient)
 {
     if (dicomOrientationPatient != null)
     {
         var xAxis = new Vector3
         {
             X = dicomOrientationPatient.Get <double>(0),
             Y = dicomOrientationPatient.Get <double>(1),
             Z = dicomOrientationPatient.Get <double>(2)
         };
         var yAxis = new Vector3
         {
             X = dicomOrientationPatient.Get <double>(3),
             Y = dicomOrientationPatient.Get <double>(4),
             Z = dicomOrientationPatient.Get <double>(5)
         };
         image.XAxisPatient = xAxis.Normalized();
         image.YAxisPatient = yAxis.Normalized();
     }
 }