Skip to content

Commit 7318043

Browse files
committed
BUG: WritePoleFigure filter bug fixes for Hex convention and unit test updates
1 parent 48a8a4f commit 7318043

4 files changed

Lines changed: 307 additions & 471 deletions

File tree

src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/WritePoleFigure.cpp

Lines changed: 80 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,7 @@ Result<> WritePoleFigure::operator()()
603603
continue;
604604
} // Skip because we have no Pole Figure data
605605

606-
std::vector<ebsdlib::UInt8ArrayType::Pointer> figures;
607-
std::vector<ebsdlib::DoubleArrayType::Pointer> intensityImages;
606+
// std::vector<ebsdlib::UInt8ArrayType::Pointer> figures;
608607

609608
ebsdlib::PoleFigureConfiguration_t config;
610609
config.eulers = subEulerAnglesPtr.get();
@@ -616,108 +615,97 @@ Result<> WritePoleFigure::operator()()
616615
config.hexConvention = m_InputValues->HexConvention;
617616

618617
m_MessageHandler({IFilter::Message::Type::Info, fmt::format("Generating Pole Figures for Phase {}", phase)});
619-
620-
switch(crystalStructures[phase])
618+
if(m_InputValues->SaveIntensityData)
621619
{
622-
case ebsdlib::CrystalStructure::Cubic_High:
623-
figures = makePoleFigures<ebsdlib::CubicOps>(config);
624-
intensityImages = createIntensityPoleFigures<ebsdlib::CubicOps>(config, m_InputValues->NormalizeToMRD);
625-
break;
626-
case ebsdlib::CrystalStructure::Cubic_Low:
627-
figures = makePoleFigures<ebsdlib::CubicLowOps>(config);
628-
intensityImages = createIntensityPoleFigures<ebsdlib::CubicLowOps>(config, m_InputValues->NormalizeToMRD);
629-
break;
630-
case ebsdlib::CrystalStructure::Hexagonal_High:
631-
figures = makePoleFigures<ebsdlib::HexagonalOps>(config);
632-
intensityImages = createIntensityPoleFigures<ebsdlib::HexagonalOps>(config, m_InputValues->NormalizeToMRD);
633-
break;
634-
case ebsdlib::CrystalStructure::Hexagonal_Low:
635-
figures = makePoleFigures<ebsdlib::HexagonalLowOps>(config);
636-
intensityImages = createIntensityPoleFigures<ebsdlib::HexagonalLowOps>(config, m_InputValues->NormalizeToMRD);
637-
break;
638-
case ebsdlib::CrystalStructure::Trigonal_High:
639-
figures = makePoleFigures<ebsdlib::TrigonalOps>(config);
640-
intensityImages = createIntensityPoleFigures<ebsdlib::TrigonalOps>(config, m_InputValues->NormalizeToMRD);
641-
// setWarningCondition(-1010, "Trigonal High Symmetry is not supported for Pole figures. This phase will be omitted from results");
642-
break;
643-
case ebsdlib::CrystalStructure::Trigonal_Low:
644-
figures = makePoleFigures<ebsdlib::TrigonalLowOps>(config);
645-
intensityImages = createIntensityPoleFigures<ebsdlib::TrigonalLowOps>(config, m_InputValues->NormalizeToMRD);
646-
// setWarningCondition(-1010, "Trigonal Low Symmetry is not supported for Pole figures. This phase will be omitted from results");
647-
break;
648-
case ebsdlib::CrystalStructure::Tetragonal_High:
649-
figures = makePoleFigures<ebsdlib::TetragonalOps>(config);
650-
intensityImages = createIntensityPoleFigures<ebsdlib::TetragonalOps>(config, m_InputValues->NormalizeToMRD);
651-
// setWarningCondition(-1010, "Tetragonal High Symmetry is not supported for Pole figures. This phase will be omitted from results");
652-
break;
653-
case ebsdlib::CrystalStructure::Tetragonal_Low:
654-
figures = makePoleFigures<ebsdlib::TetragonalLowOps>(config);
655-
intensityImages = createIntensityPoleFigures<ebsdlib::TetragonalLowOps>(config, m_InputValues->NormalizeToMRD);
656-
// setWarningCondition(-1010, "Tetragonal Low Symmetry is not supported for Pole figures. This phase will be omitted from results");
657-
break;
658-
case ebsdlib::CrystalStructure::OrthoRhombic:
659-
figures = makePoleFigures<ebsdlib::OrthoRhombicOps>(config);
660-
intensityImages = createIntensityPoleFigures<ebsdlib::OrthoRhombicOps>(config, m_InputValues->NormalizeToMRD);
661-
break;
662-
case ebsdlib::CrystalStructure::Monoclinic:
663-
figures = makePoleFigures<ebsdlib::MonoclinicOps>(config);
664-
intensityImages = createIntensityPoleFigures<ebsdlib::MonoclinicOps>(config, m_InputValues->NormalizeToMRD);
665-
break;
666-
case ebsdlib::CrystalStructure::Triclinic:
667-
figures = makePoleFigures<ebsdlib::TriclinicOps>(config);
668-
intensityImages = createIntensityPoleFigures<ebsdlib::TriclinicOps>(config, m_InputValues->NormalizeToMRD);
669-
break;
670-
default:
671-
break;
672-
}
620+
std::vector<ebsdlib::DoubleArrayType::Pointer> intensityImages;
673621

