void FitRestraint::store_particles(ParticlesTemp ps) {
  all_ps_=get_as<Particles>(ps);
  add_particles(ps);
  //sort to rigid and not rigid members
  if (use_rigid_bodies_) {
    for(Particles::iterator it = all_ps_.begin();it != all_ps_.end(); it++) {
      if (core::RigidMember::particle_is_instance(*it)) {
        core::RigidBody rb=core::RigidMember(*it).get_rigid_body();
        part_of_rb_.push_back(*it);
        if (member_map_.find(rb) == member_map_.end()) {
          member_map_[rb]=Particles();
          rbs_.push_back(rb);
        }
        member_map_[rb].push_back(*it);
      }
      else {
        not_part_of_rb_.push_back(*it);
      }
    }
  }
  else {
    not_part_of_rb_=all_ps_;
  }
  IMP_LOG(TERSE,"number of"
          <<" particles that are not rigid bodies is:"
          <<not_part_of_rb_.size()<<", "<<part_of_rb_.size()<<" particles "<<
          " are part of "<<rbs_.size()<<" rigid bodies"<<std::endl);
}
Exemple #2
0
// arm
void particle_system::explode(thing *th, bool kill)
{
    static const unsigned SHOCKWAVE_PARTICLES = 25, DEBRIS_PARTICLES = 75;

    if (board::current()->thing_lives(th)) {
        boost::array<vec2, 2*(SHOCKWAVE_PARTICLES + DEBRIS_PARTICLES)> explosion;
        unsigned i = 0;
        while (i < 2*SHOCKWAVE_PARTICLES) {
            float rho = rand_between(64.0, 81.0);
            float theta = rand_between(0.0, 1.0);
            explosion[i++] = polar_vec2(rho, rand_near(theta, 0.0625));
            explosion[i++] = polar_vec2(rho, rand_near(theta, 0.0625));
        }

        while (i < 2*(SHOCKWAVE_PARTICLES + DEBRIS_PARTICLES)) {
            float theta = rand_between(0.0, 1.0);
            explosion[i++] = polar_vec2(rand_between(3.0, 7.0)*rand_between(3.0, 7.0), theta);
            explosion[i++] = polar_vec2(rand_between(3.0, 7.0)*rand_between(3.0, 7.0), theta);
        }

        add_particles(th->center, make_vec2(1.0, 0.0), explosion);

        if (kill)
            board::current()->remove_thing(th);
    }
}
IMPEM_BEGIN_NAMESPACE

EnvelopePenetrationRestraint::EnvelopePenetrationRestraint(
   Particles ps,
   DensityMap *em_map,Float threshold
   ): Restraint("Envelope penetration restraint")
{
  IMP_LOG_TERSE("Load envelope penetration with the following input:"<<
          "number of particles:"<<ps.size()<<
           "\n");
  threshold_=threshold;
  target_dens_map_ = em_map;
  IMP_IF_CHECK(USAGE) {
    for (unsigned int i=0; i< ps.size(); ++i) {
      IMP_USAGE_CHECK(core::XYZR::particle_is_instance(ps[i]),
                      "Particle " << ps[i]->get_name()
                      << " is not XYZR"
                      << std::endl);
    }
  }
  add_particles(ps);
  ps_=ps;
  IMP_LOG_TERSE("after adding particles"<<std::endl);
  IMP_LOG_TERSE( "Finish initialization" << std::endl);
}
RadiusOfGyrationRestraint::RadiusOfGyrationRestraint(Particles ps,
                                                     int num_residues,
                                                     Float scale):
    Restraint(IMP::internal::get_model(ps), "RadiusOfGyrationRestraint"){
  if (ps.size()==0) return;
  add_particles(ps);
  mdl_=ps[0]->get_model();
  predicted_rog_ = get_approximated_radius_of_gyration(num_residues);
  scale_=scale;
  hub_=new core::HarmonicUpperBound(predicted_rog_*scale_,1);
}
IMPMULTIFIT_BEGIN_NAMESPACE

WeightedExcludedVolumeRestraint::WeightedExcludedVolumeRestraint(
    core::RigidBodies rbs, Refiner *refiner, FloatKey weight_key)
    : Restraint(IMP::internal::get_model(rbs),
                "Weighted Excluded Volume Restraint") {
    IMP_LOG_TERSE("Load WeightedExcludedVolumeRestraint \n");
    rb_refiner_ = refiner;
    add_particles(rbs);
    rbs_ = rbs;
    initialize_model_density_map(weight_key);
}