< Summary - ReFlex - Library

Information
Class: ReFlex.Core.Common.Components.PointCloud2
Assembly: ReFlex.Core.Common
File(s): D:\a\reflex\reflex\library\src\Core\Common\Components\PointCloud2.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 30
Coverable lines: 30
Total lines: 135
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 14
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Item(...)0%4260%
set_Item(...)0%620%
get_Item(...)0%620%
set_Item(...)0%620%
get_Size()100%210%
get_SizeX()100%210%
get_SizeY()100%210%
AsArray()100%210%
AsJaggedArray()100%210%
.ctor(...)100%210%
Update(...)0%620%
Initialize(...)100%210%

File(s)

D:\a\reflex\reflex\library\src\Core\Common\Components\PointCloud2.cs

#LineLine coverage
 1using System;
 2using System.Threading.Tasks;
 3using ReFlex.Core.Common.Interfaces;
 4
 5namespace ReFlex.Core.Common.Components
 6{
 7    /// <inheritdoc />
 8    /// <summary>
 9    /// A ordered Quantity of <see cref="Point2"/>
 10    /// </summary>
 11    /// <seealso cref="IDepthImage{T}" />
 12    public class PointCloud2 : IDepthImage<Point2>
 13    {
 14        private Point2[] _values1D;
 15        private Point2[][] _values2D;
 16
 17        /// <inheritdoc />
 18        /// <summary>
 19        /// Gets or sets the <see cref="T:ReFlex.Core.Common.Components.Point2" /> at the specified index.
 20        /// </summary>
 21        /// <value>
 22        /// The <see cref="T:ReFlex.Core.Common.Components.Point2" />.
 23        /// </value>
 24        /// <param name="index">The index.</param>
 25        /// <returns></returns>
 26        public Point2 this[int index]
 27        {
 28            get
 029            {
 030                if (index < 0 || index >= Size)
 031                    return new Point2();
 032                return _values1D[index] ?? (_values1D[index] = new Point2());
 033            }
 034            set => _values1D[index]?.Set(value);
 35        }
 36
 37        /// <inheritdoc />
 38        /// <summary>
 39        /// Gets or sets the <see cref="Point2" /> with the specified x.
 40        /// </summary>
 41        /// <value>
 42        /// The <see cref="Point2" />.
 43        /// </value>
 44        /// <param name="x">The x.</param>
 45        /// <param name="y">The y.</param>
 46        /// <returns></returns>
 47        public Point2 this[int x, int y]
 48        {
 049            get => _values2D[x][y] ?? (_values2D[x][y] = new Point2());
 050            set => _values2D[x][y]?.Set(value);
 51        }
 52
 53        /// <inheritdoc />
 54        /// <summary>
 55        /// Gets the size.
 56        /// </summary>
 57        /// <value>
 58        /// The size.
 59        /// </value>
 060        public int Size { get; private set; }
 61
 62        /// <inheritdoc />
 63        /// <summary>
 64        /// Gets the horizontal size.
 65        /// </summary>
 66        /// <value>
 67        /// The horizontal size.
 68        /// </value>
 069        public int SizeX { get; private set; }
 70
 71        /// <inheritdoc />
 72        /// <summary>
 73        /// Gets the vertical size.
 74        /// </summary>
 75        /// <value>
 76        /// The vertical size.
 77        /// </value>
 078        public int SizeY { get; private set; }
 79
 80        /// <inheritdoc />
 81        /// <summary>
 82        /// Get [this] instance as an array.
 83        /// </summary>
 84        /// <returns>
 85        /// [this] instance as an array
 86        /// </returns>
 087        public Point2[] AsArray() => _values1D;
 88
 89        /// <inheritdoc />
 90        /// <summary>
 91        /// Get [this] instance as an jagged array
 92        /// </summary>
 93        /// <returns>
 94        /// [this] instance as an jagged array
 95        /// </returns>
 096        public Point2[][] AsJaggedArray() => _values2D;
 97
 98        /// <summary>
 99        /// Initializes a new instance of the <see cref="PointCloud2"/> class.
 100        /// </summary>
 101        /// <param name="sizeX">The size x.</param>
 102        /// <param name="sizeY">The size y.</param>
 0103        public PointCloud2(int sizeX, int sizeY) => Initialize(sizeX, sizeY);
 104
 105        /// <summary>
 106        /// Updates [this] instance with the data of the specified source.
 107        /// </summary>
 108        /// <param name="source">The source value.</param>
 109        public void Update(ReadOnlyMemory<Point2> source, float defaultZ)
 0110        {
 0111            Parallel.For(0, source.Length, i =>
 0112                {
 0113                    var val = _values1D[i];
 0114                    _values1D[i].Set(val.IsValid ? source.Span[i] : new Point2(0f,0f));
 0115                }
 0116            );
 0117        }
 118
 119        /// <summary>
 120        /// Initializes the specified size y.
 121        /// </summary>
 122        /// <param name="sizeX">The size x.</param>
 123        /// <param name="sizeY">The size y.</param>
 124        public void Initialize(int sizeX, int sizeY)
 0125        {
 0126            SizeX = sizeX;
 0127            SizeY = sizeY;
 0128            Size = sizeX * sizeY;
 129
 0130            ArrayUtils.InitializeArray(out _values1D, Size);
 0131            ArrayUtils.InitializeArray(out _values2D, SizeX, SizeY);
 0132            ArrayUtils.ReferencingArrays(_values1D, _values2D);
 0133        }
 134    }
 135}