%% Execute and manual analyse script: growth
close all
clear all

%% solve
executePbeCase('init')
executePbeCase('seededDissolution');

%% load
loadPbeResult('init')
[result pbeDefinition] = loadPbeResult('seededDissolution');

%% analyse
figure, hold on

hc1max = 0;hc2max = 0;

for iTime = 1:1:length(result)
    
    if isempty(result(iTime).hcMatrix)
        continue
    end
    
    plot(result(iTime).hcMatrix(1,1), ...
         result(iTime).hcMatrix(2,1), ...
          'm.', 'MarkerSize', 20)
    plot(result(iTime).hcMatrix(1,:), ...
          result(iTime).hcMatrix(2,:), ...
          'k.', 'MarkerSize', 1)
      
    hc1max = max(hc1max, result(iTime).hcMatrix(1,:));
    hc1max = max(hc1max);
    hc2max = max(hc2max, result(iTime).hcMatrix(2,:));
    hc2max = max(hc2max);
end

xlim([0 hc1max]*1.05)
ylim([0 hc2max]*1.05)

% plot validity cone
viewPolytope(pbeDefinition.dec.confinementCone, ...
    'infinityBoxSize', max(hc1max, hc2max), ...
    'shade', 0)
% plot inner cone
innerCone = pbeDefinition.dec.confinementCone;
pbeDefinition.optionStruct.distanceLimit
innerCone.h = innerCone.h - pbeDefinition.optionStruct.distanceLimit;
viewPolytope(innerCone, 'infinityBoxSize', max(hc1max, hc2max), ...
    'edgecolor', [1 0 0], 'shade', 0)