4

In Mathematica, one can triangulate a mesh starting from a boundary mesh region. For example:

r = BoundaryMeshRegion[{{0, 0}, {2, 0}, {2, 1}, {1, 1}, {1, 2}, {0, 2}}, Line[{1, 2, 3, 4, 5, 6, 1}]]
m = TriangulateMesh[r, MaxCellMeasure -> 0.1]

gives a mesh m with an L shape.

From m, it is possible to define another mesh as:

m2 = MeshRegion[MeshCoordinates[m], MeshCells[m, 2]]

Based on my understanding for MeshRegion, m2 should be the same as m. Sure enough if we check the mesh primitives, they are the same:

MeshPrimitives[m2] == MeshPrimitives[m]
(* True *)

However, if we compare m and m2 directly, we find that they are not equal:

m2==m
(* False *)

So why are they not equal?

Tofi
  • 291
  • 1
  • 11

1 Answers1

7

The region m appears to have an extra option set, causing them to be considered different regions:

m // Options
(* {Method -> {"PropagateMarkers" -> False}} *)

m2 // Options
(* {} *)

If you copy the options of m into m2, the two regions will be the same:

m2 = MeshRegion[MeshCoordinates[m], MeshCells[m, 2], Options[m]];

m == m2
(* True *)
Lukas Lang
  • 33,963
  • 1
  • 51
  • 97