# Get interior of mesh region

I really like the functionality of Mathematica for mesh-based regions,
and have enough understanding of it. But this problem bothers me.
There is a similar question, but the functionality used now obsolete.

Let we have mesh region (for simplicity MeshCellMeasure made large enough):

region = DiscretizeRegion[Annulus[{0, 0}, {1/2, 1}, {0,3 Pi/2}], {MaxCellMeasure -> {"Length" -> 0.15}, ImageSize -> 150}]


I need to separate the interior — all that is not RegionBoundary@region.
And in the form in which it is obtained at primary discretization;
literally everything that is not highlighted red:

bound = RegionBoundary@region;
Show[region,
HighlightMesh[
bound, {Style[1, Red], Style[0, PointSize[Medium], Red]}]]


I was only able to do it this way:

coords = MeshCoordinates@region;
boundCoords = MeshCoordinates@bound;
verts = Range@Length@coords;
boundVerts = Flatten[Position[coords, #] & /@ boundCoords, 2];
interior =
ConcaveHullMesh[coords[[Delete[verts, Partition[boundVerts, 1]]]]]


In fact, it is simplest form of erosion, but I can't get it nor with RegionErosion nor with Erosion.

I’m sure it can be made simpler and more contemporary,

• How about interior = RegionDifference[region, bound]? Commented Jan 19 at 16:51
• @user64494, it makes solid region without mesh. I need to preserve mesh from initial region! Commented Jan 19 at 17:08
• @lesobrod The "interior" is the remaining mesh when all boundary lines are removed? Commented Jan 19 at 17:45
• Boundary lines and vertices Commented Jan 19 at 18:02

interior = {interiorpoints, interiorlines, interiorpolygons} =
MeshCells[region, {#, "Interior"}] & /@ {0, 1, 2};

HighlightMesh[region, interior, ImageSize -> Large]


Row[HighlightMesh[region, ToExpression@#,
ImageSize -> Medium, PlotLabel -> Style[#, 20]] & /@
{"interiorpoints", "interiorlines", "interiorpolygons"}]


Graphics[{EdgeForm[Gray], RandomColor[], #} & /@
MeshPrimitives[region, {2, "Interior"}]]


• Very interesting answer ! Where did you find the option "Interior"? Options[MeshCells] gives {}! Thanks Commented Jan 20 at 9:44
• @UlrichNeumann, afaik these syntaxes/properties are not documented. I don't remember how I bumped into things like {1,"Interior"} , {2, "Frontier"} , {0,"Boundary"} as valid cell indices. (I played with the list returned by mesh["Properties"] (where mesh is a MeshRegion or a BoundaryMeshRegion object) and found some properties can be accessed using these propery names.) related: Boundary cells of a mesh?, total length of edges in select Voronoi diagram
– kglr
Commented Jan 20 at 10:06
• @kglr, OMG, I play sometimes with "Properties", but there are lot of non documented for MeshRegion... Even "DeepCopy" (o_O) Thank you anyway, that works for version 12, 13 and 14 very well! Commented Jan 20 at 14:39

Here's a way to remove only the faces that have an edge on the boundary. This differs from MeshCells[region, {2, "Interior"}] since that also excludes faces with only a point touching the boundary.

g = MeshConnectivityGraph[region, {1, 2}, 1];

bdedges = Pick[VertexList[g], VertexDegree[g], 1];
bdfaces = VertexOutComponent[g, bdedges, {1}][[All, 2]];
interiorfaces = Complement[Range[MeshCellCount[region, 2]], bdfaces];

submesh = MeshRegion[
MeshCoordinates[region],
MeshCells[region, {2, interiorfaces}]
]


HighlightMesh[region, {2, interiorfaces}]