Add geometry handling.
This commit is contained in:
parent
9c116b1efd
commit
c1389218f2
37 changed files with 294 additions and 278 deletions
56
src/geometry/Grid.h
Normal file
56
src/geometry/Grid.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
#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};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue