diff options
author | Giles Bathgate <gilesbathgate@gmail.com> | 2011-04-09 05:28:12 (GMT) |
---|---|---|
committer | Giles Bathgate <gilesbathgate@gmail.com> | 2011-04-09 05:28:12 (GMT) |
commit | 6d315b59211c8bcc845c85826b15e98035da5553 (patch) | |
tree | 0468951f9d47a38fcd9134a28490caf5262b7aa2 /src/OGL_helper.h | |
parent | 2066a440d0e5c11f8b45f22367ed524c5604ea33 (diff) |
Lightweight refactoring of OGL_helper to make it extensible.
Diffstat (limited to 'src/OGL_helper.h')
-rw-r--r-- | src/OGL_helper.h | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/OGL_helper.h b/src/OGL_helper.h index 46a1209..2aae31b 100644 --- a/src/OGL_helper.h +++ b/src/OGL_helper.h @@ -248,7 +248,7 @@ namespace OGL { enum { SNC_BOUNDARY, SNC_SKELETON }; class Polyhedron : public OGL_base_object { - + protected: std::list<DPoint> vertices_; std::list<DSegment> edges_; std::list<DFacet> halffacets_; @@ -341,11 +341,17 @@ namespace OGL { Bbox_3 bbox() const { return bbox_; } Bbox_3& bbox() { return bbox_; } + virtual CGAL::Color getVertexColor(Vertex_iterator v) const + { + CGAL::Color cf(CGAL_NEF3_MARKED_VERTEX_COLOR), + ct(CGAL_NEF3_UNMARKED_VERTEX_COLOR); // more blue-ish + CGAL::Color c = v->mark() ? ct : cf; + return c; + } + void draw(Vertex_iterator v) const { // CGAL_NEF_TRACEN("drawing vertex "<<*v); - CGAL::Color cf(CGAL_NEF3_MARKED_VERTEX_COLOR), - ct(CGAL_NEF3_UNMARKED_VERTEX_COLOR); // more blue-ish - CGAL::Color c = v->mark() ? ct : cf; + CGAL::Color c = getVertexColor(v); glPointSize(10); glColor3ub(c.red(), c.green(), c.blue()); glBegin(GL_POINTS); @@ -357,12 +363,18 @@ namespace OGL { glEnd(); } + virtual CGAL::Color getEdgeColor(Edge_iterator e) const + { + CGAL::Color cf(CGAL_NEF3_MARKED_EDGE_COLOR), + ct(CGAL_NEF3_UNMARKED_EDGE_COLOR); // more blue-ish + CGAL::Color c = e->mark() ? ct : cf; + return c; + } + void draw(Edge_iterator e) const { // CGAL_NEF_TRACEN("drawing edge "<<*e); Double_point p = e->source(), q = e->target(); - CGAL::Color cf(CGAL_NEF3_MARKED_EDGE_COLOR), - ct(CGAL_NEF3_UNMARKED_EDGE_COLOR); // more blue-ish - CGAL::Color c = e->mark() ? ct : cf; + CGAL::Color c = getEdgeColor(e); glLineWidth(5); glColor3ub(c.red(),c.green(),c.blue()); glBegin(GL_LINE_STRIP); @@ -371,6 +383,14 @@ namespace OGL { glEnd(); } + virtual CGAL::Color getFacetColor(Halffacet_iterator f) const + { + CGAL::Color cf(CGAL_NEF3_MARKED_FACET_COLOR), + ct(CGAL_NEF3_UNMARKED_FACET_COLOR); // more blue-ish + CGAL::Color c = (f->mark() ? ct : cf); + return c; + } + void draw(Halffacet_iterator f) const { // CGAL_NEF_TRACEN("drawing facet "<<(f->debug(),"")); GLUtesselator* tess_ = gluNewTess(); @@ -386,9 +406,7 @@ namespace OGL { GLU_TESS_WINDING_POSITIVE); DFacet::Coord_const_iterator cit; - CGAL::Color cf(CGAL_NEF3_MARKED_FACET_COLOR), - ct(CGAL_NEF3_UNMARKED_FACET_COLOR); // more blue-ish - CGAL::Color c = (f->mark() ? ct : cf); + CGAL::Color c = getFacetColor(f); glColor3ub(c.red(),c.green(),c.blue()); gluTessBeginPolygon(tess_,f->normal()); // CGAL_NEF_TRACEN(" "); |