Hierarchy create_clone(Hierarchy d) { std::map<Particle*,Particle*> map; Hierarchy nh= clone_internal(d, map, true); Bonds bds= get_internal_bonds(d); for (unsigned int i=0; i< bds.size(); ++i) { Bonded e0= bds[i].get_bonded(0); Bonded e1= bds[i].get_bonded(1); Particle *np0= map[e0.get_particle()]; Particle *np1= map[e1.get_particle()]; Bonded ne0, ne1; if (Bonded::particle_is_instance(np0)) { ne0=Bonded(np0); } else { ne0=Bonded::setup_particle(np0); } if (Bonded::particle_is_instance(np1)) { ne1=Bonded(np1); } else { ne1=Bonded::setup_particle(np1); } create_bond(ne0, ne1, bds[i]); } return nh; }
void Bonded::show(std::ostream &out) const { if (*this == Bonded()) { out << "Null Bonded"; return; } out << "Particle " << get_particle()->get_name() << " is bonded to "; for (unsigned int i = 0; i < get_number_of_bonds(); ++i) { Bond b = get_bond(i); if (b.get_bonded(0) == *this) { out << b.get_bonded(1).get_particle()->get_name(); } else { out << b.get_bonded(0).get_particle()->get_name(); } out << " "; } }