Skip to content

Commit b23e704

Browse files
authored
Merge pull request #383 from rheiland/cell-division-axis
add cell_division_direction_function for divide()
2 parents 27c5c53 + a2bd01c commit b23e704

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

core/PhysiCell_cell.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,22 @@ Cell* Cell::divide( )
608608
normalize( &rand_vec );
609609
rand_vec *= radius; // multiply direction times the displacement
610610
*/
611-
612-
std::vector<double> rand_vec = cell_division_orientation();
613-
rand_vec = rand_vec- phenotype.geometry.polarity*(rand_vec[0]*state.orientation[0]+
614-
rand_vec[1]*state.orientation[1]+rand_vec[2]*state.orientation[2])*state.orientation;
611+
612+
std::vector<double> rand_vec;
613+
if( this->functions.cell_division_direction_function )
614+
{
615+
rand_vec = this->functions.cell_division_direction_function( this );
616+
if( default_microenvironment_options.simulate_2D == true ) // ensure vec in XY plane
617+
{ rand_vec[2] = 0.0; }
618+
normalize( &rand_vec ); // ensure normalized
619+
}
620+
else
621+
{
622+
rand_vec = cell_division_orientation();
623+
rand_vec = rand_vec- phenotype.geometry.polarity*(rand_vec[0]*state.orientation[0]+
624+
rand_vec[1]*state.orientation[1]+rand_vec[2]*state.orientation[2])*state.orientation;
625+
}
626+
615627
rand_vec *= phenotype.geometry.radius;
616628

617629
child->assign_position(position[0] + rand_vec[0],
@@ -1362,6 +1374,7 @@ void Cell::ingest_cell( Cell* pCell_to_eat )
13621374
pCell_to_eat->functions.update_phenotype = NULL;
13631375
pCell_to_eat->functions.contact_function = NULL;
13641376
pCell_to_eat->functions.cell_division_function = NULL;
1377+
pCell_to_eat->functions.cell_division_direction_function = NULL;
13651378

13661379
// should set volume fuction to NULL too!
13671380
pCell_to_eat->functions.volume_update_function = NULL;
@@ -1613,6 +1626,7 @@ void Cell::fuse_cell( Cell* pCell_to_fuse )
16131626
pCell_to_fuse->functions.update_phenotype = NULL;
16141627
pCell_to_fuse->functions.contact_function = NULL;
16151628
pCell_to_fuse->functions.cell_division_function = NULL;
1629+
pCell_to_fuse->functions.cell_division_direction_function = NULL;
16161630
pCell_to_fuse->functions.volume_update_function = NULL;
16171631

16181632
// remove all adhesions
@@ -1653,6 +1667,7 @@ void Cell::lyse_cell( void )
16531667
functions.update_phenotype = NULL;
16541668
functions.contact_function = NULL;
16551669
functions.cell_division_function = NULL;
1670+
functions.cell_division_direction_function = NULL;
16561671

16571672
// remove all adhesions
16581673

@@ -1750,6 +1765,13 @@ void display_ptr_as_bool( void (*ptr)(Cell*,Cell*), std::ostream& os )
17501765
os << "false";
17511766
return;
17521767
}
1768+
void display_ptr_as_bool( std::vector<double> (*ptr)(Cell*), std::ostream& os )
1769+
{
1770+
if( ptr )
1771+
{ os << "true"; return; }
1772+
os << "false";
1773+
return;
1774+
}
17531775

17541776
void display_cell_definitions( std::ostream& os )
17551777
{
@@ -1836,6 +1858,8 @@ void display_cell_definitions( std::ostream& os )
18361858
os << std::endl;
18371859
os << "\t\t cell division function: "; display_ptr_as_bool( pCF->cell_division_function , std::cout );
18381860
os << std::endl;
1861+
os << "\t\t cell division direction function: "; display_ptr_as_bool( pCF->cell_division_direction_function , std::cout );
1862+
os << std::endl;
18391863

18401864
// summarize motility
18411865

core/PhysiCell_phenotype.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ class Cell_Functions
517517
Cell* pOther, Phenotype& other_phenotype, double dt );
518518

519519
void (*cell_division_function)(Cell* pCell1, Cell* pCell2 );
520+
std::vector<double> (*cell_division_direction_function)(Cell* pCell1);
520521

521522
/* prototyping / beta in 1.5.0 */
522523
/*

0 commit comments

Comments
 (0)