674-
if(m_InputValues->SaveIntensityData && intensityImages.size() == 3)
675-
{
676-
DataPath amPath = m_InputValues->IntensityGeometryDataPath.createChildPath(write_pole_figure::k_ImageAttrMatName);
677-
// If there is more than a single phase we will need to add more arrays to the DataStructure
678-
if(phase > 1)
622+
switch(crystalStructures[phase])
679623
{
680-
const std::vector<size_t> intensityImageDims = {static_cast<usize>(config.imageDim), static_cast<usize>(config.imageDim), 1ULL};
681-
DataPath arrayDataPath = amPath.createChildPath(fmt::format("Phase_{}_{}", phase, m_InputValues->IntensityPlot1Name));
682-
Result<> result = ArrayCreationUtilities::CreateArray<float64>(m_DataStructure, intensityImageDims, {1ULL}, arrayDataPath, IDataAction::Mode::Execute);
624+
case ebsdlib::CrystalStructure::Cubic_High:
625+
intensityImages = createIntensityPoleFigures<ebsdlib::CubicOps>(config, m_InputValues->NormalizeToMRD);
626+
break;
627+
case ebsdlib::CrystalStructure::Cubic_Low:
628+
intensityImages = createIntensityPoleFigures<ebsdlib::CubicLowOps>(config, m_InputValues->NormalizeToMRD);
629+
break;
630+
case ebsdlib::CrystalStructure::Hexagonal_High:
631+
intensityImages = createIntensityPoleFigures<ebsdlib::HexagonalOps>(config, m_InputValues->NormalizeToMRD);
632+
break;
633+
case ebsdlib::CrystalStructure::Hexagonal_Low:
634+
intensityImages = createIntensityPoleFigures<ebsdlib::HexagonalLowOps>(config, m_InputValues->NormalizeToMRD);
635+
break;
636+
case ebsdlib::CrystalStructure::Trigonal_High:
637+
intensityImages = createIntensityPoleFigures<ebsdlib::TrigonalOps>(config, m_InputValues->NormalizeToMRD);
638+
break;
639+
case ebsdlib::CrystalStructure::Trigonal_Low:
640+
intensityImages = createIntensityPoleFigures<ebsdlib::TrigonalLowOps>(config, m_InputValues->NormalizeToMRD);
641+
break;
642+
case ebsdlib::CrystalStructure::Tetragonal_High:
643+
intensityImages = createIntensityPoleFigures<ebsdlib::TetragonalOps>(config, m_InputValues->NormalizeToMRD);
644+
break;
645+
case ebsdlib::CrystalStructure::Tetragonal_Low:
646+
intensityImages = createIntensityPoleFigures<ebsdlib::TetragonalLowOps>(config, m_InputValues->NormalizeToMRD);
647+
break;
648+
case ebsdlib::CrystalStructure::OrthoRhombic:
649+
intensityImages = createIntensityPoleFigures<ebsdlib::OrthoRhombicOps>(config, m_InputValues->NormalizeToMRD);
650+
break;
651+
case ebsdlib::CrystalStructure::Monoclinic:
652+
intensityImages = createIntensityPoleFigures<ebsdlib::MonoclinicOps>(config, m_InputValues->NormalizeToMRD);
653+
break;
654+
case ebsdlib::CrystalStructure::Triclinic:
655+
intensityImages = createIntensityPoleFigures<ebsdlib::TriclinicOps>(config, m_InputValues->NormalizeToMRD);
656+
break;
657+
default:
658+
break;
659+
}
683660

684-
arrayDataPath = amPath.createChildPath(fmt::format("Phase_{}_{}", phase, m_InputValues->IntensityPlot2Name));
685-
result = ArrayCreationUtilities::CreateArray<float64>(m_DataStructure, intensityImageDims, {1ULL}, arrayDataPath, IDataAction::Mode::Execute);
661+
if(intensityImages.size() == 3)
662+
{
663+
DataPath amPath = m_InputValues->IntensityGeometryDataPath.createChildPath(write_pole_figure::k_ImageAttrMatName);
664+
// If there is more than a single phase we will need to add more arrays to the DataStructure
665+
if(phase > 1)
666+
{
667+
const std::vector<size_t> intensityImageDims = {static_cast<usize>(config.imageDim), static_cast<usize>(config.imageDim), 1ULL};
668+
DataPath arrayDataPath = amPath.createChildPath(fmt::format("Phase_{}_{}", phase, m_InputValues->IntensityPlot1Name));
669+
Result<> result = ArrayCreationUtilities::CreateArray<float64>(m_DataStructure, intensityImageDims, {1ULL}, arrayDataPath, IDataAction::Mode::Execute);
686670

687-
arrayDataPath = amPath.createChildPath(fmt::format("Phase_{}_{}", phase, m_InputValues->IntensityPlot3Name));
688-
result = ArrayCreationUtilities::CreateArray<float64>(m_DataStructure, intensityImageDims, {1ULL}, arrayDataPath, IDataAction::Mode::Execute);
689-
}
671+
arrayDataPath = amPath.createChildPath(fmt::format("Phase_{}_{}", phase, m_InputValues->IntensityPlot2Name));
672+
result = ArrayCreationUtilities::CreateArray<float64>(m_DataStructure, intensityImageDims, {1ULL}, arrayDataPath, IDataAction::Mode::Execute);
690673

691-
auto intensityPlot1Array = m_DataStructure.getDataRefAs<Float64Array>(amPath.createChildPath(fmt::format("Phase_{}_{}", phase, m_InputValues->IntensityPlot1Name)));
692-
auto intensityPlot2Array = m_DataStructure.getDataRefAs<Float64Array>(amPath.createChildPath(fmt::format("Phase_{}_{}", phase, m_InputValues->IntensityPlot2Name)));
693-
auto intensityPlot3Array = m_DataStructure.getDataRefAs<Float64Array>(amPath.createChildPath(fmt::format("Phase_{}_{}", phase, m_InputValues->IntensityPlot3Name)));
674+
arrayDataPath = amPath.createChildPath(fmt::format("Phase_{}_{}", phase, m_InputValues->IntensityPlot3Name));
675+
result = ArrayCreationUtilities::CreateArray<float64>(m_DataStructure, intensityImageDims, {1ULL}, arrayDataPath, IDataAction::Mode::Execute);
676+
}
694677

695-
std::vector<size_t> compDims = {1ULL};
696-
for(int imageIndex = 0; imageIndex < figures.size(); imageIndex++)
697-
{
698-
intensityImages[imageIndex] = flipAndMirrorPoleFigure<double>(intensityImages[imageIndex].get(), config);
699-
}
678+
auto intensityPlot1Array = m_DataStructure.getDataRefAs<Float64Array>(amPath.createChildPath(fmt::format("Phase_{}_{}", phase, m_InputValues->IntensityPlot1Name)));
679+
auto intensityPlot2Array = m_DataStructure.getDataRefAs<Float64Array>(amPath.createChildPath(fmt::format("Phase_{}_{}", phase, m_InputValues->IntensityPlot2Name)));
680+
auto intensityPlot3Array = m_DataStructure.getDataRefAs<Float64Array>(amPath.createChildPath(fmt::format("Phase_{}_{}", phase, m_InputValues->IntensityPlot3Name)));
700681

701-
std::copy(intensityImages[0]->begin(), intensityImages[0]->end(), intensityPlot1Array.begin());
702-
std::copy(intensityImages[1]->begin(), intensityImages[1]->end(), intensityPlot2Array.begin());
703-
std::copy(intensityImages[2]->begin(), intensityImages[2]->end(), intensityPlot3Array.begin());
682+
std::vector<size_t> compDims = {1ULL};
683+
for(int imageIndex = 0; imageIndex < intensityImages.size(); imageIndex++)
684+
{
685+
intensityImages[imageIndex] = flipAndMirrorPoleFigure<double>(intensityImages[imageIndex].get(), config);
686+
}
704687

705-
DataPath metaDataPath = m_InputValues->IntensityGeometryDataPath.createChildPath(write_pole_figure::k_MetaDataName);
706-
auto metaDataArrayRef = m_DataStructure.getDataRefAs<StringArray>(metaDataPath);
707-
if(metaDataArrayRef.getNumberOfTuples() != numPhases)
708-
{
709-
metaDataArrayRef.resizeTuples(std::vector<usize>{numPhases});
710-
}
688+
std::copy(intensityImages[0]->begin(), intensityImages[0]->end(), intensityPlot1Array.begin());
689+
std::copy(intensityImages[1]->begin(), intensityImages[1]->end(), intensityPlot2Array.begin());
690+
std::copy(intensityImages[2]->begin(), intensityImages[2]->end(), intensityPlot3Array.begin());
711691

712-
std::vector<std::string> laueNames = ebsdlib::LaueOps::GetLaueNames();
713-
const uint32_t laueIndex = crystalStructures[phase];
714-
const std::string materialName = materialNames[phase];
692+
DataPath metaDataPath = m_InputValues->IntensityGeometryDataPath.createChildPath(write_pole_figure::k_MetaDataName);
693+
auto metaDataArrayRef = m_DataStructure.getDataRefAs<StringArray>(metaDataPath);
694+
if(metaDataArrayRef.getNumberOfTuples() != numPhases)
695+
{
696+
metaDataArrayRef.resizeTuples(std::vector<usize>{numPhases});
697+
}
715698

716-
metaDataArrayRef[phase] = fmt::format("Phase Num: {}\nMaterial Name: {}\nLaue Group: {}\nHemisphere: Northern\nSamples: {}\nLambert Square Dim: {}", phase, materialName, laueNames[laueIndex],
717-
config.eulers->getNumberOfTuples(), config.lambertDim);
699+
std::vector<std::string> laueNames = ebsdlib::LaueOps::GetLaueNames();
700+
const uint32_t laueIndex = crystalStructures[phase];
701+
const std::string materialName = materialNames[phase];
702+
703+
metaDataArrayRef[phase] = fmt::format("Phase Num: {}\nMaterial Name: {}\nLaue Group: {}\nHemisphere: Northern\nSamples: {}\nLambert Square Dim: {}", phase, materialName, laueNames[laueIndex],
704+
config.eulers->getNumberOfTuples(), config.lambertDim);
705+
}
718706
}
719707

