% %% Boundary Triangles % function t=BoundaryTriangles(tetr) % %given a set of tetraedrons returns the boundary triangles % % t = [tetr(:,[1,2,3]); tetr(:,[2,3,4]); tetr(:,[1,3,4]);tetr(:,[1,2,4])];%triangles not unique % clear tetr; % % nt=size(t,1); % % t=sort(t,2); % t=sortrows(t); % %gets lonely and boundary triangles % lonely=false(nt,1); % lonely(2:end-1)=any( (t(2:nt-1,:)~=t(3:end,:)),2) & any((t(2:nt-1,:)~=t(1:end-2,:)),2); % % %first and last are special % lonely(1)=lonely(2); % lonely(nt)=lonely(nt-1); % % %pick boundary triangles % %not all them will rally be bounary since slivers will fake results % t=t(lonely,:); % % % end %% Boundary Triangles function t=BoundaryTriangles(tetr) %given a set of tetraedrons returns the boundary triangles t = [tetr(:,[1,2,3]); tetr(:,[2,3,4]); tetr(:,[1,3,4]);tetr(:,[1,2,4])];%triangles not unique clear tetr; nt=size(t,1); t=double(t); somma=sum(t,2); somma=somma.*(t(:,1).*t(:,2).*t(:,3)); [somma,index]=sort(somma); %gets lonely and boundary triangles lonely=false(nt,1); lonely(2:end-1)=somma(2:nt-1,:)~=somma(3:end); %first and last are special lonely(1)=lonely(2); lonely(nt)=lonely(nt-1); % lonely(index)=lonely; t=t(index,:); %pick boundary triangles %not all them will rally be bounary since slivers will fake results t=t(lonely,:); end