/// <summary>
        /// Initializes a new instance of the <see cref="Composite3By3By3Array3D{TValue}"/> class.
        /// </summary>
        /// <param name="arrays">The indexable arrays to make the composite indexable out of.</param>
        public Composite3By3By3Array3D(IBoundedIndexable <Index3D, T>[,,] arrays)
        {
            Contracts.Requires.That(arrays != null);
            Contracts.Requires.That(arrays.GetLength(0) == 3);
            Contracts.Requires.That(arrays.GetLength(1) == 3);
            Contracts.Requires.That(arrays.GetLength(2) == 3);
            Contracts.Requires.That(CompositeArray.AreAllSameDimensionsAndZeroBounded(arrays));

            this.arrays = arrays;
            IBoundedIndexable <Index3D, T> array = this.arrays[1, 1, 1];

            this.singleArrayLengthX = array.GetLength(Axis3D.X);
            this.singleArrayLengthY = array.GetLength(Axis3D.Y);
            this.singleArrayLengthZ = array.GetLength(Axis3D.Z);
            Index3D indexingOffset = new Index3D(this.singleArrayLengthX, this.singleArrayLengthY, this.singleArrayLengthZ);

            this.dimensions  = array.Dimensions + (indexingOffset * 2);
            this.lowerBounds = array.LowerBounds - indexingOffset;
            this.upperBounds = array.UpperBounds + indexingOffset;

            this.lowerLimitX = array.LowerBounds.X;
            this.lowerLimitY = array.LowerBounds.Y;
            this.lowerLimitZ = array.LowerBounds.Z;
            this.upperLimitX = array.UpperBounds.X;
            this.upperLimitY = array.UpperBounds.Y;
            this.upperLimitZ = array.UpperBounds.Z;
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReadOnlyCompositeArray3D{TValue}" /> class.
        /// </summary>
        /// <param name="arrays">The indexable arrays to make the composite indexable out of.</param>
        /// <param name="originOffset">The origin offset for indexing into the composite.</param>
        public ReadOnlyCompositeArray3D(IBoundedReadOnlyIndexable <Index3D, T>[,,] arrays, Index3D originOffset)
        {
            Contracts.Requires.That(arrays != null);
            Contracts.Requires.That(CompositeArray.AreAllSameDimensionsAndZeroBounded(arrays));

            this.arrays = arrays;
            IBoundedReadOnlyIndexable <Index3D, T> singleArray = this.arrays[0, 0, 0];

            this.singleArrayLengthX = singleArray.GetLength(Axis3D.X);
            this.singleArrayLengthY = singleArray.GetLength(Axis3D.Y);
            this.singleArrayLengthZ = singleArray.GetLength(Axis3D.Z);
            this.originOffset       = originOffset;

            this.dimensions  = singleArray.Dimensions * this.arrays.GetDimensions();
            this.lowerBounds = -this.originOffset;
            this.upperBounds = this.lowerBounds + this.dimensions;
        }