19 #ifndef OST_GFX_IMPL_MAP_OCTREE_HH
20 #define OST_GFX_IMPL_MAP_OCTREE_HH
29 namespace ost {
namespace gfx {
namespace impl {
49 first_child_(first_child), branch_x_(branch_x),
50 branch_y_(branch_y), branch_z_(branch_z), is_leaf_(false),
54 branch_x_(false), branch_y_(false), branch_z_(false), is_leaf_(false),
77 assert(0 &&
"what the heck?");
84 float GetMin()
const {
return min_; }
85 float GetMax()
const {
return max_; }
86 bool IsLeaf()
const {
return is_leaf_; }
118 template <
typename F>
119 void VisitDF(F& f)
const
121 if (levels_.empty()) {
127 assert(levels_[0].size()==1);
128 if (f.VisitNode(levels_[0][0], 0, ext)) {
129 this->VisitDFRec<F>(levels_[0][0], f, 1, ext, map);
136 for (
char i=15; i>=0; --i) {
145 template <
typename F>
161 uint16_t bit_mask=1<<(LastSetBit(ems));
163 range_x[0][1]=range_x[0][0]+bit_mask-1;
164 range_x[1][0]=ext.
GetEnd()[0]-(ems & ~bit_mask);
165 range_x[1][1]=ext.
GetEnd()[0];
168 range_x[0][1]=ext.
GetEnd()[0];
172 uint16_t bit_mask=1<<(LastSetBit(ems));
174 range_y[0][1]=range_y[0][0]+bit_mask-1;
175 range_y[1][0]=ext.
GetEnd()[1]-(ems & ~bit_mask);
176 range_y[1][1]=ext.
GetEnd()[1];
179 range_y[0][1]=ext.
GetEnd()[1];
183 uint16_t bit_mask=1<<(LastSetBit(ems));
185 range_z[0][1]=range_z[0][0]+bit_mask-1;
186 range_z[1][0]=ext.
GetEnd()[2]-(ems & ~bit_mask);
187 range_z[1][1]=ext.
GetEnd()[2];
190 range_z[0][1]=ext.
GetEnd()[2];
192 for (
int i=0; i<cx; ++i) {
193 for (
int j=0; j<cy; ++j) {
194 for (
int k=0; k<cz; ++k, ++c) {
196 f.VisitLeaf(map,
img::Point(range_x[i][0], range_y[j][0],
204 if (f.VisitNode(cn, level, ext)) {
205 this->VisitDFRec<F>(cn, f, level+1, ext, map);
214 std::pair<float, float> BuildOctreeRec(
const OcRangeVector& range_vec,
221 std::vector<OcNodeEntryList> levels_;