示例#1
0
void destroy(Hierarchy d) {
  ParticlesTemp all;
  //core::Hierarchy h=d;

  core::gather(d, True(), std::back_inserter(all));
  for (unsigned int i=0; i< all.size(); ++i) {
    if (Bonded::particle_is_instance(all[i])) {
     Bonded b(all[i]);
      while (b.get_number_of_bonds() > 0) {
        destroy_bond(b.get_bond(b.get_number_of_bonds()-1));
      }
    }
    Hierarchy hc(all[i]);
    while (hc.get_number_of_children() > 0) {
      hc.remove_child(hc.get_child(hc.get_number_of_children()-1));
    }
  }

  // If this Hierarchy has a parent, remove the relationship
  Hierarchy parent = d.get_parent();
  if (parent) {
    parent.remove_child(d);
  }

  for (unsigned int i=0; i< all.size(); ++i) {
    all[i]->get_model()->remove_particle(all[i]);
  }
}
示例#2
0
文件: Chain.cpp 项目: jennystone/imp
Chain get_chain(Hierarchy h) {
    do {
        if (h == Hierarchy()) {
            return Chain();
        }

        if (Chain::get_is_setup(h)) {
            return Chain(h);
        }
    } while ((h = h.get_parent()));
    return Chain();
}