From 8697179803d11155e4ab561d399453d7b8f71fa0 Mon Sep 17 00:00:00 2001
From: Nicola Vigano <vigano@yoda.esrf.fr>
Date: Thu, 12 May 2016 15:26:01 +0200
Subject: [PATCH] 6D-reconstruction: share some setup code

Signed-off-by: Nicola Vigano <vigano@yoda.esrf.fr>
---
 .../Gt6DReconstructionAlgorithmFactory.m      | 38 +++++++------------
 1 file changed, 13 insertions(+), 25 deletions(-)

diff --git a/zUtil_Deformation/Gt6DReconstructionAlgorithmFactory.m b/zUtil_Deformation/Gt6DReconstructionAlgorithmFactory.m
index 5b13cffc..b5550482 100644
--- a/zUtil_Deformation/Gt6DReconstructionAlgorithmFactory.m
+++ b/zUtil_Deformation/Gt6DReconstructionAlgorithmFactory.m
@@ -42,14 +42,7 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
         function [algo, good_orients, blobs] = getGrainReconstructionAlgo(self, sampler, num_interp, varargin)
             % Build Empty volumes
             ref_gr = sampler.get_reference_grain();
-            proj = ref_gr.proj(self.det_index);
-
-            spacing = mean([proj.vol_size_y, proj.vol_size_x, proj.vol_size_z]) * (self.rspace_oversize - 1);
-            volume_size = ceil([proj.vol_size_y, proj.vol_size_x, proj.vol_size_z] + spacing);
-
-            if (self.volume_downscaling > 1)
-                volume_size = ceil(volume_size / self.volume_downscaling);
-            end
+            volume_size = self.get_volume_size(ref_gr);
 
             switch (lower(self.shape_functions_type))
                 case 'none'
@@ -93,14 +86,7 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
 
             % Build Empty volumes
             ref_gr = sampler(1).get_reference_grain();
-            proj = ref_gr.proj(self.det_index);
-
-            spacing = mean([proj.vol_size_y, proj.vol_size_x, proj.vol_size_z]) * (self.rspace_oversize - 1);
-            volume_size = ceil([proj.vol_size_y, proj.vol_size_x, proj.vol_size_z] + spacing);
-
-            if (self.volume_downscaling > 1)
-                volume_size = ceil(volume_size / self.volume_downscaling);
-            end
+            volume_size = self.get_volume_size(ref_gr);
 
             for ii_g = 1:num_grains
                 gr = sampler(ii_g).get_reference_grain();
@@ -536,6 +522,17 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
                 'good_orients', {true(1, tot_orient)} );
         end
 
+        function volume_size = get_volume_size(self, ref_gr)
+            proj = ref_gr.proj(self.det_index);
+
+            spacing = mean([proj.vol_size_y, proj.vol_size_x, proj.vol_size_z]) * (self.rspace_oversize - 1);
+            volume_size = ceil([proj.vol_size_y, proj.vol_size_x, proj.vol_size_z] + spacing);
+
+            if (self.volume_downscaling > 1)
+                volume_size = ceil(volume_size / self.volume_downscaling);
+            end
+        end
+
         function [sub_blob_slices, proj_coeffs] = get_sub_blobs(self, blobs, slices_interp, padding)
             num_blobs = numel(blobs);
             sub_blob_slices = cell(num_blobs, 1);
@@ -771,18 +768,9 @@ classdef Gt6DReconstructionAlgorithmFactory < handle
             sliceLims = [floor(sliceLims(:, 1)), ceil(sliceLims(:, 2))] + 1;
         end
 
-        function volume_size = get_volume_size(self, gr_center, Ws, bls)
-            % At this point we kinda lost the original blob size
-            % information! so we get it from the mask ;)
-            BBs(:, [1, 3]) = cat(1, bls(:).bbuim);
-            BBs(:, [2, 4]) = cat(1, bls(:).bbvim);
 
-            BBs = [BBs(:, 1:2), (BBs(:, 3:4) - BBs(:, 1:2) + 1)];
 
-            verts = gtFwdSimComputeCircumscribingPolyhedron(gr_center, Ws, BBs, self.parameters, self.det_index);
 
-            volume_size = round(max(verts, [], 1) - min(verts, [], 1) / self.parameters.fsim.oversize);
-        end
 
         function [geometries, offsets] = makeSubBlobGeometries( self, ...
                 grains_props, proj_coeffs, extreemes_blobs_w, w_tab, abs_lims)
-- 
GitLab