2
$\begingroup$

A region in 3D space has been discretized to obtain a list of points.

The resulting ListPointPlot3D plot is:

enter image description here

I will like to obtain a mesh from these points, but the mesh should not connect points that are too far away from each other.

Using ConvexHullMesh and BoundingRegion directly gives the following result:

enter image description here

The mesh connects points that are far away, closing a part of the volume which must be concave. Is there a way to set the maximum distance between the nodes of the mesh?

The list of 3D points is available at: Points

$\endgroup$
4
  • $\begingroup$ You asked for ConvexHullMesh and you got it. You can of course refine it by applying DiscretizeRegion with a small setting for MaxCellMeasure. Want you obtain is the remeshed convex hull. But maybe you want to compute an $\alpha$-shape? $\endgroup$ Commented Jul 4, 2019 at 0:36
  • $\begingroup$ In general, it is a very nontrivial problem to construct a mesh from just a point cloud. $\endgroup$ Commented Jul 4, 2019 at 0:46
  • $\begingroup$ Don't know much about meshing, but I guess I want to compute an alpha shape. How can I do this in Mathematica? $\endgroup$ Commented Jul 4, 2019 at 12:19
  • 1
    $\begingroup$ mathematica.stackexchange.com/a/8812 $\endgroup$ Commented Jul 4, 2019 at 12:57

1 Answer 1

1
$\begingroup$

Thank you for pointing me in the right direction, Henrik Schumacher!

These two links helped me to solve this problem:

Finding a concave hull

Random discrete data 3D plot

Adequately modifying this code by Taiki and Simon Woods was just what I needed:

tetrahedra = Level[MeshPrimitives[DelaunayMesh[data], 3], {-3}];
radius[p_] := Circumsphere[p][[2]];
radii = radius /@ tetrahedra;
alphashape[rmax_] := Pick[tetrahedra, radii, r_ /; r < rmax]
faces[tetras_] := Flatten[
   tetras /. {a_, b_, c_, d_} :> {{a, b, c}, {a, b, d}, {a, c, d}, {b, c, d}}, 1];
externalfaces[faces_] := Cases[Tally[Sort /@ faces], {face_, 1} :> face];
radiusmax = 150;
polys = externalfaces@faces@alphashape[radiusmax];
Graphics3D[
  {EdgeForm[{Thin, Opacity[1/30, Black]}], Polygon@polys},
  AxesLabel -> {"x", "y", "z"},
  Axes -> True,
  Boxed -> False,
  BoxRatios -> {1, 1, 1},
  ViewPoint -> 1000 {-1, 1, -1}
]

The result is: enter image description here

Further playing with the rmax parameter can yield even more refined results.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.