A MeshRegion
seems to function quite differently from any other Mathematica expression. One cannot take a Part
of it. Nor can I simply exchange its head to something else using Apply
. What is going on here and how do I extract the argument in some manipulable form?
MeshRegion
is an atomic expression. This may be to allow an optimized internal form. See an explanation for why Graph
is atomic in Why is Graph an atomic expression in Mathematica?. Parts can be taken using MeshCoordinates[]
, MeshCells[]
and Options[]
. (I do not know whether these three functions can obtain all data contained in a MeshRegion but for now it seems like it.)
Another workaround would be to convert to a String
and act on that:
takeArgumentMeshRegion[meshreg_]:=ToExpression@StringCases[ToString[FullForm@meshreg],"MeshRegion["~~x__~~"]":>"{"<>x<>"}"];
However, this might be a bad idea since there is a reason why Mathematica tries to keep us from taking arguments like this.
MeshRegion
is an atomic expression. See also AtomQ $\endgroup$ – Pinti Jan 27 '20 at 13:22MeshCoordinates[]
andMeshCells[]
for. $\endgroup$ – J. M.'s ennui♦ Jan 27 '20 at 13:35MeshRegion
is like this it is probably for similar reasons as forGraph
which are discussed here mathematica.stackexchange.com/questions/127522/…. $\endgroup$ – Kvothe Jan 27 '20 at 13:44