Skip to content
Snippets Groups Projects
Commit 7e55657f authored by ansgar's avatar ansgar
Browse files

added atom pos access in CoordGroup

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@1895 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent ad68e27a
No related branches found
No related tags found
No related merge requests found
...@@ -48,6 +48,8 @@ void export_CoordGroup() ...@@ -48,6 +48,8 @@ void export_CoordGroup()
.def("GetAtomCount",&CoordGroupHandle::GetAtomCount) .def("GetAtomCount",&CoordGroupHandle::GetAtomCount)
.def("GetFrameCount",&CoordGroupHandle::GetFrameCount) .def("GetFrameCount",&CoordGroupHandle::GetFrameCount)
.def("SetFramePositions",&CoordGroupHandle::SetFramePositions) .def("SetFramePositions",&CoordGroupHandle::SetFramePositions)
.def("SetAtomPos",&CoordGroupHandle::SetAtomPos)
.def("GetAtomPos",&CoordGroupHandle::GetAtomPos)
.def("CopyFrame",&CoordGroupHandle::CopyFrame) .def("CopyFrame",&CoordGroupHandle::CopyFrame)
.def("IsValid", &CoordGroupHandle::IsValid) .def("IsValid", &CoordGroupHandle::IsValid)
.def("Capture", capture1) .def("Capture", capture1)
......
...@@ -100,6 +100,18 @@ void CoordGroupHandle::CheckValidity() const ...@@ -100,6 +100,18 @@ void CoordGroupHandle::CheckValidity() const
} }
} }
void CoordGroupHandle::SetAtomPos(uint frame, AtomHandle atom, const geom::Vec3& pos)
{
this->CheckValidity();
source_->SetAtomPos(frame,atom,pos);
}
geom::Vec3 CoordGroupHandle::GetAtomPos(uint frame, AtomHandle atom) const
{
this->CheckValidity();
return source_->GetAtomPos(frame,atom);
}
CoordFramePtr CoordGroupHandle::GetFrame(uint frame) const CoordFramePtr CoordGroupHandle::GetFrame(uint frame) const
{ {
this->CheckValidity(); this->CheckValidity();
......
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
/// \brief assign positions to the given frame - order and count must match /// \brief assign positions to the given frame - order and count must match
/// initial atomlist /// initial atomlist
void SetFramePositions(uint frame, const std::vector<geom::Vec3>& clist); void SetFramePositions(uint frame, const std::vector<geom::Vec3>& clist);
/// \brief copy atom positions of given frame to stored atoms in entity /// \brief copy atom positions of given frame to stored atoms in entity
void CopyFrame(uint frame); void CopyFrame(uint frame);
...@@ -68,6 +68,12 @@ public: ...@@ -68,6 +68,12 @@ public:
/// \brief add frame /// \brief add frame
void AddFrame(const std::vector<geom::Vec3>& clist); void AddFrame(const std::vector<geom::Vec3>& clist);
/// \brief set an indidivial atom position in the given frame
void SetAtomPos(uint frame, AtomHandle atom, const geom::Vec3& pos);
/// \brief retrieve an indidivial atom position in the given frame
geom::Vec3 GetAtomPos(uint frame, AtomHandle atom) const;
/// \brief check for handle validity /// \brief check for handle validity
bool IsValid() const; bool IsValid() const;
......
...@@ -31,11 +31,17 @@ namespace ost { namespace mol { ...@@ -31,11 +31,17 @@ namespace ost { namespace mol {
CoordSource::CoordSource(const AtomHandleList& atoms): CoordSource::CoordSource(const AtomHandleList& atoms):
atoms_(atoms), mutable_(false) atoms_(atoms),
entity_(),
mutable_(false),
atom_dict_()
{ {
if (!atoms_.empty()) { if (!atoms_.empty()) {
entity_=atoms_.front().GetEntity(); entity_=atoms_.front().GetEntity();
} }
for(uint n=0;n<atoms_.size();++n) {
atom_dict_[atoms_[n].GetHashCode()]=n;
}
} }
...@@ -105,8 +111,6 @@ CoordSourcePtr CoordSource::Extract(int start, int stop, int step) ...@@ -105,8 +111,6 @@ CoordSourcePtr CoordSource::Extract(int start, int stop, int step)
return in_mem_source; return in_mem_source;
} }
EntityHandle CoordSource::GetEntity() const EntityHandle CoordSource::GetEntity() const
{ {
return entity_; return entity_;
...@@ -132,4 +136,25 @@ const AtomHandleList& CoordSource::GetAtomList() const ...@@ -132,4 +136,25 @@ const AtomHandleList& CoordSource::GetAtomList() const
return atoms_; return atoms_;
} }
}} void CoordSource::SetAtomPos(uint frame, AtomHandle atom, const geom::Vec3& pos)
{
if(!atom.IsValid()) return;
std::map<long,uint>::iterator it = atom_dict_.find(atom.GetHashCode());
if(it!=atom_dict_.end()) {
CoordFrame& fp=*(GetFrame(frame));
fp[it->second]=pos;
}
}
geom::Vec3 CoordSource::GetAtomPos(uint frame, AtomHandle atom) const
{
if(!atom.IsValid()) return geom::Vec3();
std::map<long,uint>::const_iterator it = atom_dict_.find(atom.GetHashCode());
if(it!=atom_dict_.end()) {
const CoordFrame& fp=*(GetFrame(frame));
return fp[it->second];
}
return geom::Vec3();
}
}} // ns
...@@ -49,13 +49,18 @@ public: ...@@ -49,13 +49,18 @@ public:
virtual uint GetFrameCount()=0; virtual uint GetFrameCount()=0;
virtual CoordFramePtr GetFrame(uint frame_id)=0; virtual CoordFramePtr GetFrame(uint frame_id) const = 0;
int GetAtomCount() const; int GetAtomCount() const;
EntityHandle GetEntity() const; EntityHandle GetEntity() const;
const AtomHandleList& GetAtomList() const; const AtomHandleList& GetAtomList() const;
void SetAtomPos(uint frame, AtomHandle atom, const geom::Vec3& pos);
geom::Vec3 GetAtomPos(uint frame, AtomHandle atom) const;
/// \brief assign the coordinates in the given frame to the atoms /// \brief assign the coordinates in the given frame to the atoms
void CopyFrame(uint frame); void CopyFrame(uint frame);
bool IsMutable() const; bool IsMutable() const;
...@@ -70,6 +75,7 @@ private: ...@@ -70,6 +75,7 @@ private:
AtomHandleList atoms_; AtomHandleList atoms_;
EntityHandle entity_; EntityHandle entity_;
bool mutable_; bool mutable_;
std::map<long,uint> atom_dict_;
}; };
}} }}
......
...@@ -14,7 +14,7 @@ uint InMemCoordSource::GetFrameCount() ...@@ -14,7 +14,7 @@ uint InMemCoordSource::GetFrameCount()
return frames_.size(); return frames_.size();
} }
CoordFramePtr InMemCoordSource::GetFrame(uint frame_id) CoordFramePtr InMemCoordSource::GetFrame(uint frame_id) const
{ {
return frame_id>=frames_.size() ? CoordFramePtr() : frames_[frame_id]; return frame_id>=frames_.size() ? CoordFramePtr() : frames_[frame_id];
......
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
virtual uint GetFrameCount(); virtual uint GetFrameCount();
virtual CoordFramePtr GetFrame(uint frame_id); virtual CoordFramePtr GetFrame(uint frame_id) const;
void AddFrame(const CoordFramePtr& frame); void AddFrame(const CoordFramePtr& frame);
virtual void AddFrame(const std::vector<geom::Vec3>& coords); virtual void AddFrame(const std::vector<geom::Vec3>& coords);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment