Ejemplo n.º 1
0
std::string pp(const Segment_3& segment)
{
    std::stringstream out;
    out << std::setprecision(pp_precision);
    out << "[" << pp(segment.source()) << ", " << pp(segment.target()) << "]";
    return out.str();
}
Ejemplo n.º 2
0
std::string pp_id(const Segment_3& segment)
{
    std::stringstream out;
    size_t a = segment.source().id();
    size_t b = segment.target().id();
    if (a > b)
        swap(a, b);
    out << a << "--" << b;
    return out.str();
}
Ejemplo n.º 3
0
Segment_2 project_2(const Segment_3& s)
{
  return Segment_2(s.source().point_2(), s.target().point_2());
}
Ejemplo n.º 4
0
Segment_3 lexicographically_ordered(const Segment_3& s)
{
  if (CGAL::lexicographically_xyz_smaller(s.source(), s.target()))
    return s;
  return s.opposite();
}
Ejemplo n.º 5
0
void Viewer::compute_elements()
{
    //glColor3f(1.0f, 0.72f, 0.06f);
    pos_points.resize(0);
    pos_lines.resize(0);
    pos_8lines.resize(0);
    pos_8lines2D.resize(0);

    for(Periodic_point_iterator ppit
      = scene->periodic_triangulation.periodic_points_begin(
          P3DT3::UNIQUE) ;
        ppit != scene->periodic_triangulation.periodic_points_end(P3DT3::UNIQUE);
        ++ppit){
      Point_3 p(scene->periodic_triangulation.point(*ppit));
      pos_points.push_back(p.x()); pos_points.push_back(p.y()); pos_points.push_back(p.z());
    }

    //glColor3f(0.27f, 0.51f, 0.7f);
    for (Periodic_triangle_iterator ptit
       = scene->periodic_triangulation.periodic_triangles_begin(
           P3DT3::UNIQUE);
         ptit != scene->periodic_triangulation.periodic_triangles_end(
         P3DT3::UNIQUE);
        ++ptit) {
      for (int i=0 ; i<4 ; i++) {
        Segment_3 dual = scene->periodic_triangulation.construct_segment(
        scene->periodic_triangulation.dual(*(ptit.get_facet())));

        FT sz = dual.source().z();
        FT tz = dual.target().z();

        if (scene->two_dimensional && ((sz-tz > 0.5) || (sz-tz < -0.5))) continue;

        if (scene->two_dimensional) { sz = 0.; tz = 0.; }
        FT sx = dual.source().x();
        FT tx = dual.target().x();
        FT sy = dual.source().y();
        FT ty = dual.target().y();
        pos_lines.push_back(sx); pos_lines.push_back(sy); pos_lines.push_back(sz);
        pos_lines.push_back(tx); pos_lines.push_back(ty); pos_lines.push_back(tz);
        Iso_cuboid_3 d = scene->periodic_triangulation.domain();

        pos_8lines2D.push_back(sx+0.); pos_8lines2D.push_back(sy+d.ymax()-d.ymin()); pos_8lines2D.push_back(sz+0.);
        pos_8lines2D.push_back(tx+0.); pos_8lines2D.push_back(ty+d.ymax()-d.ymin()); pos_8lines2D.push_back(tz+0.);
        pos_8lines2D.push_back(sx+d.xmax()-d.xmin()); pos_8lines2D.push_back(sy+0.); pos_8lines2D.push_back(sz+0.);
        pos_8lines2D.push_back(tx+d.xmax()-d.xmin()); pos_8lines2D.push_back(ty+0.); pos_8lines2D.push_back(tz+0.);
        pos_8lines2D.push_back(sx+d.xmax()-d.xmin()); pos_8lines2D.push_back(sy+d.ymax()-d.ymin()); pos_8lines2D.push_back(sz+0.);
        pos_8lines2D.push_back(tx+d.xmax()-d.xmin()); pos_8lines2D.push_back(ty+d.ymax()-d.ymin()); pos_8lines2D.push_back(tz+0.);

        pos_8lines.push_back(sx+0.); pos_8lines.push_back(sy+0.); pos_8lines.push_back(sz+d.zmax()-d.zmin());
        pos_8lines.push_back(tx+0.); pos_8lines.push_back(ty+0.); pos_8lines.push_back(tz+d.zmax()-d.zmin());
        pos_8lines.push_back(sx+0.); pos_8lines.push_back(sy+d.ymax()-d.ymin()); pos_8lines.push_back(sz+d.zmax()-d.zmin());
        pos_8lines.push_back(tx+0.); pos_8lines.push_back(ty+d.ymax()-d.ymin()); pos_8lines.push_back(tz+d.zmax()-d.zmin());
        pos_8lines.push_back(sx+d.xmax()-d.xmin()); pos_8lines.push_back(sy+0.); pos_8lines.push_back(sz+d.zmax()-d.zmin());
        pos_8lines.push_back(tx+d.xmax()-d.xmin()); pos_8lines.push_back(ty+0.); pos_8lines.push_back(tz+d.zmax()-d.zmin());
        pos_8lines.push_back(sx+d.xmax()-d.xmin()); pos_8lines.push_back(sy+d.ymax()-d.ymin()); pos_8lines.push_back(sz+d.zmax()-d.zmin());
        pos_8lines.push_back(tx+d.xmax()-d.xmin()); pos_8lines.push_back(ty+d.ymax()-d.ymin()); pos_8lines.push_back(tz+d.zmax()-d.zmin());
      }

    }
}
Ejemplo n.º 6
0
void 
Viewer::gl_draw_surface()
{
  ::glColor3f(1.0f, 0.72f, 0.06f);
  ::glDisable(GL_LIGHTING);

  ::glEnable(GL_BLEND);
  ::glEnable(GL_POINT_SMOOTH);
  ::glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
  ::glEnable(GL_LINE_SMOOTH);
  ::glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
  ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

  ::glPointSize(5);
  ::glBegin(GL_POINTS);
  for(Periodic_point_iterator ppit
	= scene->periodic_triangulation.periodic_points_begin(
	    P3DT3::UNIQUE) ;
      ppit != scene->periodic_triangulation.periodic_points_end(P3DT3::UNIQUE);
      ++ppit){
    Point_3 p(scene->periodic_triangulation.point(*ppit));
    ::glVertex3d(p.x(), p.y(), p.z());
  }
  ::glEnd();

  ::glBegin(GL_LINES);

  ::glColor3f(0.27f, 0.51f, 0.7f);

  for (Periodic_triangle_iterator ptit
	 = scene->periodic_triangulation.periodic_triangles_begin(
	     P3DT3::UNIQUE);
       ptit != scene->periodic_triangulation.periodic_triangles_end(
	   P3DT3::UNIQUE);
      ++ptit) {
    for (int i=0 ; i<4 ; i++) {
      Segment_3 dual = scene->periodic_triangulation.segment(
	  scene->periodic_triangulation.dual(*(ptit.get_facet())));

      FT sz = dual.source().z();
      FT tz = dual.target().z();

      if (scene->two_dimensional && ((sz-tz > 0.5) || (sz-tz < -0.5))) continue;
      
      if (scene->two_dimensional) { sz = 0.; tz = 0.; }
      FT sx = dual.source().x();
      FT tx = dual.target().x();
      FT sy = dual.source().y();
      FT ty = dual.target().y();

      ::glVertex3d(sx,sy,sz); ::glVertex3d(tx,ty,tz);
      Iso_cuboid_3 d = scene->periodic_triangulation.domain();
      if (scene->eight_copies) {
	::glColor3f(0.69f, 0.77f, 0.87f);
	::glVertex3d(sx+0.,sy+d.ymax()-d.ymin(),sz+0.);
	::glVertex3d(tx+0.,ty+d.ymax()-d.ymin(),tz+0.);
	::glVertex3d(sx+d.xmax()-d.xmin(),sy+0.,sz+0.);
	::glVertex3d(tx+d.xmax()-d.xmin(),ty+0.,tz+0.);
	::glVertex3d(sx+d.xmax()-d.xmin(),sy+d.ymax()-d.ymin(),sz+0.);
	::glVertex3d(tx+d.xmax()-d.xmin(),ty+d.ymax()-d.ymin(),tz+0.);
	if (!scene->two_dimensional) {
	  ::glVertex3d(sx+0.,sy+0.,sz+d.zmax()-d.zmin());
	  ::glVertex3d(tx+0.,ty+0.,tz+d.zmax()-d.zmin());
	  ::glVertex3d(sx+0.,sy+d.ymax()-d.ymin(),sz+d.zmax()-d.zmin());
	  ::glVertex3d(tx+0.,ty+d.ymax()-d.ymin(),tz+d.zmax()-d.zmin());
	  ::glVertex3d(sx+d.xmax()-d.xmin(),sy+0.,sz+d.zmax()-d.zmin());
	  ::glVertex3d(tx+d.xmax()-d.xmin(),ty+0.,tz+d.zmax()-d.zmin());
	  ::glVertex3d(sx+d.xmax()-d.xmin(),sy+d.ymax()-d.ymin(),sz+d.zmax()-d.zmin());
	  ::glVertex3d(tx+d.xmax()-d.xmin(),ty+d.ymax()-d.ymin(),tz+d.zmax()-d.zmin());
	}
	::glColor3f(0.27f, 0.51f, 0.7f);

      }
    }
  }

  ::glEnd();
  ::glEnable(GL_LIGHTING);
}