function hrep = obtainFacetValidityCone(dec, iFacet)
% obtain facet validity cone from decomposition
%
% Syntax: hrep = obtainFacetValidityCone(dec, iFacet)
%
% obtainFacetValidityCone returns the facet validity cone for the given
%   facet index as a H-representation. Use iFacet = 0 oder (nH+1) to obtain
%   the cone for non-empty polytopes.
%
% See also: obtainDec, obtainCrystalDec

% The elk-library: convex geometry applied to crystallization modeling.
%   Copyright (C) 2013 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/>.

if ~exist('iFacet', 'var') || isempty(iFacet) || iFacet == 0
    iFacet = dec.nH + 1;
end

% index vector of constraints belonging to that facet
constraintIdxVector = dec.facetValidityData.responsibleMatrix(...
    dec.facetValidityData.responsibleMatrix(:, 2) == iFacet, 1);
hrep.A = dec.facetValidityData.A(constraintIdxVector, :);
hrep.h = constraintIdxVector(:)*0;