示例#1
0
IMPCGAL_BEGIN_INTERNAL_NAMESPACE

algebra::Sphere3D get_enclosing_sphere(const algebra::Sphere3Ds &ss) {
  IMP_USAGE_CHECK(!ss.empty(),
                  "Must pass some spheres to have a bounding sphere");
  typedef CGAL::Cartesian<double> K;
  typedef CGAL::Min_sphere_of_spheres_d_traits_3<K, K::RT> Traits;
  typedef CGAL::Min_sphere_of_spheres_d<Traits> Min_sphere;
  typedef K::Point_3 Point;
  typedef Traits::Sphere Sphere;

  Vector<Sphere> spheres;
  for (unsigned int i = 0; i < ss.size(); ++i) {
    // need cast to resolve ambiguity
    spheres.push_back(Sphere(Point(ss[i].get_center()[0], ss[i].get_center()[1],
                                   ss[i].get_center()[2]),
                             // this really is just radius
                             (ss[i].get_radius())));
  }
  Min_sphere ms(spheres.begin(), spheres.end());
  double x = *ms.center_cartesian_begin();
  double y = *(ms.center_cartesian_begin() + 1);
  double z = *(ms.center_cartesian_begin() + 2);
  double r = CGAL::to_double(ms.radius());
  algebra::Sphere3D s(algebra::Vector3D(x, y, z), r);
  /*IMP_IF_LOG(VERBOSE) {
    IMP_LOG_VERBOSE( "Enclosing sphere is " << s << " for ");
    for (unsigned int i=0; i< ss.size(); ++i) {
      IMP_LOG_VERBOSE( ss[i] << "| ");
    }
    IMP_LOG_VERBOSE( std::endl);
    }*/
  return s;
}
示例#2
0
std::pair<algebra::Vector3Ds, Ints> get_skin_surface(
    const algebra::Sphere3Ds &ss) {
    IMP_FUNCTION_LOG;
    typedef IKernel::Point_3 Bare_point;
    typedef CGAL::Weighted_point<Bare_point, IKernel::RT> Weighted_point;
    IMP::Vector<Weighted_point> l(ss.size());
    for (unsigned int i = 0; i < ss.size(); ++i) {
        l[i] = Weighted_point(trp<IKernel>(ss[i].get_center()),
                              algebra::get_squared(ss[i].get_radius()));
    }
    CGAL::Polyhedron_3<IKernel> p;
    CGAL::Union_of_balls_3<CGAL::Skin_surface_traits_3<IKernel> > skin_surface(
        l.begin(), l.end());
    CGAL::mesh_skin_surface_3(skin_surface, p);
    return get_indexed_facets(p);
}