Skip to content

Commit ac503cd

Browse files
committed
BUG: Fixes incorrect number of features in the feature Attribute Matrix
The number of tuples of the Feature Attribute Matrix was always +1 due to how a counter was being incremented. A new unit test was created to more thoroughly test both the Ebsd and CAxis segment features filters
1 parent 2729ec1 commit ac503cd

File tree

9 files changed

+441
-107
lines changed

9 files changed

+441
-107
lines changed

src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/EBSDSegmentFeaturesFilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Parameters EBSDSegmentFeaturesFilter::parameters() const
6464
params.insertSeparator(Parameters::Separator{"Input Parameter(s)"});
6565
params.insert(std::make_unique<Float32Parameter>(k_MisorientationTolerance_Key, "Misorientation Tolerance (Degrees)",
6666
"Tolerance (in degrees) used to determine if neighboring Cells belong to the same Feature", 5.0f));
67-
params.insert(std::make_unique<BoolParameter>(k_RandomizeFeatureIds_Key, "Randomize Feature IDs", "Specifies if feature IDs should be randomized during calculations", false));
67+
params.insert(std::make_unique<BoolParameter>(k_RandomizeFeatureIds_Key, "Randomize Feature Ids", "Specifies if feature IDs should be randomized during calculations", false));
6868
params.insert(std::make_unique<ChoicesParameter>(k_NeighborScheme_Key, "Neighbor Scheme", "How many neighbors to use", segment_features::k_6NeighborIndex, segment_features::k_OperationChoices));
6969

7070
params.insertSeparator(Parameters::Separator{"Optional Data Mask"});

src/Plugins/OrientationAnalysis/test/CAxisSegmentFeaturesTest.cpp

Lines changed: 220 additions & 60 deletions
Large diffs are not rendered by default.

src/Plugins/OrientationAnalysis/test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ if(EXISTS "${DREAM3D_DATA_DIR}" AND SIMPLNX_DOWNLOAD_TEST_FILES)
152152
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME 7_ComputeAvgOrientation.tar.gz SHA512 5ee425b9a45da4daab1d43a870b54d57ac8d8e300acda162fa7a974a22b9f5662a98e768cebac1844eb87fcb2bb01624ffaf117d3aacc722aa8701712cbf3c52)
153153
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME 7_read_oem_ebsd_h5_files.tar.gz SHA512 95fa4cc0fb6bce26bfd6d28c0205a9e0f6497ad876a7cc4381117e668836936b35683ed5ec757cadd124a6c6fec7b38fe11f72512105bbd677bcf4210892ac19)
154154
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME read_ang_test.tar.gz SHA512 de7cd89d925da01f291f44686964ec89d469659d0005219f9869afe26b8f62af278461ac3f5deb3afe7f3e65ec074ab3a1357d77a1a5f92eb3a1ea8cc5e4b236)
155+
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME compute_feature_neighbor_caxis_misalignments.tar.gz SHA512 955cd35b7ae24579ef9c533df34e1118012a8e5e2a71f8613117c714fc220c5dfa78d91a2964b41752e70684b79d4aa790e488e9a7be4c9dcf7b642ee2897ceb)
156+
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME segment_features_test_data.tar.gz SHA512 a345212de5bb969490d66a4ae1066a7ab3c85890d9dc7f26554b421fb2171626f15a842ff76573b1f9f71625828a46bb304df6416a2894dba7a84c0014f0c00a)
155157

156158
endif()
157159

src/Plugins/OrientationAnalysis/test/EBSDSegmentFeaturesFilterTest.cpp

Lines changed: 206 additions & 34 deletions
Large diffs are not rendered by default.

src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RandomizeFeatureIdsFilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Uuid RandomizeFeatureIdsFilter::uuid() const
4040
//------------------------------------------------------------------------------
4141
std::string RandomizeFeatureIdsFilter::humanName() const
4242
{
43-
return "Randomize Feature IDs";
43+
return "Randomize Feature Ids";
4444
}
4545

4646
//------------------------------------------------------------------------------

src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ScalarSegmentFeaturesFilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Parameters ScalarSegmentFeaturesFilter::parameters() const
6464

