43 lines
801 B
C++
43 lines
801 B
C++
#include "Grid.h"
|
|
|
|
Grid::Grid(const Bounds& bounds)
|
|
: mBounds(bounds)
|
|
{
|
|
mValues = std::vector<double>(mNumX*mNumY, 0.0);
|
|
}
|
|
|
|
const Bounds& Grid::getBounds() const
|
|
{
|
|
return mBounds;
|
|
}
|
|
|
|
double Grid::getXSpacing() const
|
|
{
|
|
const auto width = mBounds.mMaxX - mBounds.mMinX;
|
|
return width/double(mNumX);
|
|
}
|
|
|
|
double Grid::getYSpacing() const
|
|
{
|
|
const auto height = mBounds.mMaxY - mBounds.mMinY;
|
|
return height/double(mNumY);
|
|
}
|
|
|
|
const std::vector<double>& Grid::getValues() const
|
|
{
|
|
return mValues;
|
|
}
|
|
|
|
void Grid::resetBounds(const Bounds& bounds)
|
|
{
|
|
mBounds = bounds;
|
|
mValues = std::vector<double>(mNumX*mNumY, 0.0);
|
|
}
|
|
|
|
void Grid::setValues(const std::vector<std::size_t>& indices, double value)
|
|
{
|
|
for (auto index : indices)
|
|
{
|
|
mValues[index] = value;
|
|
}
|
|
}
|