function info = identifyPolytope(input)
% returns basic information on the geometric object
%
% Syntax: info = identifyiPolytope(input)
%
% Where info is a structure containing:
%   info.dim - dimension of polytope
%   info.rep - the representation of the input
%   info.m   - dependent on representation: number of vertices or number of
%              facets.
%
% The possible representations are:
%   Hrep: H-representation. The variable is a struct with two fields. An m 
%         by n matrix A containing the facet normals and an m by 1 vector h
%         containing the corresponding facet distances.
%   Vrep: V-representation. The variable is a struct with one field. An m
%         by n matrix containing the vertices for which the convex hull
%         represents the polytope.
%
% see also: obtainPolytope

% 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/>.

%% Some list
if iscell(input)
    info = identifyPolytopeList(input);
%% H-representation
elseif isstruct(input) && isfield(input, 'A') && isfield(input, 'h') && ...
        ismatrix(input.A) && isvector(input.h)
    info.rep = 'Hrep';
    info.dim = size(input.A, 2);
    info.m   = size(input.A, 1);
    %% Consistency checks
    assert(size(input.h, 2) == 1, 'elk:polytope:wrongType', ...
        'The vector of facet distances should be a column vector');
    assert(size(input.h, 1) == size(input.A, 1), 'elk:polytope:wrongType', ...
        'matrix of facet normals does not match the vector of facet distances')
%% V-representation
elseif isstruct(input) && isfield(input, 'V') && ...
        ismatrix(input.V) && isnumeric(input.V) 
    info.rep = 'Vrep';
    info.dim = size(input.V, 2);
    info.m   = size(input.V, 1);
%% No supportet representation
else
    error('elk:polytope:wrongType', ...
        'check the geometric representation of the input');
end
