Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

wireframe.C

Go to the documentation of this file.
00001 /**********************************************************************
00002  * wireframe.C
00003  **********************************************************************/
00004 #include "std/config.H"
00005 #include "geom/gl_view.H"
00006 #include "mesh/bfilters.H"
00007 #include "wireframe.H"
00008 
00009 static bool debug = Config::get_var_bool("DEBUG_WIREFRAME", false);
00010 
00011 /**********************************************************************
00012  * WireframeTexture:
00013  **********************************************************************/
00014 bool  WireframeTexture::_show_quad_diagonals = false;
00015 COLOR WireframeTexture::_default_line_color = Color::black;
00016 
00017 void
00018 WireframeTexture::set_default_line_color(CCOLOR& color) 
00019 {
00020    _default_line_color = color;
00021 }
00022 
00023 int
00024 WireframeTexture::draw(CVIEWptr& v)
00025 {
00026    if (_ctrl)
00027       return _ctrl->draw(v);
00028 
00029    // 'a' is opacity (alpha) determined by GL_VIEW::init_line_smooth()
00030    // needed to simulate line widths below the minimum supported value:
00031    GLfloat a = 1;
00032    static bool line_smooth = Config::get_var_bool("ANTIALIAS_WIREFRAME",false);
00033    if (line_smooth) {
00034       // set line smoothing, set line width, and push attributes:
00035       GLfloat w = GLfloat(v->line_scale()*_width);
00036       GL_VIEW::init_line_smooth(w, GL_CURRENT_BIT);//, &a);
00037    } else {
00038       glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT);
00039       glLineWidth(_width);
00040    }
00041 
00042    // set state
00043    GL_COL(_color, a*alpha());   // GL_CURRENT_BIT
00044    glDisable(GL_LIGHTING);      // GL_ENABLE_BIT
00045 
00046    if (!(_quad_diagonals_in_dl == _show_quad_diagonals &&
00047          BasicTexture::draw(v))) {
00048 
00049       _quad_diagonals_in_dl = _show_quad_diagonals;
00050 
00051       int dl = _dl.get_dl(v, 1, _patch->stamp());
00052       if (dl)
00053          glNewList(dl, GL_COMPILE);
00054 
00055       // Build the edge strip at the current subdivision level
00056       Bedge_list edges = _patch->cur_edges();
00057       edges.clear_flags();
00058 
00059       // If secondary edges shouldn't be drawn, set their flags
00060       // so they won't be drawn:
00061       if (!BMESH::show_secondary_faces())
00062          edges.secondary_edges().set_flags(1);
00063 
00064       err_adv(debug, "wireframe: %d edges", edges.num());
00065 
00066       // Construct filter that accepts unreached strong edges of
00067       // this patch:
00068       UnreachedSimplexFilter    unreached;
00069       StrongEdgeFilter          strong;
00070       PatchEdgeFilter           mine(_patch->cur_patch());
00071       if (_show_quad_diagonals)
00072          EdgeStrip(edges, unreached + mine).draw(_cb);
00073       else
00074          EdgeStrip(edges, unreached + strong + mine).draw(_cb);
00075 
00076       // end the display list here
00077       if (_dl.dl(v)) {
00078          _dl.close_dl(v);
00079 
00080          // the display list is built; now execute it
00081          BasicTexture::draw(v);
00082       }
00083    }
00084 
00085    glPopAttrib();
00086 
00087    return _patch->num_faces();
00088 }
00089    
00090 /* end of file wireframe.C */
00091 
00092 
00093 

Generated on Mon Sep 18 11:39:34 2006 for jot by  doxygen 1.4.4