ear_clip_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 ** Harry Storbacka
27 */
28
29
30 #pragma once
31
32 #include <memory>
33 #include "../Math/point.h"
34 #include <vector>
35
36 namespace clan
37 {
40
42 class EarClipTriangulator_Triangle
43 {
44 public:
45 float x1,y1,x2,y2,x3,y3;
46 };
47
48 class EarClipTriangulator_Impl;
49 class EarClipResult;
50
52 enum PolygonOrientation
53 {
54 cl_clockwise,
55 cl_counter_clockwise
56 };
57
59 class EarClipTriangulator
60 {
63
64 public:
66 EarClipTriangulator();
67
68 virtual ~EarClipTriangulator();
69
73
74 public:
76 std::vector<Pointf> get_vertices();
77
79 int get_vertice_count();
80
82 PolygonOrientation calculate_polygon_orientation();
83
87
88 public:
90 void add_vertex(float x, float y);
91
95 void add_vertex(const Pointf &p);
96
98 void clear();
99
101 void set_orientation( PolygonOrientation orientation );
102
104 EarClipResult triangulate();
105
107 void begin_hole();
108
110 void end_hole();
111
115
116 private:
117 std::shared_ptr<EarClipTriangulator_Impl> impl;
119 };
120
121 }
122
clan::EarClipTriangulator_Triangle
EarClipTriangulator_Triangle.
Definition: ear_clip_triangulator.h:42
clan
Definition: clanapp.h:35
clan::EarClipTriangulator::~EarClipTriangulator
virtual ~EarClipTriangulator()
clan::EarClipTriangulator::begin_hole
void begin_hole()
Mark beginning of a polygon hole.
clan::Key::x
clan::EarClipTriangulator_Triangle::y2
float y2
Definition: ear_clip_triangulator.h:45
clan::EarClipTriangulator_Triangle::x1
float x1
Definition: ear_clip_triangulator.h:45
clan::EarClipTriangulator::triangulate
EarClipResult triangulate()
Perform triangulation.
clan::EarClipTriangulator_Triangle::x3
float x3
Definition: ear_clip_triangulator.h:45
clan::EarClipTriangulator_Triangle::y1
float y1
Definition: ear_clip_triangulator.h:45
clan::cl_counter_clockwise
Definition: ear_clip_triangulator.h:55
clan::EarClipTriangulator::end_hole
void end_hole()
Mark ending of a polygon hole.
clan::EarClipTriangulator::get_vertice_count
int get_vertice_count()
Returns the number of vertices in the triangulator.
clan::PolygonOrientation
PolygonOrientation
Polygon orientations.
Definition: ear_clip_triangulator.h:52
clan::Key::y
clan::EarClipTriangulator
Ear-clipping triangulator.
Definition: ear_clip_triangulator.h:59
clan::Key::p
clan::cl_clockwise
Definition: ear_clip_triangulator.h:54
clan::EarClipTriangulator::set_orientation
void set_orientation(PolygonOrientation orientation)
Set polygon orientation.
clan::EarClipTriangulator_Triangle::y3
float y3
Definition: ear_clip_triangulator.h:45
clan::EarClipTriangulator::get_vertices
std::vector< Pointf > get_vertices()
Returns a list of the vertices added to the triangulator.
clan::EarClipResult
Ear clipping triangulation result structure.
Definition: ear_clip_result.h:44
clan::EarClipTriangulator::add_vertex
void add_vertex(float x, float y)
Add the next vertex of the polygon to the triangulator.
clan::Pointf
2D (x,y) point structure - Float
Definition: point.h:72
clan::EarClipTriangulator_Triangle::x2
float x2
Definition: ear_clip_triangulator.h:45
clan::EarClipTriangulator::EarClipTriangulator
EarClipTriangulator()
Constructs a triangulator.
clan::EarClipTriangulator::clear
void clear()
Remove all vertices from triangulator.
clan::EarClipTriangulator::calculate_polygon_orientation
PolygonOrientation calculate_polygon_orientation()
Determine the orientation of the vertices in the triangulator.