From 54f863057dfdaabfa0ef4b9e288877ef4c0411af Mon Sep 17 00:00:00 2001
From: Yoann Guilhem <yoann.guilhem@esrf.fr>
Date: Thu, 18 Apr 2013 15:58:15 +0200
Subject: [PATCH] Bugfix about bad input shape for gtMathsRod2OriMat.

Signed-off-by: Yoann Guilhem <yoann.guilhem@esrf.fr>
---
 5_reconstruction/gtFindSimilarGrains.m            |  4 ++--
 6_rendering/gtCrystAxisPoles.m                    |  2 +-
 6_rendering/gtIPFCmap.m                           | 11 +++++------
 6_rendering/gtPlotHexagon.m                       |  2 +-
 6_rendering/gtRvectorCmap.m                       |  4 ++--
 6_rendering/gtShowSampleSurface.m                 |  2 +-
 zUtil_Boundaries/gtAnalyseBoundaryIndexPlane.m    | 10 +++++++---
 zUtil_Indexter/gtINDEXMatchGrains.m               |  4 ++--
 zUtil_Indexter/gtIndexRefineGrains.m              |  5 ++++-
 zUtil_Indexter/gtIndexStatisticalFit.m            |  9 ++++++---
 zUtil_Strain/gtStrainDrawPrincipalStrainVectors.m |  8 ++++++--
 zUtil_Strain/gtStrainFitElasticConstants.m        |  5 ++++-
 zUtil_Strain/gtStrainFitElasticConstants_test.m   |  5 ++++-
 zUtil_Taper/gtTaperConvertFableOutputToDCT.m      |  2 +-
 14 files changed, 46 insertions(+), 27 deletions(-)

diff --git a/5_reconstruction/gtFindSimilarGrains.m b/5_reconstruction/gtFindSimilarGrains.m
index 003bd1d6..8693ab86 100644
--- a/5_reconstruction/gtFindSimilarGrains.m
+++ b/5_reconstruction/gtFindSimilarGrains.m
@@ -24,8 +24,8 @@ map2.pos=map2.pos-repmat(mean(map2.pos,1), length(map2.pos), 1);
 map2.pos=map2.pos*parameters2.acq.pixelsize/parameters1.acq.pixelsize;
 
 % Compute all orientation matrices g on each map
