Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete_point doesn't work on the boundary #104

Closed
Kevin-Mattheus-Moerman opened this issue Apr 23, 2024 · 4 comments
Closed

Delete_point doesn't work on the boundary #104

Kevin-Mattheus-Moerman opened this issue Apr 23, 2024 · 4 comments

Comments

@Kevin-Mattheus-Moerman
Copy link

@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 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,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

To obtain the following:
Screenshot from 2024-04-23 10-05-53

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.

@DanielVandH
Copy link
Member

DanielVandH commented Apr 25, 2024 via email

@DanielVandH
Copy link
Member

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.

@DanielVandH
Copy link
Member

Going to close this due to lack of activity and since it doesn't seem reproducible. Feel free to open if needed.

@DanielVandH
Copy link
Member

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 DanielVandH reopened this Jul 17, 2024
@DanielVandH DanielVandH changed the title Delete_point Delete_point doesn't work on the boundary Jul 17, 2024
@DanielVandH DanielVandH reopened this Oct 1, 2024
@DanielVandH DanielVandH closed this as not planned Won't fix, can't repro, duplicate, stale Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants