20 #ifndef __OpenKarto_Grid_h__ 21 #define __OpenKarto_Grid_h__ 70 Grid* pGrid =
new Grid(width, height);
85 delete m_pCoordinateConverter;
95 memset(m_pData, 0, GetDataSize() *
sizeof(T));
104 Grid* pGrid = CreateGrid(GetWidth(), GetHeight(), GetResolution());
121 m_WidthStep = math::AlignValue<kt_int32s>(width, 8);
131 m_pData =
new T[GetDataSize()];
133 if (m_pCoordinateConverter == NULL)
171 if (boundaryCheck ==
true)
173 if (IsValidGridIndex(rGrid) ==
false)
176 errorMessage <<
"Index (" << rGrid.
GetX() <<
", " << rGrid.
GetY() <<
")" <<
" out of range. Index must be between [0; " << GetWidth() <<
") and [0; " << GetHeight() <<
")";
183 if (boundaryCheck ==
true)
200 grid.
SetY(index / m_WidthStep);
201 grid.
SetX(index - grid.
GetY() * m_WidthStep);
214 return GetCoordinateConverter()->WorldToGrid(rWorld, flipY);
225 return GetCoordinateConverter()->GridToWorld(rGrid, flipY);
235 kt_int32s index = GridIndex(rGrid,
true);
236 return m_pData + index;
246 kt_int32s index = GridIndex(rGrid,
true);
247 return m_pData + index;
310 return m_WidthStep * GetHeight();
321 return m_pData[index];
332 m_pData[index] = rValue;
341 return m_pCoordinateConverter;
350 return GetCoordinateConverter()->GetResolution();
359 return GetCoordinateConverter()->GetBoundingBox();
373 kt_bool steep = abs(y1 - y0) > abs(x1 - x0);
417 if (2 * error >= deltaX)
424 if (IsValidGridIndex(gridIndex))
426 kt_int32s index = GridIndex(gridIndex,
false);
427 T* pGridPointer = GetDataPointer();
428 pGridPointer[index]++;
450 , m_pCoordinateConverter(NULL)
452 Resize(width, height);
492 #endif // __OpenKarto_Grid_h__ kt_int32s GetHeight() const
kt_int32s GetDataSize() const
const Size2< kt_int32s > GetSize() const
T * GetDataPointer() const
kt_int32s GetWidthStep() const
T GetValue(const Vector2i &rGrid) const
T * GetDataPointer(const Vector2i &rGrid) const
kt_bool IsValidGridIndex(const Vector2i &rGrid) const
void SetValue(const Vector2i &rGrid, T rValue) const
BoundingBox2 GetBoundingBox() const
kt_bool IsUpTo(const T &value, const T &maximum)
kt_int32s GetWidth() const
TFSIMD_FORCE_INLINE const tfScalar & y() const
virtual kt_int32s GridIndex(const Vector2i &rGrid, kt_bool boundaryCheck=true) const
void SetOffset(const Vector2d &rOffset)
void SetScale(kt_double scale)
void TraceLine(kt_int32s x0, kt_int32s y0, kt_int32s x1, kt_int32s y1, Functor *f=NULL)
kt_double GetResolution() const
virtual void Resize(kt_int32s width, kt_int32s height)
static Grid * CreateGrid(kt_int32s width, kt_int32s height, kt_double resolution)
Vector2d GridToWorld(const Vector2i &rGrid, kt_bool flipY=false) const
TFSIMD_FORCE_INLINE const tfScalar & x() const
const String & ToString() const
KARTO_TYPE(Grid< kt_int8u >)
CoordinateConverter * GetCoordinateConverter() const
Vector2i WorldToGrid(const Vector2d &rWorld, kt_bool flipY=false) const
CoordinateConverter * m_pCoordinateConverter
Vector2i IndexToGrid(kt_int32s index) const
T * GetDataPointer(const Vector2i &rGrid)
Grid(kt_int32s width, kt_int32s height)