|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Polygon triangulation using the ear-cutting algorithm. More...
#include <geom_algorithms.H>
Public Member Functions | |
| DynList< Triangle > | operator() (Polygon &p) |
| Triangulate the polygon. | |
Static Public Member Functions | |
| static bool | diagonalie (const Polygon &p, const Segment &s) |
| Check if a segment is a valid diagonal of the polygon. | |
| static bool | in_cone (const Polygon &p, const Vertex &a, const Vertex &b) |
| Check if vertex b is inside the cone formed at vertex a. | |
| static bool | diagonal (const Polygon &p, const Vertex &a, const Vertex &b) |
| Check if segment (a, b) is a valid internal diagonal. | |
| static EarsSet | init_ears (const Polygon &p) |
| Initialize the set of ear vertices. | |
Private Types | |
| using | EarsSet = DynSetTree< const Vertex *, Treap_Rk > |
Polygon triangulation using the ear-cutting algorithm.
Decomposes a simple polygon into a set of non-overlapping triangles. An "ear" is a triangle formed by three consecutive vertices where the diagonal between the first and third vertices lies entirely inside the polygon.
Definition at line 168 of file geom_algorithms.H.
|
private |
Definition at line 170 of file geom_algorithms.H.
|
inlinestatic |
Check if segment (a, b) is a valid internal diagonal.
| p | The polygon. |
| a | First vertex of the diagonal. |
| b | Second vertex of the diagonal. |
Definition at line 230 of file geom_algorithms.H.
References diagonalie(), in_cone(), and Aleph::maps().
Referenced by init_ears(), and operator()().
|
inlinestatic |
Check if a segment is a valid diagonal of the polygon.
A diagonal is valid if it doesn't intersect any edge of the polygon (except at endpoints).
| p | The polygon. |
| s | The candidate diagonal segment. |
Definition at line 184 of file geom_algorithms.H.
References Segment::get_src_point(), Segment::get_tgt_point(), Polygon::Segment_Iterator::has_curr(), Segment::intersects_with(), and Aleph::maps().
Referenced by diagonal().
|
inlinestatic |
Check if vertex b is inside the cone formed at vertex a.
The cone is defined by the edges adjacent to a (from prev to next).
| p | The polygon. |
| a | The vertex forming the cone apex. |
| b | The vertex to test. |
Definition at line 209 of file geom_algorithms.H.
References Polygon::get_next_vertex(), Polygon::get_prev_vertex(), and Aleph::maps().
Referenced by diagonal().
Initialize the set of ear vertices.
| p | The polygon. |
Definition at line 242 of file geom_algorithms.H.
References diagonal(), Polygon::get_next_vertex(), Polygon::get_prev_vertex(), Aleph::DynList< T >::insert(), Aleph::maps(), and Aleph::next().
Referenced by operator()().
Triangulate the polygon.
| p | The polygon to triangulate (will be modified). |
| domain_error | if the polygon has fewer than 3 vertices. |
Definition at line 270 of file geom_algorithms.H.
References ah_domain_error_if, Aleph::DynList< T >::append(), diagonal(), Polygon::get_first_vertex(), Polygon::get_next_vertex(), Polygon::get_prev_vertex(), init_ears(), Aleph::DynList< T >::insert(), Aleph::maps(), Aleph::next(), Vertex::next_vertex(), Aleph::DynList< T >::remove(), Polygon::remove_vertex(), and Polygon::size().