Esempio n. 1
0
Strings get_live_object_names() {
  IMP::Vector<std::string> ret;
  for (boost::unordered_set<Object*>::const_iterator it = live_.begin();
       it != live_.end(); ++it) {
    ret.push_back((*it)->get_name());
  }
  return ret;
}
Esempio n. 2
0
int main(int argc, char *argv[]) {
  IMP::setup_from_argv(argc, argv, "Test grid storage.");
  {
    typedef UnboundedGridRangeD<4> UBGS;
    UBGS ubgs;
    int lb[] = {1, 2, 3, 4};
    int ub[] = {2, 4, 6, 8};
    ExtendedGridIndexD<4> elb(lb, lb + 4);
    ExtendedGridIndexD<4> eub(ub, ub + 4);
    std::cout << "eus " << elb << " " << eub << std::endl;
    IMP::Vector<ExtendedGridIndexD<4> > ids =
        ubgs.get_extended_indexes(elb, eub);
    for (unsigned int i = 0; i < ids.size(); ++i) {
      std::cout << ids[i] << "\n";
    }
    std::cout << ids.size() << std::endl;
    IMP_INTERNAL_CHECK(ids.size() == 2 * 3 * 4 * 5, "Sizes don't match");
  }
  return EXIT_SUCCESS;
}
Esempio n. 3
0
void refine_unit_sphere_cover_d(IMP::Vector<algebra::VectorD<D> > &ret,
                                bool ALL) {
    unsigned int n = ret.size();
    typedef ::CGAL::Cartesian_d< ::CGAL::Lazy_exact_nt< ::CGAL::Gmpq> > K;
    typedef typename K::Point_d P;
    typedef ::CGAL::Convex_hull_d<K> CH;
    std::map<typename CH::Vertex_handle, int> indexes;
    for (unsigned int rep = 0; rep < 10 * D; ++rep) {
        CH ch(D);
        for (unsigned int i = 0; i < ret.size(); ++i) {
            P p(D, ret[i].begin(), ret[i].end());
            typename CH::Vertex_handle vh = ch.insert(p);
            indexes[vh] = i + 1;
            if (!ALL) {
                algebra::VectorD<D> nr = -ret[i];
                P p(D, nr.begin(), nr.end());
                typename CH::Vertex_handle vh = ch.insert(p);
                indexes[vh] = -static_cast<int>(i) - 1;
            }
        }
        IMP::Vector<algebra::VectorD<D> > sums(n, algebra::get_zero_vector_d<D>());
        Floats counts(n, 0);
        for (CH::Facet_iterator it = ch.facets_begin(); it != ch.facets_end();
                ++it) {
            for (unsigned int i = 0; i < D; ++i) {
                int vi = indexes[ch.vertex_of_facet(it, i)];
                algebra::VectorD<D> pi;
                if (vi > 0) {
                    pi = ret[vi - 1];
                } else {
                    continue;
                }
                /*vector<VectorD<D> > simplex;
                for (unsigned int j=0; i< D; ++i ) {
                  int vj=indexes[ch.vertex_of_facet(it, j)];
                  VectorD<D> pj;
                  if (vj > 0) {
                    pj= ret[vj-1];
                  } else {
                    pj= ret[-vj+1];
                  }
                  simplex.push_back((pj-pi).get_unit_vector());
                }
                double w= simplex_volume(simplex);*/
                for (unsigned int j = 0; i < D; ++i) {
                    if (i == j) continue;
                    int vj = indexes[ch.vertex_of_facet(it, j)];
                    algebra::VectorD<D> pj;
                    if (vj > 0) {
                        pj = ret[vj - 1];
                    } else {
                        pj = ret[-vj - 1];
                    }
                    double d = (pj - pi).get_magnitude();
                    if (counts[vi - 1] < d) {
                        counts[vi - 1] = d;
                        sums[vi - 1] = pj;
                    }
                }
            }
        }
        for (unsigned int i = 0; i < (ALL ? 2 * D : D); ++i) {
            sums[i] = ret[i];
        }
        for (unsigned int i = (ALL ? 2 * D : D); i < ret.size(); ++i) {
            if (counts[i] != 0) {
                sums[i] = (.1 * sums[i] + .9 * ret[i]);
                sums[i] = sums[i].get_unit_vector();
            } else {
                // coincident points
                /*IMP_WARN("Coincident points at " << ret[i] << " in iteration " << rep
                  << std::endl);*/
                sums[i] =
                    algebra::get_random_vector_on<D>(algebra::get_unit_sphere_d<D>());
            }
        }
        std::swap(sums, ret);
    }
}