30 #ifndef PLANNER_CSPACE_BLOCKMEM_GRIDMAP_H 31 #define PLANNER_CSPACE_BLOCKMEM_GRIDMAP_H 37 template <
class T,
int DIM,
int NONCYCLIC,
int BLOCK_WIDTH = 0x20>
41 std::unique_ptr<T[]>
c_;
54 for (
int i = 0; i < NONCYCLIC; i++)
57 addr += pos[i] % BLOCK_WIDTH;
58 baddr *= block_size_[i];
59 baddr += pos[i] / BLOCK_WIDTH;
61 for (
int i = NONCYCLIC; i < DIM; i++)
69 std::function<void(CyclicVecInt<3, 2>,
size_t&,
size_t&)>
getAddressor()
const 74 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
101 auto size_tmp =
size;
103 for (
int i = 0; i < NONCYCLIC; i++)
105 if (size_tmp[i] < BLOCK_WIDTH)
106 size_tmp[i] = BLOCK_WIDTH;
111 for (
int i = 0; i < DIM; i++)
117 block_size_[i] = (size_tmp[i] + width - 1) / width;
125 block_ser_size_ *= width;
126 block_num_ *= block_size_[i];
130 c_.reset(
new T[ser_size_]);
144 if (addr >= block_ser_size_ || baddr >= block_num_)
146 dummy_ = std::numeric_limits<T>::max();
149 return c_[baddr * block_ser_size_ + addr];
155 if (addr >= block_ser_size_ || baddr >= block_num_)
156 return std::numeric_limits<T>::max();
157 return c_[baddr * block_ser_size_ + addr];
161 for (
int i = 0; i < NONCYCLIC; i++)
163 if (pos[i] < tolerance || size_[i] - tolerance <= pos[i])
166 for (
int i = NONCYCLIC; i < DIM; i++)
168 if (pos[i] < 0 || size_[i] <= pos[i])
183 #endif // PLANNER_CSPACE_BLOCKMEM_GRIDMAP_H
void reset(const CyclicVecInt< DIM, NONCYCLIC > &size)
BlockMemGridmap(const CyclicVecInt< DIM, NONCYCLIC > &size_)
CyclicVecInt< DIM, NONCYCLIC > block_size_
bool validate(const CyclicVecInt< DIM, NONCYCLIC > &pos, const int tolerance=0) const
void block_addr(const CyclicVecInt< DIM, NONCYCLIC > &pos, size_t &baddr, size_t &addr) const
const CyclicVecInt< DIM, NONCYCLIC > & size() const
CyclicVecInt< DIM, NONCYCLIC > size_
const BlockMemGridmap< T, DIM, NONCYCLIC, BLOCK_WIDTH > & operator=(const BlockMemGridmap< T, DIM, NONCYCLIC, BLOCK_WIDTH > &gm)
T & operator[](const CyclicVecInt< DIM, NONCYCLIC > &pos)
void clear_positive(const T zero)
std::function< void(CyclicVecInt< 3, 2 >, size_t &, size_t &)> getAddressor() const
const T operator[](const CyclicVecInt< DIM, NONCYCLIC > &pos) const