// write approximate function, remove rigid bodies for intermediates core::RigidBody create_rigid_body(const Hierarchies &h, std::string name) { if (h.empty()) return core::RigidBody(); for (unsigned int i = 0; i < h.size(); ++i) { IMP_USAGE_CHECK(h[i].get_is_valid(true), "Invalid hierarchy passed."); } kernel::Particle *rbp = new kernel::Particle(h[0]->get_model()); rbp->set_name(name); kernel::ParticlesTemp all; for (unsigned int i = 0; i < h.size(); ++i) { kernel::ParticlesTemp cur = rb_process(h[i]); all.insert(all.end(), cur.begin(), cur.end()); } core::RigidBody rbd = core::RigidBody::setup_particle(rbp, all); rbd.set_coordinates_are_optimized(true); for (unsigned int i = 0; i < h.size(); ++i) { IMP_INTERNAL_CHECK(h[i].get_is_valid(true), "Invalid hierarchy produced"); } return rbd; }
IMP::core::RigidBody create_compatible_rigid_body(Hierarchy h, Hierarchy reference) { ParticlesTemp hl= get_leaves(h); ParticlesTemp rl= get_leaves(reference); algebra::Transformation3D tr = algebra::get_transformation_aligning_first_to_second(rl, hl); algebra::Transformation3D rtr = core::RigidMember(reference).get_rigid_body().\ get_reference_frame().get_transformation_to(); algebra::Transformation3D rbtr= tr*rtr; Particle *rbp= new Particle(h->get_model()); rbp->set_name(h->get_name()+" rigid body"); ParticlesTemp all = rb_process(h); core::RigidBody rbd = core::RigidBody::setup_particle(rbp, algebra::ReferenceFrame3D(rbtr)); for (unsigned int i=0; i< all.size(); ++i) { rbd.add_member(all[i]); } rbd.set_coordinates_are_optimized(true); IMP_INTERNAL_CHECK(h.get_is_valid(true), "Invalid hierarchy produced"); return rbd; }