Beispiel #1
0
void HierarchySaveLink::add_recursive(Model *m, kernel::ParticleIndex root,
                                      kernel::ParticleIndex p,
                                      kernel::ParticleIndexes rigid_bodies,
                                      RMF::NodeHandle cur, Data &data) {
  IMP_LOG_VERBOSE("Adding " << atom::Hierarchy(m, p) << std::endl);
  // make sure not to double add
  if (p != root) set_association(cur, m->get_particle(p));
  data.save_static.setup_node(m, p, cur);
  bool local_coords =
      data.save_local_coordinates.setup_node(m, p, cur, rigid_bodies);
  bool global_coords =
      data.save_global_coordinates.setup_node(m, p, cur, rigid_bodies);
  bool static_coords =
      data.save_static_coordinates.setup_node(m, p, cur, rigid_bodies);
  IMP_INTERNAL_CHECK(!local_coords || !global_coords,
                     "A particle can't have saved local and global coords");

  do_setup_node(m, root, p, cur);

  if (core::RigidBody::get_is_setup(m, p)) {
    rigid_bodies.push_back(p);
  }
  for (unsigned int i = 0; i < atom::Hierarchy(m, p).get_number_of_children();
       ++i) {
    kernel::ParticleIndex pc = atom::Hierarchy(m, p).get_child_index(i);
    RMF::NodeHandle curc =
        cur.add_child(get_good_name(m, pc), RMF::REPRESENTATION);
    add_recursive(m, root, pc, rigid_bodies, curc, data);
  }
}
Beispiel #2
0
void HierarchyLoadLink::create_recursive(kernel::Model *m,
                                         kernel::ParticleIndex root,
                                         kernel::ParticleIndex cur,
                                         RMF::NodeConstHandle name,
                                         kernel::ParticleIndexes rigid_bodies,
                                         Data &data) {
  set_association(name, m->get_particle(cur));
  unsigned int state = get_coords_state(name, intermediate_particle_factory_,
                                        reference_frame_factory_);
  data.load_static.setup_particle(name, m, cur, rigid_bodies);
  data.load_local_coordinates.setup_particle(name, state, m, cur, rigid_bodies);
  data.load_static_coordinates.setup_particle(name, state, m, cur,
                                              rigid_bodies);
  data.load_global_coordinates.setup_particle(name, state, m, cur,
                                              rigid_bodies);

  if (core::RigidBody::get_is_setup(m, cur)) {
    rigid_bodies.push_back(cur);
  }
  RMF::NodeConstHandles ch = name.get_children();
  for (unsigned int i = 0; i < ch.size(); ++i) {
    if (ch[i].get_type() == RMF::REPRESENTATION) {
      kernel::ParticleIndex child = m->add_particle(ch[i].get_name());
      atom::Hierarchy(m, cur)
          .add_child(atom::Hierarchy::setup_particle(m, child));
      create_recursive(m, root, child, ch[i], rigid_bodies, data);
    }
  }
  do_setup_particle(m, root, cur, name);
}
Beispiel #3
0
void HierarchyLoadLink::add_link_recursive(kernel::Model *m,
                                           kernel::ParticleIndex root,
                                           kernel::ParticleIndex cur,
                                           RMF::NodeConstHandle node,
                                           kernel::ParticleIndexes rigid_bodies,
                                           Data &data) {
  IMP_USAGE_CHECK(get_good_name(m, cur) == node.get_name(),
                  "Names don't match");
  set_association(node, m->get_particle(cur), true);
  RMF::NodeConstHandles ch = node.get_children();
  unsigned int state = get_coords_state(node, intermediate_particle_factory_,
                                        reference_frame_factory_);
  data.load_static.link_particle(node, m, cur, rigid_bodies);
  data.load_global_coordinates.link_particle(node, state, m, cur, rigid_bodies);
  // data.load_static_coordinates.link_particle(node, m, cur, rigid_bodies);
  data.load_local_coordinates.link_particle(node, state, m, cur, rigid_bodies);

  do_link_particle(m, root, cur, node);

  if (core::RigidBody::get_is_setup(m, cur)) {
    rigid_bodies.push_back(cur);
  }
  int child = 0;
  for (unsigned int i = 0; i < ch.size(); ++i) {
    if (ch[i].get_type() == RMF::REPRESENTATION) {
      add_link_recursive(m, root,
                         atom::Hierarchy(m, cur).get_child_index(child), ch[i],
                         rigid_bodies, data);
      ++child;
    }
  }
}