-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathv2s.m
37 lines (34 loc) · 1.11 KB
/
v2s.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
30
31
32
33
34
35
36
37
function [no, el, regions, holes] = v2s(img, isovalues, opt, method)
%
% [no,el,regions,holes]=v2s(img,isovalues,opt,method)
%
% surface mesh generation from binary or gray-scale volumetric images
% shortcut for vol2surf
%
% author: Qianqian Fang (q.fang at neu.edu)
%
% inputs and outputs are similar to those defined in vol2surf; In v2s,
% method can be set to 'cgalmesh' in addition to those allowed by vol2surf.
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%
if (nargin == 3)
method = 'cgalsurf';
end
if (strcmp(method, 'cgalmesh'))
[no, tet, el] = v2m(uint8(img), isovalues, opt, 1000, method);
regions = [];
fclist = unique(el(:, 4));
len = length(fclist);
for i = 1:len
pt = surfinterior(no(:, 1:3), el(find(el(:, 4) == fclist(i)), 1:3));
if (~isempty(pt))
regions = [regions; pt];
end
end
el = unique(el(:, 1:3), 'rows');
[no, el] = removeisolatednode(no(:, 1:3), el(:, 1:3));
holes = [];
return
end
[no, el, regions, holes] = vol2surf(img, 1:size(img, 1), 1:size(img, 2), 1:size(img, 3), opt, 1, method, isovalues);