From c089bc2376892bd9a8343262807de27654ce1cf3 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Tue, 20 Feb 2024 10:27:51 -0500 Subject: [PATCH] BUG: ReadH5Ebsd-Fix issue creating proper sized Attribute Matrix for Ensemble Data (#863) Signed-off-by: Michael Jackson --- .../Filters/Algorithms/ReadH5Ebsd.cpp | 6 +---- .../Filters/ReadH5EbsdFilter.cpp | 27 ++++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5Ebsd.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5Ebsd.cpp index de3e52367d..fafaa9397c 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5Ebsd.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5Ebsd.cpp @@ -313,12 +313,9 @@ Result<> ReadH5Ebsd::operator()() std::array eulerTransAxis = volumeInfoReader->getEulerTransformationAxis(); float eulerTransAngle = volumeInfoReader->getEulerTransformationAngle(); - // This will effectively close the reader + // This will effectively close the reader and free any memory being used volumeInfoReader = H5EbsdVolumeInfo::NullPointer(); - // Now create the specific reader that we need. - H5EbsdVolumeReader::Pointer ebsdReader; - std::set mSelectedArrayNames; for(const auto& selectedArrayName : m_InputValues->hdf5DataPaths) { @@ -352,7 +349,6 @@ Result<> ReadH5Ebsd::operator()() return {MakeErrorResult(-50001, fmt::format("Could not determine or match a supported manufacturer from the data file. Supported manufacturer codes are: '{}' and '{}'", EbsdLib::Ctf::Manufacturer, EbsdLib::Ang::Manufacturer))}; } - // Sanity Check the Error Condition or the state of the EBSD Reader Object. if(m_InputValues->useRecommendedTransform) { diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5EbsdFilter.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5EbsdFilter.cpp index 6ed498defc..f0268a2dec 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5EbsdFilter.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5EbsdFilter.cpp @@ -103,7 +103,8 @@ IFilter::PreflightResult ReadH5EbsdFilter::preflightImpl(const DataStructure& da if(err < 0) { // This really should have been hit during the parameter validation... but just in case. - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + preflightUpdatedValues.push_back({"ERROR:", fmt::format("Could not read input file {}", pReadH5EbsdFilterValue.inputFilePath)}); + return {MakeErrorResult(-67500, fmt::format("Could not read input file '{}'", pReadH5EbsdFilterValue.inputFilePath)), std::move(preflightUpdatedValues)}; } std::vector dims = {0, 0, 0}; @@ -121,12 +122,6 @@ IFilter::PreflightResult ReadH5EbsdFilter::preflightImpl(const DataStructure& da resultOutputActions.value().appendAction( std::make_unique(std::move(imageGeomPath), std::move(imageGeomDims), std::move(origin), std::move(spacing), pCellAttributeMatrixNameValue)); - // Create the Ensemble AttributeMatrix - { - auto createDataGroupAction = std::make_unique(pCellEnsembleAttributeMatrixNameValue, std::vector{2}); - resultOutputActions.value().appendAction(std::move(createDataGroupAction)); - } - EbsdLib::OEM m_Manufacturer = {EbsdLib::OEM::Unknown}; std::string manufacturer = reader->getManufacturer(); if(manufacturer == EbsdLib::Ang::Manufacturer) @@ -143,12 +138,14 @@ IFilter::PreflightResult ReadH5EbsdFilter::preflightImpl(const DataStructure& da { AngFields angFeatures; reader = H5AngVolumeReader::New(); + reader->setFileName(pReadH5EbsdFilterValue.inputFilePath); names = angFeatures.getFilterFeatures>(); } else if(m_Manufacturer == EbsdLib::OEM::Oxford) { CtfFields cfeatures; reader = H5CtfVolumeReader::New(); + reader->setFileName(pReadH5EbsdFilterValue.inputFilePath); names = cfeatures.getFilterFeatures>(); } else @@ -161,7 +158,6 @@ IFilter::PreflightResult ReadH5EbsdFilter::preflightImpl(const DataStructure& da { m_SelectedArrayNames.insert(selectedArrayName); } - // std::set m_DataArrayNames = reader->getDataArrayNames(); std::vector cDims = {1ULL}; for(int32_t i = 0; i < names.size(); ++i) @@ -205,7 +201,20 @@ IFilter::PreflightResult ReadH5EbsdFilter::preflightImpl(const DataStructure& da // Now create the Ensemble arrays for the XTal Structures, Material Names and LatticeConstants cDims[0] = 1; - tupleDims = {2}; + tupleDims = {static_cast(reader->getNumPhases() + 1)}; + if(tupleDims[0] == 0) + { + return {MakeErrorResult(-67501, + fmt::format("H5EBSD File: Number of phases is ZERO. This should not have happened. Please check the source data.", pReadH5EbsdFilterValue.inputFilePath)), + std::move(preflightUpdatedValues)}; + } + + // Create the Ensemble AttributeMatrix + { + auto createDataGroupAction = std::make_unique(pCellEnsembleAttributeMatrixNameValue, tupleDims); + resultOutputActions.value().appendAction(std::move(createDataGroupAction)); + } + { const DataPath dataArrayPath = pCellEnsembleAttributeMatrixNameValue.createChildPath(EbsdLib::EnsembleData::CrystalStructures); auto action = std::make_unique(nx::core::DataType::uint32, tupleDims, cDims, dataArrayPath);