9 #ifndef IMPATOM_HIERARCHY_H
10 #define IMPATOM_HIERARCHY_H
12 #include <IMP/atom/atom_config.h>
27 #define IMP_GET_AS_DECL(UCName, lcname, CAPSNAME) \
28 UCName get_as_##lcname() const;
31 #define IMP_GET_AS_DEF(UCName, lcname, CAPSNAME) \
32 UCName Hierarchy::get_as_##lcname() const { \
33 if (UCName::particle_is_instance(get_particle())) { \
34 return UCName(get_particle()); \
41 #define IMP_FOREACH_HIERARCHY_TYPE_LIST(macro) \
42 macro(Atom, atom, ATOM_TYPE), \
43 macro(Residue, residue, RESIDUE_TYPE), \
44 macro(Chain, chain, CHAIN_TYPE), \
45 macro(Molecule, molecule, MOLECULE_TYPE), \
46 macro(Domain, domain, DOMAIN_TYPE), \
47 macro(Fragment, fragment, FRAGMENT_TYPE), \
48 macro(core::XYZ, xyz, XYZ_TYPE), \
49 macro(core::XYZR, xyzr, XYZR_TYPE), \
50 macro(Mass, mass, MASS_TYPE)
53 #define IMP_FOREACH_HIERARCHY_TYPE_STATEMENTS(macro) \
54 macro(Atom, atom, ATOM_TYPE); \
55 macro(Residue, residue, RESIDUE_TYPE); \
56 macro(Chain, chain, CHAIN_TYPE); \
57 macro(Molecule, molecule, MOLECULE_TYPE); \
58 macro(Domain, domain, DOMAIN_TYPE); \
59 macro(Fragment, fragment, FRAGMENT_TYPE); \
60 macro(core::XYZ, xyz, XYZ_TYPE); \
61 macro(core::XYZR, xyzr, XYZR_TYPE); \
62 macro(Mass, mass, MASS_TYPE)
65 #define IMP_FOREACH_HIERARCHY_TYPE_FUNCTIONS(macro) \
66 macro(Atom, atom, ATOM_TYPE) \
67 macro(Residue, residue, RESIDUE_TYPE) \
68 macro(Chain, chain, CHAIN_TYPE) \
69 macro(Molecule, molecule, MOLECULE_TYPE) \
70 macro(Domain, domain, DOMAIN_TYPE) \
71 macro(Fragment, fragment, FRAGMENT_TYPE) \
72 macro(core::XYZ, xyz, XYZ_TYPE) \
73 macro(core::XYZR, xyzr, XYZR_TYPE) \
74 macro(Mass, mass, MASS_TYPE) \
75 IMP_REQUIRE_SEMICOLON_NAMESPACE
78 #define IMP_CAPS_NAME(UCName, lcname, CAPSNAME) \
82 IMPATOM_BEGIN_NAMESPACE
91 IMP_DECORATORS_DECL(Hierarchy, Hierarchies);
225 H::decorate_particle(p, get_traits());
232 || h.get_traits() == get_traits(),
233 "Cannot construct a IMP.atom.Hierarchy from a general "
234 " IMP.core.Hierarchy");
238 const ParticlesTemp &children) {
239 H::setup_particle(p, get_traits());
241 for (
unsigned int i=0; i< children.size(); ++i) {
245 ret.add_child(Hierarchy(children[i]));
253 const ParticlesTemp &children
256 H::setup_particle(p, get_traits());
258 for (
unsigned int i=0; i< children.size(); ++i) {
275 return H::particle_is_instance(p, get_traits());
279 return H::particle_is_instance(m->get_particle(p), get_traits());
287 bool get_is_valid(
bool print_info)
const;
299 H hd= H::get_child(i);
304 Hierarchies ret(get_number_of_children());
305 for (
unsigned int i=0; i< get_number_of_children(); ++i) {
306 ret[i]= get_child(i);
314 C ret(get_number_of_children());
315 for (
unsigned int i=0; i< get_number_of_children(); ++i) {
316 ret[i]= get_child(i);
323 H hd= H::get_parent();
340 IMP_FOREACH_HIERARCHY_TYPE_FUNCTIONS(IMP_GET_AS_DECL);
350 IMP_DECORATORS_DEF(Hierarchy, Hierarchies);
356 enum GetByType {ATOM_TYPE, RESIDUE_TYPE, CHAIN_TYPE, MOLECULE_TYPE.
357 DOMAIN_TYPE, FRAGMENT_TYPE,
358 XYZ_TYPE,XYZR_TYPE,MASS_TYPE};
361 IMP_FOREACH_HIERARCHY_TYPE_LIST(IMP_CAPS_NAME)
371 IMPATOMEXPORT Hierarchies
389 IMPATOMEXPORT Hierarchy
403 IMPATOMEXPORT Hierarchy
432 for (
unsigned int i=0; i< h.size(); ++i) {
434 ret.insert(ret.end(), cur.begin(), cur.end());
436 return get_as<Hierarchies>(ret);
443 IMP::core::show<Hierarchy>(h, out);
458 std::string name=std::string(
"created rigid body"));
475 Hierarchy reference);
545 IMPATOM_END_NAMESPACE