Skip to content

Commit

Permalink
ENH: Reading OEM EBSD HDF5 Files should have better error messages ge…
Browse files Browse the repository at this point in the history
…nerated (#996)

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
  • Loading branch information
imikejackson authored Jun 20, 2024
1 parent 788e073 commit 95f41e7
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Plugins/OrientationAnalysis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ set(PLUGIN_EXTRA_SOURCES
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/inicpp.h"
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/PhaseType.hpp"
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/PhaseType.cpp"
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/ReadH5Data.hpp"
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/IEbsdOemReader.hpp"
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/OrientationUtilities.hpp"
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/OrientationUtilities.cpp"
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/Fonts.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace nx::core;
// -----------------------------------------------------------------------------
ReadH5EspritData::ReadH5EspritData(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, const ReadH5DataInputValues* inputValues,
ReadH5EspritDataInputValues* espritInputValues)
: ReadH5Data<H5EspritReader>(dataStructure, mesgHandler, shouldCancel, inputValues)
: IEbsdOemReader<H5EspritReader>(dataStructure, mesgHandler, shouldCancel, inputValues)
, m_EspritInputValues(espritInputValues)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "OrientationAnalysis/OrientationAnalysis_export.hpp"
#include "OrientationAnalysis/utilities/ReadH5Data.hpp"
#include "OrientationAnalysis/utilities/IEbsdOemReader.hpp"

#include "simplnx/DataStructure/DataStructure.hpp"
#include "simplnx/Filter/IFilter.hpp"
Expand All @@ -19,7 +19,7 @@ struct ORIENTATIONANALYSIS_EXPORT ReadH5EspritDataInputValues
* @brief This filter will read a single .h5 file into a new Image Geometry, allowing the immediate use of Filters on the data instead of having to generate the intermediate .h5ebsd file.
*/

class ORIENTATIONANALYSIS_EXPORT ReadH5EspritData : public ReadH5Data<H5EspritReader>
class ORIENTATIONANALYSIS_EXPORT ReadH5EspritData : public IEbsdOemReader<H5EspritReader>
{
public:
ReadH5EspritData(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, const ReadH5DataInputValues* inputValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using namespace nx::core;

// -----------------------------------------------------------------------------
ReadH5OimData::ReadH5OimData(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, ReadH5DataInputValues* inputValues)
: ReadH5Data<H5OIMReader>(dataStructure, mesgHandler, shouldCancel, inputValues)
: IEbsdOemReader<H5OIMReader>(dataStructure, mesgHandler, shouldCancel, inputValues)
{
}

Expand Down Expand Up @@ -93,4 +93,4 @@ Result<> ReadH5OimData::copyRawEbsdData(int index)
}

return {};
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "OrientationAnalysis/OrientationAnalysis_export.hpp"
#include "OrientationAnalysis/utilities/ReadH5Data.hpp"
#include "OrientationAnalysis/utilities/IEbsdOemReader.hpp"

namespace nx::core
{
Expand All @@ -11,7 +11,7 @@ namespace nx::core
* intermediate .h5ebsd file.
*/

class ORIENTATIONANALYSIS_EXPORT ReadH5OimData : public ReadH5Data<H5OIMReader>
class ORIENTATIONANALYSIS_EXPORT ReadH5OimData : public IEbsdOemReader<H5OIMReader>
{
public:
ReadH5OimData(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, ReadH5DataInputValues* inputValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void convertHexEulerAngle(const ReadH5DataInputValues* m_InputValues, size_t tot

// -----------------------------------------------------------------------------
ReadH5OinaData::ReadH5OinaData(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, ReadH5DataInputValues* inputValues)
: ReadH5Data<H5OINAReader>(dataStructure, mesgHandler, shouldCancel, inputValues)
: IEbsdOemReader<H5OINAReader>(dataStructure, mesgHandler, shouldCancel, inputValues)
{
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "OrientationAnalysis/OrientationAnalysis_export.hpp"
#include "OrientationAnalysis/utilities/ReadH5Data.hpp"
#include "OrientationAnalysis/utilities/IEbsdOemReader.hpp"

namespace nx::core
{
Expand All @@ -12,7 +12,7 @@ namespace nx::core
* intermediate .h5ebsd file.
*/

class ORIENTATIONANALYSIS_EXPORT ReadH5OinaData : public ReadH5Data<H5OINAReader>
class ORIENTATIONANALYSIS_EXPORT ReadH5OinaData : public IEbsdOemReader<H5OINAReader>
{
public:
ReadH5OinaData(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, ReadH5DataInputValues* inputValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "EbsdLib/IO/HKL/H5OINAReader.h"
#include "EbsdLib/IO/TSL/H5OIMReader.h"

#include <fmt/format.h>

namespace nx::core
{
struct ORIENTATIONANALYSIS_EXPORT ReadH5DataInputValues
Expand All @@ -30,10 +32,10 @@ struct ORIENTATIONANALYSIS_EXPORT ReadH5DataInputValues
*/

template <class T>
class ORIENTATIONANALYSIS_EXPORT ReadH5Data
class ORIENTATIONANALYSIS_EXPORT IEbsdOemReader
{
public:
ReadH5Data(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, const ReadH5DataInputValues* inputValues)
IEbsdOemReader(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, const ReadH5DataInputValues* inputValues)
: m_DataStructure(dataStructure)
, m_ShouldCancel(shouldCancel)
, m_MessageHandler(mesgHandler)
Expand All @@ -43,12 +45,12 @@ class ORIENTATIONANALYSIS_EXPORT ReadH5Data
m_Reader->setFileName(inputValues->SelectedScanNames.inputFilePath.string());
}

virtual ~ReadH5Data() noexcept = default;
virtual ~IEbsdOemReader() noexcept = default;

ReadH5Data(const ReadH5Data&) = delete;
ReadH5Data(ReadH5Data&&) noexcept = delete;
ReadH5Data& operator=(const ReadH5Data&) = delete;
ReadH5Data& operator=(ReadH5Data&&) noexcept = delete;
IEbsdOemReader(const IEbsdOemReader&) = delete;
IEbsdOemReader(IEbsdOemReader&&) noexcept = delete;
IEbsdOemReader& operator=(const IEbsdOemReader&) = delete;
IEbsdOemReader& operator=(IEbsdOemReader&&) noexcept = delete;

Result<> execute()
{
Expand Down Expand Up @@ -90,13 +92,14 @@ class ORIENTATIONANALYSIS_EXPORT ReadH5Data

if(const int32 err = m_Reader->readFile(); err < 0)
{
return MakeErrorResult(-8970, "EbsdReader could not read the .h5 file.");
return MakeErrorResult(-8970, fmt::format("Attempting to read scan '{}' from file '{}' produced an error from the '{}' class.\n Error Code: {}\n Message: {}", scanName,
m_Reader->getFileName(), m_Reader->getNameOfClass(), m_Reader->getErrorCode(), m_Reader->getErrorMessage()));
}

const auto phases = m_Reader->getPhaseVector();
if(phases.empty())
{
return MakeErrorResult(-8971, "EbsdReader could not read the phase vector from the .h5 file.");
return MakeErrorResult(-8971, fmt::format("'{}' did not parse any phases from from the .h5 file '{}' for scan '{}'", m_Reader->getNameOfClass(), scanName, m_Reader->getFileName()));
}

// These arrays are purposely created using the AngFile constant names for BOTH the Oim and the Esprit readers!
Expand Down

0 comments on commit 95f41e7

Please sign in to comment.