-
Notifications
You must be signed in to change notification settings - Fork 0
/
stlSlimVerts.m
29 lines (27 loc) · 906 Bytes
/
stlSlimVerts.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function [vnew, fnew]= stlSlimVerts(v, f)
% PATCHSLIM removes duplicate vertices in surface meshes.
%
% This function finds and removes duplicate vertices.
%
% USAGE: [v, f]=patchslim(v, f)
%
% Where v is the vertex list and f is the face list specifying vertex
% connectivity.
%
% v contains the vertices for all triangles [3*n x 3].
% f contains the vertex lists defining each triangle face [n x 3].
%
% This will reduce the size of typical v matrix by about a factor of 6.
%
% For more information see:
% http://www.esmonde-white.com/home/diversions/matlab-program-for-loading-stl-files
%
% Francis Esmonde-White, May 2010
if ~exist('v','var')
error('The vertex list (v) must be specified.');
end
if ~exist('f','var')
error('The vertex connectivity of the triangle faces (f) must be specified.');
end
[vnew, indexm, indexn] = unique(v, 'rows');
fnew = indexn(f);