Esempio n. 1
0
        public void Calculate_Volume_ReturnsVolume()
        {
            //Arrange
            IVolumeCalculator _calculator = new VolumeCalculator();

            //Act
            decimal volume = _calculator.CalculateVolume(12, 6, 3);

            //Assert
            Assert.IsTrue(volume > 0);
        }
Esempio n. 2
0
        public void Calculate_Volume_ReturnsVolume_Logic_Test()
        {
            //Arrange
            IVolumeCalculator _calculator = new VolumeCalculator();
            decimal           length = 15, width = 20, height = 3;

            //Act
            decimal volume = _calculator.CalculateVolume(length, width, height);

            //Assert
            Assert.IsTrue(volume == (length * width * height), "Volume correctly calculated");
        }
Esempio n. 3
0
        public double CalculateZeroBoundaryVolumeCC()
        {
            //double vol = 0;
            var contours = this.Find2DIsodoseLines(new RT.IsodoseLevel()
            {
                Value = 0
            }).FirstOrDefault().SliceContours;

            //for (int z = 0; z < DimensionZ; z++)
            //{
            //    var zPos = ImageToPatientTx(new Vector3(0, 0, z)).Z;
            //    var slice = FloatMat.WindowLevelColor(GetZPlaneBySlice(z));
            //    foreach(var contour in contours.Where(c=>c.Z == zPos))
            //    {
            //        contour.DrawOnSlice(z, PatientTransformMatrix, slice);
            //    }
            //    Cv2.ImShow("Color", slice);
            //    Cv2.WaitKey();
            //}
            //var voxelLocations = this.GetImageGridPointsPatientCoordinates();
            //for (int i = 0; i < contours.Count; i++)
            //{
            //    var contour = contours[i];
            //    contour.ContourPoints = contour.ContourPoints.Select(c =>
            //    {
            //        var index = IndexHelper.LatticeXYToIndex((int)c.X, (int)c.Y, DimensionX);
            //        return voxelLocations[index];
            //    }).ToList();
            //}
            return(VolumeCalculator.CalculateVolume(contours));

            //for (int z = 0; z < DimensionZ; z++)
            //{
            //    using (var slice = GetZPlaneBySlice(z))
            //    {
            //        var iso = slice.Find2DIsodoseLine(new RT.IsodoseLevel() { Value = 0 });
            //    }
            //}
            //return vol;
            var histogram = this.CalcHistogram(5000);
            var negative  = histogram.Count(float.MinValue, -0.001f);

            histogram.Dispose();
            return(negative * this.ZRes * this.YRes * this.XRes / 1000);
        }
Esempio n. 4
0
        public void Calculate_Volume_ReturnsDecimalVolumes()
        {
            //Arrange
            IVolumeCalculator _calculator = new VolumeCalculator();
            int precision = 0;

            //Act
            decimal volume = _calculator.CalculateVolume(12.00050002m, 6.49007002m, 3.045m);


            //Checks how many decimal places the calculation is accurate too
            while (volume * (decimal)Math.Pow(10, precision) !=
                   Math.Round(volume * (decimal)Math.Pow(10, precision)))
            {
                precision++;
            }

            //Assert
            Assert.IsTrue(precision >= 10, "Accurate to at least {0} decimal places", precision);
        }