delauney_triangulator.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28
29
30 #pragma once
31
32 #include <memory>
33 #include <vector>
34
35 namespace clan
36 {
39
41 class DelauneyTriangulator_Vertex
42 {
45
46 public:
48 void *data;
49
51 float x;
52
54 float y;
56 };
57
59 class DelauneyTriangulator_Triangle
60 {
63
64 public:
66 DelauneyTriangulator_Vertex *vertex_A;
67
69 DelauneyTriangulator_Vertex *vertex_B;
70
72 DelauneyTriangulator_Vertex *vertex_C;
74 };
75
76 class DelauneyTriangulator_Impl;
77
83 class DelauneyTriangulator
84 {
87
88 public:
90 DelauneyTriangulator();
91
92 virtual ~DelauneyTriangulator();
93
97
98 public:
100 const std::vector<DelauneyTriangulator_Vertex> &get_vertices() const;
101
103 const std::vector<DelauneyTriangulator_Triangle> &get_triangles() const;
104
108
109 public:
111 void add_vertex(float x, float y, void *data);
112
114 void generate();
115
119
120 private:
121 std::shared_ptr<DelauneyTriangulator_Impl> impl;
123 };
124
125 }
126
clan::DelauneyTriangulator::add_vertex
void add_vertex(float x, float y, void *data)
This function specifies a point to be used in the triangulation.
clan
Definition: clanapp.h:35
clan::DelauneyTriangulator::get_triangles
const std::vector< DelauneyTriangulator_Triangle > & get_triangles() const
Returns the resulting triangles produced from triangulation.
clan::Key::x
clan::DelauneyTriangulator_Vertex::x
float x
X position of vertex.
Definition: delauney_triangulator.h:51
clan::DelauneyTriangulator::generate
void generate()
Converts passed points into triangles.
clan::DelauneyTriangulator::~DelauneyTriangulator
virtual ~DelauneyTriangulator()
clan::DelauneyTriangulator_Vertex::data
void * data
Data pointer given when adding the vertex.
Definition: delauney_triangulator.h:48
clan::DelauneyTriangulator_Vertex
Vertex in the delauney triangulation.
Definition: delauney_triangulator.h:41
clan::DelauneyTriangulator::get_vertices
const std::vector< DelauneyTriangulator_Vertex > & get_vertices() const
Returns the list of vertices in the triangulation.
clan::DelauneyTriangulator_Triangle::vertex_B
DelauneyTriangulator_Vertex * vertex_B
Second point in the triangle.
Definition: delauney_triangulator.h:69
clan::Key::y
clan::DelauneyTriangulator
Delauney triangulator.
Definition: delauney_triangulator.h:83
clan::DelauneyTriangulator_Triangle::vertex_C
DelauneyTriangulator_Vertex * vertex_C
Third point in the triangle.
Definition: delauney_triangulator.h:72
clan::DelauneyTriangulator_Vertex::y
float y
Y position of vertex.
Definition: delauney_triangulator.h:54
clan::DelauneyTriangulator_Triangle
Triangle generated from a delauney triangulation.
Definition: delauney_triangulator.h:59
clan::DelauneyTriangulator::DelauneyTriangulator
DelauneyTriangulator()
Creates a triangulator object.
clan::DelauneyTriangulator_Triangle::vertex_A
DelauneyTriangulator_Vertex * vertex_A
First point in the triangle.
Definition: delauney_triangulator.h:66