File: polyhedron_prog_vertex_color.cpp

package info (click to toggle)
cgal 6.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 141,840 kB
  • sloc: cpp: 797,081; ansic: 203,398; sh: 490; python: 411; makefile: 286; javascript: 174
file content (34 lines) | stat: -rw-r--r-- 1,031 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <CGAL/Simple_cartesian.h>
#include <CGAL/IO/Color.h>
#include <CGAL/Polyhedron_3.h>

// A vertex type with a color member variable.
template <class Refs, class Point>
struct My_vertex
    : public CGAL::HalfedgeDS_vertex_base<Refs, CGAL::Tag_true, Point>
{
    CGAL::IO::Color color;
    My_vertex() {} // repeat the required constructors
    My_vertex( const Point& p)
        : CGAL::HalfedgeDS_vertex_base<Refs, CGAL::Tag_true, Point>(p) {}
};

// An items type using my vertex.
struct My_items : public CGAL::Polyhedron_items_3 {
    template <class Refs, class Traits>
    struct Vertex_wrapper {
        typedef typename Traits::Point_3 Point_3;
        typedef My_vertex<Refs,Point_3> Vertex;
    };
};

typedef CGAL::Simple_cartesian<double>        Kernel;
typedef CGAL::Polyhedron_3<Kernel, My_items>  Polyhedron;
typedef Polyhedron::Halfedge_handle           Halfedge_handle;

int main() {
    Polyhedron P;
    Halfedge_handle h = P.make_tetrahedron();
    h->vertex()->color = CGAL::IO::red();
    return 0;
}