00001
00002
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
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
00030
00031 GLfloat a = 1;
00032 static bool line_smooth = Config::get_var_bool("ANTIALIAS_WIREFRAME",false);
00033 if (line_smooth) {
00034
00035 GLfloat w = GLfloat(v->line_scale()*_width);
00036 GL_VIEW::init_line_smooth(w, GL_CURRENT_BIT);
00037 } else {
00038 glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT);
00039 glLineWidth(_width);
00040 }
00041
00042
00043 GL_COL(_color, a*alpha());
00044 glDisable(GL_LIGHTING);
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
00056 Bedge_list edges = _patch->cur_edges();
00057 edges.clear_flags();
00058
00059
00060
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
00067
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
00077 if (_dl.dl(v)) {
00078 _dl.close_dl(v);
00079
00080
00081 BasicTexture::draw(v);
00082 }
00083 }
00084
00085 glPopAttrib();
00086
00087 return _patch->num_faces();
00088 }
00089
00090
00091
00092
00093