Skip to content

Commit 9ad3b4d

Browse files
committed
Added cleanup method to remove cells from attackers pAttackTarget pointer
1 parent cbf625e commit 9ad3b4d

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

core/PhysiCell_cell.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,9 @@ void delete_cell( int index )
12071207
// released internalized substrates (as of 1.5.x releases)
12081208
pDeleteMe->release_internalized_substrates();
12091209

1210+
// new Dec 2, 2025
1211+
pDeleteMe->remove_self_from_attackers();
1212+
12101213
// performance goal: don't delete in the middle -- very expensive reallocation
12111214
// alternative: copy last element to index position, then shrink vector by 1 at the end O(constant)
12121215

@@ -3433,6 +3436,16 @@ void Cell::remove_all_spring_attachments( void )
34333436
return;
34343437
}
34353438

3439+
void Cell::remove_self_from_attackers( void )
3440+
{
3441+
#pragma omp parallel for
3442+
for (int j=0; j < all_cells->size(); j++)
3443+
{
3444+
if (j != index && (*all_cells)[j]->phenotype.cell_interactions.pAttackTarget != NULL && (*all_cells)[j]->phenotype.cell_interactions.pAttackTarget == this) {
3445+
(*all_cells)[j]->phenotype.cell_interactions.pAttackTarget = NULL;
3446+
}
3447+
}
3448+
}
34363449

34373450
void attach_cells( Cell* pCell_1, Cell* pCell_2 )
34383451
{

core/PhysiCell_cell.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class Cell : public Basic_Agent
238238
void attach_cell_as_spring( Cell* pAddMe ); // done
239239
void detach_cell_as_spring( Cell* pRemoveMe ); // done
240240
void remove_all_spring_attachments( void ); // done
241+
void remove_self_from_attackers( void );
241242

242243
// I want to eventually deprecate this, by ensuring that
243244
// critical BioFVM and PhysiCell data elements are synced when they are needed

0 commit comments

Comments
 (0)