Skip to content

Commit

Permalink
Now use absolute values for comparison of principal directions
Browse files Browse the repository at this point in the history
* May be temporary depending on feedback on the issue

Signed-off-by: Jared Duffey <[email protected]>
  • Loading branch information
JDuffeyBQ committed Jul 1, 2024
1 parent 3b99ea3 commit ee160c7
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/Plugins/SimplnxCore/test/FeatureFaceCurvatureTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@

using namespace nx::core;

inline void CompareDataArrays(const DataStructure& dataStructure, const DataPath& arrayPath1, const DataPath& arrayPath2)
namespace
{
enum class FloatComparison
{
Standard,
Absolute
};

template <FloatComparison ComparisonValue = FloatComparison::Standard>
void CompareDataArrays(const DataStructure& dataStructure, const DataPath& arrayPath1, const DataPath& arrayPath2)
{
const auto* dataArray1 = dataStructure.getDataAs<Float64Array>(arrayPath1);
const auto* dataArray2 = dataStructure.getDataAs<Float64Array>(arrayPath2);
Expand All @@ -26,9 +35,18 @@ inline void CompareDataArrays(const DataStructure& dataStructure, const DataPath

for(usize i = 0; i < length; i++)
{
REQUIRE(UnitTest::CloseEnough<float64>(dataStore1[i], dataStore2[i]));
INFO(fmt::format("i = {} | d1 = {} | d2 = {}", i, dataStore1[i], dataStore2[i]));
if constexpr(ComparisonValue == FloatComparison::Standard)
{
REQUIRE(UnitTest::CloseEnough<float64>(dataStore1[i], dataStore2[i]));
}
else
{
REQUIRE(UnitTest::CloseEnoughAbs<float64>(dataStore1[i], dataStore2[i]));
}
}
}
} // namespace

TEST_CASE("SimplnxCore::FeatureFaceCurvatureFilter: Test Algorithm", "[FeatureFaceCurvatureFilter]")
{
Expand Down Expand Up @@ -101,13 +119,17 @@ TEST_CASE("SimplnxCore::FeatureFaceCurvatureFilter: Test Algorithm", "[FeatureFa
CompareDataArrays(dataStructure, path1, path2);
}

/*
* The principal directions can be sign flipped. This is due to Eigen::SelfAdjointEigenSolver
* which returns unique eigenvectors up to a sign.
*/
{
INFO("Principal Direction 1");
DataPath path1 = faceAttribMatrixPath.createChildPath("PrincipalDirection1_D3D");
DataPath path2 = k_PrincipalDirection1_Path;
const auto* dataArray1 = dataStructure.getDataAs<Float64Array>(path1);
const auto* dataArray2 = dataStructure.getDataAs<Float64Array>(path2);
CompareDataArrays(dataStructure, path1, path2);
CompareDataArrays<FloatComparison::Absolute>(dataStructure, path1, path2);
}

{
Expand All @@ -116,7 +138,7 @@ TEST_CASE("SimplnxCore::FeatureFaceCurvatureFilter: Test Algorithm", "[FeatureFa
DataPath path2 = k_PrincipalDirection2_Path;
const auto* dataArray1 = dataStructure.getDataAs<Float64Array>(path1);
const auto* dataArray2 = dataStructure.getDataAs<Float64Array>(path2);
CompareDataArrays(dataStructure, path1, path2);
CompareDataArrays<FloatComparison::Absolute>(dataStructure, path1, path2);
}

{
Expand Down

0 comments on commit ee160c7

Please sign in to comment.