function patch2tri_test

%patch2tri_test  tests for patch2tri
%
%See also: patch2tri, http://oss.deltares.nl/web/delft3d/d-flow-flexible-mesh/-/message_boards/view_message/220151

%%
close
cor.x = [0 2 3.5 4.5 5.5 6.5 5.5 4.5 3.5 2 0 0];
cor.y = [1 1 1   2   2   3   4   4   3   3 5 3];
map   = [10  11  12  0  0  0;  % 3-angle
         01  02  10 12  0  0;  % 4-angle
         02  03  04 09 10  0;  % 5-angle
         04  05  06 07 08 09]; % 6-angle
cen.x = [0.5 1 3 5];
cen.y = [3.5 2 2 3];
cen.z = [1   2 3 4];

[tri3,map3,ntyp]=patch2tri(cor.x,cor.y,map);

% tri3 =[ 10 11 12
%          1  2 10
%          1 10 12
%         10  2  3
%         10  3  9
%          3  4  9
%          9  4  8
%          4  5  8
%          8  5  7
%          5  6  7]
% map3 = [1 2 2 3 3 3 4 4 4 4];
% ntyp = [0 0 1 1 1 1];

h = trisurfcorcen(tri3,cor.x,cor.y,map3);
colormap(repmat([.2 .4 .6 .8],[3 1])')
view(0,90);axis equal
text(cen.x,cen.y,{'3','4','5','6'});
print2screensizeoverwrite([mfilename,'1'])
close

%%
cor.x = [0 1 2;0 1 2;0 1 2];
cor.y = [0 0 0;1 1 1;2 2 2];
cor.z = [0 2 3;5 4 4;5 6 7];

cen.x = corner2center(cor.x);
cen.y = corner2center(cor.y);
cen.z = corner2center(cor.z);

%tri = delaunay(cor.x,cor.y);
[quad,bi] = quat2net(cor.x,cor.y);
[tri3,map3,ntyp]=patch2tri(cor.x,cor.y,quad);

clf
subplot(2,4,1)
h = surfcorcen(cor.x,cor.y,cor.z,cor.z,[0 0 0]);
patch2tri_test_layout('surf(zcor,ccor)',h)

subplot(2,4,2)
h = surfcorcen(cor.x,cor.y,cor.z,cen.z,[0 0 0]);
patch2tri_test_layout('surf(zcor,ccen)',h)

subplot(2,4,5)
h = trisurfcorcen(tri3,cor.x,cor.y,cor.z,cor.z);
patch2tri_test_layout('trisurf(zcor,ccor)',h)

subplot(2,4,6)
h = trisurfcorcen(tri3,cor.x,cor.y,cor.z,cen.z(map3));
patch2tri_test_layout('trisurf(zcor,ccen)',h)

subplot(2,4,7)
h = trisurfcorcen(tri3,cor.x,cor.y,cen.z(map3),cen.z(map3));
patch2tri_test_layout('trisurf(zcen,ccen)',h)

subplot(2,4,8)
h = trisurfcorcen(tri3,cor.x,cor.y,cen.z(map3),cor.z);
patch2tri_test_layout('trisurf(zcen,ccor)',h)

print2screensizeoverwrite([mfilename,'2'])

close

function patch2tri_test_layout(arg,h)
daspect([1 1 3])
axis([0 2 0 2 0 6])
view(45,45)
title(arg)
grid on

set(h,'linewidth',2)
