Пример #1
0
Файл: io.cpp Проект: drussel/imp
Sphere3Ds read_spheres(base::TextInput oin) {
  Sphere3Ds ret;
  std::istream &in=oin;
  while (true) {
    char buf[2000];
    in.getline(buf, 2000);
    if (!in) break;;
    if (buf[0]=='#') continue;
    std::istringstream iss(buf);
    IMP::Float x,y,z, r;
    iss >> x >> y >> z >> r;
    if (!iss) {
      throw IMP::base::ValueException((std::string("Unable to parse line ")
                                 + buf).c_str());
    }
    Sphere3D v(Vector3D(x,y,z), r);
    ret.push_back(v);
  }
  return ret;
}
Пример #2
0
IMPALGEBRA_BEGIN_NAMESPACE

Sphere3D get_enclosing_sphere(const Sphere3Ds &ss) {
  IMP_USAGE_CHECK(!ss.empty(),
                  "Must pass some spheres to have a bounding sphere");
#ifdef IMP_ALGEBRA_USE_IMP_CGAL
  return cgal::internal::get_enclosing_sphere(ss);
#else
  BoundingBox3D bb = get_bounding_box(ss[0]);
  for (unsigned int i = 1; i < ss.size(); ++i) {
    bb += get_bounding_box(ss[i]);
  }
  Vector3D c = .5 * (bb.get_corner(0) + bb.get_corner(1));
  double r = 0;
  for (unsigned int i = 0; i < ss.size(); ++i) {
    double d = (c - ss[i].get_center()).get_magnitude();
    d += ss[i].get_radius();
    r = std::max(r, d);
  }
  return Sphere3D(c, r);
#endif
}
Пример #3
0
Файл: io.cpp Проект: drussel/imp
void write_spheres(const Sphere3Ds &vs,
                   base::TextOutput out) {
  for (unsigned int i=0; i< vs.size(); ++i) {
    out.get_stream() << spaces_io(vs[i]) << "\n";
  }
}