1

Consider the following mesh

mesh0 = VoronoiMesh[RandomReal[1, {50, 2}]]

enter image description here

I can select interior polygons with

mesh = MeshRegion[MeshCoordinates[mesh0], MeshCells[mesh0, {2, "Interior"}]]

enter image description here

My goal is to select only the edges that share a polygon. MeshPrimitives gets me close

Graphics[MeshPrimitives[mesh, 1]]

enter image description here

Now I would just need to select the edges from MeshPrimitives[mesh, 1] that share a polygon, in order to get something like

enter image description here

I know about "Frontier" as an option for MeshCells, but not entirely sure if I could use it. Any ideas?

sam wolfe
  • 4,663
  • 7
  • 37

2 Answers2

1

In the meantime, I have figured out an answer. The code

Complement[MeshPrimitives[mesh, 1], MeshPrimitives[BoundaryMesh[mesh], 1]] // Graphics

yields

enter image description here

which is what I want. Any comments/improvements are welcome.

sam wolfe
  • 4,663
  • 7
  • 37
1

With the syntax that you brought up yourself:

edges = Complement[
   MeshCells[mesh, {1}, "Multicells" -> True][[1, 1]],
   MeshCells[mesh, {1, "Boundary"}, "Multicells" -> True][[1, 1]]
   ];
primitives = Partition[MeshCoordinates[mesh][[Flatten[edges]]], 2];

But also

edges= Union[
 MeshCells[mesh, {1, "Frontier"}, "Multicells" -> True][[1, 1]],
 MeshCells[mesh, {1, "Interior"}, "Multicells" -> True][[1, 1]]
 ]

looks good.

Henrik Schumacher
  • 106,770
  • 7
  • 179
  • 309