Progressing with the implementation
This commit is contained in:
parent
9086de8dae
commit
0da607ab3d
14 changed files with 192 additions and 59 deletions
|
@ -7,6 +7,11 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11 -O3 -Wall -We
|
||||||
|
|
||||||
find_library(Boost 1.21.0 REQUIRED)
|
find_library(Boost 1.21.0 REQUIRED)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
"${CMAKE_SOURCE_DIR}/src/${PROJECT_NAME}Config.h.in"
|
||||||
|
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.h"
|
||||||
|
)
|
||||||
|
|
||||||
include_directories(SYSTEM
|
include_directories(SYSTEM
|
||||||
${Boost_INCLUDE_DIRECTORIES}
|
${Boost_INCLUDE_DIRECTORIES}
|
||||||
)
|
)
|
||||||
|
@ -14,6 +19,7 @@ include_directories(SYSTEM
|
||||||
include_directories(
|
include_directories(
|
||||||
src/
|
src/
|
||||||
include/
|
include/
|
||||||
|
"${PROJECT_BINARY_DIR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}
|
add_executable(${PROJECT_NAME}
|
||||||
|
|
|
@ -3,20 +3,24 @@
|
||||||
|
|
||||||
#include "primitivetypes.hpp"
|
#include "primitivetypes.hpp"
|
||||||
#include "components/tilestreamer.hpp"
|
#include "components/tilestreamer.hpp"
|
||||||
|
#include "components/tileiterator.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace dk {
|
namespace dk {
|
||||||
|
template <typename T, size_t D>
|
||||||
|
class Viewport;
|
||||||
|
|
||||||
template <size_t D>
|
template <size_t D>
|
||||||
class LayerBase {
|
class LayerBase {
|
||||||
public:
|
public:
|
||||||
typedef Vector<CoordinateScalarType, D> coords;
|
typedef Vector<CoordinateScalarType, D> coords;
|
||||||
|
|
||||||
LayerBase ( const coords& parSize, const coords& parTileSize, const coords& parMasterTileSize );
|
LayerBase ( const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize );
|
||||||
virtual ~LayerBase ( void ) noexcept = default;
|
virtual ~LayerBase ( void ) noexcept = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
coords m_size;
|
coords m_count;
|
||||||
coords m_tilesize;
|
coords m_tilesize;
|
||||||
coords m_mastersize;
|
coords m_mastersize;
|
||||||
};
|
};
|
||||||
|
@ -26,18 +30,28 @@ namespace dk {
|
||||||
public:
|
public:
|
||||||
typedef typename LayerBase<D>::coords coords;
|
typedef typename LayerBase<D>::coords coords;
|
||||||
typedef TileStreamer<T, D> streamer_type;
|
typedef TileStreamer<T, D> streamer_type;
|
||||||
|
typedef TileIterator<T, D> iterator;
|
||||||
|
|
||||||
Layer ( const Layer& ) = delete;
|
Layer ( const Layer& ) = delete;
|
||||||
Layer ( Layer&& ) = default;
|
Layer ( Layer&& ) = default;
|
||||||
Layer ( const coords& parSize, const coords& parTileSize, const coords& parMasterTileSize, streamer_type&& parStreamer );
|
Layer ( const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize, streamer_type&& parStreamer );
|
||||||
virtual ~Layer ( void ) noexcept = default;
|
virtual ~Layer ( void ) noexcept = default;
|
||||||
|
|
||||||
Layer& operator= ( const Layer& ) = delete;
|
Layer& operator= ( const Layer& ) = delete;
|
||||||
|
|
||||||
|
iterator begin ( void );
|
||||||
|
void setActiveViewport ( const coords& parFrom, const coords& parCount );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
streamer_type m_streamer;
|
streamer_type m_streamer;
|
||||||
|
Viewport<T, D> m_activeViewport;
|
||||||
std::vector<T> m_tiles;
|
std::vector<T> m_tiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace implem {
|
||||||
|
template <size_t D>
|
||||||
|
typename LayerBase<D>::coords::value_type area ( const typename LayerBase<D>::coords& parVec ) a_pure;
|
||||||
|
}
|
||||||
} //namespace dk
|
} //namespace dk
|
||||||
|
|
||||||
#include "implem/layer.inl"
|
#include "implem/layer.inl"
|
||||||
|
|
|
@ -7,26 +7,38 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace dk {
|
namespace dk {
|
||||||
|
namespace implem {
|
||||||
|
template <size_t D>
|
||||||
|
inline size_t get_index_from_pos ( const Vector<CoordinateScalarType, D>& parPos, const Vector<CoordinateScalarType, D>& parSize ) a_pure;
|
||||||
|
|
||||||
|
#if defined(NDEBUG)
|
||||||
|
template <>
|
||||||
|
inline size_t get_index_from_pos ( const Vector<CoordinateScalarType, 2>& parPos, const Vector<CoordinateScalarType, 2>& parSize ) a_pure;
|
||||||
|
#endif
|
||||||
|
} //namespace implem
|
||||||
|
|
||||||
template <typename T, size_t D>
|
template <typename T, size_t D>
|
||||||
class TileIterator : public boost::iterator_facade<TileIterator<T, D>, T, boost::biderectional_traversal_tag> {
|
class TileIterator : public boost::iterator_facade<TileIterator<T, D>, T, boost::bidirectional_traversal_tag> {
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
public:
|
public:
|
||||||
typedef Vector<CoordinateScalarType, D> coords;
|
typedef Vector<CoordinateScalarType, D> coords;
|
||||||
|
|
||||||
TileIterator ( void );
|
TileIterator ( void );
|
||||||
TileIterator ( const TileIterator& parOther ) = default;
|
TileIterator ( const TileIterator& parOther ) = default;
|
||||||
TileIterator ( const coords& parFrom, const coords& parTo );
|
TileIterator ( std::vector<T>* parData, const coords& parFrom, const coords& parTo );
|
||||||
TileIterator ( const coords& parFrom, const coords& parTo, const coords& parAreaFrom, const coords& parAreaTo, const coords& parTotal );
|
TileIterator ( std::vector<T>* parData, const coords& parFrom, const coords& parTo, const coords& parAreaFrom, const coords& parAreaTo, const coords& parTotal );
|
||||||
~TileIterator ( void ) = default;
|
~TileIterator ( void ) = default;
|
||||||
|
|
||||||
|
const coords& position ( void ) const { return m_pos; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void increment ( void );
|
void increment ( void );
|
||||||
void decrement ( void );
|
void decrement ( void );
|
||||||
void advance ( size_t parAdvance );
|
void advance ( size_t parAdvance );
|
||||||
ptrdiff_t distance_to ( const MeshSelectionIterator& parOther );
|
ptrdiff_t distance_to ( const TileIterator& parOther );
|
||||||
bool equal ( const MeshSelectionIterator& parOther ) const;
|
bool equal ( const TileIterator& parOther ) const;
|
||||||
T& dereference ( void ) const { return m_data[get_current_index()]; }
|
T& dereference ( void ) const { return (*m_data)[get_current_index()]; }
|
||||||
size_t get_current_index ( void ) const;
|
size_t get_current_index ( void ) const { return implem::get_index_from_pos(m_pos, m_total); }
|
||||||
|
|
||||||
coords m_pos;
|
coords m_pos;
|
||||||
coords m_from;
|
coords m_from;
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace dk {
|
namespace dk {
|
||||||
template <size_t D>
|
|
||||||
class Viewport;
|
|
||||||
|
|
||||||
template <size_t D>
|
template <size_t D>
|
||||||
class Tyler {
|
class Tyler {
|
||||||
typedef std::unique_ptr<LayerBase<D>> LayerPtr;
|
typedef std::unique_ptr<LayerBase<D>> LayerPtr;
|
||||||
|
@ -24,10 +21,11 @@ namespace dk {
|
||||||
|
|
||||||
typename coords::value_type tiles_count ( void ) const;
|
typename coords::value_type tiles_count ( void ) const;
|
||||||
const coords& map_size ( void ) const { return m_size; }
|
const coords& map_size ( void ) const { return m_size; }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
size_t push_layer ( typename Layer<T, D>::streamer_type&& parStreamer );
|
Layer<T, D>& push_layer ( typename Layer<T, D>::streamer_type&& parStreamer );
|
||||||
template <typename T>
|
template <typename T>
|
||||||
size_t push_layer ( typename Layer<T, D>::streamer_type&& parStreamer, const coords& parSubdiv );
|
Layer<T, D>& push_layer ( typename Layer<T, D>::streamer_type&& parStreamer, const coords& parSubdiv );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const coords m_size;
|
const coords m_size;
|
||||||
|
|
|
@ -2,23 +2,35 @@
|
||||||
#define id0ADBCC15BA574485BF3267254090D99B
|
#define id0ADBCC15BA574485BF3267254090D99B
|
||||||
|
|
||||||
#include "primitivetypes.hpp"
|
#include "primitivetypes.hpp"
|
||||||
|
#include "components/tileiterator.hpp"
|
||||||
|
#include "components/layer.hpp"
|
||||||
|
|
||||||
namespace dk {
|
namespace dk {
|
||||||
template <size_t D>
|
template <typename T, size_t D>
|
||||||
|
class Layer;
|
||||||
|
|
||||||
|
template <typename T, size_t D>
|
||||||
class Viewport {
|
class Viewport {
|
||||||
public:
|
public:
|
||||||
typedef Vector<CoordinateScalarType, D> coords;
|
typedef Vector<CoordinateScalarType, D> coords;
|
||||||
|
typedef typename Layer<T, D>::iterator iterator;
|
||||||
|
|
||||||
explicit Viewport ( const coords& parSize );
|
explicit Viewport ( Layer<T, D>& parLayer );
|
||||||
Viewport ( const coords& parSize, const coords& parPos );
|
Viewport ( Layer<T, D>& parLayer, const coords& parSize, const coords& parPos );
|
||||||
~Viewport ( void ) noexcept = default;
|
~Viewport ( void ) noexcept = default;
|
||||||
|
|
||||||
Viewport& operator= ( const Viewport& ) = default;
|
Viewport& operator= ( const Viewport& ) = default;
|
||||||
|
|
||||||
|
void setSize ( const coords& parSize ) { m_size = parSize; }
|
||||||
|
void setFrom ( const coords& parFrom ) { m_position = parFrom; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
coords m_size;
|
coords m_size;
|
||||||
coords m_position;
|
coords m_position;
|
||||||
|
Layer<T, D>& m_layer;
|
||||||
};
|
};
|
||||||
} //namespace dk
|
} //namespace dk
|
||||||
|
|
||||||
|
#include "implem/viewport.inl"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,9 +1,22 @@
|
||||||
namespace dk {
|
namespace dk {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///--------------------------------------------------------------------------
|
///--------------------------------------------------------------------------
|
||||||
///--------------------------------------------------------------------------
|
///--------------------------------------------------------------------------
|
||||||
template <size_t D>
|
template <size_t D>
|
||||||
LayerBase<D>::LayerBase (const coords& parSize, const coords& parTileSize, const coords& parMasterTileSize) :
|
LayerBase<D>::LayerBase (const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize) :
|
||||||
m_size(parSize),
|
m_count(parCount),
|
||||||
m_tilesize(parTileSize),
|
m_tilesize(parTileSize),
|
||||||
m_mastersize(parMasterTileSize)
|
m_mastersize(parMasterTileSize)
|
||||||
{
|
{
|
||||||
|
@ -13,9 +26,29 @@ namespace dk {
|
||||||
///--------------------------------------------------------------------------
|
///--------------------------------------------------------------------------
|
||||||
///--------------------------------------------------------------------------
|
///--------------------------------------------------------------------------
|
||||||
template <typename T, size_t D>
|
template <typename T, size_t D>
|
||||||
Layer<T, D>::Layer (const coords& parSize, const coords& parTileSize, const coords& parMasterTileSize, streamer_type&& parStreamer) :
|
Layer<T, D>::Layer (const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize, streamer_type&& parStreamer) :
|
||||||
LayerBase<D>(parSize, parTileSize, parMasterTileSize),
|
LayerBase<D>(parCount, parTileSize, parMasterTileSize),
|
||||||
m_streamer(std::move(parStreamer))
|
m_streamer(std::move(parStreamer)),
|
||||||
|
m_activeViewport(*this)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,27 @@
|
||||||
namespace dk {
|
namespace dk {
|
||||||
|
namespace implem {
|
||||||
|
template <size_t D>
|
||||||
|
inline size_t get_index_from_pos (const Vector<CoordinateScalarType, D>& parPos, const Vector<CoordinateScalarType, D>& parSize) {
|
||||||
|
size_t index = 0;
|
||||||
|
for (size_t d = 0; d < D; ++d) {
|
||||||
|
size_t pos = static_cast<size_t>(parPos[D - 1 - d]);
|
||||||
|
for (size_t p = 0; p < D - 1 - d; ++p) {
|
||||||
|
pos *= static_cast<size_t>(parSize[p]);
|
||||||
|
}
|
||||||
|
|
||||||
|
index += pos;
|
||||||
|
}
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(NDEBUG)
|
||||||
|
template <>
|
||||||
|
inline size_t get_index_from_pos (const Vector<CoordinateScalarType, 2>& parPos, const Vector<CoordinateScalarType, 2>& parSize) {
|
||||||
|
return parPos.y() * parSize.x() + parPos.x();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} //namespace implem
|
||||||
|
|
||||||
template <typename T, size_t D>
|
template <typename T, size_t D>
|
||||||
TileIterator<T, D>::TileIterator() :
|
TileIterator<T, D>::TileIterator() :
|
||||||
m_pos(CoordinateScalarType()),
|
m_pos(CoordinateScalarType()),
|
||||||
|
@ -6,30 +29,35 @@ namespace dk {
|
||||||
m_to(CoordinateScalarType()),
|
m_to(CoordinateScalarType()),
|
||||||
m_areafrom(CoordinateScalarType()),
|
m_areafrom(CoordinateScalarType()),
|
||||||
m_areato(CoordinateScalarType()),
|
m_areato(CoordinateScalarType()),
|
||||||
m_total(CoordinateScalarType())
|
m_total(CoordinateScalarType()),
|
||||||
|
m_data(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, size_t D>
|
template <typename T, size_t D>
|
||||||
TileIterator<T, D>::TileIterator (const coords& parFrom, const coords& parTo) :
|
TileIterator<T, D>::TileIterator (std::vector<T>* parData, const coords& parFrom, const coords& parTo) :
|
||||||
m_pos(parFrom),
|
m_pos(parFrom),
|
||||||
m_from(parFrom),
|
m_from(parFrom),
|
||||||
m_to(parTo),
|
m_to(parTo),
|
||||||
m_areafrom(parFrom),
|
m_areafrom(parFrom),
|
||||||
m_areato(parTo),
|
m_areato(parTo),
|
||||||
m_total(parTo - parFrom)
|
m_total(parTo - parFrom),
|
||||||
|
m_data(parData)
|
||||||
{
|
{
|
||||||
|
DK_ASSERT(parData);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, size_t D>
|
template <typename T, size_t D>
|
||||||
TileIterator<T, D>::TileIterator (const coords& parFrom, const coords& parTo, const coords& parAreaFrom, const coords& parAreaTo, const coords& parTotal) :
|
TileIterator<T, D>::TileIterator (std::vector<T>* parData, const coords& parFrom, const coords& parTo, const coords& parAreaFrom, const coords& parAreaTo, const coords& parTotal) :
|
||||||
m_pos(parFrom),
|
m_pos(parFrom),
|
||||||
m_from(parFrom),
|
m_from(parFrom),
|
||||||
m_to(parTo),
|
m_to(parTo),
|
||||||
m_areafrom(parAreaFrom),
|
m_areafrom(parAreaFrom),
|
||||||
m_areato(parAreaTo),
|
m_areato(parAreaTo),
|
||||||
m_total(parTotal)
|
m_total(parTotal),
|
||||||
|
m_data(parData)
|
||||||
{
|
{
|
||||||
|
DK_ASSERT(parData);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, size_t D>
|
template <typename T, size_t D>
|
||||||
|
@ -58,33 +86,18 @@ namespace dk {
|
||||||
++m_pos[D - 1];
|
++m_pos[D - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, size_t D>
|
|
||||||
size_t TileIterator<T, D>::get_current_index() const {
|
|
||||||
size_t index = 0;
|
|
||||||
for (size_t d = 0; d < D; ++d) {
|
|
||||||
size_t pos = static_cast<size_t>(m_pos[D - 1 - d]);
|
|
||||||
for (size_t p = 0; p < D - 1 - d; ++p) {
|
|
||||||
pos *= static_cast<size_t>(m_total[p]);
|
|
||||||
}
|
|
||||||
|
|
||||||
index += pos;
|
|
||||||
}
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, size_t D>
|
template <typename T, size_t D>
|
||||||
void TileIterator<T, D>::advance (size_t parAdvance) {
|
void TileIterator<T, D>::advance (size_t parAdvance) {
|
||||||
//TODO: implement
|
//TODO: implement
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, size_t D>
|
template <typename T, size_t D>
|
||||||
ptrdiff_t TileIterator<T, D>::distance_to (const MeshSelectionIterator& parOther) {
|
ptrdiff_t TileIterator<T, D>::distance_to (const TileIterator& parOther) {
|
||||||
//TODO: implement
|
return std::distance(this->get_current_index(), parOther.get_current_index());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, size_t D>
|
template <typename T, size_t D>
|
||||||
bool TileIterator<T, D>::equal (const MeshSelectionIterator& parOther) const {
|
bool TileIterator<T, D>::equal (const TileIterator& parOther) const {
|
||||||
//TODO: implement
|
return m_data == parOther.m_data and m_pos == parOther.m_pos;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
} //namespace dk
|
} //namespace dk
|
||||||
|
|
|
@ -24,19 +24,19 @@ namespace dk {
|
||||||
///--------------------------------------------------------------------------
|
///--------------------------------------------------------------------------
|
||||||
template <size_t D>
|
template <size_t D>
|
||||||
template <typename T>
|
template <typename T>
|
||||||
size_t Tyler<D>::push_layer (typename Layer<T, D>::streamer_type&& parStreamer) {
|
Layer<T, D>& Tyler<D>::push_layer (typename Layer<T, D>::streamer_type&& parStreamer) {
|
||||||
const size_t retval = m_layers.size();
|
auto newLayer = new Layer<T, D>(m_size, m_tilesize, m_tilesize, std::move(parStreamer));
|
||||||
m_layers.push_back(LayerPtr(new Layer<T, D>(m_size, m_tilesize, coords(1), std::move(parStreamer))));
|
m_layers.push_back(LayerPtr(newLayer));
|
||||||
return retval;
|
return *newLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
///--------------------------------------------------------------------------
|
///--------------------------------------------------------------------------
|
||||||
///--------------------------------------------------------------------------
|
///--------------------------------------------------------------------------
|
||||||
template <size_t D>
|
template <size_t D>
|
||||||
template <typename T>
|
template <typename T>
|
||||||
size_t Tyler<D>::push_layer (typename Layer<T, D>::streamer_type&& parStreamer, const coords& parSubdiv) {
|
Layer<T, D>& Tyler<D>::push_layer (typename Layer<T, D>::streamer_type&& parStreamer, const coords& parSubdiv) {
|
||||||
const size_t retval = m_layers.size();
|
auto newLayer = new Layer<T, D>(m_size * parSubdiv, m_tilesize / parSubdiv, m_tilesize, std::move(parStreamer));
|
||||||
m_layers.push_back(LayerPtr(new Layer<T, D>(m_size * parSubdiv, m_tilesize / parSubdiv, m_tilesize, std::move(parStreamer))));
|
m_layers.push_back(LayerPtr(newLayer));
|
||||||
return retval;
|
return *newLayer;
|
||||||
}
|
}
|
||||||
} //namespace dk
|
} //namespace dk
|
||||||
|
|
15
include/implem/viewport.inl
Normal file
15
include/implem/viewport.inl
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
namespace dk {
|
||||||
|
template <typename T, size_t D>
|
||||||
|
Viewport<T, D>::Viewport (Layer<T, D>& parLayer) :
|
||||||
|
m_layer(parLayer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, size_t D>
|
||||||
|
Viewport<T, D>::Viewport (Layer<T, D>& parLayer, const coords& parSize, const coords& parPos) :
|
||||||
|
m_size(parSize),
|
||||||
|
m_position(parPos),
|
||||||
|
m_layer(parLayer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
} //namespace dk
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef id583F11FE0934446E9135B4ADCFA1E4F9
|
#ifndef id583F11FE0934446E9135B4ADCFA1E4F9
|
||||||
#define id583F11FE0934446E9135B4ADCFA1E4F9
|
#define id583F11FE0934446E9135B4ADCFA1E4F9
|
||||||
|
|
||||||
|
#include <ciso646>
|
||||||
|
#include "implem/compatibility.h"
|
||||||
#include "implem/configuration.h"
|
#include "implem/configuration.h"
|
||||||
#include "implem/vector.hpp"
|
#include "implem/vector.hpp"
|
||||||
|
|
||||||
|
|
10
src/doorkeeperConfig.h.in
Normal file
10
src/doorkeeperConfig.h.in
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef idFEDC74BA6A4345AD8D76106228CB2E89
|
||||||
|
#define idFEDC74BA6A4345AD8D76106228CB2E89
|
||||||
|
|
||||||
|
#if !defined(NDEBUG)
|
||||||
|
# define DATA_PATH "@CMAKE_SOURCE_DIR@"
|
||||||
|
#else
|
||||||
|
# define DATA_PATH ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
19
src/main.cpp
19
src/main.cpp
|
@ -1,16 +1,27 @@
|
||||||
|
#include "doorkeeper.hpp"
|
||||||
|
#include "doorkeeperConfig.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "doorkeeper.hpp"
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
typedef dk::Tyler<2> Tiler;
|
typedef dk::Tyler<2> Tiler;
|
||||||
typedef std::unique_ptr<std::ifstream> ifstreamptr;
|
typedef std::unique_ptr<std::ifstream> ifstreamptr;
|
||||||
|
|
||||||
Tiler tiler(Tiler::coords(200, 150), Tiler::coords(64));
|
Tiler tiler(Tiler::coords(8, 6), Tiler::coords(64));
|
||||||
|
|
||||||
tiler.push_layer<int>(dk::Layer<int, 2>::streamer_type(ifstreamptr(new std::ifstream("test.map"))));
|
auto bottom_layer = &tiler.push_layer<int>(dk::Layer<int, 2>::streamer_type(ifstreamptr(new std::ifstream(DATA_PATH"test.map"))));
|
||||||
tiler.push_layer<char>(dk::Layer<char, 2>::streamer_type(ifstreamptr(new std::ifstream("test_2.map"))));
|
tiler.push_layer<char>(dk::Layer<char, 2>::streamer_type(ifstreamptr(new std::ifstream(DATA_PATH"test_2.map"))));
|
||||||
|
|
||||||
|
{
|
||||||
|
auto ittest = bottom_layer->begin();
|
||||||
|
for (int z = 0; z < 10; ++z) {
|
||||||
|
#if !defined(NDEBUG)
|
||||||
|
std::cout << "At tile " << ittest.position() << " value " << *ittest << '\n';
|
||||||
|
#endif
|
||||||
|
++ittest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(NDEBUG)
|
#if !defined(NDEBUG)
|
||||||
std::cout << "Map size: " << tiler.map_size() << '\n';
|
std::cout << "Map size: " << tiler.map_size() << '\n';
|
||||||
|
|
6
test.map
Normal file
6
test.map
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
1101111011
|
||||||
|
1100011000
|
||||||
|
1111011110
|
||||||
|
1111000110
|
||||||
|
0000010111
|
||||||
|
1111110111
|
1
test_2.map
Symbolic link
1
test_2.map
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
test.map
|
Loading…
Reference in a new issue