|
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() (const Polygon &poly) const |
| Triangulate the polygon. | |
Static Public Member Functions | |
| static bool | diagonalize (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 > |
Static Private Member Functions | |
| static Array< Point > | extract_vertices (const Polygon &p) |
| static Geom_Number | signed_double_area (const Polygon &p) |
| static void | normalize_to_ccw (Polygon &p) |
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 639 of file geom_algorithms.H.
|
private |
Definition at line 641 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 723 of file geom_algorithms.H.
References Aleph::and, diagonalize(), in_cone(), and Aleph::Vertex::to_point().
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 679 of file geom_algorithms.H.
References Aleph::and, Aleph::Segment::get_src_point(), Aleph::Segment::get_tgt_point(), Aleph::Polygon::Segment_Iterator::has_curr(), and Aleph::Segment::intersects_with().
Referenced by diagonal().
|
inlinestaticprivate |
Definition at line 643 of file geom_algorithms.H.
References Aleph::GeomPolygonUtils::extract_vertices().
Referenced by normalize_to_ccw().
|
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 702 of file geom_algorithms.H.
References Aleph::and, Aleph::divide_and_conquer_partition_dp(), Aleph::Polygon::get_next_vertex(), Aleph::Polygon::get_prev_vertex(), Aleph::Point::is_left_of(), and Aleph::Point::is_to_left_on_from().
Referenced by diagonal().
Initialize the set of ear vertices.
| p | The polygon. |
Definition at line 735 of file geom_algorithms.H.
References diagonal(), Aleph::divide_and_conquer_partition_dp(), Aleph::Polygon::get_next_vertex(), Aleph::Polygon::get_prev_vertex(), Aleph::Dlink::Iterator::has_curr(), Aleph::Dlink::insert(), and Aleph::next().
Referenced by operator()().
Definition at line 653 of file geom_algorithms.H.
References Aleph::Polygon::add_vertex(), ah_domain_error_if, Aleph::divide_and_conquer_partition_dp(), extract_vertices(), and signed_double_area().
Referenced by operator()().
|
inline |
Triangulate the polygon.
| poly | The polygon to triangulate. |
| domain_error | if polygon is not closed. |
| domain_error | if the polygon has fewer than 3 vertices. |
| domain_error | if polygon is degenerate (zero area). |
| domain_error | if no valid ear can be found. |
Definition at line 762 of file geom_algorithms.H.
References ah_domain_error_if, Aleph::Dlink::append(), diagonal(), Aleph::divide_and_conquer_partition_dp(), Aleph::Polygon::get_first_vertex(), Aleph::Polygon::get_next_vertex(), Aleph::Polygon::get_prev_vertex(), init_ears(), Aleph::Dlink::insert(), Aleph::Polygon::is_closed(), Aleph::next(), Aleph::Vertex::next_vertex(), normalize_to_ccw(), Aleph::Polygon::remove_vertex(), Aleph::Polygon::size(), and Aleph::Vertex::to_point().
|
inlinestaticprivate |
Definition at line 648 of file geom_algorithms.H.
References Aleph::GeomPolygonUtils::signed_double_area().
Referenced by normalize_to_ccw().