Skip to content

Commit 60420a0

Browse files
authored
fix(delaunay): reserve premade tets' darts in main insertion loop (#459)
1 parent 1334290 commit 60420a0

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

  • applications/incremental_delaunay/internals

applications/incremental_delaunay/internals/cavity.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl IncompleteTets {
8383
self.index.write_atomic(0);
8484
self.tets.extend(
8585
range
86-
.filter(|&d| atomically(|t| map.is_unused_tx(t, d)))
86+
.filter(|&d| atomically(|t| Ok(map.is_unused_tx(t, d)? & map.is_free_tx(t, d)?)))
8787
.collect::<Vec<_>>()
8888
.chunks_exact(9)
8989
.map(|c| {
@@ -421,8 +421,11 @@ pub fn rebuild_cavity_3d<T: CoordsFloat>(
421421
let mut tmp = None;
422422

423423
for (_, [(da, da_neigh), (db, db_neigh), (dc, dc_neigh)]) in boundary.into_iter() {
424-
let [d1, d2, _, _, d5, _, _, d8, _]: [DartIdType; 9] =
424+
let darts @ [d1, d2, _, _, d5, _, _, d8, _]: [DartIdType; 9] =
425425
try_or_coerce!(TETS.with_borrow(|tets| tets.get(t)), CavityError);
426+
for d in darts {
427+
map.claim_dart_tx(t, d)?;
428+
}
426429
let vid = map.vertex_id_tx(t, d1)?;
427430
map.write_vertex_tx(t, vid, point)?;
428431
if tmp.is_none() {
@@ -454,13 +457,9 @@ pub fn rebuild_cavity_3d<T: CoordsFloat>(
454457
fn make_incomplete_tet<T: CoordsFloat>(
455458
t: &mut Transaction,
456459
map: &CMap3<T>,
457-
darts @ [d1, d2, d3, d4, d5, d6, d7, d8, d9]: [DartIdType; 9],
460+
[d1, d2, d3, d4, d5, d6, d7, d8, d9]: [DartIdType; 9],
458461
// p: Vertex3<T>,
459462
) -> TransactionClosureResult<(), LinkError> {
460-
for d in darts {
461-
map.claim_dart_tx(t, d)?;
462-
}
463-
464463
// build 3 triangles
465464
map.link_tx::<1>(t, d1, d2)?;
466465
map.link_tx::<1>(t, d2, d3)?;

0 commit comments

Comments
 (0)