-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw_mesh.m
33 lines (30 loc) · 1.39 KB
/
draw_mesh.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
% Code implementing the paper "Injective and Bounded Mappings in 3D".
% Disclaimer: The code is provided as-is and without any guarantees. Please contact the author to report any bugs.
% Written by Noam Aigerman, https://www.wisdom.weizmann.ac.il/~noamaig/
function draw_mesh( XX,tri,distortion,hadflip,anchor_coords,static_anchors ,OPTIONS)
%draw the mesh with distortion and flips highlighted and anchors marked
if OPTIONS.PROBLEM.TD==OPTIONS.PROBLEM.SD&& OPTIONS.PROBLEM.SD==3
[tris,inds]=boundary_faces(tri,hadflip);
else
tris=tri;
inds=1:length(distortion);
end
c=distortion(inds,:);
if ~isempty(tri)
if OPTIONS.PROBLEM.TD==3
FV={};
FV.faces=tris;
FV.vertices=XX;
%VN=patchnormals(FV);
trimesh(tris(hadflip(inds)==0,:),XX(:,1), XX(:,2), XX(:,3),'EdgeColor','k','FaceColor','flat','FaceVertexCData',c(hadflip(inds)==0),'CDataMapping','scaled','FaceLighting','flat','BackFaceLighting','lit');%,'VertexNormals',VN);
hold on
trimesh(tris(hadflip(inds)==1,:),XX(:,1), XX(:,2), XX(:,3),'EdgeColor','k','FaceColor','yellow');
else
end
end
if ~isempty(anchor_coords)
scatter3(anchor_coords(static_anchors,1),anchor_coords(static_anchors,2),anchor_coords(static_anchors,3),50,'blue','filled');
scatter3(anchor_coords(~static_anchors,1),anchor_coords(~static_anchors,2),anchor_coords(~static_anchors,3),50,'green','filled');
end
hold off;
end