Is it possible to obtain the region inequalities from a mesh file (vtk-file).

On gmsh I build a Sphere, and with Mathematica I would like to obtain the analytics region function, that's is possible?.

I can obtain the vertex from the file sphere.vtk, using that:

data = Import["mesh_2_5.vtk", "VertexData"];

But I do not know if exists a routine for obtaining the analytics equations that define this structure. The sphere.vtk can be downloaded from: https://gofile.io/d/OscWUA


  • $\begingroup$ Your Sphere.vtk file doesn't contain any inequalities or expressions. They are all points and cells. If you want the equation for this sphere, you need to perform a fit to find parameters of a sphere equation. $\endgroup$ – flinty Jul 27 '20 at 12:10
  • $\begingroup$ You do sphere = Import["Sphere.vtk"]; mesh = DiscretizeGraphics@sphere; coords = MeshCoordinates[mesh]; Then have a look at ListPointPlot3D[coords, BoxRatios -> 1] You only need the radius since it's clearly centered at zero. The radius is Max[Norm /@ coords] which returns 1. So your sphere is best fit by Sphere[{0,0,0},1] - or better Ball[{0,0,0},1] since points can appear on the inside. $\endgroup$ – flinty Jul 27 '20 at 12:17
  • $\begingroup$ Thank you very much, do you know if there is any function in Mathematica that looks for the equation of the surface of the sphere ?, from the numerical data $\endgroup$ – F.Mark Jul 27 '20 at 13:55
  • $\begingroup$ No - just get the points on the shell with pts=MeshCoordinates[ConvexHullMesh[coords]] then assuming a uniform distribution of points, c=Mean[pts] will get the center, and Max[Norm[#-c]&/@pts] will get you the radius. $\endgroup$ – flinty Jul 27 '20 at 14:16
  • 1
    $\begingroup$ Get the faces with MeshPrimitives[mesh, 2] and calculate their normals and a random point on the surface. This should be enough to set up a system of inequalities provided the normals point out of the object. But your sphere is problematic because you have self intersecting geometry and faces internal to the sphere. If your objects are convex, you could treat this with a ConvexHullMesh first. $\endgroup$ – flinty Jul 27 '20 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.