function dec = addMinkowskiPartitionData(dec, partitionData, zerotol)
% add acucmulated data to decomposition structure
%
% the data was generated by generateMinkowskiPartition during
%   decomposeCone.
%
% THIS IS NO USER FUNCTION

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

%% initialize additional data
dec.simplexPartition = cell(0);
dec.unifiedPartition = cell(0);
dec.simplexToUnifiedVector = [];
dec.seIncidenceMatrix = eye(dec.nS, dec.nS);

for iPart = 1:length(partitionData)
    % eliminate summands, which are existing SE's
    [thisSeMatrix decomposedSeIndexVector] = ...
        eliminateRows(partitionData(iPart).seMatrix, ...
                      dec.seScaledToClose, zerotol);
                  
	% store new SE's
    for iS = 1:size(thisSeMatrix, 1)
        dec.nS = dec.nS + 1;
        dec.seScaledToClose = [dec.seScaledToClose; ...
                               thisSeMatrix(iS,:)];
        dec.se = [dec.se; ...
                  scaleToReal(thisSeMatrix(iS, :), dec, zerotol)];
        decomposedSeIndexVector(end+1) = dec.nS;
        % structuring element can be added with itself without creating new
        %   facets
        dec.seIncidenceMatrix(dec.nS, dec.nS) = 1;
    end
                  
                  
    % save partition
    dec = appendUnifiedPartition(dec, decomposedSeIndexVector, zerotol, 1, 1);
end

dec.nPU = length(dec.unifiedPartition);
dec.nPS = length(dec.simplexPartition);