92 void Add(
const ITEM& item,
const VEC& pos) {
93 bool first = map_.empty();
94 Index indx=gen_index(pos);
95 map_[indx].push_back(Entry(item,pos));
97 min_ = Index::Min(min_, indx);
98 max_ = Index::Max(max_, indx);
116 void Remove(
const ITEM& item,
const VEC& pos) {
120 Index indx=gen_index(pos);
121 typename ItemMap::iterator i = map_.find(indx);
122 if(i != map_.end()) {
123 for (
size_t j=0; j<i->second.size(); ++j) {
124 if (i->second[j].item==item) {
125 i->second.erase(i->second.begin()+j);
134 Real dist2=dist*dist;
135 Index imin = Index::Max(min_, gen_index(pos-VEC(dist,dist,dist)));
136 Index imax = Index::Min(max_, gen_index(pos+VEC(dist,dist,dist)));
137 const size_t tmp = (imax.u-imin.u+1)*(imax.v-imin.v+1)*(imax.w-imin.w+1);
138 if (tmp > map_.size()) {
139 return this->has_within_all_buckets(pos, dist2);
141 for(
int wc=imin.w;wc<=imax.w;++wc) {
142 for(
int vc=imin.v;vc<=imax.v;++vc) {
143 for(
int uc=imin.u;uc<=imax.u;++uc) {
144 typename ItemMap::const_iterator map_it = map_.find(Index(uc,vc,wc));
145 if(map_it!=map_.end()) {
146 for(
typename EntryList::const_iterator entry_it = map_it->second.begin();
147 entry_it != map_it->second.end(); ++entry_it) {
154 Real delta_x = entry_it->pos[0]-pos[0];
155 Real delta_y = entry_it->pos[1]-pos[1];
156 Real delta_z = entry_it->pos[2]-pos[2];
157 if(delta_x*delta_x+delta_y*delta_y+delta_z*delta_z<=dist2) {
169 Real dist2=dist*dist;
170 Index imin = gen_index(pos-VEC(dist,dist,dist));
171 Index imax = gen_index(pos+VEC(dist,dist,dist));
175 for(
int wc=imin.w;wc<=imax.w;++wc) {
176 for(
int vc=imin.v;vc<=imax.v;++vc) {
177 for(
int uc=imin.u;uc<=imax.u;++uc) {
178 typename ItemMap::const_iterator map_it = map_.find(Index(uc,vc,wc));
180 if(map_it!=map_.end()) {
181 for(
typename EntryList::const_iterator entry_it = map_it->second.begin();
182 entry_it != map_it->second.end(); ++entry_it) {
189 Real delta_x = entry_it->pos[0]-pos[0];
190 Real delta_y = entry_it->pos[1]-pos[1];
191 Real delta_z = entry_it->pos[2]-pos[2];
192 if(delta_x*delta_x+delta_y*delta_y+delta_z*delta_z<=dist2) {
193 item_list.push_back(entry_it->item);