#pragma once

#include "Rectangle.h"
#include <vector>

class Grid
{
public:

    Grid(const Rectangle& bounds)
        : mBounds(bounds)
    {
        mValues = std::vector<double>(mNumX*mNumY, 0.0);
    }

    Rectangle GetBounds() const
    {
        return mBounds;
    }

    double GetXSpacing() const
    {
        return mBounds.GetWidth()/double(mNumX);
    }

    double GetYSpacing() const
    {
        return mBounds.GetHeight()/double(mNumY);
    }

    std::vector<double> GetValues() const
    {
        return mValues;
    }

    void ResetBounds(const Rectangle& bounds)
    {
        mBounds = bounds;
        mValues = std::vector<double>(mNumX*mNumY, 0.0);
    }

    void SetValues(const std::vector<std::size_t>& indices, double value)
    {
        for (auto index : indices)
        {
            mValues[index] = value;
        }
    }


private:
    Rectangle mBounds;
    std::vector<double> mValues;
    unsigned mNumX{5};
    unsigned mNumY{5};
};
