-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathboundary_extract.m
More file actions
46 lines (39 loc) · 1.21 KB
/
boundary_extract.m
File metadata and controls
46 lines (39 loc) · 1.21 KB
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
38
39
40
41
42
43
function boundary_faces = boundary_extract(objects)
global faces;
% Extract the boundary faces of a given set of faces
% Input:
% objects: 1 x F logical array of the target faces among all faces
% Output:
% boundary_faces: an array of indices that forms a closed boundary ring
object_faces = find(objects == 1);
object_face_rings = compute_face_ring(faces(:, object_faces)); % compute face ring on the subset object faces
boundary_face = zeros(length(object_faces), 1);
for f = 1 : length(object_faces)
if length(object_face_rings{f}) < 3
boundary_face(f) = 1;
end
end
boundary_faces = object_faces(boundary_face == 1);
% old
% DFS to reach the edge face
% s = CStack();
% starter = randi(size(object_faces, 2)); % random start
% visited = zeros(size(object_faces, 2), 1);
% s.push(starter); visited(starter) = 1;
% found = 0;
% while true
% curr = s.pop();
% neighbors = object_face_rings{curr};
% if length(neighbors) < 3
% found = curr;
% break;
% end
% for f = 1 : length(neighbors)
% if visited(neighbors(f)) == 0
% visited(neighbors(f)) = 1;
% s.push(neighbors(f));
% end
% end
% end
% edge_face_idx = object_face_idx(found)
end