void Scene::compute_distance_function(const Tree& tree) { // Get transformation Aff_transformation t = frame_transformation(); m_max_distance_function = FT(0); FT diag = bbox_diag(); const FT dx = diag; const FT dy = diag; const FT z (0); for(int i=0 ; i<m_grid_size ; ++i) { FT x = -diag/FT(2) + FT(i)/FT(m_grid_size) * dx; for(int j=0 ; j<m_grid_size ; ++j) { FT y = -diag/FT(2) + FT(j)/FT(m_grid_size) * dy; Point query = t( Point(x,y,z) ); FT dist = CGAL::sqrt( tree.squared_distance(query) ); m_distance_function[i][j] = Point_distance(query,dist); m_max_distance_function = (std::max)(dist, m_max_distance_function); } } }
void Scene::draw_cut_segment_plane() const { float diag = .6f * float(bbox_diag()); ::glDisable(GL_LIGHTING); ::glLineWidth(1.0f); ::glColor3f(.6f, .6f, .6f); // draw grid ::glPushMatrix(); ::glMultMatrixd(m_frame->matrix()); QGLViewer::drawGrid(diag); ::glPopMatrix(); // draw cut segments ::glLineWidth(2.0f); ::glColor3f(1.f, 0.f, 0.f); ::glBegin(GL_LINES); for ( std::vector<Segment>::const_iterator it = m_cut_segments.begin(), end = m_cut_segments.end() ; it != end ; ++it ) { const Point& a = it->source(); const Point& b = it->target(); ::glVertex3d(a.x(), a.y(), a.z()); ::glVertex3d(b.x(), b.y(), b.z()); } ::glEnd(); // fill grid with transparent blue ::glPushMatrix(); ::glMultMatrixd(m_frame->matrix()); ::glColor4f(.6f, .85f, 1.f, .65f); ::glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); ::glEnable(GL_BLEND); ::glBegin(GL_QUADS); ::glVertex3d(-diag, -diag, 0.); ::glVertex3d(-diag, diag, 0.); ::glVertex3d( diag, diag, 0.); ::glVertex3d( diag, -diag, 0.); ::glEnd(); ::glDisable(GL_BLEND); ::glPopMatrix(); }
void Scene::compute_elements(int mode) { pos_points.resize(0); pos_lines.resize(0); pos_poly.resize(0); pos_cut_segments.resize(0); tex_map.resize(0); pos_grid.resize(66); pos_plane.resize(18); float diag = .6f * float(bbox_diag()); //The Points { std::list<Point>::iterator pit; for(pit = m_points.begin(); pit != m_points.end(); pit++) { const Point& p = *pit; pos_points.push_back(p.x()); pos_points.push_back(p.y()); pos_points.push_back(p.z()); } } //The Segements { std::list<Segment>::iterator sit; for(sit = m_segments.begin(); sit != m_segments.end(); sit++) { const Segment& s = *sit; const Point& p = s.source(); const Point& q = s.target(); pos_lines.push_back(p.x()); pos_lines.push_back(p.y()); pos_lines.push_back(p.z()); pos_lines.push_back(q.x()); pos_lines.push_back(q.y()); pos_lines.push_back(q.z()); } } //The Polygon's edges { Polyhedron::Edge_iterator he; for(he = m_pPolyhedron->edges_begin(); he != m_pPolyhedron->edges_end(); he++) { const Point& a = he->vertex()->point(); const Point& b = he->opposite()->vertex()->point(); pos_poly.push_back(a.x()); pos_poly.push_back(a.y()); pos_poly.push_back(a.z()); pos_poly.push_back(b.x()); pos_poly.push_back(b.y()); pos_poly.push_back(b.z()); } } //The cutting segments { for ( std::vector<Segment>::const_iterator csit = m_cut_segments.begin(), end = m_cut_segments.end() ; csit != end ; ++csit ) { const Point& a = csit->source(); const Point& b = csit->target(); pos_cut_segments.push_back(a.x()); pos_cut_segments.push_back(a.y()); pos_cut_segments.push_back(a.z()); pos_cut_segments.push_back(b.x()); pos_cut_segments.push_back(b.y()); pos_cut_segments.push_back(b.z()); } } //The cutting plane { pos_plane[0]= -diag; pos_plane[1]=-diag; pos_plane[2]=0.0; pos_plane[3]= -diag; pos_plane[4]= diag; pos_plane[5]=0.; pos_plane[6]= diag; pos_plane[7]= diag; pos_plane[8]=0.; pos_plane[9]= -diag; pos_plane[10]= -diag; pos_plane[11]=0.; pos_plane[12]= diag; pos_plane[13]= diag; pos_plane[14]= 0.; pos_plane[15]= diag; pos_plane[16]= -diag; pos_plane[17]= 0.; //UV Mapping tex_map.push_back(-0.11f); tex_map.push_back(-0.11f); tex_map.push_back(-0.11f); tex_map.push_back(1.11f); tex_map.push_back(1.11f); tex_map.push_back(1.11f); tex_map.push_back(-0.11f); tex_map.push_back(-0.11f); tex_map.push_back(1.11f); tex_map.push_back(1.11f); tex_map.push_back(1.11f); tex_map.push_back(-0.11f); } //The grid { float z = 0; float x = (2 * diag)/10.0; float y = (2 * diag)/10.0; for(int u = 0; u < 11; u++) { pos_grid.push_back(-diag + x* u); pos_grid.push_back(-diag); pos_grid.push_back(z); pos_grid.push_back(-diag + x* u); pos_grid.push_back(diag); pos_grid.push_back(z); } for(int v=0; v<11; v++) { pos_grid.push_back(-diag); pos_grid.push_back(-diag + v * y); pos_grid.push_back(z); pos_grid.push_back(diag); pos_grid.push_back(-diag + v * y); pos_grid.push_back(z); } } //The texture switch(mode) { case _SIGNED: for( int i=0 ; i < texture->getWidth(); i++ ) { for( int j=0 ; j < texture->getHeight() ; j++) { compute_texture(i,j,m_red_ramp,m_blue_ramp); } } break; case _UNSIGNED: for( int i=0 ; i < texture->getWidth(); i++ ) { for( int j=0 ; j < texture->getHeight() ; j++) { compute_texture(i,j,m_thermal_ramp,m_thermal_ramp); } } break;} sampler_location = tex_rendering_program.attributeLocation("texture"); }