Scene_interface::Bbox Scene_polylines_item::bbox() const { if(isEmpty()) return Bbox(); std::list<Point_3> boxes; for(std::list<std::vector<Point_3> >::const_iterator it = polylines.begin(); it != polylines.end(); ++it){ if(it->begin() != it->end()) { Iso_cuboid_3 cub = CGAL::bounding_box(it->begin(), it->end()); boxes.push_back((cub.min)()); boxes.push_back((cub.max)()); } } Iso_cuboid_3 bbox = boxes.begin() != boxes.end() ? CGAL::bounding_box(boxes.begin(), boxes.end()) : Iso_cuboid_3(); return Bbox(bbox.xmin(), bbox.ymin(), bbox.zmin(), bbox.xmax(), bbox.ymax(), bbox.zmax()); }
void Viewer::sceneChanged() { Iso_cuboid_3 bb = CGAL::bounding_box(scene->points.begin(), scene->points.end()); this->camera()->setSceneBoundingBox(qglviewer::Vec(bb.xmin(), bb.ymin(), bb.zmin()), qglviewer::Vec(bb.xmax(), bb.ymax(), bb.zmax())); this->showEntireScene(); }
double zmax(Iso_cuboid_3 cuboid){ return CGAL::to_double(cuboid.zmax());}
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()); } } }
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); }