%% This example file uses the Toolbox of Gabriel Peyre "Toolbox_Graph" to 
%% read the mesh files. It is possible to use any other "ply" reading function.

[hole_vertex hole_faces] = read_mesh('holes\hole_1f2_wHF_15f2_H1.ply');
[patch_vertex patch_faces] = read_mesh('patches\patch_1f2_wHF_15f2_H1.ply');


load('metadata\1f2_wHF_15f2_H1.mat')
figure
subplot(1,2,1),grid on,hold on
for j=1:size(patch_faces,1)
    patch(patch_vertex(patch_faces(j,:),1),patch_vertex(patch_faces(j,:),2),patch_vertex(patch_faces(j,:),3),'g','FaceAlpha',0.1)
end
for i=1:size( metaData.groundTruth.triangs_to_remove,2)
    patch(patch_vertex(metaData.groundTruth.triangs_to_remove(:,i),1),patch_vertex(metaData.groundTruth.triangs_to_remove(:,i),2),patch_vertex(metaData.groundTruth.triangs_to_remove(:,i),3),'r','FaceAlpha',0.3)
end
for k=1:size(metaData.hole.added_triangs,2)
    patch(hole_vertex(metaData.hole.added_triangs(:,k),1),hole_vertex(metaData.hole.added_triangs(:,k),2),hole_vertex(metaData.hole.added_triangs(:,k),3),'y')
end
title('Ground Truth Mesh. Red: Triangles to remove; Yellow: Added triangles')

subplot(1,2,2),grid on,hold on
for i=1:size(hole_faces,1)
    patch(hole_vertex(hole_faces(i,:),1),hole_vertex(hole_faces(i,:),2),hole_vertex(hole_faces(i,:),3),'b','FaceAlpha',0.3)
end
title('Hole mesh')