Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Cell.cpp

Go to the documentation of this file.
00001 // Cell.cpp: implementation of the CCell class.
00002 //
00004 
00005 #include <iostream.h>           //***this is temporary
00006 #include "Components.h"
00007 #include "Display.h"
00008 #include "DNA.h"
00009 #include "Geometry.h"
00010 #include "Cell.h"
00011 #include <math.h>
00012 
00014 // Construction/Destruction
00016 
00017 //Constructor
00018 CCell::CCell()
00019 {
00020         m_pComponents=new CComponents(this);    //Create the components
00021         m_pDisplay=new CDisplay(this);                  //Create the display
00022         m_pDNA=new CDNA(this);                                  //Create the DNA
00023         m_pGeometry = new CGeometry(this);              //Create the geometry
00024         GenTime=0;
00025         TotalTime=0;
00026         NGEN=0;
00027 }
00028 
00029 //Destructor
00030 CCell::~CCell()
00031 {
00032         //Free up memory allocated in the constructor
00033         delete m_pComponents;
00034         delete m_pDisplay;                      
00035         delete m_pDNA;                          
00036         delete m_pGeometry;
00037 }
00038 
00039 //Copy constructor
00040 CCell::CCell(const CCell& rCell)        
00041 {
00042         m_pComponents=new CComponents(*rCell.m_pComponents,this);       //Create and copy the components
00043         m_pDisplay=new CDisplay(*rCell.m_pDisplay,this);                        //Create and copy the display
00044         m_pDNA=new CDNA(*rCell.m_pDNA,this);                                            //Create and copy DNA
00045         m_pGeometry=new CGeometry(*rCell.m_pGeometry,this);             //Create and copy the geometry
00046 }
00047 
00048 //Assignment operator (safe but imperfect)
00049 CCell& CCell::operator =(const CCell & rhs)
00050 {
00051         if(this == &rhs)                //check addresses, if equal
00052                 return *this;           //return the 1st operand
00053 
00054         delete m_pComponents;
00055         delete m_pDisplay;              
00056         delete m_pDNA;          
00057         delete m_pGeometry;             //delete any existing values
00058         
00059         m_pComponents=new CComponents(*rhs.m_pComponents,this); //Create and copy the components
00060         m_pDisplay=new CDisplay(*rhs.m_pDisplay,this);                  //Create and copy the display
00061         m_pDNA=new CDNA(*rhs.m_pDNA,this);                                              //Create and copy DNA
00062         m_pGeometry=new CGeometry(*rhs.m_pGeometry,this);               //Create and copy the geometry
00063         
00064         //***DON'T USE YET, m_pCell POINTERS STILL POINT TO SAME PARENT***
00065         return *this;
00066 }
00067 
00068 void CCell::Run()
00069 {
00070         int NGENMAX=30;
00071         NGEN = 0;               //Number of generations
00072         m_pGeometry->CheckVolume();             //Make sure volume and total mass agree
00073         
00074         for(;NGEN<=NGENMAX;)                            //Loop for generations
00075         {
00076                 m_pComponents->StartAverages();
00077                 Generation();
00078         }
00079 }
00080 
00081 void CCell::Division()
00082 {
00083         ++NGEN;
00084         m_pComponents->Divide();
00085         m_pDNA->Divide();
00086         m_pGeometry->Divide();
00087 }
00088 
00089 CGeometry* CCell::GetGeometry()
00090 {
00091         return m_pGeometry;                             //return pointer to the geometry
00092 }
00093 CComponents* CCell::GetComponents()
00094 {
00095         return m_pComponents;                   //return pointer to the components
00096 }
00097 
00098 CDisplay* CCell::GetDisplay()
00099 {
00100         return m_pDisplay;                              //return pointer to the display
00101 }
00102 
00103 void CCell::Generation()                        //runs one complete generation to division
00104 {
00105         static double PrintTime=0;
00106         GenTime=0;                                              //reset GenTime;                                        
00107         m_pComponents->FirstInt();              //run only on first generation
00108                                 
00109         do{                                                             //loop until division
00110                 m_pComponents->Integrate();     //integrate one time step
00111                 m_pDNA->AdvanceFork();          //DNA replication
00112                 m_pDNA->EcoInit();
00113                 m_pDNA->Termination();          //does termination occur?
00114                 m_pGeometry->UpdateShape();     //envelope elongation and cross-wall synthesis
00115                 if(TotalTime>PrintTime)
00116                 {
00117                 //      m_pDisplay->PrintComponents();  //Print
00118                 //      PrintTime+=0.02;
00119                 }
00120         }while(!DivisionCheck());       
00121         Division();
00122         m_pDisplay->PrintComponents();          //Print on division
00123 }
00124 
00125 bool CCell::DivisionCheck()
00126 {
00127         double SEP=3.14159*pow(GetGeometry()->GetWidth(),2);                    //Area of hemispherical ends
00128         //if cell doesn't divide
00129         if((GetGeometry()->GetSepf()-SEP)<=0.0)         //if pinching off doesn't occur
00130         {
00131                 GetComponents()->NextY();
00132                 return 0;
00133         }
00134         else
00135                 return 1;
00136 }
00137 
00138 //DEL double CCell::GetTime()
00139 //DEL {
00140 //DEL   return GenTime;
00141 //DEL }
00142 
00143 void CCell::AdvanceTime(double DT)
00144 {
00145         GenTime+=DT;
00146         TotalTime+=DT;
00147 }
00148 
00149 CDNA* CCell::GetDNA()
00150 {
00151         return m_pDNA;
00152 }

Generated on Mon Nov 3 09:37:39 2003 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002