Skip to content

Commit

Permalink
ENH: Merge Twins Rework and Segment Features Cleanup (#955)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
Co-authored-by: Michael Jackson <mike.jackson@bluequartz.net>
  • Loading branch information
nyoungbq and imikejackson committed May 14, 2024
1 parent 984e51a commit 0c003a4
Show file tree
Hide file tree
Showing 15 changed files with 250 additions and 522 deletions.
1 change: 0 additions & 1 deletion src/Plugins/OrientationAnalysis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ set(filter_algorithms
GenerateGBCDPoleFigure
GenerateIPFColors
GenerateQuaternionConjugate
GroupFeatures
MergeTwins
NeighborOrientationCorrelation
ReadAngData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ Result<> CAxisSegmentFeatures::operator()()
active->fill(1);

// Generate the random voxel indices that will be used for the seed points to start a new grain growth/agglomeration
constexpr int64 rangeMin = 0;
const int64 rangeMax = m_FeatureIdsArray->getNumberOfTuples() - 1;
Int64Distribution distribution;
initializeStaticVoxelSeedGenerator(distribution, rangeMin, rangeMax);

execute(imageGeometry);

const auto totalFeatures = static_cast<int64>(active->getNumberOfTuples());
Expand All @@ -80,7 +75,7 @@ Result<> CAxisSegmentFeatures::operator()()
// By default we randomize grains
if(m_InputValues->RandomizeFeatureIds)
{
randomizeFeatureIds(m_FeatureIdsArray, imageGeometry->getNumberOfCells(), totalFeatures, distribution);
randomizeFeatureIds(m_FeatureIdsArray, totalFeatures);
}

return {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Result<> EBSDSegmentFeatures::operator()()

execute(gridGeom);

IDataArray* activeArray = m_DataStructure.getDataAs<IDataArray>(m_InputValues->activeArrayPath);
auto* activeArray = m_DataStructure.getDataAs<IDataArray>(m_InputValues->activeArrayPath);
auto totalFeatures = activeArray->getNumberOfTuples();
if(totalFeatures < 2)
{
Expand All @@ -57,15 +57,7 @@ Result<> EBSDSegmentFeatures::operator()()
// would look like a smooth gradient. This is a user input parameter
if(m_InputValues->shouldRandomizeFeatureIds)
{
auto totalPoints = m_QuatsArray->getNumberOfTuples();

const int64 rangeMin = 0;
const auto rangeMax = static_cast<int64>(totalPoints - 1);
Int64Distribution distribution;
initializeStaticVoxelSeedGenerator(distribution, rangeMin, rangeMax);

totalPoints = gridGeom->getNumberOfCells();
randomizeFeatureIds(m_FeatureIdsArray, totalPoints, totalFeatures, distribution);
randomizeFeatureIds(m_FeatureIdsArray, totalFeatures);
}

return {};
Expand All @@ -81,29 +73,29 @@ int64_t EBSDSegmentFeatures::getSeed(int32 gnum, int64 nextSeed) const

int64 seed = -1;
// start with the next voxel after the last seed
usize randpoint = static_cast<usize>(nextSeed);
while(seed == -1 && randpoint < totalPoints)
auto randPoint = static_cast<usize>(nextSeed);
while(seed == -1 && randPoint < totalPoints)
{
if(featureIds->getValue(randpoint) == 0) // If the GrainId of the voxel is ZERO then we can use this as a seed point
if(featureIds->getValue(randPoint) == 0) // If the GrainId of the voxel is ZERO then we can use this as a seed point
{
if((!m_InputValues->useGoodVoxels || m_GoodVoxelsArray->isTrue(randpoint)) && cellPhases->getValue(randpoint) > 0)
if((!m_InputValues->useGoodVoxels || m_GoodVoxelsArray->isTrue(randPoint)) && cellPhases->getValue(randPoint) > 0)
{
seed = static_cast<int64>(randpoint);
seed = static_cast<int64>(randPoint);
}
else
{
randpoint += 1;
randPoint += 1;
}
}
else
{
randpoint += 1;
randPoint += 1;
}
}
if(seed >= 0)
{
UInt8Array& activeArray = m_DataStructure.getDataRefAs<UInt8Array>(m_InputValues->activeArrayPath);
AttributeMatrix& cellFeatureAM = m_DataStructure.getDataRefAs<AttributeMatrix>(m_InputValues->cellFeatureAttributeMatrixPath);
auto& activeArray = m_DataStructure.getDataAs<UInt8Array>(m_InputValues->activeArrayPath)->getDataStoreRef();
auto& cellFeatureAM = m_DataStructure.getDataRefAs<AttributeMatrix>(m_InputValues->cellFeatureAttributeMatrixPath);
featureIds->setValue(static_cast<usize>(seed), gnum);
std::vector<usize> tDims = {static_cast<usize>(gnum) + 1};
cellFeatureAM.resizeTuples(tDims); // This will resize the actives array
Expand All @@ -113,15 +105,15 @@ int64_t EBSDSegmentFeatures::getSeed(int32 gnum, int64 nextSeed) const
}

// -----------------------------------------------------------------------------
bool EBSDSegmentFeatures::determineGrouping(int64 referencepoint, int64 neighborpoint, int32 gnum) const
bool EBSDSegmentFeatures::determineGrouping(int64 referencePoint, int64 neighborPoint, int32 gnum) const
{
bool group = false;

// Get the phases for each voxel
nx::core::AbstractDataStore<int32>* cellPhases = m_CellPhases->getDataStore();

int32_t phase1 = (*m_CrystalStructures)[(*cellPhases)[referencepoint]];
int32_t phase2 = (*m_CrystalStructures)[(*cellPhases)[neighborpoint]];
int32_t phase1 = (*m_CrystalStructures)[(*cellPhases)[referencePoint]];
int32_t phase2 = (*m_CrystalStructures)[(*cellPhases)[neighborPoint]];
// If either of the phases is 999 then we bail out now.
if(phase1 >= m_OrientationOps.size() || phase2 >= m_OrientationOps.size())
{
Expand All @@ -133,24 +125,24 @@ bool EBSDSegmentFeatures::determineGrouping(int64 referencepoint, int64 neighbor
bool neighborPointIsGood = false;
if(m_GoodVoxelsArray != nullptr)
{
neighborPointIsGood = m_GoodVoxelsArray->isTrue(neighborpoint);
neighborPointIsGood = m_GoodVoxelsArray->isTrue(neighborPoint);
}

if(featureIds[neighborpoint] == 0 && (m_GoodVoxelsArray == nullptr || neighborPointIsGood))
if(featureIds[neighborPoint] == 0 && (m_GoodVoxelsArray == nullptr || neighborPointIsGood))
{
float w = std::numeric_limits<float>::max();
QuatF q1(currentQuatPtr[referencepoint * 4], currentQuatPtr[referencepoint * 4 + 1], currentQuatPtr[referencepoint * 4 + 2], currentQuatPtr[referencepoint * 4 + 3]);
QuatF q2(currentQuatPtr[neighborpoint * 4 + 0], currentQuatPtr[neighborpoint * 4 + 1], currentQuatPtr[neighborpoint * 4 + 2], currentQuatPtr[neighborpoint * 4 + 3]);
QuatF q1(currentQuatPtr[referencePoint * 4], currentQuatPtr[referencePoint * 4 + 1], currentQuatPtr[referencePoint * 4 + 2], currentQuatPtr[referencePoint * 4 + 3]);
QuatF q2(currentQuatPtr[neighborPoint * 4 + 0], currentQuatPtr[neighborPoint * 4 + 1], currentQuatPtr[neighborPoint * 4 + 2], currentQuatPtr[neighborPoint * 4 + 3]);

if((*cellPhases)[referencepoint] == (*cellPhases)[neighborpoint])
if((*cellPhases)[referencePoint] == (*cellPhases)[neighborPoint])
{
OrientationF axisAngle = m_OrientationOps[phase1]->calculateMisorientation(q1, q2);
w = axisAngle[3];
}
if(w < m_InputValues->misorientationTolerance)
{
group = true;
featureIds[neighborpoint] = gnum;
featureIds[neighborPoint] = gnum;
}
}

Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 0c003a4

Please sign in to comment.