2014-12-09 22:53:09 +00:00
|
|
|
namespace dk {
|
2014-12-12 19:04:48 +00:00
|
|
|
namespace implem {
|
|
|
|
///----------------------------------------------------------------------
|
|
|
|
///----------------------------------------------------------------------
|
|
|
|
template <size_t D>
|
|
|
|
typename LayerBase<D>::coords::value_type area (const typename LayerBase<D>::coords& parVec) {
|
|
|
|
typename LayerBase<D>::coords::value_type retval(1);
|
|
|
|
for (size_t d = 0; d < D; ++d) {
|
|
|
|
retval *= parVec[d];
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-09 22:53:09 +00:00
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
template <size_t D>
|
2014-12-12 19:04:48 +00:00
|
|
|
LayerBase<D>::LayerBase (const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize) :
|
|
|
|
m_count(parCount),
|
2014-12-11 22:58:52 +00:00
|
|
|
m_tilesize(parTileSize),
|
|
|
|
m_mastersize(parMasterTileSize)
|
2014-12-09 22:53:09 +00:00
|
|
|
{
|
2014-12-11 22:58:52 +00:00
|
|
|
DK_ASSERT((parMasterTileSize / parTileSize) * parTileSize == parMasterTileSize);
|
2014-12-09 22:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
template <typename T, size_t D>
|
2014-12-12 19:04:48 +00:00
|
|
|
Layer<T, D>::Layer (const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize, streamer_type&& parStreamer) :
|
|
|
|
LayerBase<D>(parCount, parTileSize, parMasterTileSize),
|
|
|
|
m_streamer(std::move(parStreamer)),
|
|
|
|
m_activeViewport(*this)
|
2014-12-09 22:53:09 +00:00
|
|
|
{
|
|
|
|
}
|
2014-12-12 19:04:48 +00:00
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
template <typename T, size_t D>
|
|
|
|
typename Layer<T, D>::iterator Layer<T, D>::begin() {
|
|
|
|
return iterator(&m_tiles, coords(0), this->m_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
template <typename T, size_t D>
|
|
|
|
void Layer<T, D>::setActiveViewport (const coords& parFrom, const coords& parCount) {
|
|
|
|
m_tiles.clear();
|
|
|
|
const auto area = implem::area(parCount);
|
|
|
|
m_tiles.reserve(area);
|
|
|
|
m_streamer.copy(m_tiles, parFrom, parFrom + parCount);
|
|
|
|
m_activeViewport.setFrom(parFrom);
|
|
|
|
m_activeViewport.setSize(parCount);
|
|
|
|
}
|
2014-12-09 22:53:09 +00:00
|
|
|
}
|