diff --git a/modules/mol/base/src/coord_group.cc b/modules/mol/base/src/coord_group.cc index 3ab9ec3dbf7077bf88c56a62aa582984833e0a70..49c9f45128b7e61e7175a3844bd41f54bf65c08e 100644 --- a/modules/mol/base/src/coord_group.cc +++ b/modules/mol/base/src/coord_group.cc @@ -92,10 +92,14 @@ void CoordGroupHandle::SetStartTime(float t) } void CoordGroupHandle::SetFramePositions(uint frame, - const std::vector<geom::Vec3>& clist) + const geom::Vec3List& clist) { this->CheckValidity(); - //source_->SetFramePositions(frame, clist); + if (source_->IsMutable()) { + source_->SetFramePositions(frame, clist); + } else { + throw IntegrityError("Can't add set frame positions in immutable CoordGroup"); + } } @@ -164,7 +168,11 @@ void CoordGroupHandle::CheckValidity() const void CoordGroupHandle::SetAtomPos(uint frame, AtomHandle atom, const geom::Vec3& pos) { this->CheckValidity(); - source_->SetAtomPos(frame,atom,pos); + if (source_->IsMutable()) { + source_->SetAtomPos(frame,atom,pos); + } else { + throw IntegrityError("Can't set atom position in immutable CoordGroup"); + } } geom::Vec3 CoordGroupHandle::GetAtomPos(uint frame, AtomHandle atom) const diff --git a/modules/mol/base/src/coord_group.hh b/modules/mol/base/src/coord_group.hh index 754330d6c3b703809ee734e79e53f2afe58558bc..d72cf12e7e46f2a34c7751d359e9d416043d440c 100644 --- a/modules/mol/base/src/coord_group.hh +++ b/modules/mol/base/src/coord_group.hh @@ -69,7 +69,7 @@ public: /// \brief assign positions to the given frame - order and count must match /// initial atomlist - void SetFramePositions(uint frame, const std::vector<geom::Vec3>& clist); + void SetFramePositions(uint frame, const geom::Vec3List& clist); /// \brief get the positions of all the atoms in the given frame geom::Vec3List GetFramePositions(uint frame); diff --git a/modules/mol/base/src/coord_source.cc b/modules/mol/base/src/coord_source.cc index fa58ce041c963aaac3dbf522be37533fb33e0b4a..8d07abb40aeadbae49d768a51a564f94f6db21d0 100644 --- a/modules/mol/base/src/coord_source.cc +++ b/modules/mol/base/src/coord_source.cc @@ -82,6 +82,19 @@ void CoordSource::Capture() this->AddFrame(coords); } +void CoordSource::SetFramePositions(uint frame, const std::vector<geom::Vec3>& clist) +{ + CoordFrame& fp=*(GetFrame(frame)); + if(fp.size()!=clist.size()) { + throw Error("atom count and length of position vector are not equal"); + return; + } + unsigned int count=0; + for (std::vector<geom::Vec3>::const_iterator i=clist.begin(); i!=clist.end(); ++i) { + fp[count++]=*i; + } +} + void CoordSource::CaptureInto(int pos) { std::vector<geom::Vec3> coords; diff --git a/modules/mol/base/src/coord_source.hh b/modules/mol/base/src/coord_source.hh index 3f83e5a3e19800956364a2c679d38660412d0736..7c3ce96a2532063f4b7f2473947098e4a852a815 100644 --- a/modules/mol/base/src/coord_source.hh +++ b/modules/mol/base/src/coord_source.hh @@ -80,7 +80,8 @@ public: void Capture(); void CaptureInto(int pos); void Capture(uint f); - + void SetFramePositions(uint frame, const std::vector<geom::Vec3>& clist); + virtual void AddFrame(const std::vector<geom::Vec3>& coords) = 0; virtual void AddFrame(const std::vector<geom::Vec3>& coords,const geom::Vec3& cell_size,const geom::Vec3& cell_angles) = 0; virtual void InsertFrame(int pos, const std::vector<geom::Vec3>& coords) = 0;