Consider a set of points generated via Lloyd's relaxation algorithm
rel = Function[{pts},
Block[{cells},
cells = MeshPrimitives[VoronoiMesh[pts, {{-1, 1}, {-1, 1}}],
"Faces"];
RegionCentroid /@
cells[[SparseArray[Outer[#2@#1 &, pts, RegionMember /@ cells, 1],
Automatic, False]["NonzeroPositions"][[All, 2]]]]]];
n = 30;
pts = RandomReal[{-1, 1}, {n, 2}];
vor = VoronoiMesh[Nest[rel, pts, 20]]
Then, if I wanted a more "realistic" mesh and exclude the boundary cells, I could get something like this
vori = MeshCellIndex[vor, {2, "Interior"}];
Graphics[{Gray, EdgeForm[{Thick, White}],
Table[MeshPrimitives[vor, 2][[vori[[j, 2]]]], {j, Length[vori]}]}]
Now, the problem with this approach is that I can't get the exact number of interior cells that I want (same as this approach). It will always depend on which cells touch the boundary (or "Frontier", as it's sometimes used) and which don't. Now, an alternative way is to consider a periodic mesh, and in that case we get
ptsi = Nest[rel, pts, 20];
pts2 = Flatten[
Table[TranslationTransform[{2 i, 2 j}][ptsi], {i, -1, 1}, {j, -1,
1}], 2];
vorp = VoronoiMesh[pts2, {{-3, 3}, {-3, 3}}];
vcells = Catenate[NearestMeshCells[{vorp, 2}, #] & /@ ptsi];
pvor = MeshRegion[MeshCoordinates[vorp], MeshCells[vorp, vcells]]
This seems to do the trick (despite some occasional problems with rel), but it still has the problem that it is only considering periodic meshes.
My goal: Given a number n, generate a roughly square mesh of similar "realistic-looking" cells, in the sense of the examples above. For instance, I think it would be enough to simply fix the mean and variance of the cells area and perimeter, such that the tissue has a "uniform" look, and no "spiky" cells appear. I'm sorry for the over-usage of " ", but I'm ok with slightly different mathematical descriptions, as long as I get a mesh with a similar look to the ones presented above.
On top of that, if the mesh moves (as seen here, for example), I want the cells to be able to move accordingly (so that suddenly a cell doesn't become a frontier cell and disappears, which could happen in the first approach). Naturally I could draw the cells, but I want to specifically use VoronoiMesh and avoid periodic meshes.
Any ideas?





VoronoiMesh. – sam wolfe Jul 08 '20 at 14:13ncells which seeds intersect the disk, with increasing radius, until thenthreshold is met. This should work, right? In this setting I wouldn't even care about areas or perimeters, Lloyd would cover that for me. Wonder if this is efficient for largenthough.. – sam wolfe Jul 08 '20 at 14:28