Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions core/PhysiCell_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ Cell::~Cell()
this->remove_all_attached_cells();
// 1.11.0
this->remove_all_spring_attachments();

// new Dec 5, 2024:
this->remove_self_from_all_neighbors();

// released internalized substrates (as of 1.5.x releases)
this->release_internalized_substrates();
Expand Down Expand Up @@ -1183,6 +1186,9 @@ void delete_cell( int index )
pDeleteMe->remove_all_attached_cells();
// 1.11.0
pDeleteMe->remove_all_spring_attachments();

// new Dec 5, 2024:
pDeleteMe->remove_self_from_all_neighbors();

// released internalized substrates (as of 1.5.x releases)
pDeleteMe->release_internalized_substrates();
Expand Down Expand Up @@ -3355,6 +3361,36 @@ void Cell::detach_cell_as_spring( Cell* pRemoveMe )
return;
}

void Cell::remove_self_from_all_neighbors( void )
{
Cell* pCell = this;
// go through all neighbors (pN) of this (pC)

for( int j = 0 ; j < pCell->state.neighbors.size(); j++ )
{
Cell* pN = pCell->state.neighbors[j];

// for each pN, remove pC from list of neighbors
// find pC in neighbors


auto SearchResult = std::find(
pN->state.neighbors.begin(),pN->state.neighbors.end(),pCell );

// if pC is indeed found, remove it
// erase pC from neighbors
if( SearchResult != pN->state.neighbors.end() )
{
// if the target is found, set the appropriate rate
pN->state.neighbors.erase( SearchResult );
}
else
{ /* future error message */ }
}

return;
}

void Cell::remove_all_attached_cells( void )
{
{
Expand Down
2 changes: 2 additions & 0 deletions core/PhysiCell_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ class Cell : public Basic_Agent

void attach_cell( Cell* pAddMe ); // done
void detach_cell( Cell* pRemoveMe ); // done

void remove_self_from_all_neighbors( void );
void remove_all_attached_cells( void ); // done

void attach_cell_as_spring( Cell* pAddMe ); // done
Expand Down
Loading