void Scene::compute_texture(int i, int j,Color_ramp pos_ramp ,Color_ramp neg_ramp) { const FT& d00 = m_distance_function[i][j].second; // determines grey level unsigned int i00 = 255-(unsigned)(255.0 * (double)std::fabs(d00) / m_max_distance_function); if(d00 > 0.0) texture->setData(i,j,pos_ramp.r(i00),pos_ramp.g(i00),pos_ramp.b(i00)); else texture->setData(i,j,neg_ramp.r(i00),neg_ramp.g(i00),neg_ramp.b(i00)); }
void Scene_implicit_function_item:: draw_grid_vertex(const Point_value& pv, const Color_ramp& ramp_positive, const Color_ramp& ramp_negative) const { const Point& p = pv.first; double v = pv.second; // determines grey level if ( v > 0 ) { v = v/max_value_; ::glColor3d(ramp_positive.r(v),ramp_positive.g(v),ramp_positive.b(v)); } else { v = v/min_value_; ::glColor3d(ramp_negative.r(v),ramp_negative.g(v),ramp_negative.b(v)); } ::glVertex3d(p.x,p.y,p.z); }
void Scene::draw_distance_function(const Color_ramp& ramp_pos, const Color_ramp& ramp_neg) const { ::glDisable(GL_LIGHTING); if ( m_fast_distance ) { ::glShadeModel(GL_FLAT); } else { ::glShadeModel(GL_SMOOTH); } ::glBegin(GL_QUADS); int i,j; const int nb_quads = m_grid_size-1; for(i=0; i<nb_quads; i++) { for(j=0; j<nb_quads; j++) { const Point_distance& pd00 = m_distance_function[i][j]; const Point_distance& pd01 = m_distance_function[i][j+1]; const Point_distance& pd11 = m_distance_function[i+1][j+1]; const Point_distance& pd10 = m_distance_function[i+1][j]; const Point& p00 = pd00.first; const Point& p01 = pd01.first; const Point& p11 = pd11.first; const Point& p10 = pd10.first; const FT& d00 = pd00.second; const FT& d01 = pd01.second; const FT& d11 = pd11.second; const FT& d10 = pd10.second; // determines grey level unsigned int i00 = 255-(unsigned)(255.0 * (double)std::fabs(d00) / m_max_distance_function); unsigned int i01 = 255-(unsigned)(255.0 * (double)std::fabs(d01) / m_max_distance_function); unsigned int i11 = 255-(unsigned)(255.0 * (double)std::fabs(d11) / m_max_distance_function); unsigned int i10 = 255-(unsigned)(255.0 * (double)std::fabs(d10) / m_max_distance_function); // assembles one quad if(d00 > 0.0) ::glColor3ub(ramp_pos.r(i00),ramp_pos.g(i00),ramp_pos.b(i00)); else ::glColor3ub(ramp_neg.r(i00),ramp_neg.g(i00),ramp_neg.b(i00)); ::glVertex3d(p00.x(),p00.y(),p00.z()); if(d01 > 0.0) ::glColor3ub(ramp_pos.r(i01),ramp_pos.g(i01),ramp_pos.b(i01)); else ::glColor3ub(ramp_neg.r(i01),ramp_neg.g(i01),ramp_neg.b(i01)); ::glVertex3d(p01.x(),p01.y(),p01.z()); if(d11 > 0) ::glColor3ub(ramp_pos.r(i11),ramp_pos.g(i11),ramp_pos.b(i11)); else ::glColor3ub(ramp_neg.r(i11),ramp_neg.g(i11),ramp_neg.b(i11)); ::glVertex3d(p11.x(),p11.y(),p11.z()); if(d10 > 0) ::glColor3ub(ramp_pos.r(i10),ramp_pos.g(i10),ramp_pos.b(i10)); else ::glColor3ub(ramp_neg.r(i10),ramp_neg.g(i10),ramp_neg.b(i10)); ::glVertex3d(p10.x(),p10.y(),p10.z()); } } ::glEnd(); }