function info = identifyPolytopeList(input)
% returns basic information on the list of polytopes
%
% THIS FUNCTION IS PUBLISHED BUT TESTED AND MAINTAINED ONLY IN SCOPE 
%   OF APPLICATIONS (decomposition case study; technical reports)
%
% Syntax: info = identifyiPolytopeList(input)
%
% Where info is a structure containing:
%   info.nPoly - number of polytopes in list
%   info.dim - dimension of the polytopes
%   info.rep - the representation of the input (equal for all elements)
%   info.m   - vector of number of facets/vertices
%
% The representation and the dimension must be consistent throughout the
%   given list.
%
% see also: identifyPolytope, triangulatePolytope, subtractPolytope

% The elk-library: convex geometry applied to crystallization modeling.
%   Copyright (C) 2012 Alexander Reinhold
%
% This program is free software: you can redistribute it and/or modify it 
%   under the terms of the GNU General Public License as published by the 
%   Free Software Foundation, either version 3 of the License, or (at your 
%   option) any later version.
%
% This program is distributed in the hope that it will be useful, but 
%   WITHOUT ANY WARRANTY; without even the implied warranty of 
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
%   General Public License for more details.
%
% You should have received a copy of the GNU General Public License along 
%   with this program.  If not, see <http://www.gnu.org/licenses/>.

%% Input handling
if ~iscell(input)
    error('elk:polytope:wrongInput', ...
        'Input must be a list (cell array) of either hrep or vrep');
end

%% Init
info.nPoly = length(input);
info.dim   = getfield(identifyPolytope(input{1}), 'dim');
info.m     = nan(1,info.nPoly);
info.rep   = getfield(identifyPolytope(input{1}), 'rep');

for iElement = 1:length(input)
    thisInfo = identifyPolytope(input{iElement});
    info.m(iElement) = thisInfo.m;
    
    if thisInfo.dim ~= info.dim
        error('polytope:elk:wrongInput', ...
          'dimensions of the polytopes in the list are not equal');
    end
    
    if ~strcmpi(thisInfo.rep, info.rep)
        error('polytope:elk:wrongInput', ...
          'representations of the polytopes in the list not equal');
    end
end

info.rep = [info.rep 'List'];