6565
params.insertSeparator(Parameters::Separator{"Input Parameter(s)"});
6666
params.insert(std::make_unique<NumberParameter<int>>(k_ScalarToleranceKey, "Scalar Tolerance", "Tolerance for segmenting input Cell Data", 1));
67-
params.insert(std::make_unique<BoolParameter>(k_RandomizeFeatures_Key, "Randomize Feature IDs", "Specifies if feature IDs should be randomized during calculations", false));
67+
params.insert(std::make_unique<BoolParameter>(k_RandomizeFeatures_Key, "Randomize Feature Ids", "Specifies if feature IDs should be randomized during calculations", false));
6868

6969
params.insert(std::make_unique<ChoicesParameter>(k_NeighborScheme_Key, "Neighbor Scheme", "How many neighbors to use", segment_features::k_6NeighborIndex, segment_features::k_OperationChoices));
7070

src/Plugins/SimplnxCore/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ set(${PLUGIN_NAME}UnitTest_SRCS
131131
ReverseTriangleWindingTest.cpp
132132
RobustAutomaticThresholdTest.cpp
133133
RotateSampleRefFrameTest.cpp
134-
ScalarSegmentFeaturesFilterTest.cpp
134+
ScalarSegmentFeaturesTest.cpp
135135
SetImageGeomOriginScalingFilterTest.cpp
136136
SharedFeatureFaceTest.cpp
137137
SilhouetteTest.cpp

src/Plugins/SimplnxCore/test/ScalarSegmentFeaturesFilterTest.cpp renamed to src/Plugins/SimplnxCore/test/ScalarSegmentFeaturesTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const std::string k_ExemplaryCombinationFaceOnlyFeatureIdsName = "Exemplary Comb
3131
const std::string k_ExemplaryCombinationAllConnectedFeatureIdsName = "Exemplary Combination FeatureIds - All Connected";
3232
} // namespace
3333

34-
TEST_CASE("SimplnxCore::ScalarSegmentFeatures", "[Reconstruction][ScalarSegmentFeatures]")
34+
TEST_CASE("SimplnxCore::ScalarSegmentFeatures", "[SimplnxCore][ScalarSegmentFeatures]")
3535
{
3636
UnitTest::LoadPlugins();
3737

src/simplnx/Utilities/SegmentFeatures.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Result<> SegmentFeatures::execute(IGridGeometry* gridGeom)
148148
// Initialize a sequence of execution modifiers
149149
int32 gnum = 1;
150150
int64 nextSeed = 0;
151-
int64 seed = getSeed(gnum, nextSeed);
151+
int64 seed = 0; // Always use the very first value of the array that we are using to segment
152152
usize size = 0;
153153

154154
// Initialize containers
@@ -205,18 +205,18 @@ Result<> SegmentFeatures::execute(IGridGeometry* gridGeom)
205205
totalVoxelsSegmented += size;
206206
}
207207

208+
// Send a progress message
209+
throttledMessenger.sendThrottledMessage([&]() { return fmt::format("{:.2f}% - Features Found: {}", 100.0f * static_cast<float>(totalVoxelsSegmented) / static_cast<float>(totalVoxels), gnum); });
210+
// Increment or set values for the next iteration
208211
voxelsList.assign(size + 1, -1);
209212
gnum++;
210-
211-
throttledMessenger.sendThrottledMessage([&]() { return fmt::format("{:.2f}% - Features Found: {}", 100.0f * static_cast<float>(totalVoxelsSegmented) / static_cast<float>(totalVoxels), gnum); });
212-
213+
// Get the next seed value
214+
seed = getSeed(gnum, nextSeed); // If seed ends up being -1, then we will exit the loop.
213215
nextSeed = seed + 1;
214-
seed = getSeed(gnum, nextSeed);
215216
}
216217

217-
m_MessageHelper.sendMessage(fmt::format("Total Features Found: {}", gnum));
218-
219-
m_FoundFeatures = gnum;
218+
m_FoundFeatures = gnum - 1; // Decrement the gnum because it will end up 1 larger than it should have been.
219+
m_MessageHelper.sendMessage(fmt::format("Total Features Found: {}", m_FoundFeatures));
220220
return {};
221221
}
222222

0 commit comments

Comments
 (0)