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

Added a function to wrap an entity in a periodic cell

parent 3e02346f
No related branches found
No related tags found
No related merge requests found
......@@ -28,4 +28,5 @@ void export_StructureAnalysis()
{
def("GetPosListFromView",&GetPosListFromView, (arg("view")));
def("CalculateAgreementWithDensityMap",&CalculateAgreementWithDensityMap,(arg("pos_list"),arg("density_map")));
def("WrapEntityInPeriodicCell",&WrapEntityInPeriodicCell,(arg("Entity"),arg("cell_center"),arg("nasis_vec")));
}
\ No newline at end of file
......@@ -51,4 +51,24 @@ Real CalculateAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle&
return sum;
}
void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 basis_vec){
mol::XCSEditor edi=eh.EditXCS(mol::BUFFERED_EDIT);
geom::Vec3 cm,wrapped_cm,shift;
edi=eh.EditXCS();
ResidueHandleList residues=eh.GetResidueList();
unsigned int n_residues=eh.GetResidueCount();
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);
}
}
}
}}} //ns
......@@ -26,11 +26,13 @@
#include <ost/mol/alg/module_config.hh>
#include <ost/mol/entity_view.hh>
#include <ost/mol/entity_handle.hh>
#include <ost/img/map.hh>
namespace ost { namespace mol { namespace alg {
geom::Vec3List DLLEXPORT_OST_MOL_ALG GetPosListFromView(const EntityView& view);
Real DLLEXPORT_OST_MOL_ALG CalculateAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map);
void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 basis_vec);
}}}//ns
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment