function pariomino_tiling_plot_test ( )

%*****************************************************************************80
%
%% pariomino_tiling_plot_test tests pariomino_tiling_plot.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 May 2020
%
%  Author:
%
%    John Burkardt
%
  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pariomino_tiling_plot_test:\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  pariomino_tiling_plot() plots tilings of a given\n' );
  fprintf ( 1, '  region R, using a set of pariominoes P.\n' );

  pariomino_tiling_plot_test01 ( );
  pariomino_tiling_plot_test02 ( );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pariomino_tiling_plot_test:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  return
end
function pariomino_tiling_plot_test01 ( )

%*****************************************************************************80
%
%% pariomino_tiling_plot_test01 sets up test example 1.
%
%  Discussion:
%
%    The region R consists of the following arrangement of square cells:
%
%      1 1 1 1
%      1 1 1 1
%
%    This region is to be tiled by 1 copy each of 3 pariominoes.
%
%    The shapes of the 3 pariominoes are
%
%      N = 1 
% 
%      O = 1 1 1
%
%      P = 0 0 1
%          1 1 1
%
%    For this problem, there are four solutions:
%
%      O O O P = x5 + x9 + x14
%      N P P P
%
%      P P P N = x4 + x12 + x15
%      P O O O
%
%      P O O O = x8 + x10 + x17
%      P P P N
%
%      N P P P = x1 + x11 + x20
%      O O O P
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 May 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pariomino_tiling_plot_test01\n' );
  fprintf ( 1, '  Given solutions for the 2x4 pariomino\n' );
  fprintf ( 1, '  tiling problem, plot corresponding tilings.\n' );
%
%  Define R.
%
  r_shape = [ ...
    +1, -1, +1, -1; ...
    -1, +1, -1, +1 ];

  [ m_r, n_r ] = size ( r_shape );
  pariomino_print ( r_shape, '  Region R:' );
%
%  Define N, O, P
%
  n_shape = [ ...
    -1 ];
  [ m_n, n_n ] = size ( n_shape );
  pariomino_print ( n_shape, '  pariomino N:' );

  o_shape = [ ...
    +1, -1, +1 ];
  [ m_o, n_o ] = size ( o_shape );
  pariomino_print ( o_shape, '  pariomino O:' );

  p_shape = [ ...
     0,  0, -1;
    +1, -1, +1 ];
  [ m_p, n_p ] = size ( p_shape );
  pariomino_print ( p_shape, '  pariomino P:' );
%
%  Pack the arrays into P.
%
  p_num = 3;
  p_shapes = zeros ( m_r, n_r, p_num );
  p_shapes(1:m_n,1:n_n,1) = n_shape(1:m_n,1:n_n);
  p_shapes(1:m_o,1:n_o,2) = o_shape(1:m_o,1:n_o);
  p_shapes(1:m_p,1:n_p,3) = p_shape(1:m_p,1:n_p);
%
%  D indicates how many times each pariomino is to be used.
%
  d = ones ( p_num, 1 );
%
%  Define the solutions X, obtained by pariomino_tiling_solver.
%
  x = [ ...
   0, 0; ...
   0, 1; ...
   1, 0; ...
   0, 0; ...
   1, 0; ...
   0, 1; ...
   1, 0; ...
   0, 1; ...
   0, 0; ...
   0, 0 ];
%
%  Plot the tilings corrresponding to each solution.
%
  filename = 'twobyfour01.png';
  label = '2x4 Pariomino Tiling';
  pariomino_tiling_plot ( r_shape, p_num, p_shapes, d, x, ...
    filename, label );

  return
end
function pariomino_tiling_plot_test02 ( )

%*****************************************************************************80
%
%% pariomino_tiling_plot_test02 sets up test example 2.
%
%  Discussion:
%
%    The region R consists of the following arrangement of square cells:
%
%      +1  0  0  0
%      -1  0  0  0
%      +1 -1 +1 -1
%      -1 +1 -1 +1
%
%    This region is to be tiled by 1 copy each of 3 pariominoes.
%
%    The shapes of the 3 pariominoes are
%
%      N =  0  0 -1
%          +1 -1 +1
% 
%      O = -1 +1 -1
%
%      P =  0 +1
%          +1 -1
%
%    For this problem, there is one solution:
%
%      N 0 0 0
%      N 0 0 0
%      N N P P
%      O O O P
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 May 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pariomino_tiling_plot_test02\n' );
  fprintf ( 1, '  Given 4 solutions for the 2x4 pariomino\n' );
  fprintf ( 1, '  tiling problem, plot corresponding tilings.\n' );
%
%  Define R.
%
  r_shape = [ ...
    +1,  0,  0,  0; ...
    -1,  0,  0,  0; ...
    +1, -1, +1, -1; ...
    -1, +1, -1, +1 ];

  [ m_r, n_r ] = size ( r_shape );
  pariomino_print ( r_shape, '  Region R:' );
%
%  Define N, O, P
%
  n_shape = [ ...
     0,  0, -1; ...
    +1, -1, +1 ];
  [ m_n, n_n ] = size ( n_shape );
  pariomino_print ( n_shape, '  pariomino N:' );

  o_shape = [ ...
    -1, +1, -1 ];
  [ m_o, n_o ] = size ( o_shape );
  pariomino_print ( o_shape, '  pariomino O:' );

  p_shape = [ ...
     0, +1;
    +1, -1 ];
  [ m_p, n_p ] = size ( p_shape );
  pariomino_print ( p_shape, '  pariomino P:' );
%
%  Pack the arrays into P.
%
  p_num = 3;
  p_shapes = zeros ( m_r, n_r, p_num );
  p_shapes(1:m_n,1:n_n,1) = n_shape(1:m_n,1:n_n);
  p_shapes(1:m_o,1:n_o,2) = o_shape(1:m_o,1:n_o);
  p_shapes(1:m_p,1:n_p,3) = p_shape(1:m_p,1:n_p);
%
%  D indicates how many times each pariomino is to be used.
%
  d = ones ( p_num, 1 );
%
%  Define the 1 solution X, obtained by pariomino_tiling_solver.
%
  x = [ ...
   0; ...
   0; ...
   1; ...
   0; ...
   0; ...
   0; ...
   0; ...
   1; ...
   0; ...
   0; ...
   0; ...
   1; ...
   0; ...
   0; ...
   0 ];
%
%  Plot the tiling corresponding to the solution.
%
  filename = 'fourbyfour01.png';
  label = '4x4 Pariomino Tiling';
  pariomino_tiling_plot ( r_shape, p_num, p_shapes, d, x, ...
    filename, label );

  return
end

