Multi-robot Playground
Common.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, Alysson Ribeiro da Silva
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. All advertising materials mentioning features or use of this software must
16  * display the following acknowledgement:
17  * This product includes software developed by Alysson Ribeiro da Silva.
18  *
19  * 4. Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * 5. The source and the binary form, and any modifications made to them
24  * may not be used for the purpose of training or improving machine learning
25  * algorithms, including but not limited to artificial intelligence, natural
26  * language processing, or data mining. This condition applies to any derivatives,
27  * modifications, or updates based on the Software code. Any usage of the source
28  * or the binary form in an AI-training dataset is considered a breach of
29  * this License.
30  *
31  * THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR
32  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
33  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
34  * EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
40  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 */
42 
43 #ifndef COMMON_H
44 #define COMMON_H
45 
46 #include <cstring>
47 #include <stdio.h>
48 #include "geometry_msgs/Pose.h"
49 #include "ros/ros.h"
50 #include "tf/tf.h"
51 #include "nav_msgs/OccupancyGrid.h"
52 #include <random>
53 
54 std::mt19937* randomglobal();
55 
56 /*
57  * For grid opperations
58  */
59 struct Vec2i {
60  union {
61  int array[2];
62  struct {
63  union {
64  int x;
65  int width;
66  };
67  union {
68  int y;
69  int height;
70  };
71  };
72  };
73 
74  static Vec2i Create(int x, int y) {
75  Vec2i result;
76  result.x = x;
77  result.y = y;
78  return result;
79  }
80 
81  static Vec2i Create(int v) {
82  Vec2i result;
83  result.x = v;
84  result.y = v;
85  return result;
86  }
87 
88  bool contains(int v) const {
89  return x == v || y == v;
90  }
91 
92  bool contains(const Vec2i& v) const {
93  return contains(v.x) || contains(v.y);
94  }
95 
96  inline void print() {
97  printf("[%d,%d]\n", x, y);
98  }
99 
100  inline bool operator==(const Vec2i& v) const { return memcmp(this, &v, sizeof(Vec2i)) == 0; }
101  inline bool operator!=(const Vec2i& v) const { return memcmp(this, &v, sizeof(Vec2i)) != 0; }
102  inline Vec2i operator-()const { return Vec2i::Create(-x, -y); }
103  inline Vec2i& operator+=(const Vec2i& v) { x += v.x; y += v.y; return (*this); }
104  inline Vec2i& operator-=(const Vec2i& v) { x -= v.x; y -= v.y; return (*this); }
105  inline Vec2i& operator*=(const Vec2i& v) { x *= v.x; y *= v.y; return (*this); }
106  inline Vec2i& operator/=(const Vec2i& v) { x /= v.x; y /= v.y; return (*this); }
107  inline Vec2i& operator+=(const int& v) { x += v; y += v; return (*this); }
108  inline Vec2i& operator-=(const int& v) { x -= v; y -= v; return (*this); }
109  inline Vec2i& operator*=(const int& v) { x *= v; y *= v; return (*this); }
110  inline Vec2i& operator/=(const int& v) { x /= v; y /= v; return (*this); }
111  inline double norm(const Vec2i& other) {
112  int dx = this->x - other.x;
113  int dy = this->y - other.y;
114  return sqrt((dx * dx) + (dy * dy));
115  }
116 
117 };
118 
119 inline double Distance(const Vec2i& rA, const Vec2i& rB) {
120  int dx = rA.x - rB.x;
121  int dy = rA.y - rB.y;
122  return (dx * dx) + (dy * dy);
123 }
124 
125 #define INLINE_OPERATION_IMPLEMENTATION_INT(TTYPE)\
126 static inline TTYPE operator/( const TTYPE& vecA, const TTYPE& vecB ){ return (TTYPE(vecA)/=vecB); } \
127 static inline TTYPE operator/( const TTYPE& vec , const int value ){ return (TTYPE(vec)/=value); } \
128 static inline TTYPE operator/( const int value, const TTYPE& vec ){ return (TTYPE::Create(value)/=vec); } \
129 static inline TTYPE operator*( const TTYPE& vecA, const TTYPE& vecB ){ return (TTYPE(vecA)*=vecB); } \
130 static inline TTYPE operator*( const TTYPE& vec , const int value ){ return (TTYPE(vec)*=value); } \
131 static inline TTYPE operator*( const int value, const TTYPE& vec ){ return (TTYPE::Create(value)*=vec); } \
132 static inline TTYPE operator+( const TTYPE& vecA, const TTYPE& vecB ){ return (TTYPE(vecA)+=vecB); } \
133 static inline TTYPE operator+( const TTYPE& vec , const int value ){ return (TTYPE(vec)+=value); } \
134 static inline TTYPE operator+( const int value, const TTYPE& vec ){ return (TTYPE::Create(value)+=vec); } \
135 static inline TTYPE operator-( const TTYPE& vecA, const TTYPE& vecB ){ return (TTYPE(vecA)-=vecB); } \
136 static inline TTYPE operator-( const TTYPE& vec , const int value ){ return (TTYPE(vec)-=value); } \
137 static inline TTYPE operator-( const int value, const TTYPE& vec ){ return (TTYPE::Create(value)-=vec); }
138 
140 
141 #if !defined(NDEBUG)
142  #define MATRIX_THROW_OUT_OF_BOUND_EXCEPTION
143 #endif
144 
145 #if defined(MATRIX_THROW_OUT_OF_BOUND_EXCEPTION)
146 
147 template <typename T>
148 class Matrix;
149 
150 template <typename _T>
152  int width;
153  _T* ptr;
154  Matrix_Proxy(int width, _T* ptr) {
155  this->width = width;
156  this->ptr = ptr;
157  }
158  public:
159  _T& operator[](int x) {
160  if (x < 0 || x >= width)
161  throw std::overflow_error("column index is out of bounds.");
162  return this->ptr[x];
163  }
164  const _T& operator[](int x)const {
165  if (x < 0 || x >= width)
166  throw std::overflow_error("column index is out of bounds.");
167  return this->ptr[x];
168  }
169  friend class Matrix<_T>;
170 };
171 #endif
172 
173 /*
174  * For grid opperations
175  */
176 template <typename T> class Matrix {
177  public:
178  T* array;
180 
181  Matrix(int width, int height) : size(Vec2i::Create(0,0)) {
182  array = NULL;
183  setSize(Vec2i::Create(width, height));
184  }
185 
186  Matrix(const Vec2i& size) : size(Vec2i::Create(0,0)) {
187  array = NULL;
188  setSize(size);
189  }
190 
191  Matrix(const Matrix& m) : size(Vec2i::Create(0,0)) {
192  setSize(m.size);
193  memcpy(array, m.array, sizeof(T)*size.width*size.height);
194  }
195 
196  void operator=(const Matrix& m) {
197  setSize(m.size);
198  memcpy(array, m.array, sizeof(T)*size.width*size.height);
199  }
200 
201  inline void CopyRegion(std::vector<Vec2i>& rValidAreas,
202  Matrix<T>& pOther,
203  const Vec2i& start,
204  const Vec2i& end) {
205  if(size != pOther.size) {
206  throw std::out_of_range("matrices need to be of the same size.");
207  }
208  if(start.x < 0 || start.x > size.width || end.x < 0 || end.x > size.width ||
209  start.y < 0 || start.y > size.height || end.y < 0 || end.y > size.height) {
210  throw std::out_of_range("box is out of range.");
211  }
212  int index = 0;
213  int val = 0;
214 
215  // should include both ends, thus using <=
216  for(int y = start.y; y < end.y; ++y) {
217  // this copy is being done this way to extract all
218  // free positions that will be used for map fusion
219  // thus reducing the algorithmic complexity of the program
220  for(int x = start.x; x < end.x; ++x) {
221  index = y*size.width+x;
222  val = pOther.array[index];
223 
224  // if val is a valid free path,
225  // them it should be added into the free
226  // paths list if it was not discovered
227  // into the robot's map
228  if(val != 50 && array[index] == 50) {
229  rValidAreas.push_back(Vec2i::Create(x,y));
230  }
231 
232  // the value will be updated only after checking
233  // its discovery on the robot's map
234  array[index] = val;
235  }
236 
237  // direct copy is efficient but does not allow fast
238  // map fusion since there is no way to get the free positions
239  // directly from the memory block
240  //index = y*size.width+x;
241  //memcpy(&array[index], &pOther.array[index], sizeof(T)*(end.x-start.x));
242  }
243  }
244 
245  inline bool CheckAny(const Vec2i& rStart, const Vec2i& rEnd, const int& rVal) {
246  Vec2i start = rStart;
247  Vec2i end = rEnd;
248  if(start.x < 0) start.x = 0;
249  if(start.x >= size.width) start.x = size.width - 1;
250  if(start.y < 0) start.y = 0;
251  if(start.y >= size.height) start.y = size.height - 1;
252  if(end.x < 0) end.x = 0;
253  if(end.x >= size.width) end.x = size.width - 1;
254  if(end.y < 0) end.y = 0;
255  if(end.y >= size.height) end.y = size.height - 1;
256 
257  // this for should be end inclusive
258  // thus is the end.[xy] + 1
259  for(int y = start.y; y < end.y + 1; ++y) {
260  for(int x = start.x; x < end.x + 1; ++x) {
261  if(array[y*size.width+x] == rVal) return true;
262  }
263  }
264  return false;
265  }
266 
267  #if defined(MATRIX_THROW_OUT_OF_BOUND_EXCEPTION)
269  if (y < 0 || y >= size.height)
270  throw std::overflow_error("row index is out of bounds.");
271  return Matrix_Proxy<T>(size.width , &this->array[y * size.width]);
272  }
273  const Matrix_Proxy<T> operator[](int y)const {
274  if (y < 0 || y >= size.height)
275  throw std::overflow_error("row index is out of bounds.");
276  return Matrix_Proxy<T>(size.width, &this->array[y * size.width]);
277  }
278  #else
279  T* operator[](int y) {
280  return &this->array[y * size.width];
281  }
282  const T* operator[](int y)const {
283  return &this->array[y * size.width];
284  }
285  #endif
286 
288  delete array;
289  array = nullptr;
290  this->size = Vec2i::Create(0);
291  }
292 
293  void setSize(const Vec2i& size) {
294  if (this->size == size)
295  return;
296  if(size.width <= 0 || size.height <= 0) {
297  throw std::bad_alloc();
298  }
299  delete array;
300  array = nullptr;
301  this->size = size;
302  array = new T[size.width * size.height];
303  }
304 
305  bool isInBounds(const Vec2i& rCoord) {
306  if(rCoord.x < 0) return false;
307  if(rCoord.y < 0) return false;
308  if(rCoord.x >= size.width) return false;
309  if(rCoord.y >= size.height) return false;
310  return true;
311  }
312 
313  void clear(const T&v) {
314  int s = size.height * size.width;
315  for(int i=0;i<s;++i) {
316  array[i] = v;
317  }
318  }
319 };
320 
321 inline void PrintIntMap(Matrix<int>& rInput) {
322  // print frontier maps for evaluation
323  for(int y = 0; y < rInput.size.height; ++y) {
324  for(int x = 0; x < rInput.size.width; ++x) {
325  if(rInput[y][x] == 100)
326  printf("%c", 251);
327  else if(rInput[y][x] == 50)
328  printf("?");
329  else
330  printf(".");
331  }
332  printf("\n");
333  }
334 }
335 
336 inline void PrintCharMap(Matrix<char>& rInput) {
337  // print frontier maps for evaluation
338  for(int y = 0; y < rInput.size.height; ++y) {
339  for(int x = 0; x < rInput.size.width; ++x) {
340  printf("%c", rInput[y][x]);
341  }
342  printf("\n");
343  }
344 }
345 
346 inline void PrintSelfMap(Matrix<int>& rInput, const Vec2i& rPos) {
347  Matrix<char> cmap(rInput.size);
348 
349  // print frontier maps for evaluation
350  for(int y = 0; y < rInput.size.height; ++y) {
351  for(int x = 0; x < rInput.size.width; ++x) {
352  if(rInput[y][x] == 100)
353  cmap[y][x] = 251;
354  else if(rInput[y][x] == 50)
355  cmap[y][x] = '?';
356  else
357  cmap[y][x] = '.';
358  }
359  }
360 
361  cmap[rPos.y][rPos.x] = 'R';
362 
363  PrintCharMap(cmap);
364 }
365 
366 inline void PrintIntPath(Matrix<int>& rInput,
367  std::list<Vec2i>& rPath,
368  const Vec2i& rStart,
369  const Vec2i& rEnd) {
370  Matrix<char> path_map(rInput.size);
371 
372  // print frontier maps for evaluation
373  for(int y = 0; y < rInput.size.height; ++y) {
374  for(int x = 0; x < rInput.size.width; ++x) {
375  if(rInput[y][x] == 100)
376  path_map[y][x] = 251;
377  else if(rInput[y][x] == 50)
378  path_map[y][x] = '?';
379  else
380  path_map[y][x] = '.';
381  }
382  }
383 
384  // mark path in the path_map
385  std::list<Vec2i>::iterator it = rPath.begin();
386  for(;it != rPath.end(); ++it) {
387  Vec2i p = (*it);
388  path_map[p.y][p.x] = '*';
389  }
390 
391  path_map[rStart.y][rStart.x] = 'S';
392  path_map[rEnd.y][rEnd.x] = 'E';
393 
394  // print full map
395  PrintCharMap(path_map);
396 }
397 
398 /*
399  * Occupancy grid helpers
400  */
401 inline void PoseToVector3(const geometry_msgs::Pose& rInput, tf::Vector3& rOut) {
402  rOut.setX(rInput.position.x);
403  rOut.setY(rInput.position.y);
404  rOut.setZ(rInput.position.z);
405  rOut.setW(1.0);
406 }
407 
408 inline void Vector3ToPose(const tf::Vector3& rInput, geometry_msgs::Pose& rOutPose) {
409  rOutPose.position.x = rInput.getX();
410  rOutPose.position.y = rInput.getY();
411  rOutPose.position.z = rInput.getZ();
412 }
413 
414 inline void WorldToMap(nav_msgs::OccupancyGrid& rOcc, geometry_msgs::Pose& rWorld, Vec2i& rOutput) {
415  double res = rOcc.info.resolution;
416  rOutput.x = (int)((rWorld.position.x - rOcc.info.origin.position.x)/res);
417  rOutput.y = (int)((rWorld.position.y - rOcc.info.origin.position.y)/res);
418 }
419 
420 inline void WorldToMap(nav_msgs::OccupancyGrid& rOcc, geometry_msgs::Pose& rWorld, tf::Vector3& rOutput) {
421  double res = rOcc.info.resolution;
422  rOutput.setX((int)((rWorld.position.x - rOcc.info.origin.position.x)/res));
423  rOutput.setY((int)((rWorld.position.y - rOcc.info.origin.position.y)/res));
424 }
425 
426 inline void WorldToMap(nav_msgs::OccupancyGrid& rOcc, tf::Vector3& rWorld, Vec2i& rOutput) {
427  double res = rOcc.info.resolution;
428  rOutput.x = (int)((rWorld.getX() - rOcc.info.origin.position.x)/res);
429  rOutput.y = (int)((rWorld.getY() - rOcc.info.origin.position.y)/res);
430 }
431 
432 inline void WorldToMap(nav_msgs::OccupancyGrid& rOcc, tf::Vector3& rWorld, tf::Vector3&rOutput) {
433  double res = rOcc.info.resolution;
434  rOutput.setX((int)((rWorld.getX() - rOcc.info.origin.position.x)/res));
435  rOutput.setY((int)((rWorld.getY() - rOcc.info.origin.position.y)/res));
436  rOutput.setZ(0.0);
437 }
438 
439 inline void MapToWorld(nav_msgs::OccupancyGrid& rOcc, Vec2i& rMap, geometry_msgs::Pose& rWorld) {
440  double res = rOcc.info.resolution;
441  double d_x = (double)rMap.x;
442  double d_y = (double)rMap.y;
443  rWorld.position.x = rOcc.info.origin.position.x + (d_x * res) + (res / 2.0);
444  rWorld.position.y = rOcc.info.origin.position.y + (d_y * res) + (res / 2.0);
445  rWorld.position.z = 0.0;
446 }
447 
448 inline void MapToWorld(nav_msgs::OccupancyGrid& rOcc, Vec2i& rMap, Vec2i& rWorld) {
449  double res = rOcc.info.resolution;
450  double d_x = (double)rMap.x;
451  double d_y = (double)rMap.y;
452  rWorld.x = rOcc.info.origin.position.x + (d_x * res) + (res / 2.0);
453  rWorld.y = rOcc.info.origin.position.y + (d_y * res) + (res / 2.0);
454 }
455 
456 inline void MapToWorld(nav_msgs::OccupancyGrid& rOcc, Vec2i& rMap, tf::Vector3& rWorld) {
457  double res = rOcc.info.resolution;
458  double d_x = (double)rMap.x;
459  double d_y = (double)rMap.y;
460  rWorld.setX(rOcc.info.origin.position.x + (d_x * res) + (res / 2.0));
461  rWorld.setY(rOcc.info.origin.position.y + (d_y * res) + (res / 2.0));
462 }
463 
464 inline double PeriodToFreqAndFreqToPeriod(const double& val) {
465  return 1.0 / val;
466 }
467 
468 inline void ApplyMask(const int& rX,
469  const int& rY,
470  const int& rRadius,
471  std::vector<int8_t>& rArr,
472  const int& rVal,
473  const int& rWidth,
474  const int& rHeight,
475  const int8_t& occupancyThreshold = 90,
476  const bool& ignoreObstacles=false) {
477  int index;
478  int dx, dy;
479  int r_squared = rRadius * rRadius;
480  for(int y = rY - rRadius; y <= rY + rRadius; ++y) {
481  for(int x = rX - rRadius; x <= rX + rRadius; ++x) {
482  if(x >= rWidth || y >= rHeight ||x < 0 || y < 0) continue;
483 
484  index = y * rWidth + x;
485 
486  // I use this condition to check if I should inflate or not obsacles
487  // this is useful to clear the space for planning near the robot's pose
488  if(ignoreObstacles == true && rArr[index] >= occupancyThreshold) continue;
489 
490  // check if y and x are inside the circle
491  // or if they satisfy the circle equation
492  dx = (x - rX);
493  dy = (y - rY);
494  dx *= dx;
495  dy *= dy;
496  if(dx + dy <= r_squared) rArr[index] = rVal;
497  }
498  }
499 }
500 
501 #endif
Matrix
Definition: Common.h:148
Vec2i::operator-=
Vec2i & operator-=(const Vec2i &v)
Definition: Common.h:104
PeriodToFreqAndFreqToPeriod
double PeriodToFreqAndFreqToPeriod(const double &val)
Definition: Common.h:464
Vec2i::norm
double norm(const Vec2i &other)
Definition: Common.h:111
Matrix_Proxy
Definition: Common.h:151
Vec2i::operator-
Vec2i operator-() const
Definition: Common.h:102
Matrix_Proxy::ptr
_T * ptr
Definition: Common.h:153
Matrix::isInBounds
bool isInBounds(const Vec2i &rCoord)
Definition: Common.h:305
Matrix_Proxy::operator[]
_T & operator[](int x)
Definition: Common.h:159
PrintIntPath
void PrintIntPath(Matrix< int > &rInput, std::list< Vec2i > &rPath, const Vec2i &rStart, const Vec2i &rEnd)
Definition: Common.h:366
Vec2i
Definition: Common.h:59
Matrix_Proxy::operator[]
const _T & operator[](int x) const
Definition: Common.h:164
Matrix::Matrix
Matrix(int width, int height)
Definition: Common.h:181
Matrix::operator=
void operator=(const Matrix &m)
Definition: Common.h:196
Distance
double Distance(const Vec2i &rA, const Vec2i &rB)
Definition: Common.h:119
Matrix::array
T * array
Definition: Common.h:178
Vec2i::contains
bool contains(int v) const
Definition: Common.h:88
Vec2i::operator+=
Vec2i & operator+=(const Vec2i &v)
Definition: Common.h:103
Vec2i::operator!=
bool operator!=(const Vec2i &v) const
Definition: Common.h:101
Vec2i::x
int x
Definition: Common.h:64
PrintIntMap
void PrintIntMap(Matrix< int > &rInput)
Definition: Common.h:321
PrintCharMap
void PrintCharMap(Matrix< char > &rInput)
Definition: Common.h:336
Vec2i::operator/=
Vec2i & operator/=(const int &v)
Definition: Common.h:110
Vec2i::height
int height
Definition: Common.h:69
Matrix::operator[]
Matrix_Proxy< T > operator[](int y)
Definition: Common.h:268
Vec2i::operator/=
Vec2i & operator/=(const Vec2i &v)
Definition: Common.h:106
Matrix::setSize
void setSize(const Vec2i &size)
Definition: Common.h:293
Matrix::CheckAny
bool CheckAny(const Vec2i &rStart, const Vec2i &rEnd, const int &rVal)
Definition: Common.h:245
Matrix::size
Vec2i size
Definition: Common.h:179
MapToWorld
void MapToWorld(nav_msgs::OccupancyGrid &rOcc, Vec2i &rMap, geometry_msgs::Pose &rWorld)
Definition: Common.h:439
Vec2i::Create
static Vec2i Create(int v)
Definition: Common.h:81
randomglobal
std::mt19937 * randomglobal()
Vec2i::y
int y
Definition: Common.h:68
Matrix::Matrix
Matrix(const Matrix &m)
Definition: Common.h:191
Vector3ToPose
void Vector3ToPose(const tf::Vector3 &rInput, geometry_msgs::Pose &rOutPose)
Definition: Common.h:408
ApplyMask
void ApplyMask(const int &rX, const int &rY, const int &rRadius, std::vector< int8_t > &rArr, const int &rVal, const int &rWidth, const int &rHeight, const int8_t &occupancyThreshold=90, const bool &ignoreObstacles=false)
Definition: Common.h:468
INLINE_OPERATION_IMPLEMENTATION_INT
#define INLINE_OPERATION_IMPLEMENTATION_INT(TTYPE)
Definition: Common.h:125
Vec2i::operator*=
Vec2i & operator*=(const int &v)
Definition: Common.h:109
Vec2i::operator+=
Vec2i & operator+=(const int &v)
Definition: Common.h:107
PoseToVector3
void PoseToVector3(const geometry_msgs::Pose &rInput, tf::Vector3 &rOut)
Definition: Common.h:401
Vec2i::contains
bool contains(const Vec2i &v) const
Definition: Common.h:92
Matrix::operator[]
const Matrix_Proxy< T > operator[](int y) const
Definition: Common.h:273
Vec2i::print
void print()
Definition: Common.h:96
Matrix::clear
void clear(const T &v)
Definition: Common.h:313
WorldToMap
void WorldToMap(nav_msgs::OccupancyGrid &rOcc, geometry_msgs::Pose &rWorld, Vec2i &rOutput)
Definition: Common.h:414
Matrix::~Matrix
~Matrix()
Definition: Common.h:287
Matrix_Proxy::Matrix_Proxy
Matrix_Proxy(int width, _T *ptr)
Definition: Common.h:154
PrintSelfMap
void PrintSelfMap(Matrix< int > &rInput, const Vec2i &rPos)
Definition: Common.h:346
Vec2i::array
int array[2]
Definition: Common.h:61
Matrix_Proxy::width
int width
Definition: Common.h:152
Vec2i::operator*=
Vec2i & operator*=(const Vec2i &v)
Definition: Common.h:105
Matrix::Matrix
Matrix(const Vec2i &size)
Definition: Common.h:186
Matrix::CopyRegion
void CopyRegion(std::vector< Vec2i > &rValidAreas, Matrix< T > &pOther, const Vec2i &start, const Vec2i &end)
Definition: Common.h:201
Vec2i::Create
static Vec2i Create(int x, int y)
Definition: Common.h:74
Vec2i::operator==
bool operator==(const Vec2i &v) const
Definition: Common.h:100
Vec2i::width
int width
Definition: Common.h:65
Vec2i::operator-=
Vec2i & operator-=(const int &v)
Definition: Common.h:108