public void Cylinder34Squamous2Columnar2(float scaleH) { //int gridSize = 2; //int ySize = 3; //innerRadius = new Vector(.5f, .5f, .5f); //innerRadius0 = new Vector(r, 1f, r); Mesh m = new Cylinder34(new Vector(.5f, .5f, .5f)); targetVertices = m.GetVertexPositions(); innerRadius.y *= scaleH; Vector nucleus = new Vector(0, -.5f, 0); for (int i = 0; i < vertices.getCount(); i++) { //Vector vec = new Vector(); //vec.x = 2 * innerRadius.x * vec.x / gridSize - innerRadius.x; targetVertices[i].y = targetVertices[i].y * scaleH; //vec.z = 2 * innerRadius.z * vec.z / gridSize - innerRadius.z; } for (int i = 0; i < nbOfParticles; i++) { nucleusEdges[i].l0 = (targetVertices[i] - nucleus).norm(); } for (int j = 0; j < edgeCount(); j++) { edges[j].l0 = Vector.Distance(targetVertices[edges[j].ends[0].pos], targetVertices[edges[j].ends[1].pos]); } }
public override void SetupSimulation() { nbOfSimulationSteps = 2000; logFrequency = 10; //logVTK = true; popSize = 8; popMaxSize = 64; Cylinder34 mesh = new Cylinder34(new Vector(.5f, 1f, .5f), false); Tissue t1 = new Tissue(8, popMaxSize, mesh); List <Tissue> tissueList = new List <Tissue>() { t1 }; nbCellTypes = tissueList.Count; cellPopulation = new CellPopulation(popSize, popMaxSize, tissueList, 2); Helper.SetNCubedInN(popMaxSize); cellPopulation.PositionCells(false); }
public void CloseEPI2() { Cylinder34 cy = new Cylinder34(new Vector(.5f, 1f, .5f), false); int[] lookUp = cy.LookUp(); int[] ring = new int[] { 58, 59, 60, 61, 62, 65, 66, 67, 68, 69, 72, 73, 74, 75, 76, 79, 80, 81, 82, 83, 86, 87, 88, 89, 90 }; /* * List<int> TE = new List<int>(){ 50, 51, 52, 53, 54, * 55, 56, 57, 58, 59, * 60, 61, 62, 63, 64, * 65, 66, 67, 68, 69, * 70, 71, 72, 73, 74}; * //*/ //* List <int> TE = new List <int>(); for (int i = 0; i < 49; i++) { TE.Add(50 + i); } //*/ int[] pFoyer = { 6, 7, 8, 11, 12, 13, 16, 17, 18 }; int[] pZmin = { 0, 1, 2, 3, 4 }; int[] pXmax = { 4, 9, 14, 19, 24 }; int[] pZmax = { 24, 23, 22, 21, 20 }; int[] pXmin = { 20, 15, 10, 5, 0 }; //int[] cSup = { 25, 27, 29, 31, 32 }; int[] cSup = { 24, 25, 26, 27, 28, 29, 30, 31, 32 }; int[] cZmin = cy.CZmin().ToArray(); int[] cZmax = cy.CZmax().ToArray(); int[] cXmin = cy.CXmin().ToArray(); int[] cXmax = cy.CXmax().ToArray(); int edgeCount = 0; List <Edge> newEdges = new List <Edge>(); for (int i = 0; i < pZmin.Length; i++) { for (int j = 0; j < cZmin.Length; j++) { //Console.WriteLine(pZmin[i] + ", " + cZmin[j]); Edge edge = new Edge(cells[pZmin[i]].vertices[cZmin[j]], cells[pZmin[i] + 25].vertices[lookUp[cZmin[j]]]); newEdges.Add(edge); edgeCount++; } } for (int i = 0; i < pZmax.Length; i++) { for (int j = 0; j < cZmax.Length; j++) { Edge edge = new Edge(cells[pZmax[i]].vertices[cZmax[j]], cells[pZmax[i] + 25].vertices[lookUp[cZmax[j]]]); //Edge edge = new Edge(cells[pZmax[i]].vertices[cZmax[j]], cells[pZmax[i] + 25].vertices[cZmax[j]]); newEdges.Add(edge); edgeCount++; } } for (int i = 0; i < pXmin.Length; i++) { for (int j = 0; j < cXmin.Length; j++) { Edge edge = new Edge(cells[pXmin[i]].vertices[cXmin[j]], cells[pXmin[i] + 25].vertices[lookUp[cXmin[j]]]); //Edge edge = new Edge(cells[pZmin[i]].vertices[cXmin[j]], cells[pZmin[i] + 25].vertices[cXmin[j]]); newEdges.Add(edge); edgeCount++; } } for (int i = 0; i < pXmax.Length; i++) { for (int j = 0; j < cXmax.Length; j++) { Edge edge = new Edge(cells[pXmax[i]].vertices[cXmax[j]], cells[pXmax[i] + 25].vertices[lookUp[cXmax[j]]]); newEdges.Add(edge); edgeCount++; } } for (int i = 0; i < pFoyer.Length; i++) { for (int j = 0; j < cSup.Length; j++) { Edge edge = new Edge(cells[pFoyer[i]].vertices[cSup[j]], cells[pFoyer[i] + 25].vertices[lookUp[cSup[j]]]); for (int n = 0; n < edge.ends[1].externalNeighbours.Count; n++) { int l = edge.ends[1].externalNeighbours[n][0]; int k = edge.ends[1].externalNeighbours[n][1]; Edge e1 = new Edge(edge.ends[0], cells[l].vertices[k]); newEdges.Add(e1); } newEdges.Add(edge); edgeCount++; } } //newEdges = newEdges.Distinct().ToList<Edge>(); newEdges = Helper.Distinct(newEdges); int count = 0; //* for (int i = 0; i < newEdges.Count; i++) { count++; Vector midPoint = (newEdges[i].ends[0].v + newEdges[i].ends[1].v) * .5; newEdges[i].ends[0].v = new Vector(midPoint); newEdges[i].ends[1].v = new Vector(midPoint); Vertex v0 = newEdges[i].ends[0]; Vertex v1 = newEdges[i].ends[1]; /* * if(v0.cellId == 22 && v0.pos == 4 && v1.cellId == 47 && v1.pos == 2) * { * for (int j = 0; j < v1.externalNeighbours.Count; j++) * { * int l = v1.externalNeighbours[j][0]; * int k = v1.externalNeighbours[j][1]; * * //Console.WriteLine(l + ", " + k); * } * } */ //* for (int j = 0; j < v0.externalNeighbours.Count; j++) { int l = v0.externalNeighbours[j][0]; int k = v0.externalNeighbours[j][1]; if (l != v1.cellId) { Edge newEdge = new Edge(v1, cells[l].vertices[k]); cells[v1.cellId].externalEdges.add(newEdge); cells[l].externalEdges.add(new Edge(cells[l].vertices[k], v1)); //v1.externalNeighbours.Add(new int[] { l, k }); } } for (int j = 0; j < v1.externalNeighbours.Count; j++) { int l = v1.externalNeighbours[j][0]; int k = v1.externalNeighbours[j][1]; //cells[l].vertices[k].v = new Vector(v1.v); if (l != v0.cellId) { if (TE.Contains(l))// && !TE.Contains(l)) { Edge newEdge = new Edge(v1, cells[l].vertices[k]); cells[v1.cellId].externalEdges.remove(newEdge); cells[l].externalEdges.remove(new Edge(cells[l].vertices[k], v1)); } else { Edge newEdge = new Edge(v0, cells[l].vertices[k]); cells[v0.cellId].externalEdges.add(newEdge); cells[l].externalEdges.add(new Edge(cells[l].vertices[k], v0)); //v0.externalNeighbours.Add(new int[] { l, k }); } } } //*/ v0.externalNeighbours.Add(new int[] { v1.cellId, v1.pos }); v1.externalNeighbours.Add(new int[] { v0.cellId, v0.pos }); cells[newEdges[i].ends[0].cellId].externalEdges.add(newEdges[i]); cells[newEdges[i].ends[1].cellId].externalEdges.add(new Edge(newEdges[i].ends[1], newEdges[i].ends[0])); } //*/ int[] corners = new int[] { 0, 4, 24, 20 }; for (int i = 0; i < corners.Length; i++) { Cylinder34 cl = new Cylinder34(new Vector(.5f, 1f, .5f), false); cl.ApicalConstrictionWithPositionChange(.4f, Vector.up); Cylinder34 clDown = new Cylinder34(new Vector(.5f, 1f, .5f), false); clDown.ApicalConstrictionWithPositionChange(.4f, Vector.down); Vector normal = new Vector(); Vector normal25 = new Vector(); if (i == 0) { normal = new Vector(cl.vertices[0].v.x, 0, cl.vertices[0].v.z); //normal25 = new Vector(cl.vertices[4].v.x, 0, cl.vertices[4].v.z); normal25 = new Vector(cl.vertices[6].v.x, 0, cl.vertices[6].v.z); } if (i == 1) { normal = new Vector(cl.vertices[2].v.x, 0, cl.vertices[2].v.z); //normal25 = new Vector(cl.vertices[6].v.x, 0, cl.vertices[6].v.z); normal25 = new Vector(cl.vertices[4].v.x, 0, cl.vertices[4].v.z); } if (i == 2) { normal = new Vector(cl.vertices[4].v.x, 0, cl.vertices[4].v.z); //normal25 = new Vector(cl.vertices[0].v.x, 0, cl.vertices[0].v.z); normal25 = new Vector(cl.vertices[2].v.x, 0, cl.vertices[2].v.z); } if (i == 3) { normal = new Vector(cl.vertices[6].v.x, 0, cl.vertices[6].v.z); //normal25 = new Vector(cl.vertices[2].v.x, 0, cl.vertices[2].v.z); normal25 = new Vector(cl.vertices[0].v.x, 0, cl.vertices[0].v.z); } cells[corners[i]].SetElengths(cl.Slice(normal, true)); cells[corners[i] + 25].SetElengths(clDown.Slice(normal25, false)); //for(int ) //cells[corners[i]].SetElengths(cl.Slice(normal, true)); //cells[corners[i] + 25].SetElengths(clDown.Slice(normal25, true)); //cells[corners[i] + 25].SetEdgeELengths(); } }