41 template<
typename T, std::
size_t dim>
47 template<
typename T, std::
size_t dim>
60 data.insert(
data.end(), o.data.begin(), o.data.end());
73 template<
typename T, std::
size_t dim>
84 std::make_move_iterator(o.data.begin()),
85 std::make_move_iterator(o.data.end()));
96 template<
typename T, std::
size_t dim>
101 for(
size_t i=0; i<
nbCells; ++i)
105 template<
typename T, std::
size_t dim>
116 for(
size_t i=0; i<
nbCells; ++i)
124 for(
size_t i=0; i<
nbCells; ++i)
134 template<
typename T, std::
size_t dim>
150 std::make_move_iterator(o.data.begin()),
151 std::make_move_iterator(o.data.end()));
155 for(
size_t i=0; i<
nbCells; ++i)
165 template<
typename T, std::
size_t dim>
168 return (
cells[0]==
nullptr);
170 template<
typename T, std::
size_t dim>
175 template<
typename T, std::
size_t dim>
178 return (
data.size() == 0);
180 template<
typename T, std::
size_t dim>
185 for(
size_t i=0; i<
dim; ++i)
191 template<
typename T, std::
size_t dim>
194 return idx(pts.features.col(d).head(
dim));
196 template<
typename T, std::
size_t dim>
201 template<
typename T, std::
size_t dim>
206 template<
typename T, std::
size_t dim>
211 template<
typename T, std::
size_t dim>
216 template<
typename T, std::
size_t dim>
223 template<
typename T, std::
size_t dim>
230 template<
typename T, std::
size_t dim>
238 Vector minValues = pts.features.rowwise().minCoeff();
239 Vector maxValues = pts.features.rowwise().maxCoeff();
244 Point radii = max - min;
245 box.center = min + radii * 0.5;
247 box.radius = radii(0);
248 for(
size_t i=1; i<
dim; ++i)
249 if (box.radius < radii(i)) box.radius = radii(i);
254 const size_t nbpts = pts.getNbPoints();
255 std::vector<Id> indexes;
256 indexes.reserve(nbpts);
258 for(
size_t i=0; i<nbpts; ++i)
259 indexes.emplace_back(
Id(i));
264 return this->
build(pts, std::move(datas), std::move(box), maxDataByNode, maxSizeByNode, parallelBuild);
268 template<
typename T, std::
size_t dim>
303 template<
typename T, std::
size_t dim>
305 size_t maxDataByNode,
T maxSizeByNode,
bool parallelBuild)
312 if((
bb.
radius*2.0 <= maxSizeByNode) or (datas.size() <= maxDataByNode))
316 std::make_move_iterator(datas.begin()), make_move_iterator(datas.end()));
321 const std::size_t nbData = datas.size();
324 for(
size_t i=0; i<
nbCells; ++i)
325 sDatas[i].reserve(nbData);
327 for(
auto&& d : datas)
328 (sDatas[
idx(pts, d)]).emplace_back(d);
330 for(
size_t i=0; i<
nbCells; ++i)
331 sDatas[i].shrink_to_fit();
335 const T half_radius = this->
bb.
radius * 0.5;
336 for(
size_t i=0; i<
nbCells; ++i)
339 boxes[i].radius = half_radius;
340 boxes[i].center = this->
bb.
center + offset;
345 std::vector<std::future<void>> futures;
347 for(
size_t i=0; i<
nbCells; ++i)
349 auto compute = [maxDataByNode, maxSizeByNode, i, &pts, &sDatas, &boxes,
this](){
356 this->
cells[i]->
build(pts, std::move(sDatas[i]), std::move(boxes[i]), maxDataByNode, maxSizeByNode,
false);
360 futures.push_back( std::async( std::launch::async, compute ));
365 for(
auto& f : futures) f.get();
367 return (!
isLeaf() and ret);
371 template<
typename T, std::
size_t dim>
372 template<
typename Callback>
377 if (!cb(*
this))
return false;
381 for (
size_t i=0; i<
nbCells; ++i)
std::vector< Data > DataContainer
Octree_< T, dim > * operator[](std::size_t idx)
typename PM::DataPoints DP
Octree_< T, dim > & operator=(const Octree_< T, dim > &o)
DataContainer * getData()
DataContainer toData(const DP &pts, const std::vector< Id > &ids)
std::size_t getDepth() const
std::size_t idx(const Point &pt) const
static constexpr std::size_t nbCells
Eigen::Matrix< T, dim, 1 > Point
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector over ScalarType.
bool build(const DP &pts, size_t maxDataByNode=1, T maxSizeByNode=T(0.), bool parallelBuild=false)