%% Generate and evaluate test data: potash alum
% This file generates and evaluates (manually) the data for potash alum.
%   The data is stored for subsequent automatic testing.

clc
close all
clear all

cdef = obtainCrystal('generic_potash_alum', 3);
%viewCrystal(cdef)

dec = obtainDec(cdef.A, 'mapping', cdef.groupMappingMatrix);

validateDec(dec)

%% Show structuring elements
% for iS = 1:size(dec.seScaledToClose, 1)
%     figure(2)
%     hrep = struct('A', dec.A, 'h', ...
%         dec.mappingReducedToFull * dec.seScaledToClose(iS, :)');
%     hrep.A
%     hrep.h
%     viewPolytope(hrep);
%     pause;
%     close 2;
% end

%% Cone
% figure,hold on
% viewPolytope(dec.validityCone, 'color', [0.6 0 0])
% % figure,hold on
% for iPU = 1:length(dec.unifiedPartition)
%     viewPolytope(dec.unifiedPartition{iPU}, 'color', [0 0.7 0], 'shade', 0.3)
% end

%% Add measures
% The total number of measures is 6 without parameters. Together with 2
%   partitions, there should result 12 lines in 
% some random directions
dirMatrix = [1         0         0     ; ...
             1         1         0     ; ...
             1         1         1     ; ...
             0.3023    0.1863    0.5388; ...
             0.1468    0.3456    0.4192; ...
             0.0923    0.3968    0.6852];
dec = addMeasureDataDec(dec, 'volume');
dec = addMeasureDataDec(dec, 'surface');
dec = addMeasureDataDec(dec, 'projection', dirMatrix);
dec = addMeasureDataDec(dec, 'facet', [1 0 0; 1 1 0; 1 1 1]);
dec = addMeasureDataDec(dec, 'feret', dirMatrix);
dec = addMeasureDataDec(dec, 'support', dirMatrix);

validateMeasureReference = validateMeasureDataDec(dec)

decReference = dec;
save dataCasePotash decReference