4

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

dantopa
  • 1,060
  • 5
  • 10

1 Answers1

8

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]]

flinty
  • 25,147
  • 2
  • 20
  • 86
  • 1
    (Here) MeshPrimitives[#, 0] // Length == VertexCount[MeshConnectivityGraph[reg]],
    MeshPrimitives[#, 1] // Length == EdgeCount[MeshConnectivityGraph[reg]], and MeshPrimitives[#, 2] // Length == Length@FindCycle[MeshConnectivityGraph[reg], {3}, All]
    – Harshal Gajjar Jun 26 '20 at 20:21
  • 3
    You can use MeshCellCount instead of listing out and counting all primitives. – Greg Hurst Jun 27 '20 at 01:39