Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing for derived Cell objects, defined by cell types #153

Merged
merged 2 commits into from
Jul 26, 2023
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
2 changes: 1 addition & 1 deletion BioFVM/BioFVM_basic_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Basic_Agent
void update_position( double dt );

Basic_Agent();

virtual ~Basic_Agent(){};
// simulate secretion and uptake at the nearest voxel at the indicated microenvironment.
// if no microenvironment indicated, use the currently selected microenvironment.
void simulate_secretion_and_uptake( Microenvironment* M, double dt );
Expand Down
18 changes: 14 additions & 4 deletions core/PhysiCell_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ std::unordered_map<int,int> cell_definition_indices_by_type;
// in case you want the legacy method
std::vector<double> (*cell_division_orientation)(void) = UniformOnUnitSphere; // LegacyRandomOnUnitSphere;

Cell* standard_instantiate_cell()
{ return new Cell; }

Cell_Parameters::Cell_Parameters()
{
o2_hypoxic_threshold = 15.0; // HIF-1alpha at half-max around 1.5-2%, and tumors often are below 2%
Expand Down Expand Up @@ -148,6 +151,7 @@ Cell_Definition::Cell_Definition()
// the default Custom_Cell_Data constructor should take care of this

// set up the default functions
functions.instantiate_cell = NULL;
functions.volume_update_function = NULL; // standard_volume_update_function;
functions.update_migration_bias = NULL;

Expand Down Expand Up @@ -552,7 +556,7 @@ Cell* Cell::divide( )
}


Cell* child = create_cell();
Cell* child = create_cell(functions.instantiate_cell);
child->copy_data( this );
child->copy_function_pointers(this);
child->parameters = parameters;
Expand Down Expand Up @@ -1048,10 +1052,16 @@ void Cell::add_potentials(Cell* other_agent)
return;
}

Cell* create_cell( void )
Cell* create_cell( Cell* (*custom_instantiate)())
{
Cell* pNew;
pNew = new Cell;

if (custom_instantiate) {
pNew = custom_instantiate();
} else {
pNew = standard_instantiate_cell();
}

(*all_cells).push_back( pNew );
pNew->index=(*all_cells).size()-1;

Expand All @@ -1074,7 +1084,7 @@ Cell* create_cell( void )
// In that "create_cell()" uses "create_cell( cell_defaults )"
Cell* create_cell( Cell_Definition& cd )
{
Cell* pNew = create_cell();
Cell* pNew = create_cell(cd.functions.instantiate_cell);

// use the cell defaults;
pNew->type = cd.type;
Expand Down
4 changes: 2 additions & 2 deletions core/PhysiCell_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class Cell : public Basic_Agent
void step(double dt);
Cell();

~Cell();
virtual ~Cell();

bool assign_position(std::vector<double> new_position);
bool assign_position(double, double, double);
Expand Down Expand Up @@ -251,7 +251,7 @@ class Cell : public Basic_Agent
void convert_to_cell_definition( Cell_Definition& cd );
};

Cell* create_cell( void );
Cell* create_cell( Cell* (*custom_instantiate)() = NULL );
Cell* create_cell( Cell_Definition& cd );

void delete_cell( int );
Expand Down
2 changes: 2 additions & 0 deletions core/PhysiCell_phenotype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,8 @@ void Molecular::advance( Basic_Agent* pCell, Phenotype& phenotype , double dt )

Cell_Functions::Cell_Functions()
{
instantiate_cell = NULL;

volume_update_function = NULL;
update_migration_bias = NULL;

Expand Down
2 changes: 2 additions & 0 deletions core/PhysiCell_phenotype.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ class Cell_Functions
{
private:
public:
Cell* (*instantiate_cell)();

Cycle_Model cycle_model;

void (*volume_update_function)( Cell* pCell, Phenotype& phenotype , double dt ); // used in cell
Expand Down