Consider the following VoronoiMesh obtained after a few iterations of Lloyd's relaxation algorithm
L1 = 6; L2 = 10;
relaxed =
Nest[PropertyValue[{VoronoiMesh[#, {{-1, L2 + 2}, {-1,
L1 + 2}}], {2, All}},
MeshCellCentroid] &, {RandomReal[L2 + 2, (L1 + 2) (L2 + 2)],
RandomReal[L1 + 2, (L1 + 2) (L2 + 2)]} // Transpose, 200];
mesh0 = VoronoiMesh[relaxed]
Now, inspired by the discussion in this question, I can first pick the "nicely shaped" interior cells, based on the cell area
mesh1 = MeshRegion[MeshCoordinates[mesh0],
With[{a = PropertyValue[{mesh0, 2}, MeshCellMeasure]},
With[{m = 1.5}, Pick[MeshCells[mesh0, 2], UnitStep[a - m], 0]]]]
My goal is now to be able to easily manage the boundary (edges and corners independently) and interior, including/removing them in a "toggleable" way. This would define 9 regions in total (4 corners, 4 edges and 1 interior region). I'm already able to select either the boundary or the interior, as can be seen here
MeshRegion[MeshCoordinates[mesh1], MeshCells[mesh1, {2, "Frontier"}]]
and
MeshRegion[MeshCoordinates[mesh1], MeshCells[mesh1, {2, "Interior"}]]
Is there a good way to detect edges and/or corners of meshes like this? I'm aware of commands like IntersectingQ
and Pick
, that could prove to be useful. Any ideas?
Edit: For example, I would like to obtain meshes like the following (with the interior also "toggable")
Also, by edges I mean any of the four cell arrays that constitute the frontier/boundary of the mesh. Corners might be trickier to uniquely define, given that the mesh is slightly perturbed, but a solution for the edges would be great nonetheless.