-all_g1 = gtMathsRod2OriMat(map1.R_vec);
-all_g2 = gtMathsRod2OriMat(map2.R_vec);
+all_g1 = gtMathsRod2OriMat(map1.R_vec.');
+all_g2 = gtMathsRod2OriMat(map2.R_vec.');
 
 % Go through grain map 1, looking for matches in grain map 2
 output = [];
diff --git a/6_rendering/gtCrystAxisPoles.m b/6_rendering/gtCrystAxisPoles.m
index b5ac40b6..d8d193b1 100644
--- a/6_rendering/gtCrystAxisPoles.m
+++ b/6_rendering/gtCrystAxisPoles.m
@@ -68,7 +68,7 @@ poles = zeros(0,4);
 valid_poles = zeros(0,4);
 
 % Compute all orientation matrices g
-all_g = gtMathsRod2OriMat(r_vectors);
+all_g = gtMathsRod2OriMat(r_vectors.');
 
 % Express normalised hkls in cartesian SAMPLE CS
 all_normals = gtVectorCryst2Lab(normalised_hkls, all_g);
diff --git a/6_rendering/gtIPFCmap.m b/6_rendering/gtIPFCmap.m
index 1a4f2e4c..89bc23ca 100644
--- a/6_rendering/gtIPFCmap.m
+++ b/6_rendering/gtIPFCmap.m
@@ -65,16 +65,15 @@ elseif exist(fullfile(phaseDir, 'r_vectors.mat'), 'file')
 elseif exist(fullfile(phaseDir, 'index.mat'), 'file')
     grain = [];
     load(fullfile(phaseDir, 'index.mat'), 'grain');
-    r_vectors = gtIndexAllGrainValues(grain, 'R_vector', [], 1:3, []);
+    r_vectors = gtIndexAllGrainValues(grain, 'R_vector', [], 1, 1:3);
 else
     gtError('gtIPFCmap:missing_file', 'Could not find r_vectors.mat or index.mat file!');
 end
 
-% Resize r_vectors if needed and transpose to column vectors
-if size(r_vectors,2) == 4
+% Resize r_vectors if needed
+if size(r_vectors, 2) == 4
     r_vectors = r_vectors(:, 2:4);
 end
-r_vectors = r_vectors.';
 
 % Get the crystal system
 if isempty(par.crystal_system)
@@ -84,8 +83,8 @@ end
 
 % Compute all orientation matrices g
 %   Gcry = g Gsam
-%   g = U = gtMathsRod2OriMat(R_vector)
-all_g = gtMathsRod2OriMat(r_vectors);
+%   g = U = gtMathsRod2OriMat(r_vectors.')
+all_g = gtMathsRod2OriMat(r_vectors.');
 
 % Compute LDc = LD expressed in the crystal CS
 LDc = gtVectorLab2Cryst(LD, all_g);
diff --git a/6_rendering/gtPlotHexagon.m b/6_rendering/gtPlotHexagon.m
index 09b6505d..96638148 100644
--- a/6_rendering/gtPlotHexagon.m
+++ b/6_rendering/gtPlotHexagon.m
@@ -90,7 +90,7 @@ hex_faces = data.faces_end;
 vertices = zeros(12,3,size(r_vectors,1));
 
 % Compute all orientation matrices g
-all_g = gtMathsRod2OriMat(r_vectors(:, 2:4));
+all_g = gtMathsRod2OriMat(r_vectors(:, 2:4).');
 
 % Express corners3 of each grain in cartesian SAMPLE CS
 all_corners3a = gtVectorCryst2Lab(corners3, all_g);
diff --git a/6_rendering/gtRvectorCmap.m b/6_rendering/gtRvectorCmap.m
index 722312c2..f19868d6 100644
--- a/6_rendering/gtRvectorCmap.m
+++ b/6_rendering/gtRvectorCmap.m
@@ -15,8 +15,8 @@ else
         'index.mat');
     try
     load(indexFile);
-    r_vectors=gtIndexAllGrainValues(grain, 'R_vector', '', 1:3, '');
-    r_vectors=[zeros(size(r_vectors, 1), 1) r_vectors];
+    r_vectors = gtIndexAllGrainValues(grain, 'R_vector', [], 1, 1:3);
+    r_vectors = [zeros(size(r_vectors, 1), 1) r_vectors];
     catch mexc
         gtPrintException('neither r_vectors.mat nor index.mat was found :-(');
         rmap=[]
diff --git a/6_rendering/gtShowSampleSurface.m b/6_rendering/gtShowSampleSurface.m
index 5c8e0ddd..6e973928 100644
--- a/6_rendering/gtShowSampleSurface.m
+++ b/6_rendering/gtShowSampleSurface.m
@@ -119,7 +119,7 @@ disp('note that the section plane that we look at is y (--> left to right) z (--
 disp('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
 
 % Compute all orientation matrices g
-all_g = gtMathsRod2OriMat(r_vectors(:, 2:4));
+all_g = gtMathsRod2OriMat(r_vectors(:, 2:4).');
 
 % Express every c axis in cartesian SAMPLE CS
 c_axes = gtVectorCryst2Lab([0 0 1], all_g);
diff --git a/zUtil_Boundaries/gtAnalyseBoundaryIndexPlane.m b/zUtil_Boundaries/gtAnalyseBoundaryIndexPlane.m
index 02f1d34d..92e79983 100644
--- a/zUtil_Boundaries/gtAnalyseBoundaryIndexPlane.m
+++ b/zUtil_Boundaries/gtAnalyseBoundaryIndexPlane.m
@@ -46,8 +46,13 @@ end
 tmp = sqrt(sum((all_hkls.*all_hkls),2));
 normalised_hkls = all_hkls./(repmat(tmp,1,3));
 
+% Extract all the Rodrigues vectors into column vectors
+%R_vectors1 = gtIndexAllGrainValues(list, 'grain1_R_vector', [], 1, 1:3); % not used
+R_vectors2 = gtIndexAllGrainValues(list, 'grain2_R_vector', [], 1, 1:3);
+
 % Compute all orientation matrices g
-all_g = gtMathsRod2OriMat(R);
+%all_g1 = gtMathsRod2OriMat(R_vectors1.'); % not used
+all_g2 = gtMathsRod2OriMat(R_vectors2.');
 
 for ii = 1:length(list) % list(i) is the id of the boundary in the volume
   
@@ -55,7 +60,6 @@ for ii = 1:length(list) % list(i) is the id of the boundary in the volume
 
     % Get boundaries_structure data
     grainids=[boundaries_structure(list(ii)).grain1 boundaries_structure(list(ii)).grain2];
-    R=[boundaries_structure(list(ii)).grain1_R_vector; boundaries_structure(list(ii)).grain2_R_vector];
   
     % Skip external boundaries / small boundaries
     if any(grainids==0) || boundaries_structure(list(ii)).count<4
@@ -72,7 +76,7 @@ for ii = 1:length(list) % list(i) is the id of the boundary in the volume
         % find(mod(x,2)==0 & mod(y,2)==0 & mod(z,2)==0)
         % or by using a grid of the boxsize (/2?) to create subregions
 
-        g = all_g(:, :, ii);
+        g = all_g2(:, :, ii);
 
         % Loop through this volume, calculating local character
         % may want to do this in larger steps
diff --git a/zUtil_Indexter/gtINDEXMatchGrains.m b/zUtil_Indexter/gtINDEXMatchGrains.m
index 3cde44dc..f580d9c3 100644
--- a/zUtil_Indexter/gtINDEXMatchGrains.m
+++ b/zUtil_Indexter/gtINDEXMatchGrains.m
@@ -304,7 +304,7 @@ gr2.Rlines = cell(nof_grains2,1);
 gr2.Rids = cell(nof_grains2,1);
 
 % All orientation matrices in dataset2
-all_g2 = gtMathsRod2OriMat(gr2.R_vector);
+all_g2 = gtMathsRod2OriMat(gr2.R_vector.');
 
 if (any(gtIndexAllGrainValues(grain1,'R_onedge',[],1,[])) || ~isempty(drot))
    
@@ -368,7 +368,7 @@ gr1.Rlines = cell(nof_grains1,1);
 gr1.Rids   = cell(nof_grains1,1);
 
 % All orientation matrices in dataset1
-all_g1 = gtMathsRod2OriMat(gr1.R_vector);
+all_g1 = gtMathsRod2OriMat(gr1.R_vector.');
 
 % Plane normals in the Sample ref. of dataset2
 all_pl_sam1 = gtVectorCryst2Lab(pl_cry.', all_g1);
diff --git a/zUtil_Indexter/gtIndexRefineGrains.m b/zUtil_Indexter/gtIndexRefineGrains.m
index f24816a2..a751c07d 100644
--- a/zUtil_Indexter/gtIndexRefineGrains.m
+++ b/zUtil_Indexter/gtIndexRefineGrains.m
@@ -43,8 +43,11 @@ gtodel = [];
 indshkldirs_cry = gtCrystHKL2Cartesian(vertcat(cryst.shklfam{:})', ...
                                        cryst.Bmat)';
 
+% Extract all the Rodrigues vectors into column vectors
+R_vectors = gtIndexAllGrainValues(grain, 'R_vector', [], 1, 1:3);
+
 % Compute all orientation matrices g
-all_g = gtMathsRod2OriMat({grain.R_vector});
+all_g = gtMathsRod2OriMat(R_vectors.');
 
 % Express normalised signed hkl vectors in cartesian SAMPLE CS
 all_shkldirs = gtVectorCryst2Lab(indshkldirs_cry, all_g); 
diff --git a/zUtil_Indexter/gtIndexStatisticalFit.m b/zUtil_Indexter/gtIndexStatisticalFit.m
index 433ad395..9f4f55e5 100644
--- a/zUtil_Indexter/gtIndexStatisticalFit.m
+++ b/zUtil_Indexter/gtIndexStatisticalFit.m
@@ -51,11 +51,14 @@ gnesslist  = cell(nof_srefs,1);
 % All possible normalised signed hkl vectors in cartesian CRYSTAL coordinates
 shkldirs_cry = gtCrystHKL2Cartesian(vertcat(cryst.shklfam{:})', cryst.Bmat)';
 
-% Compute orientation matrix g
-all_g = gtMathsRod2OriMat({grain.R_vector});
+% Extract all the Rodrigues vectors into column vectors
+R_vectors = gtIndexAllGrainValues(grain, 'R_vector', [], 1, 1:3);
+
+% Compute all orientation matrices g
+all_g = gtMathsRod2OriMat(R_vectors.');
 
 % Express normalised signed hkl vectors in cartesian SAMPLE CS
-all_shkldirs = gtVectorCryst2Lab(indshkldirs_cry, all_g); 
+all_shkldirs = gtVectorCryst2Lab(shkldirs_cry, all_g); 
 
 for ii = 1:nof_grains
     % Store normalised signed hkl vectors in cartesian SAMPLE CS
diff --git a/zUtil_Strain/gtStrainDrawPrincipalStrainVectors.m b/zUtil_Strain/gtStrainDrawPrincipalStrainVectors.m
index 23127ac8..281c5590 100644
--- a/zUtil_Strain/gtStrainDrawPrincipalStrainVectors.m
+++ b/zUtil_Strain/gtStrainDrawPrincipalStrainVectors.m
@@ -44,9 +44,13 @@ set(h,'FaceColor','b','EdgeColor','w')
 h = findobj(gca,'Type','line');
 set(h,'Color','b','Linewidth',2)
 
+% Extract all the Rodrigues vectors into column vectors
+R_vectors = gtIndexAllGrainValues(grains, 'R_vector', [], 1, 1:3);
 
-figure('name','Hist grain orientation')
-all_g = gtMathsRod2OriMat({grains.R_vector});
+% Compute all orientation matrices g
+all_g = gtMathsRod2OriMat(R_vectors.');
+
+figure('name','Hist grain orientation');
 for ii = 1:nof_grains
     R = all_g(:, :, ii).';
     v1 = R(1,3);
diff --git a/zUtil_Strain/gtStrainFitElasticConstants.m b/zUtil_Strain/gtStrainFitElasticConstants.m
index 6fccd921..33b58b1e 100644
--- a/zUtil_Strain/gtStrainFitElasticConstants.m
+++ b/zUtil_Strain/gtStrainFitElasticConstants.m
@@ -58,8 +58,11 @@ AI=AI*ps;
 % end
 % toc
 
+% Extract all the Rodrigues vectors into column vectors
+R_vectors = gtIndexAllGrainValues(grain, 'R_vector', [], 1, 1:3);
+
 % Compute all orientation matrices g
-all_g = gtMathsRod2OriMat({grain.R_vector}); % transform from LAB to CRYSTAL
+all_g = gtMathsRod2OriMat(R_vectors.');
 
 % Express zlab in LAB CS
 all_zcryst = gtVectorLab2Cryst(zlab, all_g);
diff --git a/zUtil_Strain/gtStrainFitElasticConstants_test.m b/zUtil_Strain/gtStrainFitElasticConstants_test.m
index cfd92386..1a23b47e 100644
--- a/zUtil_Strain/gtStrainFitElasticConstants_test.m
+++ b/zUtil_Strain/gtStrainFitElasticConstants_test.m
@@ -52,8 +52,11 @@ AI=AI*ps;
 % end
 % toc
 
+% Extract all the Rodrigues vectors into column vectors
+R_vectors = gtIndexAllGrainValues(grain, 'R_vector', [], 1, 1:3);
+
 % Compute all orientation matrices g
-all_g = gtMathsRod2OriMat({grain.R_vector}); % transform from LAB to CRYSTAL
+all_g = gtMathsRod2OriMat(R_vectors.');
 
 % Express zlab in LAB CS
 all_zcryst = gtVectorLab2Cryst(zlab, all_g);
diff --git a/zUtil_Taper/gtTaperConvertFableOutputToDCT.m b/zUtil_Taper/gtTaperConvertFableOutputToDCT.m
index c94e94a4..51775e15 100644
--- a/zUtil_Taper/gtTaperConvertFableOutputToDCT.m
+++ b/zUtil_Taper/gtTaperConvertFableOutputToDCT.m
@@ -126,7 +126,7 @@ for ii = 1:length(cen)
     grain{ii}.stat.bbysmean = 1;
 end
 
-rvec = gtIndexAllGrainValues(grain,'R_vector',[],1:3,[]);
+rvec = gtIndexAllGrainValues(grain,'R_vector',[],1,1:3);
 rotmat = gtMathsRod2OriMat( rvec.' );
 
 for ii = 1:length(grain)
-- 
GitLab