mesh processing toolbox

Author & support : nicolas.douillet (at) free.fr, 2020.

Contents

Example #1 : vertex normals

addpath('data/');
addpath('src/');
load('icosahedron.mat');

ngb_degre = 1;
select_vertex_normals(V,T,ngb_degre);
Mesh with 12 vertices and 20 triangles displayed in 4.286806e-01 seconds.

Example #2 : non manifold triangles

load('kitten_nmnfld.mat');
nmnfld_tgl_idx_list = select_non_manifold_triangles(V,T);
view(0,90);
Mesh with 5224 vertices and 10911 triangles displayed in 1.021097e-01 seconds.

Example #3 : connected components

load('kitten_components.mat');

[cc_nb,components] = segment_connected_components(T);
show_mesh_components(V,components);
view(0,90);
4 components found in 1.291905e+00 seconds.

Example #4 : holes and boundary selection

load('kitten_holed.mat');

nmnfld_vtx_idx = select_non_manifold_vertices(V,T,false);
[V,T] = clone_solve_nmnfld_vertices(V,T,nmnfld_vtx_idx);
boundaries = select_holes_and_boundary(V,T);
view(0,90);
1 components found in 6.751600e-03 seconds.
1 components found in 7.270000e-04 seconds.
1 components found in 9.114000e-04 seconds.
1 components found in 7.124400e-03 seconds.
2 components found in 4.879000e-03 seconds.
duplicate_nmnfld_vertices request executed in 5.037680e-02 seconds. 5 clone vertices added.
6 boundaries detected in 7.163830e-02 seconds.
Mesh with 5120 vertices and 10115 triangles displayed in 9.344840e-02 seconds.

Example #5 : hole filling

[V,T] = remove_non_manifold_vertices(V,T);
boundaries = select_holes_and_boundary(V,T);
view(-180,-90);

max_perim_sz = 200;
T = fill_mesh_holes(V,T,boundaries,'closed',max_perim_sz);
plot_mesh(V,T);
view(-180,-90);
0 non manifold vertices removed in 7.336751e-01 seconds.
6 boundaries detected in 5.526300e-02 seconds.
Mesh with 5120 vertices and 10115 triangles displayed in 1.018476e-01 seconds.
6 hole(s) filled by adding 121 triangles in 4.209831e-01 seconds.
Mesh with 5120 vertices and 10236 triangles displayed in 7.726410e-02 seconds.

Example #6 : curvature

load('kitten.mat');

ngb_degre = 2;
N = compute_vertex_normals(V,T,ngb_degre,'raw');
curvature = compute_mesh_curvature(V,T,N,ngb_degre,'mean');
show_mesh_curvature(V,T,curvature);
view(0,90);
mean curvature computed in 6.471313e-01 seconds.

Example #7 : subselection

load('Gargoyle_3k.mat');

plot_mesh(V,T);
view(-90,0);

n = [0 1 0];
I = [0 -25 800];
[V_out,T_out] = submesh_selection(V,T,n,I); % Gargoyle top part

plot_mesh(V_out,T_out);
view(-90,0);
Mesh with 1429 vertices and 2836 triangles displayed in 7.448580e-02 seconds.
submesh with 729 vertices and 4221 triangles selected in 3.537560e-02 seconds.
Mesh with 726 vertices and 4221 triangles displayed in 6.693860e-02 seconds.

Example #8 : smoothing

plot_mesh(V,T), shading interp, camlight right;
view(0,90);

N = compute_vertex_normals(V,T,2);
nb_iterations = 1;
ngb_degre = 1;
V = mesh_smooth(V,T,nb_iterations,ngb_degre);

plot_mesh(V,T), shading interp, camlight right;
view(0,90);
Mesh with 1429 vertices and 2836 triangles displayed in 6.801540e-02 seconds.
Laplacian mesh smoothed in 5.547760e-02 seconds.
Mesh with 1429 vertices and 2836 triangles displayed in 1.069149e-01 seconds.

Example #9 : convex hull

nb_vtx = 128;
X = 2*(rand(nb_vtx,1)-0.5);
Y = 2*(rand(nb_vtx,1)-0.5);
Z = 2*(rand(nb_vtx,1)-0.5);

Rho = X.^2 + Y.^2 + Z.^2;
i = Rho <= 1;
X = X(i);
Y = Y(i);
Z = Z(i);
V = cat(2,X,Y,Z);

plot_point_set(V,'o','y',4);
axis equal;
view(3);

[V,Qh] = quick_hull(V);
plot_mesh(V,Qh);
axis equal;
view(3);
Mesh quick hull computed in 6.490910e-01s.
Mesh with 34 vertices and 64 triangles displayed in 7.013080e-02 seconds.