42
42
43
43
#include < algorithm>
44
44
#include < fstream>
45
+ #include < optional>
45
46
#include < sstream>
46
47
#include < utility>
47
- #include < optional>
48
48
49
49
namespace
50
50
{
51
51
52
52
using Vec3Type = std::array<float , 3 >;
53
53
using Size3Type = std::array<size_t , 3 >;
54
54
55
- std::optional<size_t > GetGridIndex (Vec3Type& coords, Vec3Type& m_Origin, Vec3Type& m_Spacing, Size3Type& m_Dimensions )
55
+ std::optional<size_t > GetGridIndex (Vec3Type& coords, Vec3Type& m_Origin, Vec3Type& m_Spacing, Size3Type& m_Dimensions)
56
56
{
57
- if (coords[0 ] < m_Origin[0 ] || coords[0 ] > (static_cast <float >(m_Dimensions[0 ]) * m_Spacing[0 ] + m_Origin[0 ]))
57
+ if (coords[0 ] < m_Origin[0 ] || coords[0 ] > (static_cast <float >(m_Dimensions[0 ]) * m_Spacing[0 ] + m_Origin[0 ]))
58
58
{
59
59
return {};
60
60
}
@@ -69,7 +69,7 @@ std::optional<size_t> GetGridIndex(Vec3Type& coords, Vec3Type& m_Origin, Vec3Typ
69
69
return {};
70
70
}
71
71
72
- size_t x = static_cast <size_t >(std::floor ((coords[0 ] - m_Origin[0 ]) / m_Spacing[0 ]));
72
+ size_t x = static_cast <size_t >(std::floor ((coords[0 ] - m_Origin[0 ]) / m_Spacing[0 ]));
73
73
if (x >= m_Dimensions[0 ])
74
74
{
75
75
return {};
@@ -89,7 +89,7 @@ std::optional<size_t> GetGridIndex(Vec3Type& coords, Vec3Type& m_Origin, Vec3Typ
89
89
90
90
return (m_Dimensions[1 ] * m_Dimensions[0 ] * z) + (m_Dimensions[0 ] * y) + x;
91
91
}
92
- }
92
+ } // namespace
93
93
94
94
// -----------------------------------------------------------------------------
95
95
//
@@ -395,13 +395,17 @@ int AngReader::readFile()
395
395
return getErrorCode ();
396
396
}
397
397
std::vector<int64_t > indexMap;
398
- std::pair<int , std::string> result = fixOrderOfData (indexMap);
399
-
400
- if (result.first < 0 )
398
+ std::string grid = getGrid ();
399
+ if (grid.find (EbsdLib::Ang::SquareGrid) == 0 )
401
400
{
402
- setErrorCode (result.first );
403
- setErrorMessage (result.second );
404
- return result.first ;
401
+ std::pair<int , std::string> result = fixOrderOfData (indexMap);
402
+
403
+ if (result.first < 0 )
404
+ {
405
+ setErrorCode (result.first );
406
+ setErrorMessage (result.second );
407
+ return result.first ;
408
+ }
405
409
}
406
410
407
411
std::vector<std::string> arrayNames = {" Phi1" , " Phi" , " Phi2" , " X Position" , " Y Position" , " Image Quality" , " Confidence Index" , " PhaseData" , " SEM Signal" , " Fit" };
@@ -995,14 +999,15 @@ std::pair<int, std::string> AngReader::fixOrderOfData(std::vector<int64_t>& inde
995
999
if (std::nearbyint ((xMax - xMin) / xStep) + 1 != numCols)
996
1000
{
997
1001
std::stringstream message;
998
- message << " Error: The calculated number of columns (" << ((xMax - xMin) / xStep) + 1 << " ) does not match the actual number of columns (" << numCols << " )" << std::endl;
999
- return {-100 , message.str ()};
1002
+ message << " Error: The calculated number of columns XMax: " << xMax << " , XMin: " << xMin << " , XStep: " << xStep << " (" << ((xMax - xMin) / xStep) + 1
1003
+ << " ) does not match the actual number of columns (" << numCols + 1 << " )" << std::endl;
1004
+ return {-101100 , message.str ()};
1000
1005
}
1001
1006
if (std::nearbyint ((yMax - yMin) / yStep) + 1 != numRows)
1002
1007
{
1003
1008
std::stringstream message;
1004
- message << " Error: The calculated number of rows YMax: " << yMax << " , YMin: " << yMin << " , YStep: " << yStep << " (" << ((yMax - yMin) / yStep) + 1 << " ) does not match the actual number of rows ( " << numRows + 1
1005
- << " )" << std::endl;
1009
+ message << " Error: The calculated number of rows YMax: " << yMax << " , YMin: " << yMin << " , YStep: " << yStep << " (" << ((yMax - yMin) / yStep) + 1
1010
+ << " ) does not match the actual number of rows ( " << numRows + 1 << " ) " << std::endl;
1006
1011
return {-101101 , message.str ()};
1007
1012
}
1008
1013
@@ -1021,9 +1026,10 @@ std::pair<int, std::string> AngReader::fixOrderOfData(std::vector<int64_t>& inde
1021
1026
{
1022
1027
std::stringstream message;
1023
1028
message << " AngReader Error: The calculated index for the X and Y Position " << coords[0 ] << " , " << coords[1 ] << " will fall outside of the calculated grid.\n "
1024
- << " Origin: " << m_Origin[0 ] <<" , " << m_Origin[1 ] << " \n "
1025
- << " Spacing: " << m_Spacing[1 ] << " , " << m_Spacing[1 ] << " \n "
1026
- << " Dimensions: " << m_Dimensions[0 ] << " , " << m_Dimensions[1 ] << " \n " << std::endl;
1029
+ << " Origin: " << m_Origin[0 ] << " , " << m_Origin[1 ] << " \n "
1030
+ << " Spacing: " << m_Spacing[1 ] << " , " << m_Spacing[1 ] << " \n "
1031
+ << " Dimensions: " << m_Dimensions[0 ] << " , " << m_Dimensions[1 ] << " \n "
1032
+ << std::endl;
1027
1033
return {-101111 , message.str ()};
1028
1034
}
1029
1035
}
0 commit comments