Skip to content

Commit 3413c2e

Browse files
authored
FILT: Rename ComputeMisorientations to ComputeFeatureNeighborMisorientations, add ComputeMisorientations (#1239)
* FILT: Rename ComputeMisorientations to ComputeFeatureNeighborMisorientations * FILT: ComputeMisorientations Filter Added This filter computes the misorientation between pair of Euler Angles and outputs the misorientation as an Axis-Angle value. Also computes the Misorientation between a reference orientation and the Euler Angles. Signed-off-by: Michael Jackson <[email protected]> --------- Signed-off-by: Michael Jackson <[email protected]>
1 parent 8c3e463 commit 3413c2e

20 files changed

+1111
-303
lines changed

src/Plugins/OrientationAnalysis/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ set(FilterList
4747
ComputeGBPDMetricBasedFilter
4848
ComputeIPFColorsFilter
4949
ComputeKernelAvgMisorientationsFilter
50+
ComputeFeatureNeighborMisorientationsFilter
5051
ComputeMisorientationsFilter
5152
ComputeQuaternionConjugateFilter
5253
ComputeSchmidsFilter
@@ -86,7 +87,7 @@ set(STUB_FILTERS
8687
ComputeBoundaryStrengths
8788
FindDistsToCharactGBs
8889
ComputeKernelAvgMisorientations
89-
ComputeMisorientations
90+
ComputeFeatureNeighborMisorientations
9091
ComputeSchmids
9192
FindTwinBoundaries
9293
FindTwinBoundarySchmidFactors
@@ -182,6 +183,7 @@ set(filter_algorithms
182183
ComputeGBPDMetricBased
183184
ComputeIPFColors
184185
ComputeKernelAvgMisorientations
186+
ComputeFeatureNeighborMisorientations
185187
ComputeMisorientations
186188
ComputeQuaternionConjugate
187189
ComputeSchmids
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Compute Feature Neighbor Misorientations
2+
3+
## Group (Subgroup)
4+
5+
Statistics (Crystallographic)
6+
7+
## Description
8+
9+
This **Filter** determines, for each **Feature**, the misorientations with each of the **Features** that are in contact with it. The misorientations are stored as a list (for each **Feature**) of angles (in degrees). The axis of the misorientation is not stored by this **Filter**.
10+
11+
The user can also calculate the average misorientation between the feature and all contacting features.
12+
13+
### Notes
14+
15+
**NOTE:** Only features with identical crystal structures will be calculated. If two features have different crystal structures then a value of NaN is set for the misorientation.
16+
17+
% Auto generated parameter table will be inserted here
18+
19+
## Example Pipelines
20+
21+
+ (05) SmallIN100 Crystallographic Statistics
22+
23+
## License & Copyright
24+
25+
Please see the description file distributed with this **Plugin**
26+
27+
## DREAM3D-NX Help
28+
29+
If you need help, need to file a bug report or want to request a new feature, please head over to the [DREAM3DNX-Issues](https://github.com/BlueQuartzSoftware/DREAM3DNX-Issues/discussions) GitHub site where the community of DREAM3D-NX users can help answer your questions.

src/Plugins/OrientationAnalysis/docs/ComputeMisorientationsFilter.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
1-
# Compute Feature Neighbor Misorientations
1+
# Compute Misorientations
22

33
## Group (Subgroup)
44

5-
Statistics (Crystallographic)
5+
Tools (Orientations)
66

77
## Description
88

9-
This **Filter** determines, for each **Feature**, the misorientations with each of the **Features** that are in contact with it. The misorientations are stored as a list (for each **Feature**) of angles (in degrees). The axis of the misorientation is not stored by this **Filter**.
9+
This filter will compute the misorientation as an Axis-Angle representation between a pair of
10+
Euler Angles or an Euler Angle and a Reference Axis-Angle.
1011

11-
The user can also calculate the average misorientation between the feature and all contacting features.
12+
Use the Orientation Utility to compute an input Axis-Angle if you only have another representation.
1213

13-
### Notes
14+
## Compute by Arrays
15+
16+
If 2 Euler Arrays are used then the output is an array with the same number of Tuples as the input
17+
Euler Arrays and represents the misorientation between the each Euler Angle in the same index in each
18+
of the input Euler Angle arrays.
19+
20+
## Compute by Reference Orientation
21+
22+
In this mode the user will supply a reference orientation in the form of an Axis-Angle, where the angle portion is in degrees.
23+
Then, for every Euler Angle in the input array, the misorientation with the reference orientation will be computed.
1424

15-
**NOTE:** Only features with identical crystal structures will be calculated. If two features have different crystal structures then a value of NaN is set for the misorientation.
1625

1726
% Auto generated parameter table will be inserted here
1827

1928
## Example Pipelines
2029

21-
+ (05) SmallIN100 Crystallographic Statistics
2230

2331
## License & Copyright
2432

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#include "ComputeFeatureNeighborMisorientations.hpp"
2+
3+
#include "simplnx/Common/Constants.hpp"
4+
#include "simplnx/DataStructure/DataArray.hpp"
5+
#include "simplnx/DataStructure/DataGroup.hpp"
6+
#include "simplnx/DataStructure/NeighborList.hpp"
7+
8+
#include "EbsdLib/LaueOps/LaueOps.h"
9+
10+
using namespace nx::core;
11+
12+
// -----------------------------------------------------------------------------
13+
ComputeFeatureNeighborMisorientations::ComputeFeatureNeighborMisorientations(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel,
14+
ComputeFeatureNeighborMisorientationsInputValues* inputValues)
15+
: m_DataStructure(dataStructure)
16+
, m_InputValues(inputValues)
17+
, m_ShouldCancel(shouldCancel)
18+
, m_MessageHandler(mesgHandler)
19+
{
20+
}
21+
22+
// -----------------------------------------------------------------------------
23+
ComputeFeatureNeighborMisorientations::~ComputeFeatureNeighborMisorientations() noexcept = default;
24+
25+
// -----------------------------------------------------------------------------
26+
const std::atomic_bool& ComputeFeatureNeighborMisorientations::getCancel()
27+
{
28+
return m_ShouldCancel;
29+
}
30+
31+
// -----------------------------------------------------------------------------
32+
Result<> ComputeFeatureNeighborMisorientations::operator()()
33+
{
34+
35+
std::vector<LaueOps::Pointer> orientationOps = LaueOps::GetAllOrientationOps();
36+
37+
// Input Arrays
38+
const auto& inFeaturePhases = m_DataStructure.getDataRefAs<Int32Array>(m_InputValues->FeaturePhasesArrayPath);
39+
const auto& inAvgQuats = m_DataStructure.getDataRefAs<Float32Array>(m_InputValues->AvgQuatsArrayPath);
40+
const auto& inXtalStruct = m_DataStructure.getDataRefAs<UInt32Array>(m_InputValues->CrystalStructuresArrayPath);
41+
const auto& inNeighborList = m_DataStructure.getDataRefAs<NeighborList<int32>>(m_InputValues->NeighborListArrayPath);
42+
43+
// The output misorientations is going to be used as a vector because the output array is optional and might
44+
// not exist in the DataStructure. We cannot get it by reference.
45+
auto* avgMisorientations = m_DataStructure.getDataAs<Float32Array>(m_InputValues->AvgMisorientationsArrayName);
46+
47+
size_t tempMisoList = 0;
48+
49+
size_t totalFeatures = inFeaturePhases.getNumberOfTuples();
50+
51+
std::vector<std::vector<float>> tempMisorientationLists(totalFeatures);
52+
usize quatIndex = 0;
53+
for(size_t i = 1; i < totalFeatures; i++)
54+
{
55+
quatIndex = i * 4;
56+
57+
QuatF q1(inAvgQuats[quatIndex], inAvgQuats[quatIndex + 1], inAvgQuats[quatIndex + 2], inAvgQuats[quatIndex + 3]);
58+
uint32_t xtalType1 = inXtalStruct[inFeaturePhases[i]];
59+
60+
const NeighborList<int32_t>::VectorType& featureNeighborList = inNeighborList.getListReference(static_cast<int32_t>(i));
61+
62+
tempMisorientationLists[i].assign(featureNeighborList.size(), -1.0);
63+
64+
for(size_t j = 0; j < featureNeighborList.size(); j++)
65+
{
66+
int32_t neighborFeatureId = featureNeighborList[j];
67+
quatIndex = neighborFeatureId * 4;
68+
QuatF q2(inAvgQuats[quatIndex], inAvgQuats[quatIndex + 1], inAvgQuats[quatIndex + 2], inAvgQuats[quatIndex + 3]);
69+
uint32_t xtalType2 = inXtalStruct[inFeaturePhases[neighborFeatureId]];
70+
tempMisoList = featureNeighborList.size();
71+
if(xtalType1 == xtalType2 && static_cast<int64_t>(xtalType1) < static_cast<int64_t>(orientationOps.size()))
72+
{
73+
OrientationD axisAngle = orientationOps[xtalType1]->calculateMisorientation(q1, q2);
74+
75+
tempMisorientationLists[i][j] = static_cast<float>(axisAngle[3] * nx::core::Constants::k_180OverPiF);
76+
if(m_InputValues->ComputeAvgMisors)
77+
{
78+
(*avgMisorientations)[i] += tempMisorientationLists[i][j];
79+
}
80+
}
81+
else
82+
{
83+
if(m_InputValues->ComputeAvgMisors)
84+
{
85+
tempMisoList > 0 ? tempMisoList-- : tempMisoList = 0;
86+
}
87+
tempMisorientationLists[i][j] = NAN;
88+
}
89+
}
90+
if(m_InputValues->ComputeAvgMisors)
91+
{
92+
if(tempMisoList != 0)
93+
{
94+
(*avgMisorientations)[i] /= static_cast<float>(tempMisoList);
95+
}
96+
else
97+
{
98+
(*avgMisorientations)[i] = NAN;
99+
}
100+
tempMisoList = 0;
101+
}
102+
}
103+
104+
// Output Variables
105+
auto& outMisorientationList = m_DataStructure.getDataRefAs<NeighborList<float32>>(m_InputValues->MisorientationListArrayName);
106+
// Set the vector for each list into the NeighborList Object
107+
for(size_t i = 1; i < totalFeatures; i++)
108+
{
109+
// Construct a shared vector<float> through the std::vector<> copy constructor.
110+
NeighborList<float>::SharedVectorType sharedMisorientationList(new std::vector<float>(tempMisorientationLists[i]));
111+
outMisorientationList.setList(static_cast<int32_t>(i), sharedMisorientationList);
112+
}
113+
114+
return {};
115+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#pragma once
2+
3+
#include "OrientationAnalysis/OrientationAnalysis_export.hpp"
4+
5+
#include "simplnx/DataStructure/DataPath.hpp"
6+
#include "simplnx/DataStructure/DataStructure.hpp"
7+
#include "simplnx/Filter/IFilter.hpp"
8+
9+
namespace nx::core
10+
{
11+
12+
struct ORIENTATIONANALYSIS_EXPORT ComputeFeatureNeighborMisorientationsInputValues
13+
{
14+
bool ComputeAvgMisors;
15+
DataPath NeighborListArrayPath;
16+
DataPath AvgQuatsArrayPath;
17+
DataPath FeaturePhasesArrayPath;
18+
DataPath CrystalStructuresArrayPath;
19+
DataPath MisorientationListArrayName;
20+
DataPath AvgMisorientationsArrayName;
21+
};
22+
23+
/**
24+
* @class
25+
*/
26+
class ORIENTATIONANALYSIS_EXPORT ComputeFeatureNeighborMisorientations
27+
{
28+
public:
29+
ComputeFeatureNeighborMisorientations(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel,
30+
ComputeFeatureNeighborMisorientationsInputValues* inputValues);
31+
~ComputeFeatureNeighborMisorientations() noexcept;
32+
33+
ComputeFeatureNeighborMisorientations(const ComputeFeatureNeighborMisorientations&) = delete;
34+
ComputeFeatureNeighborMisorientations(ComputeFeatureNeighborMisorientations&&) noexcept = delete;
35+
ComputeFeatureNeighborMisorientations& operator=(const ComputeFeatureNeighborMisorientations&) = delete;
36+
ComputeFeatureNeighborMisorientations& operator=(ComputeFeatureNeighborMisorientations&&) noexcept = delete;
37+
38+
Result<> operator()();
39+
40+
const std::atomic_bool& getCancel();
41+
42+
private:
43+
DataStructure& m_DataStructure;
44+
const ComputeFeatureNeighborMisorientationsInputValues* m_InputValues = nullptr;
45+
const std::atomic_bool& m_ShouldCancel;
46+
const IFilter::MessageHandler& m_MessageHandler;
47+
};
48+
49+
} // namespace nx::core

0 commit comments

Comments
 (0)