diff --git a/modules/mol/base/src/impl/entity_impl.cc b/modules/mol/base/src/impl/entity_impl.cc index 4d378dbbe437aad6f1b79d9bcd9b3643ae6554cd..da4000aeff07016645ef80fcdc7ee86ddd704af4 100644 --- a/modules/mol/base/src/impl/entity_impl.cc +++ b/modules/mol/base/src/impl/entity_impl.cc @@ -323,7 +323,7 @@ AtomImplPtr EntityImpl::CreateAtom(const ResidueImplPtr& rp, void EntityImpl::DeleteAtom(const AtomImplPtr& atom) { atom_map_.erase(atom.get()); - atom_organizer_.Remove(atom); + atom_organizer_.Remove(atom, atom->TransformedPos()); } ResidueImplPtr EntityImpl::CreateResidue(const ChainImplPtr& cp, diff --git a/modules/mol/base/src/spatial_organizer.hh b/modules/mol/base/src/spatial_organizer.hh index 413bc6af478e5c50c438e2ff4ac59f223376138d..fce132a258574fa59bf012b185ec46c715a4fdee 100644 --- a/modules/mol/base/src/spatial_organizer.hh +++ b/modules/mol/base/src/spatial_organizer.hh @@ -113,6 +113,23 @@ public: } } + void Remove(const ITEM& item, const VEC& pos) { + // variation of the above, first try in organizer bucket + // for which you give a hint with pos. If this is successful, + // return. Call naive Remove otherwise + Index indx=gen_index(pos); + typename ItemMap::iterator i = map_.find(indx); + if(i != map_.end()) { + for (size_t j=0; j<i->second.size(); ++j) { + if (i->second[j].item==item) { + i->second.erase(i->second.begin()+j); + return; + } + } + } + Remove(item); + } + bool HasWithin(const VEC& pos, Real dist) const { Real dist2=dist*dist; Index imin = Index::Max(min_, gen_index(pos-VEC(dist,dist,dist)));