function triangulation_node = triangulation_ijk_to_node ( triangulation_ijk )

%*****************************************************************************80
%
%% triangulation_ijk_to_node() returns the indices of triangle vertices.
%
%  Discussion:
%
%    We need to assign a unique scalar index P to a node indexed (I,J).  
%    Letting M be the largest value of I that we have recorded, we set
%    P = I + 1 + ( M + 1 ) * J, so node (0,0) -> 1, (1,0) -> 2, 
%    (M,0) -> M+1, (0,1) -> M+2, ...
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 August 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer TRIANGULATION_IJK(TRIANGLE_NUM,3), the parallelogram triangle
%    indices of each triangle in the triangulation.
%
%  Output:
%
%    integer TRIANGULATION_NODE(TRIANGLE_NUM,3), the parallelogram node
%    indices of each vertex of each triangle in the triangulation.
%
  m = max ( triangulation_ijk(:,1) );

  triangle_num = size ( triangulation_ijk, 1 );

  triangle_node = zeros ( triangle_num, 3 );
  for t = 1 : triangle_num
    ti = triangulation_ijk(t,1);
    tj = triangulation_ijk(t,2);
    tk = triangulation_ijk(t,3);
    if ( tk == 0 )
      vi(1) = ti - 1;
      vj(1) = tj - 1;
      vi(2) = ti;
      vj(2) = tj - 1;
      vi(3) = ti - 1;
      vj(3) = tj;
    elseif ( tk == 1 )
      vi(1) = ti;
      vj(1) = tj;
      vi(2) = ti - 1;
      vj(2) = tj;
      vi(3) = ti;
      vj(3) = tj - 1;
    end
    triangulation_node(t,1:3) = vi(1:3) + 1 + ( m + 1 ) * vj(1:3);
  end

  return
end

