< Summary

Information
Class: MorphoReader.BuildingOutput
Assembly: MorphoReader
File(s): D:\a\Morpho\Morpho\project\Morpho\MorphoReader\BuildingOutput.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 36
Coverable lines: 36
Total lines: 86
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 10
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

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

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.IO;
 4using System.Linq;
 5using Morpho25.Utility;
 6using MorphoGeometry;
 7
 8namespace MorphoReader
 9{
 10    /// <summary>
 11    /// Building output of envimet.
 12    /// </summary>
 13    public class BuildingOutput : BinaryOutput
 14    {
 15        /// <summary>
 16        /// Create a new building output object.
 17        /// </summary>
 18        /// <param name="edx">EDX file.</param>
 19        public BuildingOutput(string edx)
 020            : base(edx)
 021        {
 022            _offset = 4 * _numX * _numY * _numZ;
 023            _buffer = 4 * _numX * _numY * _numZ * 3;
 24
 025            BasePoint = new Vector(0, 0, 0);
 026        }
 27
 28        /// <summary>
 29        /// Create a new building output object.
 30        /// </summary>
 31        /// <param name="edx">EDX file.</param>
 32        /// <param name="basePoint">Base point.</param>
 33        public BuildingOutput(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="facades">Facades to map.</param>
 44        /// <param name="variable">Variable to read.</param>
 45        public override void SetValuesFromBinary(string edt,
 46            List<Voxel> facades, int variable)
 047        {
 048            using (FileStream SourceStream = File.Open(edt, FileMode.Open))
 049            {
 050                BinaryReader binReader = new BinaryReader(SourceStream);
 51
 052                binReader.BaseStream.Position = _buffer * variable + _offset;
 053                byte[] dateArray = binReader.ReadBytes(_buffer);
 54
 55                /*
 56                 *    |----|----|----|
 57                 */
 58
 059                int facadeLength = 12;
 60
 061                for (int f = 0; f < facades.Count; f++)
 062                {
 063                    int count = 0;
 064                    int start = f * facadeLength;
 65
 066                    for (int i = start; i < start + facadeLength; i += 4)
 067                    {
 068                        float number = BitConverter.ToSingle(dateArray, i);
 069                        if (count == 0)
 070                            facades[f].ValueX = number;
 071                        else if (count == 1)
 072                            facades[f].ValueY = number;
 73                        else
 074                            facades[f].ValueZ = number;
 75
 076                        count++;
 77
 078                        if (count == 3)
 079                            count = 0;
 080                    }
 81
 082                }
 083            }
 084        }
 85    }
 86}