#pragma once

#include "TypedGrid.h"

template<typename T>
class Grid : public TypedGrid<T>
{
public:
    Grid(const Bounds& bounds, std::size_t numPointsX, std::size_t numPointsY, std::size_t numPointsZ = 1)
        : TypedGrid<T>(bounds, numPointsX, numPointsY, numPointsZ)
    {
        this->mData->initializeTo(numPointsX * numPointsY * numPointsZ, T());
    }

    T getItem(std::size_t idx, std::size_t jdx, std::size_t kdx) const override
    {
        return this->mData->getItem(getOffset(idx, jdx, kdx));
    }

    std::size_t getOffset(std::size_t idx, std::size_t jdx, std::size_t kdx) const
    {
        return idx * this->mNumZ + jdx * this->mNumX * this->mNumZ + kdx;
    }

    void setData(const std::vector<T>& data)
    {
        this->mData->setData(data);
    }

    void setItem(std::size_t idx, std::size_t jdx, std::size_t kdx, const T& value) override
    {
        this->mData->setItem(getOffset(idx, jdx, kdx), value);
    }

    std::size_t getDataSize() const override
    {
        return this->mData->getLength();
    }
};