720-
if(figures.size() == 3)
708+
if(m_InputValues->SaveAsImageGeometry || m_InputValues->WriteImageToDisk)
721709
{
722710
// Build the composite configuration
723711
ebsdlib::CompositePoleFigureConfiguration_t compositeConfig;
@@ -740,6 +728,7 @@ Result<> WritePoleFigure::operator()()
740728
compositeConfig.phaseName = materialNames[phase];
741729
compositeConfig.phaseNumber = static_cast<int32_t>(phase);
742730
compositeConfig.title = m_InputValues->Title;
731+
compositeConfig.hexConvention = m_InputValues->HexConvention;
743732

744733
// Generate the composite pole figure image
745734
ebsdlib::PoleFigureCompositor compositor;

src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/WritePoleFigureFilter.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ float32 GetXCharWidth(int32 imageSize, float32 fontPtSize)
4949
tempContext.set_font(m_LatoBold.data(), static_cast<int>(m_LatoBold.size()), fontPtSize);
5050
return tempContext.measure_text("X");
5151
}
52+
5253
} // namespace
5354

5455
namespace nx::core
@@ -104,7 +105,7 @@ Parameters WritePoleFigureFilter::parameters() const
104105
" X parallel to a: EDAX/TSL/OIM Analysis convention. This is the convention every released DREAM.3D / DREAM3DNX / SIMPL / SIMPLNX file stores hex/trig EulerAngles in.\n"
105106
" X parallel to a*: MTEX / Oxford Channel 5 / AZtec convention. Pick this for apples-to-apples comparison against MTEX-produced pole figures.\n"
106107
"Cubic, tetragonal, orthorhombic, monoclinic, and triclinic phases ignore this setting.",
107-
0, ChoicesParameter::Choices{"X parallel to a (EDAX/TSL)", "X parallel to a* (MTEX)"}));
108+
0, ChoicesParameter::Choices{"X || A (EDAX/TSL)", "X || A* (MTEX/Aztec)"}));
108109

