# Subdivision Surfaces¶


Subdvision methods progressively refine a discrete mesh and converge to a smooth surface. This allows to perform an interpolation or approximation of a given coarse dataset.

In [2]:

## Subdivision of a Regular Polyedra¶

Starting from a control mesh which is a regular polyhedra, one can construct a sequence of mesh that converge to a sphere by subdividing each edge into two edges, and each triangle into four smaller triangles. The position of the mid points are projected onto the sphere.

Compute two examples of initial base mesh.

In [3]:
[vertex1,face1] = compute_base_mesh('oct');
[vertex0,face0] = compute_base_mesh('ico');

Display it.

In [4]:
clf;
subplot(1,2,1);
plot_mesh(vertex1,face1);
subplot(1,2,2);
plot_mesh(vertex0,face0);

Initialize the subdivision.

In [5]:
face = face0;
vertex = vertex0;

Compute the set of edges.

In [6]:
edge = compute_edges(face);

Number of vertex and edges.

In [7]:
n = size(vertex,2);
ne = size(edge,2);

Compute the number of the three edges associated to each face.

In [8]:
A = sparse([edge(1,:);edge(2,:)],[edge(2,:);edge(1,:)],[n+(1:ne);n+(1:ne)],n,n);
v12 = full( A( face(1,:) + (face(2,:)-1)*n ) );
v23 = full( A( face(2,:) + (face(3,:)-1)*n ) );
v31 = full( A( face(3,:) + (face(1,:)-1)*n ) );

Compute the new faces, each old face generates 4 faces.

In [9]:
face = [  cat(1,face(1,:),v12,v31),...
cat(1,face(2,:),v23,v12),...
cat(1,face(3,:),v31,v23),...
cat(1,v12,v23,v31)   ];

Add new vertices at the edges center.

In [10]:
vertex = [vertex, (vertex(:,edge(1,:))+vertex(:,edge(2,:)))/2 ];

Project the points on the sphere.

In [11]:
d = sqrt( sum(vertex.^2,1) );
vertex = vertex ./ repmat( d, [size(vertex,1) 1]);

Display before/after subdivision.

In [12]:
clf;
subplot(1,2,1);
plot_mesh(vertex0,face0);
subplot(1,2,2);
plot_mesh(vertex,face);

Exercise 1

Perform the full subdivision.

In [13]:
exo1()
In [14]:

Exercise 2

Try with other control meshes.

In [15]:
exo2()
In [16]:

## Triangulated Mesh Subdivision¶

The same method can be applied to an arbitrary control mesh, but without the projection on the sphere. More clever interpolations should be used to avoid having a simple piecewise linear surface.

In [17]:
name = 'mannequin';

Display it.

In [18]:
options.name = name;
clf;
plot_mesh(vertex0,face0,options);

Initialize.

In [19]:
face = face0;
vertex = vertex0;

Perform the subdivision.

In [20]:
edge = compute_edges(face);
n = size(vertex,2);
ne = size(edge,2);

Compute the number of the three edges associated to each face.

In [21]:
A = sparse([edge(1,:);edge(2,:)],[edge(2,:);edge(1,:)],[n+(1:ne);n+(1:ne)],n,n);
v12 = full( A( face(1,:) + (face(2,:)-1)*n ) );
v23 = full( A( face(2,:) + (face(3,:)-1)*n ) );
v31 = full( A( face(3,:) + (face(1,:)-1)*n ) );

Compute the new faces, each old face generates 4 faces.

In [22]:
face_old = face;
face = [  cat(1,face(1,:),v12,v31),...
cat(1,face(2,:),v23,v12),...
cat(1,face(3,:),v31,v23),...
cat(1,v12,v23,v31)   ];

Compute the vertex and face ring.

In [23]:
global vring e2f fring facej;
vring = compute_vertex_ring(face);
e2f = compute_edge_face_ring(face_old);
fring = compute_face_ring(face_old);
facej = face_old;

Compute the interpolated position using

In [24]:
for k=n+1:n+ne
[e,v,g] = compute_butterfly_neighbors(k, n);
vertex(:,k) = 1/2*sum(vertex(:,e),2) + 1/8*sum(vertex(:,v),2) - 1/16*sum(vertex(:,g),2);
end

Display before/after subdivision.

In [25]:
clf;
subplot(1,2,1);
plot_mesh(vertex0,face0,options);