Skip to content

Commit 0a77a36

Browse files
authored
Fix issue with exterior ghost vertices (#196)
1 parent 455b592 commit 0a77a36

File tree

11 files changed

+434
-384
lines changed

11 files changed

+434
-384
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
- Bugfix: Introduced `is_linear` to fix issues with boundary enrichment of domains with `LineSegment`s. In particular, `LineSegment`s are no longer enriched. See [#195](https://github.com/JuliaGeometry/DelaunayTriangulation.jl/pull/195).
77
- Bugfix: `orientation_markers` now uses `uniquetol` instead of `unique` for the final set of markers (it already did it for the intermediate markers). See [#195](https://github.com/JuliaGeometry/DelaunayTriangulation.jl/pull/195).
88
- Bugfix: For large `Tuple`s, functions like `eval_fnc_at_het_tuple_two_elements` are problematic and allocate more than their non-type-stable counterparts. To get around this, for `Tuple`s of length `N > 32`, the non-type-stable version is used. See [#195](https://github.com/JuliaGeometry/DelaunayTriangulation.jl/pull/195).
9+
- Bigfix: Fixed issue with `use_barriers` when a ghost edge is selected at random during point location. See [#196](https://github.com/JuliaGeometry/DelaunayTriangulation.jl/pull/196).
10+
- Feature: Introduced the (currently internal) function `get_positive_curve_indices` for finding curves with positive orientation in a `Triangulation`. [#196](https://github.com/JuliaGeometry/DelaunayTriangulation.jl/pull/196).
11+
- `is_exterior_curve`, `is_interior_curve`, `num_exterior_curves`, and `is_disjoint` are now defined based on `get_positive_curve_indices` rather than `get_exterior_curve_indices`. See [#196](https://github.com/JuliaGeometry/DelaunayTriangulation.jl/pull/196).
912

1013
## 1.5.0
1114

src/data_structures/trees/polygon_hierarchy.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,17 @@ Returns the indices of the exterior curves of `hierarchy`.
282282
"""
283283
get_exterior_curve_indices(hierarchy::PolygonHierarchy) = keys(get_trees(hierarchy))
284284

285+
"""
286+
get_positive_curve_indices(hierarchy::PolygonHierarchy) -> Generator
287+
288+
Returns the indices of the positively oriented curves of `hierarchy` as a generator, i.e.
289+
as a lazy result.
290+
"""
291+
function get_positive_curve_indices(hierarchy::PolygonHierarchy)
292+
orientations = get_polygon_orientations(hierarchy)
293+
return (index for (index, orientation) in enumerate(orientations) if orientation)
294+
end
295+
285296
"""
286297
get_trees(hierarchy::PolygonHierarchy) -> Dict{I,PolygonTree{I}}
287298

src/data_structures/triangulation/methods/exterior_curve_indices.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Returns `true` if the `curve_index`th curve in `tri` is an exterior curve, and `false` otherwise.
55
"""
6-
is_exterior_curve(tri::Triangulation, curve_index) = curve_index get_exterior_curve_indices(tri)
6+
is_exterior_curve(tri::Triangulation, curve_index) = curve_index get_positive_curve_indices(tri)
77

88
"""
99
is_interior_curve(tri::Triangulation, curve_index) -> Bool
@@ -17,7 +17,7 @@ is_interior_curve(tri::Triangulation, curve_index) = !is_exterior_curve(tri, cur
1717
1818
Returns the number of exterior curves in `tri`.
1919
"""
20-
num_exterior_curves(tri::Triangulation) = (length get_exterior_curve_indices)(tri)
20+
num_exterior_curves(tri::Triangulation) = count(get_polygon_orientations(get_polygon_hierarchy(tri)))
2121

2222
"""
2323
is_disjoint(tri::Triangulation) -> Bool

src/data_structures/triangulation/triangulation.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ Returns the set of all curve indices that correspond to exterior curves of `tri`
306306
"""
307307
get_exterior_curve_indices(tri::Triangulation) = get_exterior_curve_indices(get_polygon_hierarchy(tri))
308308

309+
"""
310+
get_positive_curve_indices(tri::Triangulation) -> Generator
311+
312+
Returns the indices of the positively oriented curves of `hierarchy` as a generator, i.e.
313+
as a lazy result.
314+
"""
315+
get_positive_curve_indices(tri::Triangulation) = get_positive_curve_indices(get_polygon_hierarchy(tri))
316+
309317
"""
310318
get_boundary_enricher(tri::Triangulation) -> BoundaryEnricher
311319

test/data_structures/polygon_hierarchy.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ for _ in 1:20 # Run many times to make sure the segfault is gone
124124
@test DT.get_bounding_boxes(hierarchy) [DT.bounding_box(points)]
125125
@test DT.get_bounding_box(hierarchy, 1) DT.bounding_box(points)
126126
@test DT.get_exterior_curve_indices(hierarchy) == Set(1)
127+
@test collect(DT.get_positive_curve_indices(hierarchy)) == findall(DT.get_polygon_orientations(hierarchy))
127128
@test DT.get_trees(hierarchy) === hierarchy.trees
128129
@test DT.get_tree(hierarchy, 1) === hierarchy.trees[1]
129130
tree = DT.get_tree(hierarchy, 1)
@@ -144,6 +145,7 @@ for _ in 1:20 # Run many times to make sure the segfault is gone
144145
@test DT.get_bounding_boxes(hierarchy) [DT.BoundingBox(DT.polygon_bounds(points, boundary_nodes)...)]
145146
@test DT.get_bounding_box(hierarchy, 1) DT.BoundingBox(DT.polygon_bounds(points, boundary_nodes)...)
146147
@test DT.get_exterior_curve_indices(hierarchy) == Set(1)
148+
@test collect(DT.get_positive_curve_indices(hierarchy)) == findall(DT.get_polygon_orientations(hierarchy))
147149
@test DT.get_trees(hierarchy) === hierarchy.trees
148150
@test DT.get_tree(hierarchy, 1) === hierarchy.trees[1]
149151
tree = DT.get_tree(hierarchy, 1)
@@ -161,6 +163,7 @@ for _ in 1:20 # Run many times to make sure the segfault is gone
161163
@test DT.get_bounding_boxes(hierarchy) [DT.BoundingBox(DT.polygon_bounds(points, boundary_nodes)...)]
162164
@test DT.get_bounding_box(hierarchy, 1) DT.BoundingBox(DT.polygon_bounds(points, boundary_nodes)...)
163165
@test DT.get_exterior_curve_indices(hierarchy) == Set(1)
166+
@test collect(DT.get_positive_curve_indices(hierarchy)) == findall(DT.get_polygon_orientations(hierarchy))
164167
@test DT.get_trees(hierarchy) === hierarchy.trees
165168
@test DT.get_tree(hierarchy, 1) === hierarchy.trees[1]
166169
tree = DT.get_tree(hierarchy, 1)
@@ -179,6 +182,7 @@ for _ in 1:20 # Run many times to make sure the segfault is gone
179182
@test DT.get_bounding_box(hierarchy, 1) DT.BoundingBox(DT.polygon_bounds(points, get_boundary_nodes(boundary_nodes, 1))...)
180183
@test DT.get_bounding_box(hierarchy, 2) DT.BoundingBox(DT.polygon_bounds(points, get_boundary_nodes(boundary_nodes, 2))...)
181184
@test DT.get_exterior_curve_indices(hierarchy) == Set(1)
185+
@test collect(DT.get_positive_curve_indices(hierarchy)) == findall(DT.get_polygon_orientations(hierarchy))
182186
@test DT.get_trees(hierarchy) === hierarchy.trees
183187
@test DT.get_tree(hierarchy, 1) === hierarchy.trees[1]
184188
tree = DT.get_tree(hierarchy, 1)
@@ -228,6 +232,7 @@ for _ in 1:20 # Run many times to make sure the segfault is gone
228232
boundary_nodes, points = convert_boundary_points_to_indices([_Q1, _Q2, _Q3, _Q4, _Q5, _Q6, _Q7, _Q8, _Q9, _Q10, _Q11, _Q12, _Q13, _Q14, _Q15])
229233
hierarchy = DT.construct_polygon_hierarchy(points, boundary_nodes)
230234
@test DT.get_exterior_curve_indices(hierarchy) == Set([6, 5, 7, 15])
235+
@test collect(DT.get_positive_curve_indices(hierarchy)) == findall(DT.get_polygon_orientations(hierarchy))
231236
@test DT.get_bounding_boxes(hierarchy) [
232237
DT.BoundingBox(-9.0, -2.0, -1.0, 7.0),
233238
DT.BoundingBox(0.0, 10.0, -5.0, 6.0),

test/data_structures/triangulation.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ refine!(tri_4; max_area=1.0e-1A, use_circumcenter=true, use_lens=false)
122122
@test DT.get_convex_hull(tri) == tri.convex_hull
123123
@test DT.get_representative_point_list(tri) == tri.representative_point_list
124124
@test DT.get_exterior_curve_indices(tri) == keys(tri.polygon_hierarchy.trees)
125+
@test collect(DT.get_positive_curve_indices(tri)) == findall(tri.polygon_hierarchy.polygon_orientations)
125126
@test DT.get_boundary_enricher(tri) === tri.boundary_enricher
126127
@test compare_trees(DT.get_polygon_hierarchy(tri), DT.construct_polygon_hierarchy(tri.points, tri.boundary_nodes))
127128
@test compare_edge_vectors(collect(DT.get_all_segments(tri)), collect(tri.all_segments))
@@ -149,6 +150,7 @@ refine!(tri_4; max_area=1.0e-1A, use_circumcenter=true, use_lens=false)
149150
@inferred DT.get_convex_hull(tri)
150151
@inferred DT.get_representative_point_list(tri)
151152
@inferred DT.get_exterior_curve_indices(tri)
153+
@inferred DT.get_positive_curve_indices(tri)
152154
@inferred DT.get_boundary_enricher(tri)
153155
@inferred DT.get_polygon_hierarchy(tri)
154156
@inferred DT.get_cache(tri)
@@ -1484,4 +1486,4 @@ end
14841486
@test validate_triangulation(tri2)
14851487
@test tri1 == tri2
14861488
@test !DT.has_boundary_nodes(tri2)
1487-
end
1489+
end

0 commit comments

Comments
 (0)