function polyomino_multihedral_tiling_plot_test ( )

%*****************************************************************************80
%
%% polyomino_multihedral_tiling_plot_test tests POLYOMINO_MULTIHEDRAL_TILING_PLOT.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 June 2018
%
%  Author:
%
%    John Burkardt
%
  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'polyomino_multihedral_tiling_plot_test:\n' );
  fprintf ( 1, '  POLYOMINO_MULTIHEDRAL_TILING_PLOT plots\n' );
  fprintf ( 1, '  tilings of a given region R, using\n' );
  fprintf ( 1, '  copies of a set of polyominoes P.\n' );

  polyomino_multihedral_tiling_plot_test01 ( );
  polyomino_multihedral_tiling_plot_test02 ( );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'polyomino_multihedral_tiling_plot_test:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  return
end
function polyomino_multihedral_tiling_plot_test01 ( )

%*****************************************************************************80
%
%% POLYOMINO_MULTIHEDRAL_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 polyominoes.
%
%    The shapes of the 3 polyominoes 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:
%
%    07 June 2018
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'POLYOMINO_MULTIHEDRAL_TILING_PLOT_TEST01\n' );
  fprintf ( 1, '  Given 4 solutions for the 2x4 multihedral polyomino\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 );
%
%  Define N, O, P
%
  n_shape = [ ...
    1 ];
  [ m_n, n_n ] = size ( n_shape );

  o_shape = [ ...
    1, 1, 1 ];
  [ m_o, n_o ] = size ( o_shape );

  p_shape = [ ...
    0, 0, 1;
    1, 1, 1 ];
  [ m_p, n_p ] = size ( p_shape );
%
%  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 polyomino is to be used.
%
  d = ones ( p_num, 1 );
%
%  Define the 4 solutions X, obtained by POLYOMINO_MULTIHEDRAL.
%
  x = [ ...
   0, 0, 0, 1;
   0, 0, 0, 0;
   0, 0, 0, 0;
   0, 1, 0, 0;
   1, 0, 0, 0;
   0, 0, 0, 0;
   0, 0, 0, 0;
   0, 0, 1, 0;
   1, 0, 0, 0;
   0, 0, 1, 0;
   0, 0, 0, 1;
   0, 1, 0, 0;
   0, 0, 0, 0;
   1, 0, 0, 0;
   0, 1, 0, 0;
   0, 0, 0, 0;
   0, 0, 1, 0;
   0, 0, 0, 0;
   0, 0, 0, 0;
   0, 0, 0, 1 ];
%
%  Plot the tilings corrresponding to each solution.
%
  filename = 'twobyfour01.png';
  label = '2x4 Multihedral Tiling';
  polyomino_multihedral_tiling_plot_old ( r_shape, p_num, p_shapes, d, x, ...
    filename, label );

  return
end
function polyomino_multihedral_tiling_plot_test02 ( )

%*****************************************************************************80
%
%% POLYOMINO_MULTIHEDRAL_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 polyominoes.
%
%    The shapes of the 3 polyominoes 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 = x5 + x14 + x23
%      N 0 0 0
%      N N P P
%      O O O P
%
%    where x5, x14, and x23 are variables representing particular reflected, 
%    rotated, and translated copies of the original polyominoes.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 June 2018
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'POLYOMINO_MULTIHEDRAL_TILING_PLOT_TEST02\n' );
  fprintf ( 1, '  Given 4 solutions for the 2x4 multihedral polyomino\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 );
  polyomino_print ( m_r, n_r, r_shape, '  Region R:' );
%
%  Define N, O, P
%
  n_shape = [ ...
    0, 0, 1; ...
    1, 1, 1 ];
  [ m_n, n_n ] = size ( n_shape );
  polyomino_print ( m_n, n_n, n_shape, '  Polyomino N:' );

  o_shape = [ ...
    1, 1, 1 ];
  [ m_o, n_o ] = size ( o_shape );
  polyomino_print ( m_o, n_o, o_shape, '  Polyomino O:' );

  p_shape = [ ...
    0, 1;
    1, 1 ];
  [ m_p, n_p ] = size ( p_shape );
  polyomino_print ( m_p, n_p, p_shape, '  Polyomino 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 polyomino is to be used.
%
  d = ones ( p_num, 1 );
%
%  Define the 1 solutions X, obtained by POLYOMINO_MULTIHEDRAL.
%
  x = [ ...
   0; ...
   0; ...
   0; ...
   0; ...
   1; ...
   0; ...
   0; ...
   0; ...
   0; ...
   0; ...
   0; ...
   0; ...
   0; ...
   1; ...
   0; ...
   0; ...
   0; ...
   0; ...
   0; ...
   0; ...
   0; ...
   0; ...
   1; ...
   0; ...
   0; ...
   0; ...
   0; ...
   0; ...
   0; ...
   0 ];
%
%  Print the tiling corresponding to the solution.
%
  filename = 'fourbyfour01.png';
  label = '4x4 Multihedral Tiling';
  polyomino_multihedral_tiling_plot_old ( r_shape, p_num, p_shapes, d, x, ...
    filename, label );

  return
end

