REMOVEDUPLICATEFACES Remove duplicate faces in a face array. [V, F] = removeDuplicateFaces(V, F) Example faces = [1 2 3;2 3 4;3 4 5;2 3 4]; removeDuplicateFaces(faces) ans = 1 2 3 2 3 4 2 3 5 See also
0001 function faces2 = removeDuplicateFaces(faces, varargin) 0002 %REMOVEDUPLICATEFACES Remove duplicate faces in a face array. 0003 % 0004 % [V, F] = removeDuplicateFaces(V, F) 0005 % 0006 % Example 0007 % faces = [1 2 3;2 3 4;3 4 5;2 3 4]; 0008 % removeDuplicateFaces(faces) 0009 % ans = 0010 % 1 2 3 0011 % 2 3 4 0012 % 2 3 5 0013 % 0014 % See also 0015 % 0016 0017 % ------ 0018 % Author: David Legland 0019 % e-mail: david.legland@inra.fr 0020 % Created: 2019-01-08, using Matlab 8.6.0.267246 (R2015b) 0021 % Copyright 2019 INRA - Cepia Software Platform. 0022 0023 nFaces = size(faces, 1); 0024 0025 removeFlag = false(nFaces, 1); 0026 for iFace = 1:nFaces 0027 if removeFlag(iFace) 0028 continue; 0029 end 0030 0031 face = faces(iFace, :); 0032 0033 inds = find(sum(ismember(faces, face), 2) == 3); 0034 inds(inds <= iFace) = []; 0035 0036 if ~isempty(inds) 0037 removeFlag(inds) = true; 0038 end 0039 end 0040 0041 faces2 = faces(~removeFlag, :);