109110
params.insertSeparator(Parameters::Separator{"Input Orientation Data"});
110111
params.insert(std::make_unique<ArraySelectionParameter>(k_CellEulerAnglesArrayPath_Key, "Euler Angles", "Three angles defining the orientation of the Element in Bunge convention (Z-X-Z)",
@@ -210,8 +211,7 @@ IFilter::PreflightResult WritePoleFigureFilter::preflightImpl(const DataStructur
210211

211212
nx::core::Result<OutputActions> resultOutputActions;
212213

213-
// Roughly calculate the output dimensions of the ImageGeometry. This may change
214-
// in small amounts due to the XCharWidth not being calculated.
214+
// Roughly calculate the output dimensions of the ImageGeometry.
215215
float32 fontPtSize = pImageSizeValue / 16.0f;
216216
float32 margins = pImageSizeValue / 32.0f;
217217

@@ -316,16 +316,7 @@ Result<> WritePoleFigureFilter::executeImpl(DataStructure& dataStructure, const
316316
inputValues.IntensityPlot1Name = filterArgs.value<DataObjectNameParameter::ValueType>(k_IntensityPlot1Name);
317317
inputValues.IntensityPlot2Name = filterArgs.value<DataObjectNameParameter::ValueType>(k_IntensityPlot2Name);
318318
inputValues.IntensityPlot3Name = filterArgs.value<DataObjectNameParameter::ValueType>(k_IntensityPlot3Name);
319-
320-
switch(filterArgs.value<ChoicesParameter::ValueType>(k_HexConvention_Key))
321-
{
322-
case 1:
323-
inputValues.HexConvention = ebsdlib::HexConvention::XParallelAStar;
324-
break;
325-
default:
326-
inputValues.HexConvention = ebsdlib::HexConvention::XParallelA;
327-
break;
328-
}
319+
inputValues.HexConvention = static_cast<ebsdlib::HexConvention>(filterArgs.value<ChoicesParameter::ValueType>(k_HexConvention_Key));
329320

330321
return WritePoleFigure(dataStructure, messageHandler, shouldCancel, &inputValues)();
331322
}

src/Plugins/OrientationAnalysis/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ if(EXISTS "${DREAM3D_DATA_DIR}" AND SIMPLNX_DOWNLOAD_TEST_FILES)
148148
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME H5Oina_Test_Data.tar.gz SHA512 346573ac6b96983680078e8b0a401aa25bd9302dff382ca86ae4e503ded6db3947c4c5611ee603db519d8a8dc6ed35b044a7bfea9880fade5ab54479d140ea03 )
149149
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME INL_writer.tar.gz SHA512 7d723351e51e84540abfbc38e69a6014852ba34808f9d216a27063a616bcfbd5eb708405305fd83334e48c9ca133d3d0be797c05040e4a115cc612e385d9ada6)
150150
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME neighbor_orientation_correlation.tar.gz SHA512 122367452174ade2f24dde7a4610bddc4f147a223722d9b30c1df9eaa2cd2bf25e1c7957aba83f3f9de79b4eadd79339b848f9530d1ebf44c69244ea5442cf85)
151-
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME PoleFigure_Exemplars_v5.tar.gz SHA512 a092b02a734ac706143c1c9ded0206f141b1f8a1359621e0bbfdbc8b4188ccc075151405d1c931292e9d9952e428877f14196e751f82a3c1cdbf734366ea1293)
151+
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME Pole_Figure_Exemplars_v6.tar.gz SHA512 23ad8853c38c66f498c7a9c43d6152419506b2bcb6c7e4854728dd3ad81efd309541981bf703ad9b0a1e9b506a0098da918599d5209cb06353281d9cecf39223)
152152
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME read_ang_test.tar.gz SHA512 de7cd89d925da01f291f44686964ec89d469659d0005219f9869afe26b8f62af278461ac3f5deb3afe7f3e65ec074ab3a1357d77a1a5f92eb3a1ea8cc5e4b236)
153153
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME segment_features_test_data.tar.gz SHA512 317d69384330d40c673f8e1a42df003dede5ac85331b2549e9f45467f7af6b74284f8dad1120427690719ebcd5066830e17031533381cc2cc0cc8622a422b914)
154154
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME Small_IN100_Ang_Files.tar.gz SHA512 79e9f6948d4e8e06187e11216a67596fa786ffd2700e51f594ad014090383eb8bcc003e14de2e88082aa9ae512cc4fc9cee22c80066fc54f38c3ebc75267eb5b)

0 commit comments

Comments
 (0)