MATLAB Answers

I have a 3D volume shape and I would like to take only the surface of the shape to change it to triangular mesh.How can i do this?

1 view (last 30 days)
Shereen Ekhlas
Shereen Ekhlas on 27 Nov 2016
Edited: John D'Errico on 27 Nov 2016
Hi everybody I have a 3-D volume shape and I would like to take only the surface of this shape and document it as a triangular mesh.How can i do this? Looking forward your help and your suggestions. Thanks. Shereen

Answers (1)

John D'Errico
John D'Errico on 27 Nov 2016
Edited: John D'Errico on 27 Nov 2016
A 3-d tetrahedral mesh is composed of tetrahedra, each of which is non-overlapping, but they will all share some facets. The facets that are not shared lie on the boundary manifold that you wish to generate. So the solution is simple, even trivial.
For example, here is a simple 3-d volume mesh:
xyz = rand(10,3);
tess = delaunayn(xyz)
tess =
8 5 10 4
1 5 8 4
1 2 10 3
1 10 8 3
1 10 2 4
1 8 10 4
9 5 2 4
6 2 5 4
6 5 1 4
6 1 2 4
6 5 9 7
6 9 2 7
6 2 9 5
6 5 7 3
6 8 5 3
6 1 8 3
6 8 1 5
Each row of that array is one simplex in the mesh.
Generate a list of all facets. Each tetrahedon is composed of 4 such facets, so the complete facet list has 4*N facets in it, for N tetrahedra. Note that this operation will take ONE line of code if you think about it. (Just some index operations, concatenated into one array.) You should end up with a 4*N by 3 array that defines all facets. Some of those facets appear in the list twice.
Next, recognize that a facet (a triangle) is defined by a list of 3 vertex indices. You need to ensure those indices are sorted in increasing order within any triangle. Again, one line of code to do the sort. (Just call sort.)
Finally, delete those facets that appear twice in the list of all facets. Those that remain form the desired boundary. This should take roughly 3 lines of code to accomplish, so a call to sortrows, then use diff and find to locate the duplicated facets, and delete them.
All of the above operations are fully vectorizable, and should be done that way for efficiency. So try it! These are all easy computations I've described, and if you will be working in this area, you will need to learn to do such things often. The way to learn is to try it.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by