22 #include "ValueType.hpp"
32 namespace FotoSHOCKcore{
44 template <ValueType::Enum PixelFormat>
58 Tile (
unsigned int extent,
unsigned int bands)
throw (bad_alloc);
120 unsigned int m_extent;
121 unsigned int m_bands;
125 template <ValueType::Enum PixelFormat>
128 m_data =
new format[(extent * extent + 1) * bands]();
138 template <ValueType::Enum PixelFormat>
140 size_t dataLength = other.m_extent * other.m_extent * other.m_bands;
141 m_data =
new format[dataLength];
145 std::memcpy(m_data, other.m_data, dataLength * sizeof (format));
147 m_extent = other.m_extent;
148 m_bands = other.m_bands;
149 m_stamp = other.m_stamp;
152 template <ValueType::Enum PixelFormat>
158 template <ValueType::Enum PixelFormat>
160 if (
this != &other) {
161 if (m_extent == other.m_extent && m_bands == other.m_bands) {
162 std::memcpy(m_data, other.m_data, m_extent * m_extent * m_bands * sizeof (format));
163 m_stamp = other.m_stamp;
168 std::swap(m_data, tmp.m_data);
169 std::swap(m_extent, tmp.m_extent);
170 std::swap(m_bands, tmp.m_bands);
171 std::swap(m_stamp, tmp.m_stamp);
179 template <ValueType::Enum PixelFormat>
184 template <ValueType::Enum PixelFormat>
198 template <ValueType::Enum PixelFormat>
202 friend class Tile<PixelFormat>;
339 const unsigned int getX()
const;
346 const unsigned int getY()
const;
348 unsigned int m_extent;
349 unsigned int m_bands;
361 template <ValueType::Enum PixelFormat>
363 m_extent = tile->m_extent;
364 m_bands = tile->m_bands;
365 m_startPos = tile->m_data;
366 m_currentPos = tile->m_data;
369 template <ValueType::Enum PixelFormat>
371 m_extent = other.m_extent;
372 m_bands = other.m_bands;
373 m_startPos = other.m_startPos;
374 m_currentPos = other.m_currentPos;
378 template <ValueType::Enum PixelFormat>
386 template <ValueType::Enum PixelFormat>
389 template <ValueType::Enum PixelFormat>
391 if (
this != &other) {
392 m_extent = other.m_extent;
393 m_bands = other.m_bands;
394 m_startPos = other.m_startPos;
395 m_currentPos = other.m_currentPos;
401 template <ValueType::Enum PixelFormat>
403 assert (m_currentPos + m_bands <= (m_startPos + (m_extent) * (m_extent) * m_bands));
404 m_currentPos += m_bands;
408 template <ValueType::Enum PixelFormat>
410 assert (m_currentPos >= m_startPos + m_bands);
411 m_currentPos -= m_bands;
415 template <ValueType::Enum PixelFormat>
417 assert ((x <= m_extent) && (y <= m_extent));
418 m_currentPos = m_startPos + m_bands * (m_extent * y + x);
422 template <ValueType::Enum PixelFormat>
427 template <ValueType::Enum PixelFormat>
432 template <ValueType::Enum PixelFormat>
434 assert ((x < m_extent) && (y < m_extent));
435 return m_startPos + m_bands * (m_extent * y + x);
438 template <ValueType::Enum PixelFormat>
440 assert ((x < m_extent) && (y < m_extent));
441 return m_startPos + m_bands * (m_extent * y + x);
444 template <ValueType::Enum PixelFormat>
446 assert (n < m_bands);
447 return *(m_currentPos + n);
450 template <ValueType::Enum PixelFormat>
452 assert (n < m_bands);
453 return *(m_currentPos + n);
456 template <ValueType::Enum PixelFormat>
458 assert (band < m_bands);
459 return *(m_currentPos + band);
462 template <ValueType::Enum PixelFormat>
464 assert (band < m_bands);
465 *(m_currentPos + band) = value;
468 template <ValueType::Enum PixelFormat>
470 ptrdiff_t tmp = m_currentPos - m_startPos;
472 return tmp % m_extent;
475 template <ValueType::Enum PixelFormat>
477 ptrdiff_t tmp = m_currentPos - m_startPos;
479 return tmp / m_extent;
482 template <ValueType::Enum PixelFormat>
484 return m_currentPos == other.m_currentPos;
487 template <ValueType::Enum PixelFormat>
489 return m_currentPos != other.m_currentPos;
493 template <ValueType::Enum PixelFormat>
498 template <ValueType::Enum PixelFormat>
502 iterator.
moveTo(m_extent, m_extent - 1);
506 template <ValueType::Enum PixelFormat>