Skip to content

Commit 17234b9

Browse files
imikejacksonJDuffeyBQ
authored andcommitted
BUG: When reading a hex grid file do NOT attempt to fix location of the data.
* Updated version 1.0.25 Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
1 parent 171658d commit 17234b9

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
1515
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1616

1717
# set project's name
18-
project(EbsdLibProj VERSION 1.0.17)
18+
project(EbsdLibProj VERSION 1.0.25)
1919

2020
# ---------- Setup output Directories -------------------------
2121
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY

Source/EbsdLib/IO/TSL/AngReader.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@
4242

4343
#include <algorithm>
4444
#include <fstream>
45+
#include <optional>
4546
#include <sstream>
4647
#include <utility>
47-
#include <optional>
4848

4949
namespace
5050
{
5151

5252
using Vec3Type = std::array<float, 3>;
5353
using Size3Type = std::array<size_t, 3>;
5454

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)
5656
{
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]))
5858
{
5959
return {};
6060
}
@@ -69,7 +69,7 @@ std::optional<size_t> GetGridIndex(Vec3Type& coords, Vec3Type& m_Origin, Vec3Typ
6969
return {};
7070
}
7171

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]));
7373
if(x >= m_Dimensions[0])
7474
{
7575
return {};
@@ -89,7 +89,7 @@ std::optional<size_t> GetGridIndex(Vec3Type& coords, Vec3Type& m_Origin, Vec3Typ
8989

9090
return (m_Dimensions[1] * m_Dimensions[0] * z) + (m_Dimensions[0] * y) + x;
9191
}
92-
}
92+
} // namespace
9393

9494
// -----------------------------------------------------------------------------
9595
//
@@ -395,13 +395,17 @@ int AngReader::readFile()
395395
return getErrorCode();
396396
}
397397
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)
401400
{
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+
}
405409
}
406410

407411
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
995999
if(std::nearbyint((xMax - xMin) / xStep) + 1 != numCols)
9961000
{
9971001
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()};
10001005
}
10011006
if(std::nearbyint((yMax - yMin) / yStep) + 1 != numRows)
10021007
{
10031008
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;
10061011
return {-101101, message.str()};
10071012
}
10081013

@@ -1021,9 +1026,10 @@ std::pair<int, std::string> AngReader::fixOrderOfData(std::vector<int64_t>& inde
10211026
{
10221027
std::stringstream message;
10231028
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;
10271033
return {-101111, message.str()};
10281034
}
10291035
}

0 commit comments

Comments
 (0)