diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5EspritData.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5EspritData.cpp index 7a454da4b2..6df380d570 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5EspritData.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5EspritData.cpp @@ -23,6 +23,19 @@ Result<> ReadH5EspritData::operator()() return execute(); } +// ----------------------------------------------------------------------------- +Result<> ReadH5EspritData::updateOrigin(const std::string& scanName) +{ + /* + * Unfortunately, the file does not have the correct data to find an origin. + * This means that the origin will remain {0,0,0}. + * + * Down the line, if a solution crops up, look to ReadH5Oina.cpp for an example + * implementation. + */ + return {}; +} + // ----------------------------------------------------------------------------- Result<> ReadH5EspritData::copyRawEbsdData(int index) { diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5EspritData.hpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5EspritData.hpp index 6cc74c8780..2bce418948 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5EspritData.hpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5EspritData.hpp @@ -33,6 +33,8 @@ class ORIENTATIONANALYSIS_EXPORT ReadH5EspritData : public IEbsdOemReader operator()(); + Result<> updateOrigin(const std::string& scanName) override; + Result<> copyRawEbsdData(int index) override; Result<> copyRawEbsdData(const std::string& scanName) override; diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5OinaData.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5OinaData.cpp index 56e6affefb..ae44b040dd 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5OinaData.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5OinaData.cpp @@ -60,6 +60,33 @@ Result<> ReadH5OinaData::operator()() return execute(); } +// ----------------------------------------------------------------------------- +Result<> ReadH5OinaData::updateOrigin(const std::string& scanName) +{ + const DataPath imagePath({scanName}); + + auto& imageGeom = m_DataStructure.getDataRefAs(imagePath); + const usize totalCells = imageGeom.getNumberOfCells(); + + const auto* xPos = reinterpret_cast(m_Reader->getPointerByName(EbsdLib::Ctf::X)); + if(xPos == nullptr) + { + return MakeErrorResult(-9970, fmt::format("{}({}): Function {}: Error. Cannot find {} in supplied scan file ({})", "IEbsdOemReader", __FILE__, __LINE__, EbsdLib::Ctf::X, m_Reader->getFileName())); + } + const auto* yPos = reinterpret_cast(m_Reader->getPointerByName(EbsdLib::Ctf::Y)); + if(yPos == nullptr) + { + return MakeErrorResult(-9971, fmt::format("{}({}): Function {}: Error. Cannot find {} in supplied scan file ({})", "IEbsdOemReader", __FILE__, __LINE__, EbsdLib::Ctf::Y, m_Reader->getFileName())); + } + + float32 minX = *std::min_element(xPos, xPos + totalCells); + float32 minY = *std::min_element(yPos, yPos + totalCells); + + imageGeom.setOrigin(minX, minY, 0.0f); + + return {}; +} + // ----------------------------------------------------------------------------- Result<> ReadH5OinaData::copyRawEbsdData(int index) { diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5OinaData.hpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5OinaData.hpp index fb1f7f1890..cfd8232c8d 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5OinaData.hpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5OinaData.hpp @@ -25,6 +25,7 @@ class ORIENTATIONANALYSIS_EXPORT ReadH5OinaData : public IEbsdOemReader operator()(); + Result<> updateOrigin(const std::string& scanName) override; Result<> copyRawEbsdData(int index) override; Result<> copyRawEbsdData(const std::string& scanName) override; }; diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5EspritDataFilter.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5EspritDataFilter.cpp index e840261242..1962737e7c 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5EspritDataFilter.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5EspritDataFilter.cpp @@ -71,7 +71,7 @@ Parameters ReadH5EspritDataFilter::parameters() const /* OEMEbsdScanSelectionParameter::AllowedManufacturers{EbsdLib::OEM::Bruker, EbsdLib::OEM::DREAM3D},*/ OEMEbsdScanSelectionParameter::EbsdReaderType::Esprit, OEMEbsdScanSelectionParameter::ExtensionsType{".h5", ".hdf5"})); params.insertLinkableParameter(std::make_unique( - k_CombineScans_Key, "Combine Scans", "If true combines each of the multiple scans into a single image geometry along the z axis, else each will result in an individual geometry", true)); + k_CombineScans_Key, "Stack Scans Along Z Axis", "If true combines each of the multiple scans into a single image geometry along the z axis, else each will result in an individual geometry", true)); 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"})); params.insert(std::make_unique(k_DegreesToRadians_Key, "Convert Euler Angles to Radians", "Whether or not to convert the euler angles to radians", true)); diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5OimDataFilter.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5OimDataFilter.cpp index c6145eee9d..fe0c1930e2 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5OimDataFilter.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5OimDataFilter.cpp @@ -80,8 +80,9 @@ Parameters ReadH5OimDataFilter::parameters() const 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::EbsdReaderType::Oim, OEMEbsdScanSelectionParameter::ExtensionsType{".h5"})); - params.insertLinkableParameter(std::make_unique( - k_CombineScans_Key, "Combine Scans", "If true combines each of the multiple scans into a single image geometry along the z axis, else each will result in an individual geometry", true)); + params.insertLinkableParameter( + std::make_unique(k_CombineScans_Key, "Stack Scans Along Z Axis", + "If true combines each of the multiple scans into a single image geometry along the z axis, else each will result in an individual geometry", true)); 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"})); params.insert(std::make_unique(k_ReadPatternData_Key, "Import Pattern Data", "Whether or not to import the pattern data", false)); diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5OinaDataFilter.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5OinaDataFilter.cpp index 20dd21d88b..2a0ad7902c 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5OinaDataFilter.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5OinaDataFilter.cpp @@ -66,8 +66,9 @@ Parameters ReadH5OinaDataFilter::parameters() const params.insert(std::make_unique(k_SelectedScanNames_Key, "Scan Names", "The name of the scan in the .h5oina file. Oxford can store multiple scans in a single file", OEMEbsdScanSelectionParameter::ValueType{}, OEMEbsdScanSelectionParameter::EbsdReaderType::H5Oina, OEMEbsdScanSelectionParameter::ExtensionsType{".h5oina"})); - params.insertLinkableParameter(std::make_unique( - k_CombineScans_Key, "Combine Scans", "If true combines each of the multiple scans into a single image geometry along the z axis, else each will result in an individual geometry", true)); + params.insertLinkableParameter( + std::make_unique(k_CombineScans_Key, "Stack Scans Along Z Axis", + "If true combines each of the multiple scans into a single image geometry along the z axis, else each will result in an individual geometry", true)); params.insert(std::make_unique(k_EdaxHexagonalAlignment_Key, "Convert Hexagonal X-Axis to EDAX Standard", "Whether or not to convert a Hexagonal phase to the EDAX standard for x-axis alignment", true)); params.insert(std::make_unique(k_ConvertPhaseToInt32_Key, "Convert Phase Data to Int32", "Native Phases data value is uint8. Convert to Int32 for better filter compatibility", true)); diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/utilities/IEbsdOemReader.hpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/utilities/IEbsdOemReader.hpp index 7faf74d227..5178b5bc63 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/utilities/IEbsdOemReader.hpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/utilities/IEbsdOemReader.hpp @@ -81,13 +81,6 @@ class ORIENTATIONANALYSIS_EXPORT IEbsdOemReader auto& imageGeom = m_DataStructure.getDataRefAs(DataPath({currentScanName})); imageGeom.setUnits(IGeometry::LengthUnit::Micrometer); copyDataResults = copyRawEbsdData(currentScanName); - - if(copyDataResults.invalid()) - { - return copyDataResults; - } - - copyDataResults = updateOrigin(currentScanName); } if(copyDataResults.invalid()) @@ -133,8 +126,7 @@ class ORIENTATIONANALYSIS_EXPORT IEbsdOemReader const DataPath cellEnsembleAM = imagePath.createChildPath(m_InputValues->CellEnsembleAttributeMatrixName); auto& crystalStructures = m_DataStructure.getDataRefAs(cellEnsembleAM.createChildPath(EbsdLib::AngFile::CrystalStructures)); auto& materialNames = m_DataStructure.getDataRefAs(cellEnsembleAM.createChildPath(EbsdLib::AngFile::MaterialName)); - auto& latticeConstantsArray = - m_DataStructure.getDataRefAs(cellEnsembleAM.createChildPath(EbsdLib::AngFile::LatticeConstants)); + auto& latticeConstantsArray = m_DataStructure.getDataRefAs(cellEnsembleAM.createChildPath(EbsdLib::AngFile::LatticeConstants)); Float32Array::store_type* latticeConstants = latticeConstantsArray.getDataStore(); crystalStructures[0] = EbsdLib::CrystalStructure::UnknownCrystalStructure; @@ -160,28 +152,19 @@ class ORIENTATIONANALYSIS_EXPORT IEbsdOemReader latticeConstants->setComponent(phaseId, 5, lc[5]); } - return {}; + if(m_InputValues->CombineScans) + { + // No need to update origin + return {}; + } + + return updateOrigin(scanName); } + virtual Result<> updateOrigin(const std::string& scanName) = 0; + virtual Result<> copyRawEbsdData(int index) = 0; virtual Result<> copyRawEbsdData(const std::string& scanName) = 0; - virtual Result<> updateOrigin(const std::string& scanName) - { - const DataPath imagePath({scanName}); - - auto& imageGeom = m_DataStructure.getDataRefAs(imagePath); - const usize totalCells = imageGeom.getNumberOfCells(); - - const auto* xPos = reinterpret_cast(m_Reader->getPointerByName(EbsdLib::Ang::XPosition)); - const auto* yPos = reinterpret_cast(m_Reader->getPointerByName(EbsdLib::Ang::YPosition)); - - float32 minX = *std::min_element(xPos, xPos + totalCells); - float32 minY = *std::min_element(yPos, yPos + totalCells); - - imageGeom.setOrigin(minX, minY, 0.0f); - - return {}; - } protected: std::shared_ptr m_Reader;