4
$\begingroup$

Mesh information

Using the helpful tips from Triangular mesh of random points on a sphere, it's easy to generate solids:

reg = DiscretizeGraphics[Sphere[{0, 0, 0}, 5], 
  MaxCellMeasure -> {"Length" -> 15}]

MeshCellCount[reg]

The interrogation tab provides useful information, but it would be helpful if the data could be captured in a text format.

Question

How can the information in the information tab (shown below) be harvested with a script?

Screen capture

enter image description here

$\endgroup$
8
$\begingroup$

I don't think there's anything particularly special in the mesh info tab. All of it can be found with various functions which I've encapsulated below:

meshinfo[mesh_] := {{"Embedding Dimension", RegionEmbeddingDimension[#]},
    {"Geometric Dimension", RegionDimension[#]},
    {"Vertex Cells" , MeshPrimitives[#, 0] // Length},
    {"Edge Cells" , MeshPrimitives[#, 1] // Length},
    {"Face Cells" , MeshPrimitives[#, 2] // Length},
    {"Volume Cells" , MeshPrimitives[#, 3] // Length},
    {"Area", Area[#]},
    {"Region Bounds", RegionBounds[#]},
    {"Region Centroid", RegionCentroid[#]}} &@mesh

meshinfo[reg] // Grid

Association[Rule @@@ meshinfo[reg]]
| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ (Here) MeshPrimitives[#, 0] // Length == VertexCount[MeshConnectivityGraph[reg]], MeshPrimitives[#, 1] // Length == EdgeCount[MeshConnectivityGraph[reg]], and MeshPrimitives[#, 2] // Length == Length@FindCycle[MeshConnectivityGraph[reg], {3}, All] $\endgroup$ – Harshal Gajjar Jun 26 at 20:21
  • 3
    $\begingroup$ You can use MeshCellCount instead of listing out and counting all primitives. $\endgroup$ – Chip Hurst Jun 27 at 1:39

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.