Skip to content

Commit 7a4b09a

Browse files
committed
Refine a bit
1 parent 8ad05ed commit 7a4b09a

File tree

8 files changed

+10
-57
lines changed

8 files changed

+10
-57
lines changed

src/algorithms/triangulation/basic_operations/delete_ghost_triangles.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ function delete_ghost_triangles!(tri::Triangulation)
2626
delete_triangle!(T, u, v, g)
2727
end
2828
end
29-
# Clear the boundary_vertex_to_ghost map since ghost triangles are deleted
3029
empty!(get_boundary_vertex_to_ghost(tri))
3130
set_has_ghosts!(tri, false)
3231
return tri

src/algorithms/triangulation/basic_operations/lock_convex_hull.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function lock_convex_hull!(tri::Triangulation; rng::Random.AbstractRNG = Random.
4545
add_edge!(interior_segments_on_hull, e)
4646
end
4747
end
48-
# Also add the last vertex (which equals the first in a closed boundary)
48+
# Add the last vertex (closed boundary)
4949
u = get_boundary_nodes(bn, ne + 1)
5050
add_boundary_vertex_to_ghost!(tri, u, ghost_vertex)
5151
for e in keys(bnn_map)

src/algorithms/triangulation/triangulate_convex.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ function postprocess_triangulate_convex!(tri::Triangulation, S; delete_ghosts, d
187187
add_adjacent2vertex!(tri, ghost_vertex, v, u)
188188
add_adjacent!(tri, v, u, ghost_vertex)
189189
end
190-
# Add the last boundary vertex to ghost mapping only for constrained boundaries
191190
populate_map && add_boundary_vertex_to_ghost!(tri, u, ghost_vertex)
192-
# Set has_ghosts flag based on whether we added ghost triangles
193191
set_has_ghosts!(tri, !delete_ghosts)
194192
delete_empty_features && clear_empty_features!(tri)
195193
empty_representative_points!(tri)

src/data_structures/triangulation/methods/boundary_nodes.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ function merge_boundary_edge!(tri::Triangulation, i, j, node)
160160
node_pos = (pos[1], pos[2] + 1)
161161
bnn = get_boundary_edge_map(tri)
162162
delete_boundary_node!(tri, node_pos)
163-
# Remove the merged node from boundary_vertex_to_ghost map
164163
delete_boundary_vertex_from_ghost_map!(tri, node)
165164
E = edge_type(tri)
166165
delete!(bnn, construct_edge(E, i, node))

test/data_structures/triangulation.jl

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,51 +1669,32 @@ end
16691669
@test DT.has_ghosts(tri)
16701670
end
16711671

1672-
@testset "Triangulation fields are const (except has_ghosts)" begin
1672+
@testset "Mutating has_ghosts" begin
16731673
points = [(0.0, 0.0), (1.0, 0.0), (0.5, 0.5)]
16741674
tri = DT.Triangulation(points)
1675-
1676-
# Test that has_ghosts can be modified (is not const)
16771675
@test !DT.has_ghosts(tri)
16781676
DT.set_has_ghosts!(tri, true)
16791677
@test DT.has_ghosts(tri)
1680-
1681-
# Test that trying to reassign const fields should error
1682-
# Note: We can't easily test this at runtime since const fields are checked at compile time
1683-
# But we can verify that the struct is mutable
16841678
@test ismutable(tri)
1685-
1686-
# Verify the field can be directly accessed (for the getter implementation)
16871679
@test tri.has_ghosts == DT.has_ghosts(tri)
1688-
1689-
# Verify we can modify has_ghosts but the struct itself is the same object
1690-
old_tri = tri
1691-
DT.set_has_ghosts!(tri, false)
1692-
@test old_tri === tri # Same object
1693-
@test !DT.has_ghosts(tri)
16941680
end
16951681

1696-
@testset "has_ghosts with Base.copy" begin
1682+
@testset "has_ghosts with copy" begin
16971683
points = [(0.0, 0.0), (1.0, 0.0), (0.5, 0.5)]
16981684
tri = DT.Triangulation(points)
16991685

1700-
# Set has_ghosts to true
17011686
DT.set_has_ghosts!(tri, true)
17021687
@test DT.has_ghosts(tri)
17031688

1704-
# Copy the triangulation
17051689
tri_copy = Base.copy(tri)
17061690

1707-
# Verify the copy has the same has_ghosts value
17081691
@test DT.has_ghosts(tri_copy) == DT.has_ghosts(tri)
17091692
@test DT.has_ghosts(tri_copy) == true
17101693

1711-
# Modify the original
17121694
DT.set_has_ghosts!(tri, false)
17131695
@test !DT.has_ghosts(tri)
1714-
@test DT.has_ghosts(tri_copy) # Copy should still be true
1696+
@test DT.has_ghosts(tri_copy)
17151697

1716-
# Test with has_ghosts = false
17171698
tri2 = DT.Triangulation(points)
17181699
@test !DT.has_ghosts(tri2)
17191700
tri2_copy = Base.copy(tri2)
@@ -1725,24 +1706,20 @@ end
17251706
tri1 = DT.Triangulation(points)
17261707
tri2 = DT.Triangulation(points)
17271708

1728-
# Both have has_ghosts = false initially
17291709
@test !DT.has_ghosts(tri1)
17301710
@test !DT.has_ghosts(tri2)
17311711
@test tri1 == tri2
17321712

1733-
# Set one to true
17341713
DT.set_has_ghosts!(tri1, true)
17351714
@test DT.has_ghosts(tri1)
17361715
@test !DT.has_ghosts(tri2)
1737-
@test tri1 != tri2 # Should not be equal
1716+
@test tri1 != tri2
17381717

1739-
# Set both to true
17401718
DT.set_has_ghosts!(tri2, true)
17411719
@test DT.has_ghosts(tri1)
17421720
@test DT.has_ghosts(tri2)
1743-
@test tri1 == tri2 # Should be equal again
1721+
@test tri1 == tri2
17441722

1745-
# Set both to false
17461723
DT.set_has_ghosts!(tri1, false)
17471724
DT.set_has_ghosts!(tri2, false)
17481725
@test !DT.has_ghosts(tri1)

test/operations/add_ghost_triangles.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ using StaticArrays
66
@testset "Adding ghost triangles" begin
77
tri, label_map, index_map = simple_geometry()
88

9-
# Test that has_ghosts is initially false
109
@test !DT.has_ghosts(tri)
1110
@test !DT.has_ghost_triangles(tri)
1211

1312
DT.add_ghost_triangles!(tri)
1413

15-
# Test that has_ghosts is now true after adding ghost triangles
1614
@test DT.has_ghosts(tri)
1715
@test DT.has_ghost_triangles(tri)
1816
outer_edges = [

test/operations/delete_ghost_triangles.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@ using StaticArrays
99
tri, label_map, index_map = simple_geometry()
1010
_tri = deepcopy(tri)
1111

12-
# Test initial state
1312
@test !DT.has_ghosts(tri)
1413
@test !DT.has_ghost_triangles(tri)
1514

1615
DT.add_ghost_triangles!(tri)
1716

18-
# Test after adding ghost triangles
1917
@test DT.has_ghosts(tri)
2018
@test DT.has_ghost_triangles(tri)
2119

2220
DT.delete_ghost_triangles!(tri)
2321

24-
# Test after deleting ghost triangles
2522
@test !DT.has_ghosts(tri)
2623
@test !DT.has_ghost_triangles(tri)
2724

test/predicates/boundaries_and_ghosts.jl

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ A = get_area(tri)
1515
refine!(tri; max_area = 1.0e-2A, rng, use_circumcenter = true)
1616

1717
tri2, label_map, index_map = simple_geometry()
18-
# Manually repopulate boundary_vertex_to_ghost after simple_geometry() which uses delete_ghosts=true
19-
# This is needed because add_boundary_information! clears the map but the package code changes
20-
# may not be loaded in the current session
2118
let bn = get_boundary_nodes(tri2)
2219
bv_map = DT.get_boundary_vertex_to_ghost(tri2)
2320
ghost = DT.𝒢
@@ -309,12 +306,11 @@ end
309306
end
310307
end
311308

312-
# Test that boundary_vertex_to_ghost map is correctly maintained
313309
@testset "boundary_vertex_to_ghost consistency" begin
314310
# Test with complicated geometry (multiple curves and sections)
315-
# Note: For junction nodes (nodes shared between sections), the map will only
316-
# contain ONE ghost vertex, whichever was set last during processing.
317-
# So we check that each boundary node IS in the map and maps to a VALID
311+
# Note: For junction nodes, the map will only
312+
# contain one ghost vertex, whichever was set last during processing.
313+
# So we check that each boundary node is in the map and maps to a valid
318314
# ghost vertex (one that is in the ghost vertex range for that curve).
319315
bv_map = DT.get_boundary_vertex_to_ghost(tri)
320316
for (ghost_vertex, segment_index) in get_ghost_vertex_map(tri)
@@ -350,12 +346,10 @@ end
350346
@testset "boundary_vertex_to_ghost getter and setters" begin
351347
tri, label_map, index_map = simple_geometry()
352348

353-
# Test initial state - empty map for unconstrained tri before boundary info added
354349
bv_map = DT.get_boundary_vertex_to_ghost(tri)
355350
@test bv_map isa Dict
356351
@test isempty(bv_map)
357352

358-
# Manually add some mappings for testing
359353
I = DT.integer_type(tri)
360354
test_vertex = I(5)
361355
test_ghost = I(-2)
@@ -364,56 +358,47 @@ end
364358
@test haskey(DT.get_boundary_vertex_to_ghost(tri), test_vertex)
365359
@test DT.get_boundary_vertex_to_ghost(tri)[test_vertex] == test_ghost
366360

367-
# Test deletion
368361
DT.delete_boundary_vertex_from_ghost_map!(tri, test_vertex)
369362
@test !haskey(DT.get_boundary_vertex_to_ghost(tri), test_vertex)
370363

371-
# Test with actual triangulation with boundaries
372364
x, y = complicated_geometry()
373365
rng = StableRNG(99988)
374366
boundary_nodes, points = convert_boundary_points_to_indices(x, y)
375367
tri_with_boundary = triangulate(points; rng, boundary_nodes, delete_ghosts = false)
376368

377-
# Verify map is populated
378369
bv_map = DT.get_boundary_vertex_to_ghost(tri_with_boundary)
379370
@test !isempty(bv_map)
380371

381-
# Verify all boundary nodes are in the map
382372
all_boundary_nodes = reduce(vcat, reduce(vcat, get_boundary_nodes(tri_with_boundary)))
383373
for bn in all_boundary_nodes
384374
@test haskey(bv_map, bn)
385375
end
386376

387-
# Verify non-boundary nodes are not in the map
388377
for v in each_vertex(tri_with_boundary)
389378
if v all_boundary_nodes
390379
@test !haskey(bv_map, v)
391380
end
392381
end
393382
end
394383

395-
@testset "boundary_vertex_to_ghost with Base.copy and ==" begin
384+
@testset "boundary_vertex_to_ghost with copy and ==" begin
396385
x, y = complicated_geometry()
397386
rng = StableRNG(99988)
398387
boundary_nodes, points = convert_boundary_points_to_indices(x, y)
399388
tri = triangulate(points; rng, boundary_nodes, delete_ghosts = false)
400389

401-
# Test Base.copy preserves the map
402390
tri_copy = copy(tri)
403391
@test DT.get_boundary_vertex_to_ghost(tri) == DT.get_boundary_vertex_to_ghost(tri_copy)
404392
@test DT.get_boundary_vertex_to_ghost(tri) !== DT.get_boundary_vertex_to_ghost(tri_copy) # Different objects
405393

406-
# Test Base.== compares the map
407394
@test tri == tri_copy
408395

409-
# Modify the copy's map and verify inequality
410396
I = DT.integer_type(tri_copy)
411397
fake_vertex = I(999999)
412398
fake_ghost = I(-999)
413399
DT.add_boundary_vertex_to_ghost!(tri_copy, fake_vertex, fake_ghost)
414400
@test tri != tri_copy
415401

416-
# Remove it and verify equality again
417402
DT.delete_boundary_vertex_from_ghost_map!(tri_copy, fake_vertex)
418403
@test tri == tri_copy
419404
end

0 commit comments

Comments
 (0)