< Summary

Information
Class: MorphoReader.GridOutput
Assembly: MorphoReader
File(s): D:\a\Morpho\Morpho\project\Morpho\MorphoReader\GridOutput.cs
Line coverage
83%
Covered lines: 20
Uncovered lines: 4
Coverable lines: 24
Total lines: 70
Line coverage: 83.3%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%
.ctor(...)100%10%
SetValuesFromBinary(...)100%2100%

File(s)

D:\a\Morpho\Morpho\project\Morpho\MorphoReader\GridOutput.cs

#LineLine coverage
 1using MorphoGeometry;
 2using System;
 3using System.Collections.Generic;
 4using System.IO;
 5using System.Linq;
 6using System.Text;
 7using System.Threading.Tasks;
 8
 9namespace MorphoReader
 10{
 11    /// <summary>
 12    /// Grid output of envimet.
 13    /// </summary>
 14    public class GridOutput : BinaryOutput
 15    {
 16        /// <summary>
 17        /// Create a new grid output object.
 18        /// </summary>
 19        /// <param name="edx">EDX file.</param>
 20        public GridOutput(string edx)
 121            : base(edx)
 122        {
 123            _offset = _buffer = 4 * _numX * _numY * _numZ;
 24
 125            BasePoint = new Vector(0, 0, 0);
 126        }
 27
 28        /// <summary>
 29        /// Create a new grid output object.
 30        /// </summary>
 31        /// <param name="edx">EDX file.</param>
 32        /// <param name="basePoint">Base point.</param>
 33        public GridOutput(string edx, Vector basePoint)
 034            : this(edx)
 035        {
 036            BasePoint = basePoint;
 037        }
 38
 39        /// <summary>
 40        /// Set values from a binary file.
 41        /// </summary>
 42        /// <param name="edt">EDT file.</param>
 43        /// <param name="voxels">Voxels to map.</param>
 44        /// <param name="variable">Variable to read.</param>
 45        public override void SetValuesFromBinary(string edt,
 46            List<Voxel> voxels, int variable)
 147        {
 148            using (FileStream SourceStream = File.Open(edt, FileMode.Open))
 149            {
 150                BinaryReader binReader = new BinaryReader(SourceStream);
 51
 152                binReader.BaseStream.Position = _buffer * variable;
 153                byte[] dateArray = binReader.ReadBytes(_buffer);
 54
 55                /*
 56                 *    |----|
 57                 */
 58
 159                int count = 0;
 60                float number;
 17829461                for (int i = 0; i < dateArray.Length; i += 4)
 8914662                {
 8914663                    number = BitConverter.ToSingle(dateArray, i);
 8914664                    voxels[count].ValueZ = number;
 8914665                    count++;
 8914666                }
 167            }
 168        }
 69    }
 70}