-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimplifyMeshTri.m
More file actions
28 lines (21 loc) · 1.03 KB
/
simplifyMeshTri.m
File metadata and controls
28 lines (21 loc) · 1.03 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
function [newFaces,newVertices] = simplifyMeshTri(newFaces,newVertices,threshold)
%Compute pair sets separated by vertices
pairSet = computePairs(newVertices,newFaces,threshold);
triadSet = computeTriads(newVertices,newFaces,threshold,pairSet);
%Compute Q for all Vertices
Q = zeros(4,4,length(newVertices));
parfor index = 1:length(newVertices)
Q(:,:,index) = computeQ(index,newFaces,newVertices);
end
sortingList = zeros(size(triadSet,1),7);
%compute error for each triad
parfor sIndex = 1:length(triadSet)
currentTriads = triadSet(sIndex,:);
if ~isempty(currentTriads)
[error,vBar] = computeErrorTri(Q,newVertices,currentTriads(1),currentTriads(2),currentTriads(3));
sortingList(sIndex,:) = horzcat(currentTriads,error,vBar);
end
end
sortingList = sortrows(sortingList,4);
[newFaces,newVertices] = updateValuesTri(newFaces,newVertices,sortingList(1,5:7),sortingList(1,1),sortingList(1,2),sortingList(1,3));
end