function totalArea = getFacesArea(mesh_in, ListFaces)

% to measure the area of a ROI given by a list of faces

%% === Original version commented by Yasser Alemán-Gómez (LIM, HGGM, Spain, 23/12/2016) ======== %

% % % % % totalArea = 0;
% % % % % 
% % % % % for iF = 1:size(ListFaces,1)
% % % % %     totalArea = totalArea + getFaceArea(mesh_in,ListFaces,iF);
% % % % % end


%% ==== Changes made by Yasser Alemán-Gómez (LIM, HGGM, Spain, 23/12/2016) ==== % 

d12 = sqrt(sum((mesh_in.vertices(ListFaces(:,1),:) - mesh_in.vertices(ListFaces(:,2),:)).^2,2));
d23 = sqrt(sum((mesh_in.vertices(ListFaces(:,2),:) - mesh_in.vertices(ListFaces(:,3),:)).^2,2));
d13 = sqrt(sum((mesh_in.vertices(ListFaces(:,1),:) - mesh_in.vertices(ListFaces(:,3),:)).^2,2));
per = (d12+d23+d13)/2;
Af = sqrt(per.*(per-d12).*(per-d23).*(per-d13));%  Area for each face in mm^2
totalArea = sum(Af); 
%% End of changes made by Yasser Alemán-Gómez (LIM, HGGM, Spain, 23/12/2016) % 