Skip to content
Snippets Groups Projects
Commit c1c194ce authored by BIOPZ-Johner Niklaus's avatar BIOPZ-Johner Niklaus
Browse files

Implemented SetFramPositions function

parent 766bfe3e
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment