Open Kevin-Mattheus-Moerman opened 4 months ago
Thanks for the issue - I'll look into it soon within a few days.
On Tue, 23 Apr 2024, 10:09 am Kevin Mattheus Moerman, < @.***> wrote:
@DanielVandH https://github.com/DanielVandH thanks for putting this package together. In the below I attempt to create a crossed square mesh (4 corners and a central point). I then wanted to test the removal of points from this set using delete_point!. Perhaps I am using it wrong, but this function does not seem to work properly. In the below example I use delete_point!(TR,5), which seems to work. However, the 5th point is the only point I can remove, any other point, e.g. 1:4 will produce this error: ERROR: BoundsError: attempt to access 5-element Vector{Point3{Float64}} at index [0].
Any help would be appreciated.
using GeometryBasicsusing DelaunayTriangulation
Create a crossed square grid (4 corners and 1 central point)
V = reshape([ Point{3,Float64}(i,j,0.0) for i in -1:2:1, j in -1:2:1],4)push!(V,Point{3,Float64}(0.0,0.0,0.0))
Delaunay triangulation
TR = triangulate(V)
Get faces
F1 = [TriangleFace{Int64}(tr) for tr in TR.triangles]println(F1)
Remove a selected pointdelete_point!(TR,5)
F2 = [TriangleFace{Int64}(tr) for tr in TR.triangles]println(F2)
For context, I am removing these red points (which are 3 or 4 connected) in this triangulation: Screenshot.from.2024-04-23.10-06-43.png (view on web) https://github.com/JuliaGeometry/DelaunayTriangulation.jl/assets/8392709/fdaf4975-aaeb-41b8-ba0c-8f6debedb947
To obtain the following: Screenshot.from.2024-04-23.10-05-53.png (view on web) https://github.com/JuliaGeometry/DelaunayTriangulation.jl/assets/8392709/d73a3e02-a1a8-49b2-bd8a-a4530a6ba5a2
Currently I just repeat your Delaunay method on the set of reduced points. However I was wondering if the delete_point! approach is more efficient.
Thanks.
— Reply to this email directly, view it on GitHub https://github.com/JuliaGeometry/DelaunayTriangulation.jl/issues/104, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWZPH4D5U3WTZ4U7W47JBT3Y6YQOLAVCNFSM6AAAAABGUPAUQWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI2TQMZVGE4TKMY . You are receiving this because you were mentioned.Message ID: @.***>
In your example, what version of DelaunayTriangulation are you on? Here's what I get for deleting 1
:
julia> begin
using GeometryBasics
using DelaunayTriangulation
# Create a crossed square grid (4 corners and 1 central point)
V = reshape([Point{3,Float64}(i, j, 0.0) for i in -1:2:1, j in -1:2:1], 4)
push!(V, Point{3,Float64}(0.0, 0.0, 0.0))
# Delaunay triangulation
TR = triangulate(V)
# Get faces
F1 = [TriangleFace{Int64}(tr) for tr in TR.triangles]
println(F1)
# Remove a selected point
delete_point!(TR, 1)
F2 = [TriangleFace{Int64}(tr) for tr in TR.triangles]
println(F2)
end
TriangleFace{Int64}[TriangleFace(3, -1, 1), TriangleFace(3, 1, 5), TriangleFace(4, 5, 2), TriangleFace(3, 5, 4), TriangleFace(4, 2, -1), TriangleFace(5, 1, 2), TriangleFace(2, 1, -1), TriangleFace(3, 4, -1)]
ERROR: Tried to delete the vertex 1 which forms part of the boundary of the triangulation. This is not allowed - only interior vertices not adjoining a segment may be deleted.
Stacktrace:
[1] check_delete_point_args(tri::Triangulation{…}, vertex::Int64, S::Vector{…})
@ DelaunayTriangulation c:\Users\User\.julia\dev\DelaunayTriangulation\src\algorithms\triangulation\basic_operations\delete_point.jl:87
[2] delete_point!(tri::Triangulation{…}, vertex::Int64; store_event_history::Val{…}, event_history::Nothing, rng::Random.TaskLocalRNG)
@ DelaunayTriangulation c:\Users\User\.julia\dev\DelaunayTriangulation\src\algorithms\triangulation\basic_operations\delete_point.jl:143
[3] delete_point!(tri::Triangulation{…}, vertex::Int64)
@ DelaunayTriangulation c:\Users\User\.julia\dev\DelaunayTriangulation\src\algorithms\triangulation\basic_operations\delete_point.jl:135
[4] top-level scope
@ c:\Users\User\.julia\dev\DelaunayTriangulation\test\triangulation\constrained.jl:1121
Some type information was truncated. Use `show(err)` to see complete types.
Going to close this due to lack of activity and since it doesn't seem reproducible. Feel free to open if needed.
I'll reopen this one too @Kevin-Mattheus-Moerman since this issue is also about allowing deleting vertices on the boundary to work, so allowing this to work will let me work on #105
@DanielVandH thanks for putting this package together. In the below I attempt to create a crossed square mesh (4 corners and a central point). I then wanted to test the removal of points from this set using
delete_point!
. Perhaps I am using it wrong, but this function does not seem to work properly. In the below example I usedelete_point!(TR,5)
, which seems to work. However, the 5th point is the only point I can remove, any other point, e.g. 1:4 will produce this error:ERROR: BoundsError: attempt to access 5-element Vector{Point3{Float64}} at index [0]
.Any help would be appreciated.
For context, I am removing these red points (which are 3 or 4 connected) in this triangulation:![Screenshot from 2024-04-23 10-06-43](https://github.com/JuliaGeometry/DelaunayTriangulation.jl/assets/8392709/fdaf4975-aaeb-41b8-ba0c-8f6debedb947)
To obtain the following:![Screenshot from 2024-04-23 10-05-53](https://github.com/JuliaGeometry/DelaunayTriangulation.jl/assets/8392709/d73a3e02-a1a8-49b2-bd8a-a4530a6ba5a2)
Currently I just repeat your Delaunay method on the set of reduced points. However I was wondering if the
delete_point!
approach is more efficient.Thanks.