|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
O(log n) point location via trapezoidal map with DAG search. More...
#include <geom_algorithms.H>
Classes | |
| struct | DagNode |
| A node in the search Directed Acyclic Graph (DAG). More... | |
| struct | LocationResult |
| Result of a point location query. More... | |
| struct | Result |
| The trapezoidal map and DAG search structure. More... | |
| struct | Trapezoid |
| A trapezoid in the decomposition. More... | |
Public Types | |
| enum class | NodeType { X_NODE , Y_NODE , LEAF } |
| Types of nodes in the search DAG. More... | |
| enum class | LocationType { TRAPEZOID , ON_SEGMENT , ON_POINT } |
| Classification of a point location query result. More... | |
Public Member Functions | |
| Result | operator() (const Array< Segment > &input_segments) const |
| Build a trapezoidal map from a set of non-crossing segments. | |
| Result | operator() (const Polygon &polygon) const |
| Build a trapezoidal map from a closed polygon's edges. | |
| Result | operator() (const Array< Polygon > &polygons) const |
| Build a trapezoidal map from multiple closed polygons. | |
Static Public Attributes | |
| static constexpr size_t | NONE = ~static_cast<size_t>(0) |
Static Private Member Functions | |
| static bool | point_above_segment (const Point &p, const Segment &seg) |
| Test if point p is above segment seg (left of the directed segment). | |
| static size_t | dag_locate (const Array< Point > &pts, const Array< Segment > &segs, const Array< DagNode > &dag, const Point &p, size_t root) |
| Locate the DAG leaf (trapezoid) containing point p. | |
| static size_t | make_trapezoid (Array< Trapezoid > &traps, Array< DagNode > &dag, const size_t top, const size_t bottom, const size_t leftp, const size_t rightp) |
| Create a new trapezoid and a DAG leaf for it. | |
| static void | replace_leaf (Array< DagNode > &dag, const size_t leaf_idx, const NodeType type, const size_t index, const size_t left, const size_t right) |
| Replace a DAG leaf with an internal node (X or Y). | |
| static void | update_neighbor (Array< Trapezoid > &traps, const size_t neighbor_idx, const size_t old_ti, const size_t new_ti) |
| Update all neighbor pointers that referenced old_ti to point to new_ti. | |
| static Array< size_t > | find_crossed_trapezoids (const Array< Point > &pts, const Array< Segment > &segs, const Array< Trapezoid > &traps, const size_t seg_idx, const size_t start_trap) |
| Find all trapezoids crossed by segment seg_idx, starting from the trapezoid containing the left endpoint. | |
| static void | split_single_trapezoid (Array< Point > &pts, Array< Segment > &segs, Array< Trapezoid > &traps, Array< DagNode > &dag, const size_t seg_idx, const size_t trap_idx) |
| Handle the case where a segment is fully contained in one trapezoid. | |
| static void | split_multiple_trapezoids (Array< Point > &pts, Array< Segment > &segs, Array< Trapezoid > &traps, Array< DagNode > &dag, const size_t seg_idx, const Array< size_t > &crossed) |
| Handle the case where a segment crosses multiple trapezoids. | |
O(log n) point location via trapezoidal map with DAG search.
Given a set of non-crossing line segments (or polygon edges), builds a trapezoidal decomposition of the plane using randomized incremental construction (Seidel 1991 / de Berg et al.).
The result structure stores the trapezoidal map and a directed acyclic graph (DAG) used for point location queries.
Fast point location in planar subdivisions using trapezoidal maps.
This class implements a randomized incremental algorithm to build a trapezoidal decomposition of a set of non-crossing line segments. It provides O(log n) expected query time for point location.
Definition at line 12968 of file geom_algorithms.H.
Classification of a point location query result.
| Enumerator | |
|---|---|
| TRAPEZOID | The point is strictly inside a trapezoid. |
| ON_SEGMENT | The point lies on a segment boundary. |
| ON_POINT | The point coincides with a segment endpoint. |
Definition at line 13017 of file geom_algorithms.H.
Types of nodes in the search DAG.
| Enumerator | |
|---|---|
| X_NODE | A node that splits the search space by an X-coordinate. |
| Y_NODE | A node that splits the search space by a segment (Y-direction). |
| LEAF | A leaf node representing a trapezoid. |
Definition at line 12996 of file geom_algorithms.H.
|
inlinestaticprivate |
Locate the DAG leaf (trapezoid) containing point p.
Definition at line 13151 of file geom_algorithms.H.
References Aleph::area_of_parallelogram(), Aleph::divide_and_conquer_partition_dp(), LEAF, root(), and X_NODE.
Referenced by operator()().
|
inlinestaticprivate |
Find all trapezoids crossed by segment seg_idx, starting from the trapezoid containing the left endpoint.
Definition at line 13226 of file geom_algorithms.H.
References Aleph::and, Aleph::Array< T >::append(), Aleph::divide_and_conquer_partition_dp(), Aleph::Segment::get_tgt_point(), Aleph::TrapezoidalMapPointLocation::Trapezoid::lower_right, NONE, point_above_segment(), Aleph::TrapezoidalMapPointLocation::Trapezoid::rightp, and Aleph::TrapezoidalMapPointLocation::Trapezoid::upper_right.
Referenced by operator()().
|
inlinestaticprivate |
Create a new trapezoid and a DAG leaf for it.
Definition at line 13185 of file geom_algorithms.H.
References Aleph::Array< T >::append(), Aleph::divide_and_conquer_partition_dp(), LEAF, NONE, and Aleph::Array< T >::size().
Referenced by operator()(), split_multiple_trapezoids(), and split_single_trapezoid().
|
inline |
Build a trapezoidal map from multiple closed polygons.
| polygons | Array of closed simple polygons (must not overlap). |
Definition at line 13826 of file geom_algorithms.H.
References ah_domain_error_if, Aleph::divide_and_conquer_partition_dp(), Aleph::Polygon::Segment_Iterator::has_curr(), Aleph::Polygon::is_closed(), Aleph::Polygon::size(), and Aleph::Array< T >::size().
|
inline |
Build a trapezoidal map from a set of non-crossing segments.
| input_segments | Array of line segments (must not cross each other except at endpoints). |
| domain_error | if any segment is degenerate (src == tgt). |
Definition at line 13660 of file geom_algorithms.H.
References ah_domain_error_if, Aleph::Array< T >::append(), dag_locate(), Aleph::divide_and_conquer_partition_dp(), find_crossed_trapezoids(), Aleph::Segment::get_src_point(), Aleph::in_place_sort(), make_trapezoid(), Aleph::TrapezoidalMapPointLocation::Result::num_input_segments, Aleph::Array< T >::reserve(), split_multiple_trapezoids(), and split_single_trapezoid().
Build a trapezoidal map from a closed polygon's edges.
| polygon | A closed simple polygon. |
Definition at line 13809 of file geom_algorithms.H.
References ah_domain_error_if, Aleph::Array< T >::append(), Aleph::divide_and_conquer_partition_dp(), Aleph::Polygon::Segment_Iterator::has_curr(), Aleph::Polygon::is_closed(), and Aleph::Polygon::size().
|
inlinestaticprivate |
Test if point p is above segment seg (left of the directed segment).
Definition at line 13143 of file geom_algorithms.H.
References Aleph::area_of_parallelogram(), Aleph::Segment::get_src_point(), and Aleph::Segment::get_tgt_point().
Referenced by find_crossed_trapezoids().
|
inlinestaticprivate |
Replace a DAG leaf with an internal node (X or Y).
Definition at line 13200 of file geom_algorithms.H.
References Aleph::divide_and_conquer_partition_dp().
Referenced by split_multiple_trapezoids(), and split_single_trapezoid().
|
inlinestaticprivate |
Handle the case where a segment crosses multiple trapezoids.
Definition at line 13410 of file geom_algorithms.H.
References Aleph::and, Aleph::Array< T >::append(), Aleph::divide_and_conquer_partition_dp(), Aleph::Segment::get_src_point(), Aleph::Segment::get_tgt_point(), make_trapezoid(), NONE, replace_leaf(), Aleph::Array< T >::reserve(), Aleph::Array< T >::size(), update_neighbor(), X_NODE, and Y_NODE.
Referenced by operator()().
|
inlinestaticprivate |
Handle the case where a segment is fully contained in one trapezoid.
Definition at line 13270 of file geom_algorithms.H.
References Aleph::and, Aleph::Array< T >::append(), Aleph::divide_and_conquer_partition_dp(), Aleph::Segment::get_src_point(), Aleph::Segment::get_tgt_point(), make_trapezoid(), NONE, replace_leaf(), Aleph::Array< T >::size(), update_neighbor(), X_NODE, and Y_NODE.
Referenced by operator()().
|
inlinestaticprivate |
Update all neighbor pointers that referenced old_ti to point to new_ti.
Definition at line 13211 of file geom_algorithms.H.
References Aleph::divide_and_conquer_partition_dp(), and NONE.
Referenced by split_multiple_trapezoids(), and split_single_trapezoid().
|
staticconstexpr |
Definition at line 12971 of file geom_algorithms.H.
Referenced by find_crossed_trapezoids(), Aleph::TrapezoidalMapPointLocation::Result::locate(), make_trapezoid(), Aleph::put_trapezoidal_map_result(), split_multiple_trapezoids(), split_single_trapezoid(), and update_neighbor().