function [V] = defomesh2(V, F)
% for all vertices i in V
for i =1:length(V)
P = i
% find corresponding triangles that contain vertex i in F
N = F(find(P))
% pick one triangle
ind = randi(1,size(N))
T = N(ind)
% extract unique neighbor vertices from N
NV = []
%Scan through V to find unique neighbors of V(i)
for j = 1:length(V)
NV = unique(F(any(F==j,2),:));
%neighbors with node i, including node i
%----removed node i ------------
-
NV=NV(NV~=j);
end
%Modification of Vertex Coordinate Region
% extract vertex coordinates
A = V(T(1))
B = V(T(2))
C = V(T(3))
% TODO: add check for -1 and sort points,
such that A is i
% A_0=find(TR_N(:,1) ==-1 & TR_N(:,2)
==-1 & TR_N(:,3) ==-1) % Rows with only -1 entries
%
% tmp_index = -1; % -1 entries in rows
%
%
% if TR_N==tmp_index
% TR_N(TR_N == tmp_index) =
F(TR_N == tmp_index)
% elseif TR_N == A_0
% TR_N(TR_N == A_0) =
F(TR_N == A_0)
% end
%
% calculate planes
P_1 = (C - A)/2
P1_length = sqrt(sum(P_1.*P_1))
P_2 = (B - A)/2
P2_length = sqrt(sum(P_2.*P_2))
% move A and replace vertex i in V with it
end
end
% replace vertex i in the original list
V(i,:) = P
V_New = V
end