diff --git a/src/Plugins/ComplexCore/src/ComplexCore/Filters/ImportHDF5Dataset.cpp b/src/Plugins/ComplexCore/src/ComplexCore/Filters/ImportHDF5Dataset.cpp index 2364372892..cdb970acd3 100644 --- a/src/Plugins/ComplexCore/src/ComplexCore/Filters/ImportHDF5Dataset.cpp +++ b/src/Plugins/ComplexCore/src/ComplexCore/Filters/ImportHDF5Dataset.cpp @@ -126,10 +126,6 @@ IFilter::PreflightResult ImportHDF5Dataset::preflightImpl(const DataStructure& d fs::path inputFilePath(inputFile); std::string ext = inputFilePath.extension().string(); - if(ext != ".h5" && ext != ".hdf5" && ext != ".dream3d") - { - return {nonstd::make_unexpected(std::vector{Error{-20002, fmt::format("The selected file '{}' is not an HDF5 file.", inputFilePath.filename().string())}})}; - } if(!fs::exists(inputFilePath)) { diff --git a/src/Plugins/OrientationAnalysis/docs/Images/Hexagonal_Axis_Alignment.png b/src/Plugins/OrientationAnalysis/docs/Images/Hexagonal_Axis_Alignment.png new file mode 100644 index 0000000000..3c6a773d91 Binary files /dev/null and b/src/Plugins/OrientationAnalysis/docs/Images/Hexagonal_Axis_Alignment.png differ diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ImportH5EspritDataFilter.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ImportH5EspritDataFilter.cpp index 3b27a3e27d..a18260ed57 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ImportH5EspritDataFilter.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ImportH5EspritDataFilter.cpp @@ -67,7 +67,7 @@ Parameters ImportH5EspritDataFilter::parameters() const params.insertSeparator(Parameters::Separator{"Input Parameters"}); params.insert(std::make_unique(k_SelectedScanNames_Key, "Scan Names", "The name of the scan in the .h5 file. EDAX can store multiple scans in a single file", OEMEbsdScanSelectionParameter::ValueType{}, - OEMEbsdScanSelectionParameter::AllowedManufacturers{EbsdLib::OEM::Bruker, EbsdLib::OEM::DREAM3D}, + /* OEMEbsdScanSelectionParameter::AllowedManufacturers{EbsdLib::OEM::Bruker, EbsdLib::OEM::DREAM3D},*/ OEMEbsdScanSelectionParameter::EbsdReaderType::Esprit, OEMEbsdScanSelectionParameter::ExtensionsType{".h5"})); params.insert(std::make_unique(k_ZSpacing_Key, "Z Spacing (Microns)", "The spacing in microns between each layer.", 1.0f)); params.insert(std::make_unique(k_Origin_Key, "Origin", "The origin of the volume", std::vector{0.0F, 0.0F, 0.0F}, std::vector{"x", "y", "z"})); diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ImportH5OimDataFilter.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ImportH5OimDataFilter.cpp index 7fa8089441..a0a8b93b40 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ImportH5OimDataFilter.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ImportH5OimDataFilter.cpp @@ -64,7 +64,8 @@ Parameters ImportH5OimDataFilter::parameters() const // Create the parameter descriptors that are needed for this filter params.insertSeparator(Parameters::Separator{"Input Parameters"}); params.insert(std::make_unique(k_SelectedScanNames_Key, "Scan Names", "The name of the scan in the .h5 file. EDAX can store multiple scans in a single file", - OEMEbsdScanSelectionParameter::ValueType{}, OEMEbsdScanSelectionParameter::AllowedManufacturers{EbsdLib::OEM::EDAX}, + OEMEbsdScanSelectionParameter::ValueType{}, + /* OEMEbsdScanSelectionParameter::AllowedManufacturers{EbsdLib::OEM::EDAX},*/ OEMEbsdScanSelectionParameter::EbsdReaderType::Oim, OEMEbsdScanSelectionParameter::ExtensionsType{".h5"})); params.insert(std::make_unique(k_ZSpacing_Key, "Z Spacing (Microns)", "The spacing in microns between each layer.", 1.0f)); params.insert(std::make_unique(k_Origin_Key, "Origin", "The origin of the volume", std::vector{0.0F, 0.0F, 0.0F}, std::vector{"x", "y", "z"})); diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/OEMEbsdScanSelectionParameter.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/OEMEbsdScanSelectionParameter.cpp index e1b617e82d..78d535b9d1 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/OEMEbsdScanSelectionParameter.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/OEMEbsdScanSelectionParameter.cpp @@ -4,14 +4,6 @@ #include "complex/Common/StringLiteral.hpp" #include "complex/Utilities/StringUtilities.hpp" -#include "H5Support/H5ScopedSentinel.h" -#include "H5Support/H5Utilities.h" - -#include "EbsdLib/IO/BrukerNano/EspritConstants.h" -#include "EbsdLib/IO/BrukerNano/H5EspritReader.h" -#include "EbsdLib/IO/HKL/CtfFields.h" -#include "EbsdLib/IO/TSL/H5OIMReader.h" - #include #include @@ -28,10 +20,9 @@ constexpr StringLiteral k_ScanNames = "scan_names"; //----------------------------------------------------------------------------- OEMEbsdScanSelectionParameter::OEMEbsdScanSelectionParameter(const std::string& name, const std::string& humanName, const std::string& helpText, const ValueType& defaultValue, - const AllowedManufacturers& allowedManufacturers, const EbsdReaderType& readerType, const ExtensionsType& extensionsType) + const EbsdReaderType& readerType, const ExtensionsType& extensionsType) : ValueParameter(name, humanName, helpText) , m_DefaultValue(defaultValue) -, m_AllowedManufacturers(allowedManufacturers) , m_AvailableExtensions(extensionsType) , m_ReaderType(readerType) { @@ -111,11 +102,13 @@ Result OEMEbsdScanSelectionParameter::fromJson(const nlohmann::json& j } } + constexpr int32 k_LowtoHigh = 0; + constexpr int32 k_HightoLow = 1; const auto orderCheck = json[k_StackingOrder].get(); - if(orderCheck != EbsdLib::RefFrameZDir::LowtoHigh && orderCheck != EbsdLib::RefFrameZDir::HightoLow) + if(orderCheck != k_LowtoHigh && orderCheck != k_HightoLow) { - return MakeErrorResult(FilterParameter::Constants::k_Json_Value_Not_Enumeration, fmt::format("{}JSON value for key '{}' was not a valid ordering Value. [{}|{}] allowed.", prefix.view(), - k_StackingOrder.view(), EbsdLib::RefFrameZDir::LowtoHigh, EbsdLib::RefFrameZDir::HightoLow)); + return MakeErrorResult(FilterParameter::Constants::k_Json_Value_Not_Enumeration, + fmt::format("{}JSON value for key '{}' was not a valid ordering Value. [{}|{}] allowed.", prefix.view(), k_StackingOrder.view(), k_LowtoHigh, k_HightoLow)); } ValueType value; @@ -161,7 +154,7 @@ Result OEMEbsdScanSelectionParameter::fromJson(const nlohmann::json& j //----------------------------------------------------------------------------- IParameter::UniquePointer OEMEbsdScanSelectionParameter::clone() const { - return std::make_unique(name(), humanName(), helpText(), m_DefaultValue, m_AllowedManufacturers, m_ReaderType, m_AvailableExtensions); + return std::make_unique(name(), humanName(), helpText(), m_DefaultValue, m_ReaderType, m_AvailableExtensions); } //----------------------------------------------------------------------------- @@ -193,98 +186,9 @@ Result<> OEMEbsdScanSelectionParameter::validate(const std::any& valueRef) const { return {nonstd::make_unexpected(std::vector{{-20032, fmt::format("File extension '{}' is not a valid file extension.", value.inputFilePath.extension().string())}})}; } - - if(value.stackingOrder != EbsdLib::RefFrameZDir::LowtoHigh && value.stackingOrder != EbsdLib::RefFrameZDir::HightoLow) - { - errors.push_back({-20033, fmt::format("{} is not a valid value for the stacking order. Please choose either {} or {}", value.stackingOrder, EbsdLib::RefFrameZDir::LowtoHigh, - EbsdLib::RefFrameZDir::HightoLow)}); - return {nonstd::make_unexpected(std::move(errors))}; - } - - std::list scanNames; - int32 err = 0; - if(m_ReaderType == EbsdReaderType::Oim) - { - const H5OIMReader::Pointer reader = H5OIMReader::New(); - reader->setFileName(value.inputFilePath.string()); - err = reader->readScanNames(scanNames); - } - else - { - const H5EspritReader::Pointer reader = H5EspritReader::New(); - reader->setFileName(value.inputFilePath.string()); - err = reader->readScanNames(scanNames); - } - - if(err < 0) - { - errors.push_back({-20034, fmt::format("H5 file '{}' could not be opened. Reported error code from the H5OIMReader class is '{}'", value.inputFilePath.string(), err)}); - return {nonstd::make_unexpected(std::move(errors))}; - } - - const ManufacturerType manufacturer = ReadManufacturer(value.inputFilePath.string()); - if(m_AllowedManufacturers.find(manufacturer) == m_AllowedManufacturers.end()) - { - errors.push_back({-20035, fmt::format("Original data source type {} is not a valid manufacturer", fmt::underlying(manufacturer))}); - return {nonstd::make_unexpected(std::move(errors))}; - } - - if(value.scanNames.empty()) - { - errors.push_back({-20036, fmt::format("At least one scan must be chosen. Please select a scan from the list.")}); - return {nonstd::make_unexpected(std::move(errors))}; - } - return {}; } -//----------------------------------------------------------------------------- -OEMEbsdScanSelectionParameter::ManufacturerType OEMEbsdScanSelectionParameter::ReadManufacturer(const std::string& inputFile) -{ - EbsdLib::OEM manuf = EbsdLib::OEM::Unknown; - - const hid_t fid = H5Utilities::openFile(inputFile, true); - if(fid < 0) - { - return manuf; - } - H5ScopedFileSentinel sentinel(fid, false); - std::string dsetName; - std::list names; - herr_t err = H5Utilities::getGroupObjects(fid, H5Utilities::CustomHDFDataTypes::Any, names); - auto findIter = std::find(names.begin(), names.end(), EbsdLib::H5OIM::Manufacturer); - if(findIter != names.end()) - { - dsetName = EbsdLib::H5OIM::Manufacturer; - } - - findIter = std::find(names.begin(), names.end(), EbsdLib::H5Esprit::Manufacturer); - if(findIter != names.end()) - { - dsetName = EbsdLib::H5Esprit::Manufacturer; - } - - std::string manufacturer("Unknown"); - err = H5Lite::readStringDataset(fid, dsetName, manufacturer); - if(err < 0) - { - return manuf; - } - if(manufacturer == EbsdLib::H5OIM::EDAX) - { - manuf = EbsdLib::OEM::EDAX; - } - if(manufacturer == EbsdLib::H5Esprit::BrukerNano) - { - manuf = EbsdLib::OEM::Bruker; - } - if(manufacturer == "DREAM.3D") - { - manuf = EbsdLib::OEM::DREAM3D; - } - return manuf; -} - //----------------------------------------------------------------------------- OEMEbsdScanSelectionParameter::ExtensionsType OEMEbsdScanSelectionParameter::getAvailableExtensions() const { diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/OEMEbsdScanSelectionParameter.h b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/OEMEbsdScanSelectionParameter.h index 767f1886a3..d5ca3976a9 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/OEMEbsdScanSelectionParameter.h +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Parameters/OEMEbsdScanSelectionParameter.h @@ -5,8 +5,6 @@ #include "complex/Utilities/FilePathGenerator.hpp" #include "complex/complex_export.hpp" -#include "EbsdLib/Core/EbsdLibConstants.h" - #include #include #include @@ -26,16 +24,16 @@ class COMPLEX_EXPORT OEMEbsdScanSelectionParameter : public ValueParameter struct ValueType { fs::path inputFilePath; - int32 stackingOrder = EbsdLib::RefFrameZDir::LowtoHigh; + int32 stackingOrder = 0; // Low to High This is the same from EbsdLib. If EbsdLib changes, this should change std::list scanNames = {}; }; - using ManufacturerType = EbsdLib::OEM; - using AllowedManufacturers = std::unordered_set; + using ExtensionsType = std::unordered_set; enum EbsdReaderType : uint8 { Oim = 0, - Esprit = 1 + Esprit = 1, + H5Oina = 2 }; OEMEbsdScanSelectionParameter() = delete; @@ -47,7 +45,8 @@ class COMPLEX_EXPORT OEMEbsdScanSelectionParameter : public ValueParameter * @param helpText The help text that should be displayed to a user * @param defaultValue The default value for the parameter */ - OEMEbsdScanSelectionParameter(const std::string& name, const std::string& humanName, const std::string& helpText, const ValueType& defaultValue, const AllowedManufacturers& allowedManufacturers, + OEMEbsdScanSelectionParameter(const std::string& name, const std::string& humanName, const std::string& helpText, const ValueType& defaultValue, + /* const AllowedManufacturers& allowedManufacturers, */ const EbsdReaderType& readerType, const ExtensionsType& extensionsType); ~OEMEbsdScanSelectionParameter() override = default; @@ -112,16 +111,8 @@ class COMPLEX_EXPORT OEMEbsdScanSelectionParameter : public ValueParameter */ EbsdReaderType getReaderType() const; - /** - * @brief - * @param inputFile - * @return - */ - static ManufacturerType ReadManufacturer(const std::string& inputFile); - private: ValueType m_DefaultValue = {}; - AllowedManufacturers m_AllowedManufacturers = {}; ExtensionsType m_AvailableExtensions = {}; EbsdReaderType m_ReaderType = {}; }; diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/utilities/ImportH5Data.hpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/utilities/ImportH5Data.hpp index 2735fcf774..2f2d86b655 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/utilities/ImportH5Data.hpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/utilities/ImportH5Data.hpp @@ -20,6 +20,8 @@ struct ORIENTATIONANALYSIS_EXPORT ImportH5DataInputValues DataPath ImageGeometryPath; DataPath CellAttributeMatrixPath; DataPath CellEnsembleAttributeMatrixPath; + bool EdaxHexagonalAlignment; + bool ConvertPhaseToInt32; }; /** @@ -55,6 +57,8 @@ class ORIENTATIONANALYSIS_EXPORT ImportH5Data int index = 0; for(const auto& currentScanName : m_InputValues->SelectedScanNames.scanNames) { + m_MessageHandler({IFilter::Message::Type::Info, fmt::format("Importing Index {}", currentScanName)}); + Result<> readResults = readData(currentScanName); if(readResults.invalid()) { diff --git a/src/Plugins/OrientationAnalysis/wrapping/python/orientationanalysis.cpp b/src/Plugins/OrientationAnalysis/wrapping/python/orientationanalysis.cpp index 58d0dfb048..0fee49b690 100644 --- a/src/Plugins/OrientationAnalysis/wrapping/python/orientationanalysis.cpp +++ b/src/Plugins/OrientationAnalysis/wrapping/python/orientationanalysis.cpp @@ -43,23 +43,11 @@ PYBIND11_MODULE(orientationanalysis, mod) oemEbsdScanSelectionEbsdReaderType.value("Oim", OEMEbsdScanSelectionParameter::EbsdReaderType::Oim); oemEbsdScanSelectionEbsdReaderType.value("Esprit", OEMEbsdScanSelectionParameter::EbsdReaderType::Esprit); - py::enum_ oemEbsdScanSelectionManufacturerType(oemEbsdScanSelectionParameter, "ManufacturerType"); - oemEbsdScanSelectionManufacturerType.value("EDAX", OEMEbsdScanSelectionParameter::ManufacturerType::EDAX); - oemEbsdScanSelectionManufacturerType.value("Oxford", OEMEbsdScanSelectionParameter::ManufacturerType::Oxford); - oemEbsdScanSelectionManufacturerType.value("Bruker", OEMEbsdScanSelectionParameter::ManufacturerType::Bruker); - oemEbsdScanSelectionManufacturerType.value("HEDM", OEMEbsdScanSelectionParameter::ManufacturerType::HEDM); - oemEbsdScanSelectionManufacturerType.value("Zeiss", OEMEbsdScanSelectionParameter::ManufacturerType::Zeiss); - oemEbsdScanSelectionManufacturerType.value("Phillips", OEMEbsdScanSelectionParameter::ManufacturerType::Phillips); - oemEbsdScanSelectionManufacturerType.value("ThermoFisher", OEMEbsdScanSelectionParameter::ManufacturerType::ThermoFisher); - oemEbsdScanSelectionManufacturerType.value("DREAM3D", OEMEbsdScanSelectionParameter::ManufacturerType::DREAM3D); - oemEbsdScanSelectionManufacturerType.value("Unknown", OEMEbsdScanSelectionParameter::ManufacturerType::Unknown); - BindParameterConstructor(h5EbsdReaderParameter); - oemEbsdScanSelectionParameter.def( - py::init(), - "name"_a, "human_name"_a, "help_text"_a, "default_value"_a, "allowed_manufacturers"_a, "reader_type"_a, "extensions_type"_a); + oemEbsdScanSelectionParameter.def(py::init(), + "name"_a, "human_name"_a, "help_text"_a, "default_value"_a, "reader_type"_a, "extensions_type"_a); internals.addConversion(); internals.addConversion();