From 6e940b4c0dd77a13c1f93060729891d717a83cb1 Mon Sep 17 00:00:00 2001 From: Daniel VandenHeuvel <95613936+DanielVandH@users.noreply.github.com> Date: Mon, 8 Jul 2024 12:55:18 +0100 Subject: [PATCH] Change jump_and_march to find_triangle (#133) * Change jump_and_march to find_triangle * news * news * oops * filename --- NEWS.md | 1 + Project.toml | 2 +- docs/src/api/point_location.md | 2 +- .../literate_tutorials/point_in_polygon.jl | 6 +- docs/src/literate_tutorials/point_location.jl | 26 ++-- docs/src/manual/ghost_triangles.md | 2 +- docs/src/math/constrained.md | 2 +- docs/src/math/delaunay.md | 2 +- docs/src/tutorials/point_location.md | 46 +++---- src/DelaunayTriangulation.jl | 3 + src/algorithms/point_location/brute_force.jl | 2 +- .../point_location/jump_and_march.jl | 114 +++++++++--------- .../point_location/nearest_neighbour.jl | 8 +- .../basic_operations/add_point.jl | 14 +-- .../constrained_triangulation.jl | 4 +- src/algorithms/triangulation/main.jl | 2 +- .../triangulation/mesh_refinement.jl | 6 +- .../unconstrained_triangulation.jl | 10 +- .../mesh_refinement/refinement_arguments.jl | 2 +- src/data_structures/point_location_history.jl | 2 +- .../triangulation/methods/weights.jl | 2 +- src/predicates/predicates.jl | 2 +- .../segment_location.jl | 6 +- test/data_structures/triangulation.jl | 2 +- test/helper_functions.jl | 2 +- test/point_location/ghost_search.jl | 30 ++--- test/point_location/jump_and_march.jl | 110 ++++++++--------- test/triangulation/weighted.jl | 2 +- test/utils.jl | 4 +- 29 files changed, 210 insertions(+), 206 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8e26ee2ff..466b30096 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,7 @@ - Added `DelauanyTriangulation.validate_triangulation` for validating triangulations. See [#131](https://github.com/JuliaGeometry/DelaunayTriangulation.jl/pull/131). - Fixed a bug with the currently unused `orient(p, q, r, s)` predicate. See [#131](https://github.com/JuliaGeometry/DelaunayTriangulation.jl/pull/131). - Added private functions `getz`, `_getz`, `getxyz`, and `_getxyz`. See [#131](https://github.com/JuliaGeometry/DelaunayTriangulation.jl/pull/131). +- `jump_and_march` has now been renamed to `find_triangle`. For compatibility, `jump_and_march` still works and is simply an alias of `find_triangle`. See [#133](https://github.com/JuliaGeometry/DelaunayTriangulation.jl/pull/133). ## v1.0.5 diff --git a/Project.toml b/Project.toml index 1ab26c5fc..32264f5bf 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "DelaunayTriangulation" uuid = "927a84f5-c5f4-47a5-9785-b46e178433df" authors = ["Daniel VandenHeuvel "] -version = "1.1.0-DEV" +version = "1.1.0" [deps] EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56" diff --git a/docs/src/api/point_location.md b/docs/src/api/point_location.md index faa29565c..cead6f05a 100644 --- a/docs/src/api/point_location.md +++ b/docs/src/api/point_location.md @@ -6,7 +6,7 @@ CurrentModule = DelaunayTriangulation ```@docs brute_force_search -jump_and_march +find_triangle get_nearest_neighbour find_polygon ``` \ No newline at end of file diff --git a/docs/src/literate_tutorials/point_in_polygon.jl b/docs/src/literate_tutorials/point_in_polygon.jl index 3ccfc42e2..19e0cf98c 100644 --- a/docs/src/literate_tutorials/point_in_polygon.jl +++ b/docs/src/literate_tutorials/point_in_polygon.jl @@ -194,16 +194,16 @@ fig # Here is the second method. tri = triangulate(points; boundary_nodes=nodes) -is_inside_2 = [DelaunayTriangulation.dist(tri, q) > 0 for q in query_points] +is_inside_2 = [DelaunayTriangulation.dist(tri, q) > 0 for q in query_points]; @test is_inside == is_inside_2 #src # The third method is to use [`find_polygon`](@ref) to find the polygon containing the point. If no such polygon exists, `find_polygon` returns # `0`, so this is what we use to determine if a point is inside or outside the polygon. -is_inside_3 = [find_polygon(tri, q) ≠ 0 for q in query_points] +is_inside_3 = [find_polygon(tri, q) ≠ 0 for q in query_points]; @test mean(is_inside) ≈ mean(is_inside_3) atol = 1e-2 #src # This test is not exactly the same as the previous one (with a difference of about five points) due to points near the boundary. # The fourth method is: hierarchy = DelaunayTriangulation.construct_polygon_hierarchy(points, nodes) -is_inside_4 = [find_polygon(hierarchy, points, nodes, q) ≠ 0 for q in query_points] +is_inside_4 = [find_polygon(hierarchy, points, nodes, q) ≠ 0 for q in query_points]; @test is_inside_4 == is_inside_3 #src \ No newline at end of file diff --git a/docs/src/literate_tutorials/point_location.jl b/docs/src/literate_tutorials/point_location.jl index 89b0caca1..1a3eb5bde 100644 --- a/docs/src/literate_tutorials/point_location.jl +++ b/docs/src/literate_tutorials/point_location.jl @@ -4,7 +4,7 @@ # In this tutorial, we demonstrate how triangulations can be # used to perform point location. The problem of interest is: Given # a point `p` and a triangulation `tri`, what triangle `T` in `tri` -# contains `p`? We provide a function [`jump_and_march`](@ref) for this task, +# contains `p`? We provide a function [`find_triangle`](@ref) for this task, # implementing the algorithm of [Mücke, Saias, and Zhu (1999)](https://doi.org/10.1016/S0925-7721(98)00035-2). # The algorithm has been slightly modified to allow for regions with holes. # Support is also provided for non-convex and disjoint domains, but the algorithm @@ -35,30 +35,30 @@ scatter!(ax, q) fig # The aim is to, from `tri`, find which triangle contains the point `q` shown. -# Using the `jump_and_march` function, this is simple. -V = jump_and_march(tri, q) +# Using the `find_triangle` function, this is simple. +V = find_triangle(tri, q) # The result means that the triangle `(2, 7, 6)` contains the point, as we can easily check: DelaunayTriangulation.point_position_relative_to_triangle(tri, V, q) @test DelaunayTriangulation.is_inside(DelaunayTriangulation.point_position_relative_to_triangle(tri, V, q)) #src -# When we provide no keyword arguments, the default behaviour of `jump_and_march` is to first +# When we provide no keyword arguments, the default behaviour of `find_triangle` is to first # sample some number of points (defaults to $\lceil \sqrt[3]{n}\rceil$, where $n$ is the number of points), # and then start at the point that is closest to `q` out of those sampled, then marching along the triangulation # until `q` is found. This number of samples can be changed using the `m` keyword argument. For example, -V = jump_and_march(tri, q, m=10) +V = find_triangle(tri, q, m=10) @test DelaunayTriangulation.is_inside(DelaunayTriangulation.point_position_relative_to_triangle(tri, V, q)) #src # means that we get a sample of size 10, and start at whichever point is the closest. # (For technical reasons, this sampling is with replacement, so it is possible that the same point is sampled more than once.) # You could also instead specify the point to start at using the `k` keyword argument, in which case no points are sampled. # For example, -V = jump_and_march(tri, q, k=6) +V = find_triangle(tri, q, k=6) @test DelaunayTriangulation.is_inside(DelaunayTriangulation.point_position_relative_to_triangle(tri, V, q)) #src # starts the algorithm at the point `6`. -# Note also that the triangles found from `jump_and_march` do not have to be given in the same order as they appear +# Note also that the triangles found from `find_triangle` do not have to be given in the same order as they appear # in the triangulation. For example, if a triangle `(i, j, k)` contains the point `q`, then any of `(i, j, k)`, `(j, k, i)`, # or `(k, i, j)` could be returned. @@ -69,7 +69,7 @@ scatter!(ax, q) fig # We obtain: -V = jump_and_march(tri, q) +V = find_triangle(tri, q) @test DelaunayTriangulation.is_inside(DelaunayTriangulation.point_position_relative_to_triangle(tri, V, q)) #src # See that the result is a ghost triangle `(1, 5, -1)`. As discussed in the [manual](../manual/ghost_triangles.md), @@ -121,7 +121,7 @@ fig load_preference(DelaunayTriangulation, "USE_EXACTPREDICATES", true) && @test_reference joinpath(fig_path, "point_location_ex_3.png") fig #src # Now let's find the triangles. -Vs = [jump_and_march(tri, q; rng) for q in qs] +Vs = [find_triangle(tri, q; rng) for q in qs] # While we do find some triangles, they may not all be correct. For example, # the triangle found for `(1.2, 1.6)` is @@ -132,7 +132,7 @@ Vs[end] # will enable a check to be made that the point is actually outside the triangulation whenever # a ghost triangle is to be returned. If the check finds this to not be the case, it # restarts. With these results, we now compute: -Vs = [jump_and_march(tri, q; rng, concavity_protection=true) for q in qs] +Vs = [find_triangle(tri, q; rng, concavity_protection=true) for q in qs] # Here is how we can actually test that these results are now correct. We cannot directly # use [`DelaunayTriangulation.point_position_relative_to_triangle`](@ref) because it does not @@ -159,7 +159,7 @@ results # ## Disjoint domains # Now we continue the previous example by adding in another set of # domains that are disjoint to the current domain, thus allowing us to -# demonstrate how `jump_and_march` applies here. The new domain is below, +# demonstrate how `find_triangle` applies here. The new domain is below, # along with the points we will be searching for. m₁, n₁, o₁ = (6.0, 8.0), (8.0, 8.0), (8.0, 4.0) p₁, q₁, r₁ = (10.0, 4.0), (6.0, 6.0), (8.0, 6.0) @@ -184,8 +184,8 @@ scatter!(ax, qs, color=:blue, markersize=16) fig load_preference(DelaunayTriangulation, "USE_EXACTPREDICATES", true) && @test_reference joinpath(fig_path, "point_location_ex_4.png") fig by=psnr_equality(10) #src -# Here are the `jump_and_march` results. -Vs = [jump_and_march(tri, q; rng, concavity_protection=true) for q in qs] +# Here are the `find_triangle` results. +Vs = [find_triangle(tri, q; rng, concavity_protection=true) for q in qs] # Again, we can verify that these are all correct as follows. Without `concavity_protection=true`, # these would not be all correct. diff --git a/docs/src/manual/ghost_triangles.md b/docs/src/manual/ghost_triangles.md index 7ca352fe4..458233118 100644 --- a/docs/src/manual/ghost_triangles.md +++ b/docs/src/manual/ghost_triangles.md @@ -42,4 +42,4 @@ fig As you can see, the outer boundary has ghost edges (shown in blue) going out to infinity, oriented with the pole of inaccessibility of the entire domain (shown in red). The ghost edges along the circular boundary are finite and simply connect with the pole of inaccessibility of the circle (shown in magenta). -For more complex domains, in particular non-convex domains, the ghost edges start to overlap and they become less useful, which unfortunately slows down point location (see [`jump_and_march`](@ref)'s docstring). \ No newline at end of file +For more complex domains, in particular non-convex domains, the ghost edges start to overlap and they become less useful, which unfortunately slows down point location (see [`find_triangle`](@ref)'s docstring). \ No newline at end of file diff --git a/docs/src/math/constrained.md b/docs/src/math/constrained.md index 11c6d321d..28656e962 100644 --- a/docs/src/math/constrained.md +++ b/docs/src/math/constrained.md @@ -40,7 +40,7 @@ fig, ax, sc = triplot(tri) lines!(ax, [get_point(tri, e...)...], color = :blue, linewidth = 4) history = DelaunayTriangulation.PointLocationHistory{NTuple{3,Int},NTuple{2,Int},Int}() q = get_point(tri, 7) -jump_and_march(tri, q; k = 2, history, store_history = Val(true)) +find_triangle(tri, q; k = 2, history, store_history = Val(true)) lines!(ax, [get_point(tri, 2, history.left_vertices..., 7)...], color = :red, linewidth = 4) lines!(ax, [get_point(tri, 2, history.right_vertices..., 7)...], color = :green, linewidth = 4) for T in history.triangles diff --git a/docs/src/math/delaunay.md b/docs/src/math/delaunay.md index ff1f89d91..f04929408 100644 --- a/docs/src/math/delaunay.md +++ b/docs/src/math/delaunay.md @@ -175,7 +175,7 @@ history = DelaunayTriangulation.PointLocationHistory{NTuple{3,Int},NTuple{2,Int} q = (0.8, 0.8) p = get_point(tri, 226) fig, ax, sc = triplot(tri) -V = jump_and_march(tri, q; k = 226, store_history = Val(true), history) +V = find_triangle(tri, q; k = 226, store_history = Val(true), history) for T in history.triangles ii, jj, kk = triangle_vertices(T) pp, qq, rr = get_point(tri, ii, jj, kk) diff --git a/docs/src/tutorials/point_location.md b/docs/src/tutorials/point_location.md index aaf4ffed2..18c554e3c 100644 --- a/docs/src/tutorials/point_location.md +++ b/docs/src/tutorials/point_location.md @@ -7,7 +7,7 @@ EditURL = "https://github.com/JuliaGeometry/DelaunayTriangulation.jl/tree/main/d In this tutorial, we demonstrate how triangulations can be used to perform point location. The problem of interest is: Given a point `p` and a triangulation `tri`, what triangle `T` in `tri` -contains `p`? We provide a function [`jump_and_march`](@ref) for this task, +contains `p`? We provide a function [`find_triangle`](@ref) for this task, implementing the algorithm of [Mücke, Saias, and Zhu (1999)](https://doi.org/10.1016/S0925-7721(98)00035-2). The algorithm has been slightly modified to allow for regions with holes. Support is also provided for non-convex and disjoint domains, but the algorithm @@ -37,10 +37,10 @@ fig ```` The aim is to, from `tri`, find which triangle contains the point `q` shown. -Using the `jump_and_march` function, this is simple. +Using the `find_triangle` function, this is simple. ````@example point_location -V = jump_and_march(tri, q) +V = find_triangle(tri, q) ```` The result means that the triangle `(2, 7, 6)` contains the point, as we can easily check: @@ -49,13 +49,13 @@ The result means that the triangle `(2, 7, 6)` contains the point, as we can eas DelaunayTriangulation.point_position_relative_to_triangle(tri, V, q) ```` -When we provide no keyword arguments, the default behaviour of `jump_and_march` is to first +When we provide no keyword arguments, the default behaviour of `find_triangle` is to first sample some number of points (defaults to $\lceil \sqrt[3]{n}\rceil$, where $n$ is the number of points), and then start at the point that is closest to `q` out of those sampled, then marching along the triangulation until `q` is found. This number of samples can be changed using the `m` keyword argument. For example, ````@example point_location -V = jump_and_march(tri, q, m=10) +V = find_triangle(tri, q, m=10) ```` means that we get a sample of size 10, and start at whichever point is the closest. @@ -64,12 +64,12 @@ You could also instead specify the point to start at using the `k` keyword argum For example, ````@example point_location -V = jump_and_march(tri, q, k=6) +V = find_triangle(tri, q, k=6) ```` starts the algorithm at the point `6`. -Note also that the triangles found from `jump_and_march` do not have to be given in the same order as they appear +Note also that the triangles found from `find_triangle` do not have to be given in the same order as they appear in the triangulation. For example, if a triangle `(i, j, k)` contains the point `q`, then any of `(i, j, k)`, `(j, k, i)`, or `(k, i, j)` could be returned. @@ -85,7 +85,7 @@ fig We obtain: ````@example point_location -V = jump_and_march(tri, q) +V = find_triangle(tri, q) ```` See that the result is a ghost triangle `(1, 5, -1)`. As discussed in the [manual](../manual/ghost_triangles.md), @@ -149,7 +149,7 @@ fig Now let's find the triangles. ````@example point_location -Vs = [jump_and_march(tri, q; rng) for q in qs] +Vs = [find_triangle(tri, q; rng) for q in qs] ```` While we do find some triangles, they may not all be correct. For example, @@ -160,10 +160,10 @@ Vs[end] ```` but the point `(1.2, 1.6)` is actually inside the triangulation. We can even see -this if we run `jump_and_march` again: +this if we run `find_triangle` again: ````@example point_location -V = jump_and_march(tri, (1.2, 1.6); rng) +V = find_triangle(tri, (1.2, 1.6); rng) ```` To protect against this, you need to use `concavity_protection=true`, which @@ -172,7 +172,7 @@ a ghost triangle is to be returned. If the check finds this to not be the case, restarts. With these results, we now compute: ````@example point_location -Vs = [jump_and_march(tri, q; rng, concavity_protection=true) for q in qs] +Vs = [find_triangle(tri, q; rng, concavity_protection=true) for q in qs] ```` Here is how we can actually test that these results are now correct. We cannot directly @@ -202,7 +202,7 @@ As we see, the triangles are now all correct. ## Disjoint domains Now we continue the previous example by adding in another set of domains that are disjoint to the current domain, thus allowing us to -demonstrate how `jump_and_march` applies here. The new domain is below, +demonstrate how `find_triangle` applies here. The new domain is below, along with the points we will be searching for. ````@example point_location @@ -229,10 +229,10 @@ scatter!(ax, qs, color=:blue, markersize=16) fig ```` -Here are the `jump_and_march` results. +Here are the `find_triangle` results. ````@example point_location -Vs = [jump_and_march(tri, q; rng, concavity_protection=true) for q in qs] +Vs = [find_triangle(tri, q; rng, concavity_protection=true) for q in qs] ```` Again, we can verify that these are all correct as follows. Without `concavity_protection=true`, @@ -274,20 +274,20 @@ fig, ax, sc = triplot(tri) scatter!(ax, q) fig -V = jump_and_march(tri, q) +V = find_triangle(tri, q) DelaunayTriangulation.point_position_relative_to_triangle(tri, V, q) -V = jump_and_march(tri, q, m=10) +V = find_triangle(tri, q, m=10) -V = jump_and_march(tri, q, k=6) +V = find_triangle(tri, q, k=6) q = (-5.0, 8.0) fig, ax, sc = triplot(tri) scatter!(ax, q) fig -V = jump_and_march(tri, q) +V = find_triangle(tri, q) fig, ax, sc = triplot(tri, show_ghost_edges=true) scatter!(ax, q) @@ -321,13 +321,13 @@ fig, ax, sc = triplot(tri, show_ghost_edges=false) scatter!(ax, qs, color=:blue, markersize=16) fig -Vs = [jump_and_march(tri, q; rng) for q in qs] +Vs = [find_triangle(tri, q; rng) for q in qs] Vs[end] -V = jump_and_march(tri, (1.2, 1.6); rng) +V = find_triangle(tri, (1.2, 1.6); rng) -Vs = [jump_and_march(tri, q; rng, concavity_protection=true) for q in qs] +Vs = [find_triangle(tri, q; rng, concavity_protection=true) for q in qs] δs = [DelaunayTriangulation.dist(tri, q) for q in qs] results = Vector{Bool}(undef, length(qs)) @@ -365,7 +365,7 @@ fig, ax, sc = triplot(tri) scatter!(ax, qs, color=:blue, markersize=16) fig -Vs = [jump_and_march(tri, q; rng, concavity_protection=true) for q in qs] +Vs = [find_triangle(tri, q; rng, concavity_protection=true) for q in qs] δs = [DelaunayTriangulation.dist(tri, q) for q in qs] results = Vector{Bool}(undef, length(qs)) diff --git a/src/DelaunayTriangulation.jl b/src/DelaunayTriangulation.jl index 491ed8f06..409f915a8 100644 --- a/src/DelaunayTriangulation.jl +++ b/src/DelaunayTriangulation.jl @@ -187,6 +187,8 @@ include("algorithms/voronoi/unbounded.jl") include("validation.jl") +const jump_and_march = find_triangle # Remove in 2.0 + export each_triangle, each_solid_triangle, @@ -257,6 +259,7 @@ export triangulate_rectangle, triangulate_convex, brute_force_search, + find_triangle, jump_and_march, convert_boundary_points_to_indices, refine!, diff --git a/src/algorithms/point_location/brute_force.jl b/src/algorithms/point_location/brute_force.jl index bbe728e72..d42a90cad 100644 --- a/src/algorithms/point_location/brute_force.jl +++ b/src/algorithms/point_location/brute_force.jl @@ -16,7 +16,7 @@ end Searches for the triangle containing the point `q` by brute force. An exception will be raised if no triangle contains the point. -See also [`jump_and_march`](@ref). +See also [`find_triangle`](@ref). # Arguments - `tri::Triangulation`: The [`Triangulation`](@ref). diff --git a/src/algorithms/point_location/jump_and_march.jl b/src/algorithms/point_location/jump_and_march.jl index 9236814c9..f35a7da67 100644 --- a/src/algorithms/point_location/jump_and_march.jl +++ b/src/algorithms/point_location/jump_and_march.jl @@ -36,7 +36,7 @@ end @doc """ select_initial_point(tri::Triangulation, q; kwargs...) -> Vertex -Selects the initial point for [`jump_and_march`](@ref) to start from. +Selects the initial point for [`find_triangle`](@ref) to start from. # Arguments - `tri::Triangulation`: The [`Triangulation`](@ref). @@ -139,7 +139,7 @@ end """ select_initial_triangle_interior_vertex(tri::Triangulation, k, q, store_history=Val(false), history=nothing, rng::AbstractRNG=Random.default_rng()) -> (Point, Vertex, Vertex, Point, Point) -Selects the initial triangle for [`jump_and_march`](@ref) to start from, for the case where `k` is an interior vertex. +Selects the initial triangle for [`find_triangle`](@ref) to start from, for the case where `k` is an interior vertex. # Arguments - `tri::Triangulation`: The [`Triangulation`](@ref). @@ -159,7 +159,7 @@ Selects the initial triangle for [`jump_and_march`](@ref) to start from, for the !!! warning "Non-convex geometries" This function assumes that the geometry is convex. To deal with this, when an infinite loop is detected - we return `∅` for both `i` and `j`, and then let [`jump_and_march`](@ref) handle how to + we return `∅` for both `i` and `j`, and then let [`find_triangle`](@ref) handle how to correct the algorithm from there. # Extended help @@ -261,7 +261,7 @@ function fix_initial_collinear_edge_for_interior_vertex(tri::Triangulation, k, q \pᵢ Then we want to know if q is to the right of `ppⱼ` (here, `line_cert_j` is the collinear certificate) or to the left. If it is to the left, then it is on the edge `ppⱼ`. This is not a problem, but we let - [`jump_and_march`](@ref) handle this case somewhere else. Thus, we should want to find a case where `q` + [`find_triangle`](@ref) handle this case somewhere else. Thus, we should want to find a case where `q` is right of `ppⱼ` and not handle this interior edge case, so we check `!is_left(on_edge_cert)`. =# if !is_left(on_edge_cert) @@ -360,7 +360,7 @@ See also [`check_for_intersections_with_adjacent_boundary_edges`](@ref), which u !!! warning "Non-convex geometries" This function assumes that the geometry is convex. The function will still be able to return, but `is_outside(q_pos_cert)` may not necessarily mean `q` - is outside of the triangulation. The main function [`jump_and_march`](@ref) will have to restart the algorithm if it is found that `is_outside(q_pos_cert)` + is outside of the triangulation. The main function [`find_triangle`](@ref) will have to restart the algorithm if it is found that `is_outside(q_pos_cert)` was incorrect. # Extended help @@ -588,7 +588,7 @@ function check_for_intersections_with_triangle_left_to_boundary_vertex(tri::Tria end """ - exterior_jump_and_march(tri::Triangulation, k, q, ghost_vertex=𝒢) -> (Vertex, Vertex) + exterior_find_triangle(tri::Triangulation, k, q, ghost_vertex=𝒢) -> (Vertex, Vertex) Given a query point `q` outside of the triangulation, find the ghost triangle containing `q`. @@ -610,21 +610,21 @@ Given a query point `q` outside of the triangulation, find the ghost triangle co # Extended help This function works by first finding the position of `q` relative to `pₘp`, where `pₘ` is the representative point for the `ghost_vertex` and `p = get_point(tri, k)`. Depending on this position, we rotate counter-clockwise if `q` is -left of the line using `exterior_jump_and_march_rotate_left` and clockwise otherwise using `exterior_jump_and_march_rotate_right`. +left of the line using `exterior_find_triangle_rotate_left` and clockwise otherwise using `exterior_find_triangle_rotate_right`. By keeping track of the current position of `q` and its position relative to the next ghost edge, we can identify when `q` resides inside a ghost triangle. """ -function exterior_jump_and_march(tri::Triangulation, k, q, ghost_vertex=integer_type(tri)(𝒢)) +function exterior_find_triangle(tri::Triangulation, k, q, ghost_vertex=integer_type(tri)(𝒢)) pₘ, pᵢ = get_point(tri, ghost_vertex, k) i = k q_position = point_position_relative_to_line(pₘ, pᵢ, q) if is_left(q_position) # q is left of the ghost edge through pᵢ, so rotate left - return exterior_jump_and_march_rotate_left(tri, q, i, pₘ, ghost_vertex) + return exterior_find_triangle_rotate_left(tri, q, i, pₘ, ghost_vertex) else # rotate right - return exterior_jump_and_march_rotate_right(tri, q, i, pₘ, ghost_vertex) + return exterior_find_triangle_rotate_right(tri, q, i, pₘ, ghost_vertex) end end -function exterior_jump_and_march_rotate_left(tri, q, i, pₘ, ghost_vertex) +function exterior_find_triangle_rotate_left(tri, q, i, pₘ, ghost_vertex) j = get_right_boundary_node(tri, i, ghost_vertex) pⱼ = get_point(tri, j) new_q_pos = point_position_relative_to_line(pₘ, pⱼ, q) @@ -636,7 +636,7 @@ function exterior_jump_and_march_rotate_left(tri, q, i, pₘ, ghost_vertex) end return j, i # Swap the orientation so that i, j is a boundary edge end -function exterior_jump_and_march_rotate_right(tri, q, i, pₘ, ghost_vertex) +function exterior_find_triangle_rotate_right(tri, q, i, pₘ, ghost_vertex) j = get_left_boundary_node(tri, i, ghost_vertex) pⱼ = get_point(tri, j) new_q_pos = point_position_relative_to_line(pₘ, pⱼ, q) @@ -650,7 +650,7 @@ function exterior_jump_and_march_rotate_right(tri, q, i, pₘ, ghost_vertex) end """ - jump_and_march(tri, q; kwargs...) -> Triangle[, Bool] + find_triangle(tri, q; kwargs...) -> Triangle[, Bool] Find the triangle in the triangulation `tri` containing the query point `q` using the jump-and-march algorithm. @@ -666,7 +666,7 @@ Find the triangle in the triangulation `tri` containing the query point `q` usin - `k=select_initial_point(tri, q; point_indices, m, try_points, rng)`: The initial point to start the algorithm from. See [`select_initial_point`](@ref). - `store_history=Val(false)`: Whether to store the history of the algorithm. - `history=nothing`: The history of the algorithm. If `store_history`, then this should be a [`PointLocationHistory`](@ref) object. -- `maxiters=2 + num_exterior_curves(tri) - num_solid_vertices(tri) + num_solid_edges(tri)`: The maximum number of iterations to perform before restarting the algorithm with [`restart_jump_and_march`](@ref). +- `maxiters=2 + num_exterior_curves(tri) - num_solid_vertices(tri) + num_solid_edges(tri)`: The maximum number of iterations to perform before restarting the algorithm with [`restart_find_triangle`](@ref). !!! note "Restarting the algorithm" @@ -718,15 +718,15 @@ The algorithm underlying this function is complicated and broken into many parts documentation contains a much more detailed description. 1. Firstly, the algorithm is initialised depending on whether `k` is a boundary or an interior vertex, using - [`initialise_jump_and_march_boundary_vertex`](@ref) or [`initialise_jump_and_march_interior_vertex`](@ref) respectively. -2. From the initial triangle `(i, j, k)` chosen, we then check if `q` is one of `pᵢ`, `pⱼ`, and `p = pₖ` and then return according to [`jump_and_march_return_on_vertex`](@ref) if needed. + [`initialise_find_triangle_boundary_vertex`](@ref) or [`initialise_find_triangle_interior_vertex`](@ref) respectively. +2. From the initial triangle `(i, j, k)` chosen, we then check if `q` is one of `pᵢ`, `pⱼ`, and `p = pₖ` and then return according to [`find_triangle_return_on_vertex`](@ref) if needed. 3. If we do not return above, we need to step from the initial triangle towards `q`. Since we put `pᵢ` and `pⱼ` to the left and right of the line `pq`, respectively, this means that we step until the triangle `pᵢpⱼq` is no longer - positively oriented. So, while the triangle is positively oriented, we step according to [`jump_and_march_across_triangle`](@ref). -4. If we have not yet returned and the triangle is no longer positively oriented, we check if the triangle is degenerate using [`jump_and_march_degenerate_arrangement`](@ref) + positively oriented. So, while the triangle is positively oriented, we step according to [`find_triangle_across_triangle`](@ref). +4. If we have not yet returned and the triangle is no longer positively oriented, we check if the triangle is degenerate using [`find_triangle_degenerate_arrangement`](@ref) and reinitialise the algorithm if needed. Otherwise, we have found the triangle containing `q` and return the triangle. """ -function jump_and_march(tri::Triangulation, _q; +function find_triangle(tri::Triangulation, _q; point_indices=each_solid_vertex(tri), m=default_num_samples(num_vertices(point_indices)), try_points=(), @@ -742,11 +742,11 @@ function jump_and_march(tri::Triangulation, _q; G = number_type(tri) _qx, _qy = getxy(_q) q = (G(_qx), G(_qy)) - return _jump_and_march(tri, q, I(k), store_history, history, rng, maxiters, zero(maxiters), concavity_protection, zero(maxiters), use_barriers) + return _find_triangle(tri, q, I(k), store_history, history, rng, maxiters, zero(maxiters), concavity_protection, zero(maxiters), use_barriers) end """ - initialise_jump_and_march_interior_vertex(tri::Triangulation, q, k, store_history::F, history, rng) -> (Bool, Point, Vertex, Vertex, Point, Point) + initialise_find_triangle_interior_vertex(tri::Triangulation, q, k, store_history::F, history, rng) -> (Bool, Point, Vertex, Vertex, Point, Point) Initialise the jump-and-march algorithm for an interior vertex `k`. @@ -770,7 +770,7 @@ Initialise the jump-and-march algorithm for an interior vertex `k`. This function works by simply using [`select_initial_triangle_interior_vertex`](@ref) to find the initial triangle to start from. A check is made to see if the edge `(i, j)` refers to a non-existent edge `($∅, $∅)`, in which case the algorithm needs to be restarted. """ -function initialise_jump_and_march_interior_vertex(tri::Triangulation, q, k, store_history::F, history, rng) where {F} +function initialise_find_triangle_interior_vertex(tri::Triangulation, q, k, store_history::F, history, rng) where {F} # If k is not a boundary node, then we can rotate around the point k to find an initial triangle # to start the search. Additionally, if there are no ghost triangles, we can only hope that q # is inside the interior, meaning we should only search for the initial triangle here anyway. @@ -783,7 +783,7 @@ function initialise_jump_and_march_interior_vertex(tri::Triangulation, q, k, sto end """ - initialise_jump_and_march_boundary_vertex(tri::Triangulation, q, k, store_history:, history, ghost_vertex, concavity_protection) -> (Bool, Bool, Triangle, Point, Vertex, Vertex, Point, Point) + initialise_find_triangle_boundary_vertex(tri::Triangulation, q, k, store_history:, history, ghost_vertex, concavity_protection) -> (Bool, Bool, Triangle, Point, Vertex, Vertex, Point, Point) Initialise the jump-and-march algorithm for a boundary vertex `k`. @@ -810,17 +810,17 @@ Initialise the jump-and-march algorithm for a boundary vertex `k`. There are multiple stages to this initialisation, starting from [`check_for_intersections_with_adjacent_boundary_edges`](@ref). - If it is found that `q` is not outside of the triangulation, so that `q` is collinear with one of the boundary edges, then we use [`search_down_adjacent_boundary_edges`](@ref) to find where to start, noting - that we can return immediately if `q` is found to be on an adjacent boundary edge. Otherwise, [`exterior_jump_and_march`](@ref) can then be used to find the ghost triangle containing + that we can return immediately if `q` is found to be on an adjacent boundary edge. Otherwise, [`exterior_find_triangle`](@ref) can then be used to find the ghost triangle containing `q`; if `concavity_protection = true`, then [`concavity_protection_check`](@ref) is used to determine if a restart is needed. - If is is not found that `q` is outside of the triangulation yet based on information from the adjacent boundary edges, then we need to check the neighbouring interior edges using [`check_for_intersections_with_interior_edges_adjacent_to_boundary_vertex`](@ref), returning early if `q` is found to be inside one of the neighbouring triangles. If the line `pq`, where `p = get_point(tri, k)`, does not intersect any of the neighbouring edges and it is not inside any of - the neighbouring triangles, then it must be outside of the triangulation and so we use [`exterior_jump_and_march`](@ref) to find the triangle; as before, [`concavity_protection_check`](@ref) + the neighbouring triangles, then it must be outside of the triangulation and so we use [`exterior_find_triangle`](@ref) to find the triangle; as before, [`concavity_protection_check`](@ref) is used on the found ghost triangle if needed. If there is an intersection, then we return the triangle containing the intersection point that we can start the algorithm from, and its associated vertices and points. """ -function initialise_jump_and_march_boundary_vertex(tri::Triangulation, _q, k, store_history::F, history, ghost_vertex, concavity_protection) where {F} +function initialise_find_triangle_boundary_vertex(tri::Triangulation, _q, k, store_history::F, history, ghost_vertex, concavity_protection) where {F} q = getxy(_q) # type stability in case e.g. a user provides a vector into jump and march direction, q_pos, next_vertex, right_cert, left_cert = check_for_intersections_with_adjacent_boundary_edges(tri, k, q, ghost_vertex) @@ -831,7 +831,7 @@ function initialise_jump_and_march_boundary_vertex(tri::Triangulation, _q, k, st if is_on(q_pos) return false, true, construct_triangle(Ttype, u, v, w), q, k, k, q, q # false is the restart_flag, true is the return_flag. We return q, q, q just to get type stability with all returns else - u, v = exterior_jump_and_march(tri, u, q, ghost_vertex) + u, v = exterior_find_triangle(tri, u, q, ghost_vertex) w = get_adjacent(tri, u, v) V = construct_triangle(Ttype, u, v, w) # Can't just use I(𝒢) here since there could be multiple - just use get_adjacent if concavity_protection_check(tri, concavity_protection, V, q) @@ -847,7 +847,7 @@ function initialise_jump_and_march_boundary_vertex(tri::Triangulation, _q, k, st if is_inside(triangle_cert) return false, true, construct_triangle(Ttype, i, j, k), q, i, j, q, q elseif is_none(edge_cert) - u, v = exterior_jump_and_march(tri, k, q, ghost_vertex) + u, v = exterior_find_triangle(tri, k, q, ghost_vertex) w = get_adjacent(tri, u, v) V = construct_triangle(Ttype, u, v, w) if concavity_protection_check(tri, concavity_protection, V, q) @@ -862,7 +862,7 @@ function initialise_jump_and_march_boundary_vertex(tri::Triangulation, _q, k, st end """ - jump_and_march_return_on_vertex(tri::Triangulation, q, k, p, pᵢ, pⱼ, i, j) -> (Bool, Bool, Triangle) + find_triangle_return_on_vertex(tri::Triangulation, q, k, p, pᵢ, pⱼ, i, j) -> (Bool, Bool, Triangle) Check if `q` is one of the vertices of the triangle `(i, j, k)` and return if needed. @@ -885,7 +885,7 @@ Check if `q` is one of the vertices of the triangle `(i, j, k)` and return if ne An extra check is made in this algorithm for the case that the point that `q` is equal to is one of the points corresponding to a ghost vertex, so it may be for example that `q == pᵢ` but `is_ghost_vertex(i)`, in which case the algorithm would need to restart. """ -function jump_and_march_return_on_vertex(tri::Triangulation, q, k, p, pᵢ, pⱼ, i, j) +function find_triangle_return_on_vertex(tri::Triangulation, q, k, p, pᵢ, pⱼ, i, j) # Just return where we currently are. We do need to be careful, though: # If k was a ghost vertex, then one of pᵢ or pⱼ could come from the # representative point list, which could mean that q is equal to one of the @@ -907,9 +907,9 @@ function jump_and_march_return_on_vertex(tri::Triangulation, q, k, p, pᵢ, pⱼ end """ - jump_and_march_across_triangle(tri::Triangulation, q, k, store_history, history, maxiters, cur_iter, concavity_protection, arrangement, original_k, last_changed, p, i, j, pᵢ, pⱼ) -> (Bool, Bool, Bool, Triangle, Integer, Certificate, Vertex, Vertex, Vertex, Point, Point, Integer, Integer) + find_triangle_across_triangle(tri::Triangulation, q, k, store_history, history, maxiters, cur_iter, concavity_protection, arrangement, original_k, last_changed, p, i, j, pᵢ, pⱼ) -> (Bool, Bool, Bool, Triangle, Integer, Certificate, Vertex, Vertex, Vertex, Point, Point, Integer, Integer) -Walks across the current triangle past the edge `(i, j)`. progressing the [`jump_and_march`](@ref) algorithm. +Walks across the current triangle past the edge `(i, j)`. progressing the [`find_triangle`](@ref) algorithm. # Arguments - `tri::Triangulation`: The [`Triangulation`](@ref). @@ -917,7 +917,7 @@ Walks across the current triangle past the edge `(i, j)`. progressing the [`jump - `k`: The vertex that the algorithm started from. - `store_history`: Whether to store the history of the algorithm. - `history`: The history of the algorithm. If `store_history`, then this should be a [`PointLocationHistory`](@ref) object. -- `maxiters`: The maximum number of iterations to perform before restarting the algorithm with [`restart_jump_and_march`](@ref). +- `maxiters`: The maximum number of iterations to perform before restarting the algorithm with [`restart_find_triangle`](@ref). - `cur_iter`: The current iteration of the algorithm. - `concavity_protection`: Whether to use concavity protection. See [`concavity_protection_check`](@ref). This is only needed if your triangulation is not convex. - `arrangement`: A [`Certificate`](@ref) defining the orientation of the triangle `pᵢpⱼq`. @@ -949,7 +949,7 @@ This part of the algorithm is relatively complicated because there are many case and note that the documentation contains a much more detailed description. 1. Firstly, we need to check whether `k` is an exterior ghost vertex or not. If `k` is an exterior ghost vertex, then this means that we are stepping outside of the - triangulation. Thus, we use [`exterior_jump_and_march`](@ref) to find where `q` is, starting from the `last_changed` vertex. If `concavity_protection = true`, then + triangulation. Thus, we use [`exterior_find_triangle`](@ref) to find where `q` is, starting from the `last_changed` vertex. If `concavity_protection = true`, then [`concavity_protection_check`](@ref) is used to determine if a restart is needed, or if we can return safely. If we reach this step but `!has_ghost_triangles(tri)`, then the algorithm should need to be reinitialised since `q` should not be outside of the triangulation, and so we return with `reinitialise_flag = true`. 2. Now we consider the case where `k` is not an exterior ghost vertex. We move forward by updating the value of `k` so that `k = get_adjacent(tri, i, j)`, and then consider where `pₖ` is relative @@ -964,7 +964,7 @@ and note that the documentation contains a much more detailed description. If `last_changed = i`, then moving left is what caused us to find this collinear edge, and so we send `k` left by letting `i = k`. Otherwise, we send `k` right by letting `j = k`. 3. Now having stepped forward, we recompute the [`Certificate`](@ref) for arrangement and return, setting `restart_flag = true` if `cur_iters ≥ maxiters`. """ -function jump_and_march_across_triangle(tri::Triangulation, q, k, store_history::F, history, maxiters, cur_iter, concavity_protection, arrangement, original_k, last_changed, p, i, j, pᵢ, pⱼ) where {F} +function find_triangle_across_triangle(tri::Triangulation, q, k, store_history::F, history, maxiters, cur_iter, concavity_protection, arrangement, original_k, last_changed, p, i, j, pᵢ, pⱼ) where {F} cur_iter += 1 if is_true(store_history) if last_changed == i @@ -979,7 +979,7 @@ function jump_and_march_across_triangle(tri::Triangulation, q, k, store_history: # ghost triangles, though, we just restart the search. Note that interior boundary indices do not matter since the ghost # triangles there have the same orientation, so we can find them as normal. if has_ghost_triangles(tri) - i, j = exterior_jump_and_march(tri, last_changed == i ? j : i, q, k) # use last_changed to ensure we get the boundary point + i, j = exterior_find_triangle(tri, last_changed == i ? j : i, q, k) # use last_changed to ensure we get the boundary point V = construct_triangle(triangle_type(tri), i, j, get_adjacent(tri, i, j)) if concavity_protection_check(tri, concavity_protection, V, q) return true, false, false, V, cur_iter, arrangement, k, last_changed, original_k, pᵢ, pⱼ, i, j # restart_flag, return_flag, reinitialise_flag, V @@ -1070,7 +1070,7 @@ function jump_and_march_across_triangle(tri::Triangulation, q, k, store_history: end """ - jump_and_march_degenerate_arrangement(tri::Triangulation, q, k, store_history::F, history, pᵢ, pⱼ, i, j) -> Bool + find_triangle_degenerate_arrangement(tri::Triangulation, q, k, store_history::F, history, pᵢ, pⱼ, i, j) -> Bool Given a degenerate arrangement `pᵢpⱼq`, reinitialise the jump and march algorithm. @@ -1088,7 +1088,7 @@ Given a degenerate arrangement `pᵢpⱼq`, reinitialise the jump and march algo # Outputs - `Bool`: Whether the algorithm needs to be restarted. """ -function jump_and_march_degenerate_arrangement(tri::Triangulation, q, k, store_history::F, history, pᵢ, pⱼ, i, j) where {F} +function find_triangle_degenerate_arrangement(tri::Triangulation, q, k, store_history::F, history, pᵢ, pⱼ, i, j) where {F} pₖ = get_point(tri, k) # Need to have this here in case we skip the entire loop, above, meaning pₖ won't exist in_cert = point_position_relative_to_triangle(pᵢ, pⱼ, pₖ, q) # ... Maybe there is a better way to compute this, reusing previous certificates? Not sure. ... if is_true(store_history) @@ -1100,31 +1100,31 @@ function jump_and_march_degenerate_arrangement(tri::Triangulation, q, k, store_h return is_outside(in_cert) # if outside, we need to reinitialise. Otherwise, we're all good. end -function _jump_and_march(tri::Triangulation, q, k, store_history::F, history, rng::AbstractRNG, maxiters, cur_iter, concavity_protection, num_restarts, use_barriers::Val{U}) where {F,U} +function _find_triangle(tri::Triangulation, q, k, store_history::F, history, rng::AbstractRNG, maxiters, cur_iter, concavity_protection, num_restarts, use_barriers::Val{U}) where {F,U} is_bnd, ghost_vertex = is_boundary_node(tri, k) I = integer_type(tri) trit = triangle_type(tri) if !(is_bnd && is_exterior_ghost_vertex(tri, ghost_vertex)) || !has_ghost_triangles(tri) - restart_flag, p, i, j, pᵢ, pⱼ = initialise_jump_and_march_interior_vertex(tri, q, k, store_history, history, rng) + restart_flag, p, i, j, pᵢ, pⱼ = initialise_find_triangle_interior_vertex(tri, q, k, store_history, history, rng) if restart_flag && (!(is_bnd && is_interior_ghost_vertex(tri, ghost_vertex)) || !is_true(use_barriers)) # if we are not at an interior boundary node, then we should not have reached a barrier yet. but if we are at such a node, then the only reason to restart is if we have reached a barrier. - return restart_jump_and_march(tri, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) + return restart_find_triangle(tri, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) elseif restart_flag && is_true(use_barriers) V = construct_triangle(trit, I(∅), I(∅), I(∅)) return V, true end else - restart_flag, return_flag, V, p, i, j, pᵢ, pⱼ = initialise_jump_and_march_boundary_vertex(tri, q, k, store_history, history, ghost_vertex, concavity_protection) + restart_flag, return_flag, V, p, i, j, pᵢ, pⱼ = initialise_find_triangle_boundary_vertex(tri, q, k, store_history, history, ghost_vertex, concavity_protection) if restart_flag && !is_true(use_barriers) - return restart_jump_and_march(tri, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) + return restart_find_triangle(tri, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) elseif restart_flag && is_true(use_barriers) return V, true end return_flag && return is_true(use_barriers) ? (V, is_ghost_triangle(V)) : V end if q == p || q == pᵢ || q == pⱼ - restart_flag, return_flag, V = jump_and_march_return_on_vertex(tri, q, k, p, pᵢ, pⱼ, i, j) + restart_flag, return_flag, V = find_triangle_return_on_vertex(tri, q, k, p, pᵢ, pⱼ, i, j) if restart_flag && !is_true(use_barriers) - return restart_jump_and_march(tri, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) + return restart_find_triangle(tri, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) elseif restart_flag && is_true(use_barriers) return V, true end @@ -1147,22 +1147,22 @@ function _jump_and_march(tri::Triangulation, q, k, store_history::F, history, rn add_right_vertex!(history, j) end while is_positively_oriented(arrangement) && !reached_barrier - restart_flag, return_flag, reinitialise_flag, V, cur_iter, arrangement, k, last_changed, original_k, pᵢ, pⱼ, i, j = jump_and_march_across_triangle(tri, q, k, store_history, history, maxiters, cur_iter, concavity_protection, arrangement, original_k, last_changed, p, i, j, pᵢ, pⱼ) + restart_flag, return_flag, reinitialise_flag, V, cur_iter, arrangement, k, last_changed, original_k, pᵢ, pⱼ, i, j = find_triangle_across_triangle(tri, q, k, store_history, history, maxiters, cur_iter, concavity_protection, arrangement, original_k, last_changed, p, i, j, pᵢ, pⱼ) if restart_flag && !is_true(use_barriers) - return restart_jump_and_march(tri, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) + return restart_find_triangle(tri, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) elseif restart_flag && is_true(use_barriers) return V, true end return_flag && return is_true(use_barriers) ? (V, reached_barrier) : V - reinitialise_flag && return _jump_and_march(tri, q, k, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) + reinitialise_flag && return _find_triangle(tri, q, k, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) reached_barrier = is_true(use_barriers) && is_positively_oriented(arrangement) && contains_segment(tri, i, j) # check the arrangement cert since, if it is now negative, then we don't care about the next edge (i, j) because we have reached the triangle end # We can finish the above loop even if q is not in the triangle, in which case pᵢpⱼq was a straight line. # To clear this up, let us just restart. if is_degenerate(arrangement) - reinitialise_flag = jump_and_march_degenerate_arrangement(tri, q, k, store_history, history, pᵢ, pⱼ, i, j) + reinitialise_flag = find_triangle_degenerate_arrangement(tri, q, k, store_history, history, pᵢ, pⱼ, i, j) if reinitialise_flag && !is_true(use_barriers) - return _jump_and_march(tri, q, last_changed == I(∅) ? i : last_changed, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) + return _find_triangle(tri, q, last_changed == I(∅) ? i : last_changed, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) elseif reinitialise_flag && is_true(use_barriers) return V, true end @@ -1171,7 +1171,7 @@ function _jump_and_march(tri::Triangulation, q, k, store_history::F, history, rn k = get_adjacent(tri, j, i) V = construct_triangle(trit, j, i, k) if !reached_barrier && concavity_protection_check(tri, concavity_protection, V, q) - return restart_jump_and_march(tri, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) + return restart_find_triangle(tri, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts + 1, use_barriers) end if is_true(use_barriers) return V, reached_barrier @@ -1183,7 +1183,7 @@ end """ concavity_protection_check(tri::Triangulation, concavity_protection, V, q) -> Bool -Check whether the [`jump_and_march`](@ref) algorithm needs to restart. This is only needed if `tri` is not convex. +Check whether the [`find_triangle`](@ref) algorithm needs to restart. This is only needed if `tri` is not convex. # Arguments - `tri::Triangulation`: The [`Triangulation`](@ref). @@ -1212,9 +1212,9 @@ end const RESTART_LIMIT = 25 """ - restart_jump_and_march(tri::Triangulation, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts, use_barriers) -> Triangle[, Bool] + restart_find_triangle(tri::Triangulation, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts, use_barriers) -> Triangle[, Bool] -Restart the [`jump_and_march`](@ref) algorithm, or use [`brute_force_search`](@ref) to find `q` if `num_restarts ≥ $RESTART_LIMIT`. +Restart the [`find_triangle`](@ref) algorithm, or use [`brute_force_search`](@ref) to find `q` if `num_restarts ≥ $RESTART_LIMIT`. # Arguments - `tri::Triangulation`: The [`Triangulation`](@ref). @@ -1222,7 +1222,7 @@ Restart the [`jump_and_march`](@ref) algorithm, or use [`brute_force_search`](@r - `store_history`: Whether to store the history of the algorithm. - `history`: The history of the algorithm. If `store_history`, then this should be a [`PointLocationHistory`](@ref) object. - `rng`: The random number generator to use. -- `maxiters`: The maximum number of iterations to perform before restarting the algorithm with [`restart_jump_and_march`](@ref). +- `maxiters`: The maximum number of iterations to perform before restarting the algorithm with [`restart_find_triangle`](@ref). - `cur_iter`: The current iteration of the algorithm. - `concavity_protection`: Whether to use concavity protection. See [`concavity_protection_check`](@ref). This is only needed if your triangulation is not convex. - `num_restarts`: The number of times the algorithm has been restarted. @@ -1233,12 +1233,12 @@ Restart the [`jump_and_march`](@ref) algorithm, or use [`brute_force_search`](@r In addition, if `use_barriers = Val(true)`, then a second output is returned, which is a boolean indicating whether the algorithm reached a barrier (`true`) or not (`false`). """ -function restart_jump_and_march(tri, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts, use_barriers) +function restart_find_triangle(tri, q, store_history, history, rng, maxiters, cur_iter, concavity_protection, num_restarts, use_barriers) if num_restarts < RESTART_LIMIT m = num_solid_vertices(tri) point_indices = each_solid_vertex(tri) k = select_initial_point(tri, q; m=(m >> 1) + 1, point_indices, rng) # don't want to try all points, still want to give the algorithm a chance - return _jump_and_march(tri, q, k, store_history, history, rng, maxiters, zero(cur_iter), concavity_protection, num_restarts, use_barriers) + return _find_triangle(tri, q, k, store_history, history, rng, maxiters, zero(cur_iter), concavity_protection, num_restarts, use_barriers) else V = brute_force_search(tri, q) V_is_bad = concavity_protection_check(tri, concavity_protection, V, q) diff --git a/src/algorithms/point_location/nearest_neighbour.jl b/src/algorithms/point_location/nearest_neighbour.jl index f126d244f..1737a1fb0 100644 --- a/src/algorithms/point_location/nearest_neighbour.jl +++ b/src/algorithms/point_location/nearest_neighbour.jl @@ -8,20 +8,20 @@ Get the index of the nearest neighbour of `q` in `tri_or_vor`. - `q`: The point to be located. # Keyword Arguments -- `kwargs...`: Keyword arguments passed to [`jump_and_march`](@ref). +- `kwargs...`: Keyword arguments passed to [`find_triangle`](@ref). # Output - `i`: The index of the nearest neighbour. This is a point of the triangulation if `tri_or_vor` is a [`Triangulation`](@ref) or of a generator if `tri_or_vor` is a [`VoronoiTessellation`](@ref). """ get_nearest_neighbour -get_nearest_neighbour(vor::VoronoiTessellation, q; kwargs...) = jump_and_march(vor, q; kwargs...) +get_nearest_neighbour(vor::VoronoiTessellation, q; kwargs...) = find_triangle(vor, q; kwargs...) get_nearest_neighbour(tri::Triangulation, q; kwargs...) = jump_to_voronoi_polygon(tri, q; kwargs...) -function jump_and_march(vor::VoronoiTessellation, q; kwargs...) +function find_triangle(vor::VoronoiTessellation, q; kwargs...) return jump_to_voronoi_polygon(get_triangulation(vor), q; kwargs...) end function jump_to_voronoi_polygon(tri::Triangulation, q; kwargs...) - V = jump_and_march(tri, q; kwargs...) + V = find_triangle(tri, q; kwargs...) qx, qy = getxy(q) V = sort_triangle(V) i, j, k = triangle_vertices(V) diff --git a/src/algorithms/triangulation/basic_operations/add_point.jl b/src/algorithms/triangulation/basic_operations/add_point.jl index 2ab939cfc..095296855 100644 --- a/src/algorithms/triangulation/basic_operations/add_point.jl +++ b/src/algorithms/triangulation/basic_operations/add_point.jl @@ -7,16 +7,16 @@ - `new_point`: The point to be added to the triangulation. The second method uses `(x, y)` to represent the new point instead. If `new_point` is an integer, then the point added is `get_point(tri, new_point)`. # Keyword Arguments -- `point_indices=each_solid_vertex(tri)`: The indices of the points to be used in the [`jump_and_march`](@ref) algorithm for selecting the initial point. -- `m=default_num_samples(length(point_indices))`: The number of samples (without replacement) to be used in the [`jump_and_march`](@ref) algorithm for selecting the initial point. +- `point_indices=each_solid_vertex(tri)`: The indices of the points to be used in the [`find_triangle`](@ref) algorithm for selecting the initial point. +- `m=default_num_samples(length(point_indices))`: The number of samples (without replacement) to be used in the [`find_triangle`](@ref) algorithm for selecting the initial point. - `try_points=()`: Additional points to try for selecting the initial point, in addition to the `m` sampled. -- `rng::AbstractRNG=Random.default_rng()`: The random number generator to be used in [`jump_and_march`](@ref). -- `initial_search_point=integer_type(tri)(select_initial_point(tri, new_point; point_indices, m, try_points, rng))`: The initial point to be used in [`jump_and_march`](@ref). +- `rng::AbstractRNG=Random.default_rng()`: The random number generator to be used in [`find_triangle`](@ref). +- `initial_search_point=integer_type(tri)(select_initial_point(tri, new_point; point_indices, m, try_points, rng))`: The initial point to be used in [`find_triangle`](@ref). - `update_representative_point=false`: Whether to update the representative point of the triangulation after adding the new point. - `store_event_history=Val(false)`: Whether to store the event history of the triangulation from adding the new point. - `event_history=nothing`: The event history of the triangulation from adding the new point. Only updated if `store_event_history` is true, in which case it needs to be an [`InsertionEventHistory`](@ref) object. - `concavity_protection=false`: Whether to use concavity protection for finding `V` below. See [`concavity_protection_check`](@ref). This is only needed if your triangulation is not convex. -- `V=jump_and_march(tri, get_point(tri, new_point); m=nothing, point_indices=nothing, try_points=nothing, k=initial_search_point, concavity_protection, rng)`: The positively oriented triangle containing the point being added. +- `V=find_triangle(tri, get_point(tri, new_point); m=nothing, point_indices=nothing, try_points=nothing, k=initial_search_point, concavity_protection, rng)`: The positively oriented triangle containing the point being added. !!! warning "Non-convex domains" @@ -44,7 +44,7 @@ function add_point!(tri::Triangulation, new_point; store_event_history=Val(false), event_history=nothing, concavity_protection=false, - V=jump_and_march( + V=find_triangle( tri, get_point(tri, new_point); m=nothing, @@ -80,7 +80,7 @@ function add_point!(tri::Triangulation, new_point_x, new_point_y; store_event_history=Val(false), event_history=nothing, concavity_protection=false, - V=jump_and_march( + V=find_triangle( tri, (new_point_x, new_point_y); m=nothing, diff --git a/src/algorithms/triangulation/constrained_triangulation.jl b/src/algorithms/triangulation/constrained_triangulation.jl index 32fcb631e..5a2ccec01 100644 --- a/src/algorithms/triangulation/constrained_triangulation.jl +++ b/src/algorithms/triangulation/constrained_triangulation.jl @@ -674,7 +674,7 @@ end Find all the triangles intersected by an edge `e`. -See also [`jump_and_march`](@ref). +See also [`find_triangle`](@ref). # Arguments - `tri::Triangulation`: The [`Triangulation`](@ref). @@ -696,7 +696,7 @@ function locate_intersecting_triangles(tri::Triangulation, e, rotate=Val(true), history = PointLocationHistory{V,E,I}() add_left_vertex!(history, initial(e)) add_right_vertex!(history, initial(e)) - jump_and_march(tri, get_point(tri, terminal(e)); + find_triangle(tri, get_point(tri, terminal(e)); m=nothing, k=initial(e), store_history=Val(true), history, rng ) add_left_vertex!(history, terminal(e)) diff --git a/src/algorithms/triangulation/main.jl b/src/algorithms/triangulation/main.jl index 7a9fe6cfd..a4c961849 100644 --- a/src/algorithms/triangulation/main.jl +++ b/src/algorithms/triangulation/main.jl @@ -90,7 +90,7 @@ Computes the Delaunay triangulation of `points`, and then the constrained Delaun - `try_last_inserted_point=true`: Whether to try the last inserted point first when inserting points into the triangulation. - `skip_points=()`: The points to skip when inserting points into the triangulation. Note that, for curve-bounded domains, `skip_points` is ignored when using [`enrich_boundary!`](@ref). -- `num_sample_rule=default_num_samples`: A function mapping a number of points `n` to a number of samples `m` to use for sampling the initial points during the point location step of the algorithm within [`jump_and_march`](@ref). +- `num_sample_rule=default_num_samples`: A function mapping a number of points `n` to a number of samples `m` to use for sampling the initial points during the point location step of the algorithm within [`find_triangle`](@ref). - `rng::AbstractRNG=Random.default_rng()`: The random number generator. - `insertion_order::Vector=get_insertion_order(points, randomise, skip_points, IntegerType, rng)`: The insertion order to use for inserting points into the triangulation. This is ignored if you are defining a curve-bounded domain. - `recompute_representative_points=true`: Whether to recompute the representative points after the triangulation is computed. This is done using [`compute_representative_points!`](@ref). diff --git a/src/algorithms/triangulation/mesh_refinement.jl b/src/algorithms/triangulation/mesh_refinement.jl index f877e30ad..2bb4cc1a0 100644 --- a/src/algorithms/triangulation/mesh_refinement.jl +++ b/src/algorithms/triangulation/mesh_refinement.jl @@ -30,7 +30,7 @@ See the documentation for more information about mesh refinement, e.g. convergen - `use_lens=true`: Whether to use the diametral lens or the diametral circle for checking encroachment. - `steiner_scale=0.999`: The perturbation factor to use for generalised Steiner points if `use_circumcenter=false`. (Not currently used - see above.) - `rng=Random.default_rng()`: The random number generator to use in case it is needed during point location. -- `concavity_protection=false`: Whether to use concavity protection or not for [`jump_and_march`](@ref). Most likely not needed, but may help in pathological cases. +- `concavity_protection=false`: Whether to use concavity protection or not for [`find_triangle`](@ref). Most likely not needed, but may help in pathological cases. # Output The triangulation is refined in-place. @@ -236,7 +236,7 @@ end """ locate_steiner_point(tri::Triangulation, args::RefinementArguments, T, c) -> Triangle, Cert -Locates the Steiner point `c` of a triangle `T` of `tri` in [`get_steiner_point`](@ref). The Steiner point is located by walking from the initial vertex `init` to `c` using [`jump_and_march`](@ref). +Locates the Steiner point `c` of a triangle `T` of `tri` in [`get_steiner_point`](@ref). The Steiner point is located by walking from the initial vertex `init` to `c` using [`find_triangle`](@ref). # Arguments - `tri::Triangulation`: The [`Triangulation`](@ref) to split a triangle of. @@ -252,7 +252,7 @@ function locate_steiner_point(tri::Triangulation, args::RefinementArguments, T, flag = point_position_relative_to_triangle(tri, T, c) !is_outside(flag) && return T, flag # T is never a ghost triangle, so don't worry about checking is_on(flag) here init = get_init_for_steiner_point(tri, T) - V, _ = jump_and_march(tri, c; m=nothing, point_indices=nothing, try_points=nothing, k=init, args.rng, args.concavity_protection, use_barriers=Val(true)) + V, _ = find_triangle(tri, c; m=nothing, point_indices=nothing, try_points=nothing, k=init, args.rng, args.concavity_protection, use_barriers=Val(true)) flag = point_position_relative_to_triangle(tri, V, c) if is_ghost_triangle(V) && is_on(flag) V = replace_ghost_triangle_with_boundary_triangle(tri, V) diff --git a/src/algorithms/triangulation/unconstrained_triangulation.jl b/src/algorithms/triangulation/unconstrained_triangulation.jl index 8fd140bd7..79254fa5d 100644 --- a/src/algorithms/triangulation/unconstrained_triangulation.jl +++ b/src/algorithms/triangulation/unconstrained_triangulation.jl @@ -87,7 +87,7 @@ end """ get_initial_search_point(tri::Triangulation, num_points, new_point, insertion_order, num_sample_rule::F, rng, try_last_inserted_point) where {F} -> Vertex -For a given iteration of the Bowyer-Watson algorithm, finds the point to start the point location with [`jump_and_march`](@ref) at. +For a given iteration of the Bowyer-Watson algorithm, finds the point to start the point location with [`find_triangle`](@ref) at. # Arguments - `tri`: The triangulation. @@ -99,7 +99,7 @@ For a given iteration of the Bowyer-Watson algorithm, finds the point to start t - `try_last_inserted_point`: If `true`, then the last inserted point is also considered as the start point. # Output -- `initial_search_point`: The vertex to start the point location with [`jump_and_march`](@ref) at. +- `initial_search_point`: The vertex to start the point location with [`find_triangle`](@ref) at. """ function get_initial_search_point(tri::Triangulation, num_points, new_point, insertion_order, num_sample_rule::F, rng, try_last_inserted_point) where {F} num_currently_inserted = num_points + 3 - 1 # + 3 for the points already inserted @@ -119,7 +119,7 @@ Adds `new_point` into `tri`. # Arguments - `tri`: The triangulation. - `new_point`: The point to insert. -- `initial_search_point::I`: The vertex to start the point location with [`jump_and_march`](@ref) at. See [`get_initial_search_point`](@ref). +- `initial_search_point::I`: The vertex to start the point location with [`find_triangle`](@ref) at. See [`get_initial_search_point`](@ref). - `rng::AbstractRNG`: The random number generator to use. - `update_representative_point=true`: If `true`, then the representative point is updated. See [`update_centroid_after_addition!`](@ref). - `store_event_history=Val(false)`: If `true`, then the event history from the insertion is stored. @@ -132,7 +132,7 @@ Adds `new_point` into `tri`. # Extended help This function works as follows: -1. First, the triangle containing the new point, `V`, is found using [`jump_and_march`](@ref). +1. First, the triangle containing the new point, `V`, is found using [`find_triangle`](@ref). 2. Once the triangle is found, we call into `add_point_bowyer_watson_and_process_after_found_triangle` to properly insert the point. 3. Inside `add_point_bowyer_watson_and_process_after_found_triangle`, we first call into `add_point_bowyer_watson_after_found_triangle` to add the point into the cavity. We then call into `add_point_bowyer_watson_onto_segment` to make any changes necessary incase the triangulation is constrained and `new_point` lies on a segment, since the depth-first search of the triangles containing `new_point` in its circumcenter @@ -143,7 +143,7 @@ The function [`add_point_bowyer_watson_dig_cavities!`](@ref) is the main workhor function add_point_bowyer_watson!(tri::Triangulation, new_point, initial_search_point::I, rng::AbstractRNG=Random.default_rng(), update_representative_point=true, store_event_history=Val(false), event_history=nothing, peek::P=Val(false)) where {I,P} _new_point = is_true(peek) ? new_point : I(new_point) q = get_point(tri, _new_point) - V = jump_and_march(tri, q; m=nothing, point_indices=nothing, try_points=nothing, k=initial_search_point, rng) + V = find_triangle(tri, q; m=nothing, point_indices=nothing, try_points=nothing, k=initial_search_point, rng) if is_weighted(tri) #= This part here is why the Bowyer-Watson algorithm is not implemented for weighted triangulations yet. I don't understand why it sometimes diff --git a/src/data_structures/mesh_refinement/refinement_arguments.jl b/src/data_structures/mesh_refinement/refinement_arguments.jl index 8dbe2f1a3..5889a86f1 100644 --- a/src/data_structures/mesh_refinement/refinement_arguments.jl +++ b/src/data_structures/mesh_refinement/refinement_arguments.jl @@ -18,7 +18,7 @@ A struct for storing arguments for mesh refinement. - `locked_convex_hull::Bool`: Whether the convex hull of the triangulation had to be locked for refinement. - `had_ghosts::Bool`: Whether the triangulation initially had ghost triangles or not. - `rng::R`: The random number generator. -- `concavity_protection::Bool`: Whether to use concavity protection or not for [`jump_and_march`](@ref). Most likely not needed, but may help in pathological cases. +- `concavity_protection::Bool`: Whether to use concavity protection or not for [`find_triangle`](@ref). Most likely not needed, but may help in pathological cases. # Constructors In addition to the default constructor, we provide diff --git a/src/data_structures/point_location_history.jl b/src/data_structures/point_location_history.jl index 4c02cb158..f1de77cc0 100644 --- a/src/data_structures/point_location_history.jl +++ b/src/data_structures/point_location_history.jl @@ -1,7 +1,7 @@ """ PointLocationHistory{T,E,I} -History from using [`jump_and_march`](@ref). +History from using [`find_triangle`](@ref). # Fields - `triangles::Vector{T}`: The visited triangles. diff --git a/src/data_structures/triangulation/methods/weights.jl b/src/data_structures/triangulation/methods/weights.jl index 078bf8c0d..66a864003 100644 --- a/src/data_structures/triangulation/methods/weights.jl +++ b/src/data_structures/triangulation/methods/weights.jl @@ -167,7 +167,7 @@ function is_submerged(tri::Triangulation, i) # (If the link dies, it is the PhD thesis of Michal Zemek, "Regular Triangulation in 3D and Its Applications".) is_ghost_vertex(i) && return false q = get_point(tri, i) - V = jump_and_march(tri, q) + V = find_triangle(tri, q) return is_submerged(tri, i, V) end function is_submerged(tri::Triangulation, i, V) diff --git a/src/predicates/predicates.jl b/src/predicates/predicates.jl index d3351db2d..31fc38a23 100644 --- a/src/predicates/predicates.jl +++ b/src/predicates/predicates.jl @@ -656,7 +656,7 @@ the two does not intersect any segments. - `cert`: A [`Certificate`](@ref). This will be `Visible` if `i` is visible from `q`, and `Invisible` otherwise. """ function test_visibility(tri::Triangulation, q, i) - V, invisible_flag = jump_and_march(tri, q; use_barriers=Val(true), k=i, concavity_protection=true) + V, invisible_flag = find_triangle(tri, q; use_barriers=Val(true), k=i, concavity_protection=true) if invisible_flag return Certificate.Invisible else diff --git a/test/constrained_triangulation/segment_location.jl b/test/constrained_triangulation/segment_location.jl index c46658514..59d720b91 100644 --- a/test/constrained_triangulation/segment_location.jl +++ b/test/constrained_triangulation/segment_location.jl @@ -297,7 +297,7 @@ if load_preference(DelaunayTriangulation, "USE_EXACTPREDICATES", true) tri = triangulate(get_points(tri)) e = (23, 71) history = DT.PointLocationHistory{NTuple{3,Int},NTuple{2,Int},Int}() - jump_and_march(tri, get_point(tri, 71); + find_triangle(tri, get_point(tri, 71); m=nothing, k=23, store_history=true, history=history) collinear_segments = history.collinear_segments DT.connect_segments!(collinear_segments) @@ -311,7 +311,7 @@ end tri = triangulate_rectangle(0, 5, 0, 10, 6, 11; delete_ghosts=false) e = (14, 40) history = DT.PointLocationHistory{NTuple{3,Int},NTuple{2,Int},Int}() - jump_and_march(tri, get_point(tri, 40); + find_triangle(tri, get_point(tri, 40); m=nothing, k=14, store_history=true, history=history) collinear_segments = history.collinear_segments DT.fix_segments!(collinear_segments, history.collinear_point_indices) @@ -321,7 +321,7 @@ end e = (2, 54) history = DT.PointLocationHistory{NTuple{3,Int},NTuple{2,Int},Int}() - jump_and_march(tri, get_point(tri, 54); + find_triangle(tri, get_point(tri, 54); m=nothing, k=2, store_history=true, history=history) collinear_segments = history.collinear_segments bad_indices = history.collinear_point_indices diff --git a/test/data_structures/triangulation.jl b/test/data_structures/triangulation.jl index da9093469..7af7f05ed 100644 --- a/test/data_structures/triangulation.jl +++ b/test/data_structures/triangulation.jl @@ -654,7 +654,7 @@ end for k in each_solid_vertex(tri) q = get_point(tri, qi) history = DT.PointLocationHistory{NTuple{3,Int},NTuple{2,Int},Int}() - jump_and_march(tri, q; + find_triangle(tri, q; k, store_history=true, history) diff --git a/test/helper_functions.jl b/test/helper_functions.jl index 2862d37f5..723742a4a 100644 --- a/test/helper_functions.jl +++ b/test/helper_functions.jl @@ -1340,7 +1340,7 @@ function validate_refinement(tri, args; check_conformal=true, warn=true) minθ = min(minθ, t1, t2, t3) maxθ = max(maxθ, t1, t2, t3) end - V = jump_and_march(tri, steiner_point) + V = find_triangle(tri, steiner_point) flag = DT.point_position_relative_to_triangle(tri, V, steiner_point) if DT.is_on(flag) && DT.is_ghost_triangle(V) V = DT.replace_ghost_triangle_with_boundary_triangle(tri, V) diff --git a/test/point_location/ghost_search.jl b/test/point_location/ghost_search.jl index 658872eaf..0f205fab1 100644 --- a/test/point_location/ghost_search.jl +++ b/test/point_location/ghost_search.jl @@ -30,87 +30,87 @@ k_list = unique(boundary_nodes[1][1]) @testset "Finding points outside" begin q = [-3.94232, 15.6067] for k in k_list - i, j = DT.exterior_jump_and_march(tri, k, q) + i, j = DT.exterior_find_triangle(tri, k, q) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) @test i == index_map["h"] && j == index_map["g"] end q = [-5.0, 5.0] for k in k_list - i, j = DT.exterior_jump_and_march(tri, k, q) + i, j = DT.exterior_find_triangle(tri, k, q) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) @test i == index_map["a"] && j == index_map["h"] end q = [-4.8934362297993, -5.6330436693732] for k in k_list - i, j = DT.exterior_jump_and_march(tri, k, q) + i, j = DT.exterior_find_triangle(tri, k, q) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) @test i == index_map["b"] && j == index_map["a"] end q = [15.0, -5.0] for k in k_list - i, j = DT.exterior_jump_and_march(tri, k, q) + i, j = DT.exterior_find_triangle(tri, k, q) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) @test i == index_map["c"] && j == index_map["b"] end q = [25.0, 0.0] for k in k_list - i, j = DT.exterior_jump_and_march(tri, k, q) + i, j = DT.exterior_find_triangle(tri, k, q) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) @test i == index_map["d"] && j == index_map["c"] end q = [25.0, 15.0] for k in k_list - i, j = DT.exterior_jump_and_march(tri, k, q) - @inferred DT.exterior_jump_and_march(tri, k, q) + i, j = DT.exterior_find_triangle(tri, k, q) + @inferred DT.exterior_find_triangle(tri, k, q) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) @test i == index_map["e"] && j == index_map["d"] end q = [13.717, 22.3597] for k in k_list - i, j = DT.exterior_jump_and_march(tri, k, q) + i, j = DT.exterior_find_triangle(tri, k, q) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) @test i == index_map["f"] && j == index_map["e"] end q = [2.3469, 22.61468] for k in k_list - i, j = DT.exterior_jump_and_march(tri, k, q) + i, j = DT.exterior_find_triangle(tri, k, q) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) @test i == index_map["g"] && j == index_map["f"] end q = [-5.0, 25.0] for k in k_list - i, j = DT.exterior_jump_and_march(tri, k, q) + i, j = DT.exterior_find_triangle(tri, k, q) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) f, g, h = index_map["f"], index_map["g"], index_map["h"] @test (j, i) == (f, g) || (j, i) == (g, h) end q = [-5.0, 1.0] for k in k_list - i, j = DT.exterior_jump_and_march(tri, k, q) + i, j = DT.exterior_find_triangle(tri, k, q) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) g, h, a = index_map["g"], index_map["h"], index_map["a"] @test (j, i) == (g, h) || (j, i) == (h, a) end q = [-5.0, -5.0] for k in k_list - i, j = DT.exterior_jump_and_march(tri, k, q) + i, j = DT.exterior_find_triangle(tri, k, q) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) h, a, b = index_map["h"], index_map["a"], index_map["b"] @test (j, i) == (h, a) || (j, i) == (a, b) end q = [10.0, -5.0] for k in k_list - i, j = DT.exterior_jump_and_march(tri, k, q) + i, j = DT.exterior_find_triangle(tri, k, q) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) a, b, c = index_map["a"], index_map["b"], index_map["c"] @test (j, i) == (a, b) || (j, i) == (b, c) end q = [60.0, 60.0] for k in k_list - i, j = DT.exterior_jump_and_march(tri, k, q) + i, j = DT.exterior_find_triangle(tri, k, q) @test DT.is_ghost_vertex(get_adjacent(adj, i, j)) d, e, f = index_map["d"], index_map["e"], index_map["f"] @test (j, i) == (d, e) || (j, i) == (e, f) @@ -120,7 +120,7 @@ end @testset "Testing points that are already in the triangulation" begin for k in DT.each_point_index(pts) if DT.is_exterior_boundary_node(tri, k) - i, j = DT.exterior_jump_and_march(tri, k, get_point(tri, k)) + i, j = DT.exterior_find_triangle(tri, k, get_point(tri, k)) @test k ∈ (i, j) && DT.is_exterior_ghost_triangle(tri, i, j, get_adjacent(tri, i, j)) @test DT.is_on(DT.point_position_relative_to_triangle(tri, i, j, k, k)) diff --git a/test/point_location/jump_and_march.jl b/test/point_location/jump_and_march.jl index d055e5f0a..5499d4fa9 100644 --- a/test/point_location/jump_and_march.jl +++ b/test/point_location/jump_and_march.jl @@ -62,12 +62,12 @@ boundary_nodes = get_boundary_nodes(tri) for _ in 1:36 for k in DT.each_point_index(pts) for i in eachindex(allq) - T1 = jump_and_march(tri, allq[i]; k) - T2 = jump_and_march(tri, allq[i]) + T1 = find_triangle(tri, allq[i]; k) + T2 = find_triangle(tri, allq[i]) @test DT.is_positively_oriented(DT.triangle_orientation(tri, T1)) @test DT.is_positively_oriented(DT.triangle_orientation(tri, T2)) - @inferred jump_and_march(tri, allq[i]; k) - @inferred jump_and_march(tri, allq[i]) + @inferred find_triangle(tri, allq[i]; k) + @inferred find_triangle(tri, allq[i]) for V in [T1, T2] if length(allV[i]) == 1 @test DT.compare_triangles(V, allV[i][1]) && DT.is_inside(DT.point_position_relative_to_triangle(tri, V, allq[i])) @@ -132,7 +132,7 @@ rep[3].y = mean([12.0, 6.0, 2.0, 4.0, 6.0, 10.0]) local c c = (p .+ q .+ r) ./ 3 for k in DT.each_solid_vertex(tri) - _V = jump_and_march(tri, c; k, concavity_protection=true) + _V = find_triangle(tri, c; k, concavity_protection=true) @test DT.is_positively_oriented(DT.triangle_orientation(tri, _V)) if !DT.is_ghost_triangle(_V...) @test DT.compare_triangles(_V, V) && @@ -170,7 +170,7 @@ rep[3].y = mean([12.0, 6.0, 2.0, 4.0, 6.0, 10.0]) for k in DT.each_solid_vertex(tri) rand() < 1 / 2 && continue for j in DT.each_solid_vertex(tri) - _V = jump_and_march(tri, get_point(tri, k); k=j) + _V = find_triangle(tri, get_point(tri, k); k=j) @test k ∈ triangle_vertices(_V) @test DT.is_positively_oriented(DT.triangle_orientation(tri, _V)) end @@ -186,7 +186,7 @@ rep[3].y = mean([12.0, 6.0, 2.0, 4.0, 6.0, 10.0]) q = (50randn(), 50rand()) for k in DT.each_solid_vertex(tri) rand() < 1 / 2 && continue - _V1 = jump_and_march(tri, q; k) + _V1 = find_triangle(tri, q; k) @test DT.is_inside(DT.point_position_relative_to_triangle(tri, _V1, q)) end end @@ -212,7 +212,7 @@ end for qi in each_solid_vertex(tri) for k in each_solid_vertex(tri) q = get_point(tri, qi) - T = jump_and_march(tri, q; k) + T = find_triangle(tri, q; k) @test DT.is_positively_oriented(DT.triangle_orientation(tri, T)) @test DT.is_on(DT.point_position_relative_to_triangle(tri, T, q)) end @@ -289,7 +289,7 @@ end T = (i, j, k) r = 5 for i in 1:10000 - V = jump_and_march(tri, get_point(tri, k); point_indices=nothing, m=nothing, try_points=nothing, k=r, concavity_protection=true) + V = find_triangle(tri, get_point(tri, k); point_indices=nothing, m=nothing, try_points=nothing, k=r, concavity_protection=true) @test !DT.is_outside(DT.point_position_relative_to_triangle(tri, V, get_point(tri, k))) end end @@ -317,7 +317,7 @@ end ] δs = [DelaunayTriangulation.distance_to_polygon(q, get_points(tri), get_boundary_nodes(tri)) for q in qs] for i in 1:1000 - Vs = [jump_and_march(tri, q, concavity_protection=true, rng=StableRNG(i + j)) for (j, q) in enumerate(qs)] + Vs = [find_triangle(tri, q, concavity_protection=true, rng=StableRNG(i + j)) for (j, q) in enumerate(qs)] for (q, δ, V) in zip(qs, δs, Vs) cert = DelaunayTriangulation.point_position_relative_to_triangle(tri, V, q) if δ ≥ 0.0 @@ -334,7 +334,7 @@ end rng = StableRNG(i) qs = [((b - a) * rand(rng) + a, (d - c) * rand(rng) + c) for _ in 1:1000] δs = [DelaunayTriangulation.distance_to_polygon(q, get_points(tri), get_boundary_nodes(tri)) for q in qs] - Vs = [jump_and_march(tri, q, concavity_protection=true, rng=StableRNG(i + j)) for (j, q) in enumerate(qs)] + Vs = [find_triangle(tri, q, concavity_protection=true, rng=StableRNG(i + j)) for (j, q) in enumerate(qs)] for (q, δ, V) in zip(qs, δs, Vs) cert = DelaunayTriangulation.point_position_relative_to_triangle(tri, V, q) if δ ≥ 0.0 @@ -377,11 +377,11 @@ end (1.5, 2.0), (8.15, 6.0) ] q = (7.0, 7.0) # When you have a point that is exactly the same as a representative point, you need to be careful of (1) the point being exactly collinear with a ghost edge, and (2) the algorithm mistakenly regarding q as if it were equal to a triangle's vertices (since this is where the ghost vertices map). This is now fixed, but we need this isolated to avoid regressions. - V = jump_and_march(tri, q, rng=StableRNG(268), k=31, concavity_protection=true) + V = find_triangle(tri, q, rng=StableRNG(268), k=31, concavity_protection=true) @test !DT.is_outside(DT.point_position_relative_to_triangle(tri, V, q)) δs = [DelaunayTriangulation.distance_to_polygon(q, get_points(tri), get_boundary_nodes(tri)) for q in qs] for i in 1:1000 - Vs = [jump_and_march(tri, q; concavity_protection=true, rng=StableRNG(i)) for q in qs] + Vs = [find_triangle(tri, q; concavity_protection=true, rng=StableRNG(i)) for q in qs] for (q, δ, V) in zip(qs, δs, Vs) cert = DelaunayTriangulation.point_position_relative_to_triangle(tri, V, q) if δ > 0.0 @@ -400,7 +400,7 @@ end rng = StableRNG(i) qs = [((b - a) * rand(rng) + a, (d - c) * rand(rng) + c) for _ in 1:100] δs = [DelaunayTriangulation.distance_to_polygon(q, get_points(tri), get_boundary_nodes(tri)) for q in qs] - Vs = [jump_and_march(tri, q, concavity_protection=true, rng=StableRNG(i + j)) for (j, q) in enumerate(qs)] + Vs = [find_triangle(tri, q, concavity_protection=true, rng=StableRNG(i + j)) for (j, q) in enumerate(qs)] for (q, δ, V) in zip(qs, δs, Vs) cert = DelaunayTriangulation.point_position_relative_to_triangle(tri, V, q) if δ ≥ 0.0 @@ -419,19 +419,19 @@ end for _ in 1:10 points = [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)] tri = triangulate(points; boundary_nodes=[1, 2, 3, 4, 1], randomise=false) - V, invisible_flag = jump_and_march(tri, (1 / 2, -1.0), use_barriers=Val(true), k=4) + V, invisible_flag = find_triangle(tri, (1 / 2, -1.0), use_barriers=Val(true), k=4) @test invisible_flag && DT.is_invisible(DT.test_visibility(tri, (1 / 2, -1.0), 4)) - @inferred jump_and_march(tri, (1 / 2, -1.0), use_barriers=Val(true), k=4) + @inferred find_triangle(tri, (1 / 2, -1.0), use_barriers=Val(true), k=4) @test V == (1, 2, 3) @test DT.is_positively_oriented(DT.triangle_orientation(tri, V)) - V, invisible_flag = jump_and_march(tri, (1 / 2, -1.0), use_barriers=Val(true), k=3) + V, invisible_flag = find_triangle(tri, (1 / 2, -1.0), use_barriers=Val(true), k=3) @test invisible_flag && DT.is_invisible(DT.test_visibility(tri, (1 / 2, -1.0), 3)) @test V == (1, 2, 3) @test DT.is_positively_oriented(DT.triangle_orientation(tri, V)) - V, invisible_flag = jump_and_march(tri, (1 / 2, -1.0), use_barriers=Val(true), k=1) + V, invisible_flag = find_triangle(tri, (1 / 2, -1.0), use_barriers=Val(true), k=1) @test invisible_flag && DT.is_invisible(DT.test_visibility(tri, (1 / 2, -1.0), 1)) @test DT.is_inside(DT.point_position_relative_to_triangle(tri, V, (1 / 2, -1, 0))) # starting at a boundary edge right next to the query point - V, invisible_flag = jump_and_march(tri, (1 / 2, -1.0), use_barriers=Val(true), k=2) + V, invisible_flag = find_triangle(tri, (1 / 2, -1.0), use_barriers=Val(true), k=2) @test invisible_flag && DT.is_invisible(DT.test_visibility(tri, (1 / 2, -1.0), 2)) @test DT.is_inside(DT.point_position_relative_to_triangle(tri, V, (1 / 2, -1.0))) end @@ -446,10 +446,10 @@ end q1 = (-1.0, 1.0) q2 = (-4.0, 1.0) q3 = (-8.0, 2.0) - V1, invisible_flag1 = jump_and_march(tri, q1, use_barriers=Val(true), k=1) - V2, invisible_flag2 = jump_and_march(tri, q2, use_barriers=Val(true), k=1) - @inferred jump_and_march(tri, q1, use_barriers=Val(true), k=1) - V3, invisible_flag3 = jump_and_march(tri, q3, use_barriers=Val(true), k=1) + V1, invisible_flag1 = find_triangle(tri, q1, use_barriers=Val(true), k=1) + V2, invisible_flag2 = find_triangle(tri, q2, use_barriers=Val(true), k=1) + @inferred find_triangle(tri, q1, use_barriers=Val(true), k=1) + V3, invisible_flag3 = find_triangle(tri, q3, use_barriers=Val(true), k=1) @test DT.compare_triangles(V1, (9, 8, 1)) @test DT.is_positively_oriented(DT.triangle_orientation(tri, V1)) @test DT.compare_triangles(V2, (2, 3, 9)) @@ -459,9 +459,9 @@ end @test invisible_flag1 && DT.is_invisible(DT.test_visibility(tri, q1, 1)) @test !invisible_flag2 && DT.is_visible(DT.test_visibility(tri, q2, 1)) @test !invisible_flag3 && DT.is_visible(DT.test_visibility(tri, q3, 1)) - V1, invisible_flag1 = jump_and_march(tri, q1, use_barriers=Val(true), k=2) - V2, invisible_flag2 = jump_and_march(tri, q2, use_barriers=Val(true), k=2) - V3, invisible_flag3 = jump_and_march(tri, q3, use_barriers=Val(true), k=2) + V1, invisible_flag1 = find_triangle(tri, q1, use_barriers=Val(true), k=2) + V2, invisible_flag2 = find_triangle(tri, q2, use_barriers=Val(true), k=2) + V3, invisible_flag3 = find_triangle(tri, q3, use_barriers=Val(true), k=2) @test DT.compare_triangles(V1, (9, 3, 4)) @test DT.is_inside(DT.point_position_relative_to_triangle(tri, V1, q1)) @test DT.compare_triangles(V2, (2, 3, 9)) @@ -471,9 +471,9 @@ end @test !invisible_flag1 && DT.is_visible(DT.test_visibility(tri, q1, 2)) @test !invisible_flag2 && DT.is_visible(DT.test_visibility(tri, q2, 2)) @test !invisible_flag3 && DT.is_visible(DT.test_visibility(tri, q3, 2)) - V1, invisible_flag1 = jump_and_march(tri, q1, use_barriers=Val(true), k=3) - V2, invisible_flag2 = jump_and_march(tri, q2, use_barriers=Val(true), k=3) - V3, invisible_flag3 = jump_and_march(tri, q3, use_barriers=Val(true), k=3) + V1, invisible_flag1 = find_triangle(tri, q1, use_barriers=Val(true), k=3) + V2, invisible_flag2 = find_triangle(tri, q2, use_barriers=Val(true), k=3) + V3, invisible_flag3 = find_triangle(tri, q3, use_barriers=Val(true), k=3) @test DT.compare_triangles(V1, (9, 3, 4)) @test DT.is_inside(DT.point_position_relative_to_triangle(tri, V1, q1)) @test DT.compare_triangles(V2, (2, 3, 9)) @@ -483,9 +483,9 @@ end @test !invisible_flag1 && DT.is_visible(DT.test_visibility(tri, q1, 3)) @test !invisible_flag2 && DT.is_visible(DT.test_visibility(tri, q2, 3)) @test !invisible_flag3 && DT.is_visible(DT.test_visibility(tri, q3, 3)) - V1, invisible_flag1 = jump_and_march(tri, q1, use_barriers=Val(true), k=4) - V2, invisible_flag2 = jump_and_march(tri, q2, use_barriers=Val(true), k=4) - V3, invisible_flag3 = jump_and_march(tri, q3, use_barriers=Val(true), k=4) + V1, invisible_flag1 = find_triangle(tri, q1, use_barriers=Val(true), k=4) + V2, invisible_flag2 = find_triangle(tri, q2, use_barriers=Val(true), k=4) + V3, invisible_flag3 = find_triangle(tri, q3, use_barriers=Val(true), k=4) @test DT.compare_triangles(V1, (9, 3, 4)) @test DT.is_inside(DT.point_position_relative_to_triangle(tri, V1, q1)) @test DT.compare_triangles(V2, (2, 3, 9)) @@ -495,9 +495,9 @@ end @test !invisible_flag1 && DT.is_visible(DT.test_visibility(tri, q1, 4)) @test !invisible_flag2 && DT.is_visible(DT.test_visibility(tri, q2, 4)) @test invisible_flag3 && DT.is_invisible(DT.test_visibility(tri, q3, 4)) - V1, invisible_flag1 = jump_and_march(tri, q1, use_barriers=Val(true), k=5) - V2, invisible_flag2 = jump_and_march(tri, q2, use_barriers=Val(true), k=5) - V3, invisible_flag3 = jump_and_march(tri, q3, use_barriers=Val(true), k=5) + V1, invisible_flag1 = find_triangle(tri, q1, use_barriers=Val(true), k=5) + V2, invisible_flag2 = find_triangle(tri, q2, use_barriers=Val(true), k=5) + V3, invisible_flag3 = find_triangle(tri, q3, use_barriers=Val(true), k=5) @test DT.compare_triangles(V1, (9, 3, 4)) @test DT.is_inside(DT.point_position_relative_to_triangle(tri, V1, q1)) @test DT.compare_triangles(V2, (2, 3, 9)) @@ -507,9 +507,9 @@ end @test !invisible_flag1 && DT.is_visible(DT.test_visibility(tri, q1, 5)) @test !invisible_flag2 && DT.is_visible(DT.test_visibility(tri, q2, 5)) @test !invisible_flag3 && DT.is_visible(DT.test_visibility(tri, q3, 5)) - V1, invisible_flag1 = jump_and_march(tri, q1, use_barriers=Val(true), k=6) - V2, invisible_flag2 = jump_and_march(tri, q2, use_barriers=Val(true), k=6) - V3, invisible_flag3 = jump_and_march(tri, q3, use_barriers=Val(true), k=6) + V1, invisible_flag1 = find_triangle(tri, q1, use_barriers=Val(true), k=6) + V2, invisible_flag2 = find_triangle(tri, q2, use_barriers=Val(true), k=6) + V3, invisible_flag3 = find_triangle(tri, q3, use_barriers=Val(true), k=6) @test DT.compare_triangles(V1, (9, 3, 4)) @test DT.is_inside(DT.point_position_relative_to_triangle(tri, V1, q1)) @test DT.compare_triangles(V2, (2, 3, 9)) @@ -519,9 +519,9 @@ end @test !invisible_flag1 && DT.is_visible(DT.test_visibility(tri, q1, 6)) @test !invisible_flag2 && DT.is_visible(DT.test_visibility(tri, q2, 6)) @test invisible_flag3 && DT.is_invisible(DT.test_visibility(tri, q3, 6)) - V1, invisible_flag1 = jump_and_march(tri, q1, use_barriers=Val(true), k=7) - V2, invisible_flag2 = jump_and_march(tri, q2, use_barriers=Val(true), k=7) - V3, invisible_flag3 = jump_and_march(tri, q3, use_barriers=Val(true), k=7) + V1, invisible_flag1 = find_triangle(tri, q1, use_barriers=Val(true), k=7) + V2, invisible_flag2 = find_triangle(tri, q2, use_barriers=Val(true), k=7) + V3, invisible_flag3 = find_triangle(tri, q3, use_barriers=Val(true), k=7) @test DT.compare_triangles(V1, (9, 3, 4)) @test DT.is_inside(DT.point_position_relative_to_triangle(tri, V1, q1)) @test DT.compare_triangles(V2, (8, 9, 4)) @@ -531,9 +531,9 @@ end @test !invisible_flag1 && DT.is_visible(DT.test_visibility(tri, q1, 7)) @test invisible_flag2 && DT.is_invisible(DT.test_visibility(tri, q2, 7)) @test !invisible_flag3 && DT.is_visible(DT.test_visibility(tri, q3, 7)) - V1, invisible_flag1 = jump_and_march(tri, q1, use_barriers=Val(true), k=8) - V2, invisible_flag2 = jump_and_march(tri, q2, use_barriers=Val(true), k=8) - V3, invisible_flag3 = jump_and_march(tri, q3, use_barriers=Val(true), k=8) + V1, invisible_flag1 = find_triangle(tri, q1, use_barriers=Val(true), k=8) + V2, invisible_flag2 = find_triangle(tri, q2, use_barriers=Val(true), k=8) + V3, invisible_flag3 = find_triangle(tri, q3, use_barriers=Val(true), k=8) @test DT.compare_triangles(V1, (9, 3, 4)) @test DT.is_inside(DT.point_position_relative_to_triangle(tri, V1, q1)) @test DT.compare_triangles(V2, (2, 3, 9)) @@ -543,9 +543,9 @@ end @test !invisible_flag1 && DT.is_visible(DT.test_visibility(tri, q1, 8)) @test !invisible_flag2 && DT.is_visible(DT.test_visibility(tri, q2, 8)) @test !invisible_flag3 && DT.is_visible(DT.test_visibility(tri, q3, 8)) - V1, invisible_flag1 = jump_and_march(tri, q1, use_barriers=Val(true), k=9) - V2, invisible_flag2 = jump_and_march(tri, q2, use_barriers=Val(true), k=9) - V3, invisible_flag3 = jump_and_march(tri, q3, use_barriers=Val(true), k=9) + V1, invisible_flag1 = find_triangle(tri, q1, use_barriers=Val(true), k=9) + V2, invisible_flag2 = find_triangle(tri, q2, use_barriers=Val(true), k=9) + V3, invisible_flag3 = find_triangle(tri, q3, use_barriers=Val(true), k=9) @test DT.compare_triangles(V1, (9, 3, 4)) @test DT.is_inside(DT.point_position_relative_to_triangle(tri, V1, q1)) @test DT.compare_triangles(V2, (2, 3, 9)) @@ -599,7 +599,7 @@ end end _k = findfirst(==(a), points) - (VK, flagVK), (VL, flagVL), (VM, flagVM), (VN, flagVN), (VO, flagVO), (VP, flagVP), (VS, flagVS) = jump_and_march.(Ref(tri), all_q; k=_k, use_barriers=Val(true)) + (VK, flagVK), (VL, flagVL), (VM, flagVM), (VN, flagVN), (VO, flagVO), (VP, flagVP), (VS, flagVS) = find_triangle.(Ref(tri), all_q; k=_k, use_barriers=Val(true)) #@test blocked_test(VK, (u, f, v)) #@test visible_test(VL, (f1, g1, k), L1) || visible_test(VL, (f1, k, ℓ), L1) # on (f1, k) #@test blocked_test(VM, (d1, r1, g1)) @@ -615,7 +615,7 @@ end @test flagVP && DT.is_invisible(DT.test_visibility(tri, P1, _k)) @test !flagVS && DT.is_visible(DT.test_visibility(tri, S1, _k)) _k = findfirst(==(q), points) - (VK, flagVK), (VL, flagVL), (VM, flagVM), (VN, flagVN), (VO, flagVO), (VP, flagVP), (VS, flagVS) = jump_and_march.(Ref(tri), all_q; k=_k, use_barriers=Val(true)) + (VK, flagVK), (VL, flagVL), (VM, flagVM), (VN, flagVN), (VO, flagVO), (VP, flagVP), (VS, flagVS) = find_triangle.(Ref(tri), all_q; k=_k, use_barriers=Val(true)) #@test blocked_test(VK, (q, u, z)) #@test blocked_test(VL, (h1, z, a1)) #@test blocked_test(VM, (z, a1, h1)) @@ -631,7 +631,7 @@ end @test flagVP && DT.is_invisible(DT.test_visibility(tri, P1, _k)) @test flagVS && DT.is_invisible(DT.test_visibility(tri, S1, _k)) _k = findfirst(==(q1), points) - (VK, flagVK), (VL, flagVL), (VM, flagVM), (VN, flagVN), (VO, flagVO), (VP, flagVP), (VS, flagVS) = jump_and_march.(Ref(tri), all_q; k=_k, use_barriers=Val(true)) + (VK, flagVK), (VL, flagVL), (VM, flagVM), (VN, flagVN), (VO, flagVO), (VP, flagVP), (VS, flagVS) = find_triangle.(Ref(tri), all_q; k=_k, use_barriers=Val(true)) #@test blocked_test(VK, (a1, w, d1)) #@test blocked_test(VL, (e1, d1, f1)) #@test blocked_test(VM, (e1, d1, f1)) @@ -647,7 +647,7 @@ end @test flagVP && DT.is_invisible(DT.test_visibility(tri, P1, _k)) @test flagVS && DT.is_invisible(DT.test_visibility(tri, S1, _k)) _k = findfirst(==(p), points) - (VK, flagVK), (VL, flagVL), (VM, flagVM), (VN, flagVN), (VO, flagVO), (VP, flagVP), (VS, flagVS) = jump_and_march.(Ref(tri), all_q; k=_k, use_barriers=Val(true)) + (VK, flagVK), (VL, flagVL), (VM, flagVM), (VN, flagVN), (VO, flagVO), (VP, flagVP), (VS, flagVS) = find_triangle.(Ref(tri), all_q; k=_k, use_barriers=Val(true)) #@test blocked_test(VK, (a1, w, d1)) #@test visible_test(VL, (f1, g1, k), L1) || visible_test(VL, (f1, k, ℓ), L1) # on (f1, k) #@test blocked_test(VM, (c1, b1, o)) @@ -663,7 +663,7 @@ end @test flagVP && DT.is_invisible(DT.test_visibility(tri, P1, _k)) @test flagVS && DT.is_invisible(DT.test_visibility(tri, S1, _k)) _k = findfirst(==(b), points) - (VK, flagVK), (VL, flagVL), (VM, flagVM), (VN, flagVN), (VO, flagVO), (VP, flagVP), (VS, flagVS) = jump_and_march.(Ref(tri), all_q; k=_k, use_barriers=Val(true)) + (VK, flagVK), (VL, flagVL), (VM, flagVM), (VN, flagVN), (VO, flagVO), (VP, flagVP), (VS, flagVS) = find_triangle.(Ref(tri), all_q; k=_k, use_barriers=Val(true)) @test blocked_test(VK, (b1, e1, f1)) || blocked_test(VK, (a1, w, d1)) @test visible_test(VL, (f1, g1, k), L1) || visible_test(VL, (f1, k, ℓ), L1) # on (f1, k) @test blocked_test(VM, (f1, g1, k)) @@ -680,7 +680,7 @@ end @test flagVS && DT.is_invisible(DT.test_visibility(tri, S1, _k)) add_segment!(tri, findfirst(==(m), points), findfirst(==(ℓ), points)) push!(all_q, (9.0, 1.0), (9.5, 0.5), (8.9, 1.1)) - (VK, flagVK), (VL, flagVL), (VM, flagVM), (VN, flagVN), (VO, flagVO), (VP, flagVP), (VS, flagVS), (VH4, flagVH4), (VK9, flagVK9), (VH5, flagVH5) = jump_and_march.(Ref(tri), all_q; k=_k, use_barriers=Val(true)) + (VK, flagVK), (VL, flagVL), (VM, flagVM), (VN, flagVN), (VO, flagVO), (VP, flagVP), (VS, flagVS), (VH4, flagVH4), (VK9, flagVK9), (VH5, flagVH5) = find_triangle.(Ref(tri), all_q; k=_k, use_barriers=Val(true)) @test blocked_test(VK, (m, ℓ, b)) @test blocked_test(VL, (m, ℓ, b)) @test blocked_test(VM, (m, ℓ, b)) @@ -711,7 +711,7 @@ end tri = triangulate(points) for _ in 1:20000 q = rand(2) - V, flag = jump_and_march(tri, q; use_barriers=Val(true)) + V, flag = find_triangle(tri, q; use_barriers=Val(true)) @test !DT.is_outside(DT.point_position_relative_to_triangle(tri, V, q)) @test !flag end @@ -731,7 +731,7 @@ end while DT.is_boundary_node(tri, k)[1] k = rand(each_solid_vertex(tri)) end - V, flag = jump_and_march(tri, q; k, use_barriers=Val(true)) + V, flag = find_triangle(tri, q; k, use_barriers=Val(true)) @test !DT.is_ghost_triangle(V) end end diff --git a/test/triangulation/weighted.jl b/test/triangulation/weighted.jl index 06c5783f5..e47392991 100644 --- a/test/triangulation/weighted.jl +++ b/test/triangulation/weighted.jl @@ -191,7 +191,7 @@ end @test !DT.is_submerged(tri, i) end for i in 1:DT.num_points(tri) - @test (DT.is_submerged(tri, i, jump_and_march(tri, get_point(tri, i)))) == (i ∈ submerged) + @test (DT.is_submerged(tri, i, find_triangle(tri, get_point(tri, i)))) == (i ∈ submerged) end end end diff --git a/test/utils.jl b/test/utils.jl index f837c929b..461fdc825 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -1426,7 +1426,7 @@ Tuple{Bool, Bool, Tuple{Int64, Int64, Int64}, Vector{Float64}, Int64, In for j in 1:10 p = randn(StableRNG(i * j), 2) δ = DT.distance_to_polygon(p, get_points(tri), get_convex_hull_vertices(tri)) - V = jump_and_march(tri, p) + V = find_triangle(tri, p) if DT.is_ghost_triangle(V) @test δ < 0 else @@ -1440,7 +1440,7 @@ Tuple{Bool, Bool, Tuple{Int64, Int64, Int64}, Vector{Float64}, Int64, In for i in 1:100 p = randn(StableRNG(i^2), 2) δ = DT.distance_to_polygon(p, get_points(tri), get_boundary_nodes(tri)) - V = jump_and_march(tri, p; rng=StableRNG(i^3), concavity_protection=true) + V = find_triangle(tri, p; rng=StableRNG(i^3), concavity_protection=true) if DT.is_ghost_triangle(V) @test δ < 0 else