Consider the following discretization of a region object:
region = DiscretizeRegion[Disk[], MaxCellMeasure -> ∞]
Head[region]
InputForm[region]
which returns something like this:
By all appearances, this has created an object region
with Head MeshRegion
and which contains a bunch of points, then a Polygon
object, and other stuff inside.
I am trying to manipulate regions of this kind using standard mess-with-the-code techniques, but they're proving surprisingly ineffective. Consider the following ways to get at the juicy interior:
Replace the head with something else, e.g. via
notMeshRegion @@ region
,which doesn't do anything.
Attack it via
Part
, to get at the inner components of the expression,doesn't work, and it returns a
Part::partd
error.Attempt to replace the head or internals of the expression with something else,
which leaves it untouched.
What's going on? I might expect this kind of thing to happen with objects with HoldFirst
or HoldAll
attributes (so their internals are a bit weird and they do some nonstandard handling), but MeshRegion
's only attribute is Protected
, and under InputForm
and FullForm
region
looks exactly like every other expression. How do I get to those juicy internals?
I thought this would be obvious, since we're all grownups, but just to be clear: I'm not asking about WRI's design reasons for making the language behave like it does, which is obviously a question for WRI instead of this site. I'm asking about what features of the language cause some expressions, which can have intricate an intricate internal structure evident through InputForm
or FullForm
to make that internal structure unavailable via the normal language tools, where they are represented in the documentation, and how I can use the language to tell whether a given expression will behave this way.
AtomQ @ region
$\endgroup$MeshRegion
that will cause its output to be thus 'atomized'. $\endgroup$AtomQ
is what can tell you that. But I agree an atomic part of the WL could be documented better: comment367234 $\endgroup$