Skip to content
Snippets Groups Projects
Commit 6fd32068 authored by Niklaus Johner's avatar Niklaus Johner
Browse files

Added the possibility to wrap an entity in a periodic cell on a per-atom base

instead of per-residue base in mol::alg::structure_analysis::WrapEntityInPeriodicCell
parent 50711882
Branches
Tags
No related merge requests found
......@@ -63,10 +63,10 @@ Real CalculateAverageAgreementWithDensityMap(const geom::Vec3List& vl, img::MapH
#endif
void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 basis_vec, bool group_residues){
mol::XCSEditor edi=eh.EditXCS(mol::BUFFERED_EDIT);
geom::Vec3 cm,wrapped_cm,shift;
ResidueHandleList residues=eh.GetResidueList();
unsigned int n_residues=eh.GetResidueCount();
if (group_residues) {
geom::Vec3 cm,wrapped_cm,shift;
ResidueHandleList residues=eh.GetResidueList();
unsigned int n_residues=eh.GetResidueCount();
for (unsigned int i=0; i<n_residues; ++i) {
ResidueHandle r=residues[i];
AtomHandleList atoms=r.GetAtomList();
......@@ -75,17 +75,23 @@ void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom:
edi.SetAtomPos((*a),geom::WrapVec3((*a).GetPos(),ref_pos,basis_vec));
}
}
for (unsigned int i=0; i<n_residues; ++i) {
ResidueHandle r=residues[i];
cm=r.GetCenterOfMass();
wrapped_cm=geom::WrapVec3(cm,cell_center,basis_vec);
if (wrapped_cm==cm) continue;
AtomHandleList atoms=r.GetAtomList();
unsigned int n_atoms=r.GetAtomCount();
shift=wrapped_cm-cm;
for (unsigned int j=0; j<n_atoms; ++j) {
edi.SetAtomPos(atoms[j],atoms[j].GetPos()+shift);
}
}
}
for (unsigned int i=0; i<n_residues; ++i) {
ResidueHandle r=residues[i];
cm=r.GetCenterOfMass();
wrapped_cm=geom::WrapVec3(cm,cell_center,basis_vec);
if (wrapped_cm==cm) continue;
AtomHandleList atoms=r.GetAtomList();
unsigned int n_atoms=r.GetAtomCount();
shift=wrapped_cm-cm;
for (unsigned int j=0; j<n_atoms; ++j) {
edi.SetAtomPos(atoms[j],atoms[j].GetPos()+shift);
else {
AtomHandleList atoms=eh.GetAtomList();
for (AtomHandleList::iterator a=atoms.begin(), e=atoms.end(); a!=e; ++a) {
edi.SetAtomPos((*a),geom::WrapVec3((*a).GetPos(),cell_center,basis_vec));
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment