예제 #1
0
        public MGCell(int i, int tissueId, Mesh m)
        {
            cellId    = i;
            nuclei    = new Vertex[2];
            nuclei[0] = new Vertex();
            centre    = new Vector(0, 0, 0);

            ShapeCell(m);
            nbOfParticles = vertexCount();
            innerRadius   = m.innerRadius;
            neighbours    = new List <int>();

            sigma          = new int[nbOfParticles];
            spins          = new float[nbOfParticles];
            targetVertices = new Vector[nbOfParticles];

            externalEdges = new EdgeSet();
            nucleusEdges  = new EdgeSet();
            subset        = new List <int>();

            nuclei[0].id     = nbOfParticles;
            nuclei[0].cellId = cellId;
            axis             = new Vector[3];
            for (int j = 0; j < nbOfParticles; j++)
            {
                vertices[j].id       = j;
                vertices[j].cellId   = i;
                vertices[j].tissueId = tissueId;

                Edge edge = new Edge(vertices[j], nuclei[0]);
                nucleusEdges.add(edge);
                targetVertices[j] = vertices[j].Clone().v;

                int k = new Random().Next(2);
                spins[j] = (k == 0) ? MGModel.delta : -MGModel.delta;
                sigma[j] = j;
                vertices[j].externalNeighbours = new List <int[]>();
                vertices[j].globalForces       = new Vector();
                subset.Add(j);
            }

            nuclei[0].v = ComputeCentreFromMesh();
            SetEdgeELengths();
            ResetCell();
        }
예제 #2
0
        public void Mitosis(Vector normal, bool staticShape)
        {
            Plane        splitPlane = CreateCutPlane2(normal);
            MeshSplitter splitter   = new MeshSplitter(this, splitPlane);

            splitter.MeshInitialize();
            splitter.MeshSplit();
            Mesh lowerMesh = splitter.CreateMeshLower();
            Mesh upperMesh = splitter.CreateMeshUpper();

            MGCell newCell = new MGCell(Simulator.cellPopulation.populationSize, lowerMesh);

            if (newCell != null)
            {
                newCell.cellId        = Simulator.cellPopulation.populationSize;
                newCell.appliedForces = appliedForces;
                newCell.Rcell         = Rcell;

                newCell.inDivisionMode = false;
                newCell.inGrowMode     = true;
                newCell.isNewBorn      = true;
                newCell.parent         = cellId;
                newCell.cyclePeriod    = 200;
                newCell.cycleTime      = 0;
                newCell.centre         = newCell.ComputeCentreFromMesh();
                newCell.nuclei[0].v    = newCell.centre;
                newCell.spins          = spins;
                newCell.polarisation   = polarisation;
                subset = new List <int>();

                for (int i = 0; i < newCell.nbOfParticles; i++)
                {
                    newCell.vertices[i].globalForces = new Vector();
                    newCell.subset.Add(i);
                }
                Simulator.cellPopulation.AddCell(tissueId, newCell);
            }

            //Booleans
            inDivisionMode = false;
            hasDivided     = true;
            isNewBorn      = true;
            inGrowMode     = true;
            cycleTime      = 0;
            //cyclePeriod = 100;

            copy(upperMesh);
            nuclei[0].v  = ComputeCentreFromMesh();
            centre       = ComputeCentreFromMesh();
            nucleusEdges = new EdgeSet();
            for (int i = 0; i < nbOfParticles; i++)
            {
                Edge edge = new Edge(vertices[i], nuclei[0]);
                nucleusEdges.add(edge);

                vertices[i].globalForces = new Vector();
                targetVertices[i]        = vertices[i].Clone().v;
                subset.Add(i);
            }

            if (staticShape)
            {
                SetEdgeELengths();
                newCell.SetEdgeELengths();
            }
            else
            {
                if (polarisation == Vector.down)
                {
                    SetElengths(MGModel.modelMeshes[1]);
                    newCell.SetElengths(MGModel.modelMeshes[1]);
                }
                else
                {
                    SetElengths(MGModel.modelMeshes[0]);
                    newCell.SetElengths(MGModel.modelMeshes[0]);
                }
            }
        }