1
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ Where is "Interior" and "Frontier" documented? $\endgroup$ – Szabolcs Mar 18 at 20:12
  • $\begingroup$ I don't know. Might be undocumented. $\endgroup$ – sam wolfe Mar 18 at 20:13
  • 1
    $\begingroup$ Where did you learn about them? Can you give me a link? $\endgroup$ – Szabolcs Mar 18 at 20:14
  • $\begingroup$ I believe the first time I learned about them was on MarcoB's answer on my question: mathematica.stackexchange.com/a/212625/64001 $\endgroup$ – sam wolfe Mar 18 at 20:18
  • $\begingroup$ Also, BoundaryMesh might do the trick. I'm trying. $\endgroup$ – sam wolfe Mar 18 at 20:19
1
$\begingroup$

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.

| improve this answer | |
$\endgroup$
0
$\begingroup$

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.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.