18 void resize(
int ixmin,
int iymin,
int ixmax,
int iymax);
22 inline const Cell&
cell(
int x,
int y)
const;
23 inline Cell&
cell(
int x,
int y);
34 inline void setActiveArea(
const PointSet&,
bool patchCoords=
false);
47 m_patchMagnitude=patchMagnitude;
48 m_patchSize=1<<m_patchMagnitude;
58 for (
int x=0; x<this->m_xsize; x++){
60 for (
int y=0; y<this->m_ysize; y++)
61 this->m_cells[x][y]=hg.
m_cells[x][y];
72 for (
int x=0; x<xsize; x++){
74 for (
int y=0; y<ysize; y++){
78 int dx= xmin < 0 ? 0 : xmin;
79 int dy= ymin < 0 ? 0 : ymin;
80 int Dx=xmax<this->m_xsize?xmax:this->m_xsize;
81 int Dy=ymax<this->m_ysize?ymax:this->m_ysize;
82 for (
int x=dx; x<Dx; x++){
83 for (
int y=dy; y<Dy; y++){
84 newcells[x-xmin][y-ymin]=this->m_cells[x][y];
86 delete [] this->m_cells[x];
88 delete [] this->m_cells;
89 this->m_cells=newcells;
98 for (
int i=0; i<this->m_xsize; i++)
99 delete [] this->m_cells[i];
100 delete [] this->m_cells;
104 for (
int i=0; i<this->m_xsize; i++)
107 for (
int x=0; x<this->m_xsize; x++)
108 for (
int y=0; y<this->m_ysize; y++)
109 this->m_cells[x][y]=hg.
m_cells[x][y];
111 m_activeArea.clear();
118 template <
class Cell>
120 m_activeArea.
clear();
121 for (PointSet::const_iterator it= aa.begin(); it!=aa.end(); it++){
127 m_activeArea.insert(p);
131 template <
class Cell>
133 return new Array2D<Cell>(1<<m_patchMagnitude, 1<<m_patchMagnitude);
137 template <
class Cell>
139 if (this->isInside(patchIndexes(x,y)))
147 template <
class Cell>
149 for (PointSet::const_iterator it= m_activeArea.begin(); it!=m_activeArea.end(); it++){
153 patch=createPatch(*it);
161 template <
class Cell>
168 template <
class Cell>
171 return IntPoint(x>>m_patchMagnitude, y>>m_patchMagnitude);
175 template <
class Cell>
178 assert(this->isInside(c.
x, c.
y));
179 if (!this->m_cells[c.
x][c.
y]){
185 return (*ptr).cell(
IntPoint(x-(c.
x<<m_patchMagnitude),y-(c.
y<<m_patchMagnitude)));
188 template <
class Cell>
190 assert(isAllocated(x,y));
193 return (*ptr).cell(
IntPoint(x-(c.
x<<m_patchMagnitude),y-(c.
y<<m_patchMagnitude)));
std::set< point< int >, pointcomparator< int > > PointSet
Cell & cell(const IntPoint &p)
int getPatchMagnitude() const
void resize(int ixmin, int iymin, int ixmax, int iymax)
IntPoint patchIndexes(int x, int y) const
bool isAllocated(const IntPoint &p) const
AccessibilityState cellState(const IntPoint &p) const
HierarchicalArray2D & operator=(const HierarchicalArray2D &hg)
void setActiveArea(const PointSet &, bool patchCoords=false)
virtual Array2D< Cell > * createPatch(const IntPoint &p) const
const Cell & cell(const IntPoint &p) const
virtual ~HierarchicalArray2D()
AccessibilityState cellState(int x, int y) const
IntPoint patchIndexes(const IntPoint &p) const
HierarchicalArray2D(int xsize, int ysize, int patchMagnitude=5)
bool isAllocated(int x, int y) const
const PointSet & getActiveArea() const
const Cell & cell(int x, int y) const