Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Jan 15, 2025
1 parent 02af981 commit e0a7ccf
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ void RegularGridSampleSurfaceMesh::generatePoints(std::vector<Point3Df>& points)
// -----------------------------------------------------------------------------
Result<> RegularGridSampleSurfaceMesh::operator()()
{
const ChoicesParameter::ValueType k_UserDefinedRange = 1;
/////////////////////////////////////////////////////////////////////////////
// Slice the Triangle Geometry
SliceTriangleGeometryInputValues inputValues;
inputValues.SliceRange = 1;
inputValues.SliceRange = k_UserDefinedRange;
inputValues.Zstart = m_InputValues->Origin[2] + (m_InputValues->Spacing[2] * 0.5);
inputValues.Zend = m_InputValues->Origin[2] + (m_InputValues->Dimensions[2] * m_InputValues->Spacing[2]) + (m_InputValues->Spacing[2] * 0.5);
inputValues.SliceResolution = m_InputValues->Spacing[2];
Expand Down
5 changes: 1 addition & 4 deletions src/Plugins/SimplnxCore/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,13 @@ if(EXISTS "${DREAM3D_DATA_DIR}" AND SIMPLNX_DOWNLOAD_TEST_FILES)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME ResampleImageGeom_Exemplar.tar.gz SHA512 464029b7354b96a943d75c495ef02bac0f834032e5a86576dde9afee51febff3fd6ffd7d4f8f1e9f8315d8cda36971df26601c7212e1876151109ca5428b8659)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME reverse_triangle_winding.tar.gz SHA512 63247d7b8a0deee2fdb737527506312827331861758cd6106974d3aa1b9cb9c1d3b85d4b135e3eda27ac98e891198b4ee0498077ab231127dbb3dd8e83a5ea14)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME Rotate_Sample_Ref_Frame_Test.tar.gz SHA512 75c02a11fbb06e9df464df542be8cecc82ec73a7324abf7f12a055570ecc32ec3add6c662ab071868f6708005a6027b89065dbd70605b576520d31e16ef3c372)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME scan_path_test_data.tar.gz SHA512 3dc7104df9b49fb571caec0dca8fbeb327b477aa7d830c47e014b018d207be03e2333c51d113eef9efbbe49a6be9711e215c582bae1ed55a4ad07e157bd55344)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME Small_IN100_dream3d_v2.tar.gz SHA512 d2c6d537e3085f944ef3ce6b79553b65ead81f7f25fc4810af642e1d3dc86c465727e2bfb886b77e6da41e987e502c4263a35164aa8c07453853659d10f3de24)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME Small_IN100_h5ebsd.tar.gz SHA512 31e606285ea9e8235dcb5f608fd2b252a5ab1492abd975e5ec33a21d083aa9720fe16fb8f752742c140f40e963d692f1a46256b9d36e96b1b09796c1e4ea3db9)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME SurfaceMeshTest.tar.gz SHA512 a74e9fa40ccec78174dbbac90969bfa17367c3a7e14b7b84624032317c351de89957750803d7cb43c67dec19281ee4f647de022d474566fd43e25b8230cce6d6)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME volume_graphics_test.tar.gz SHA512 94d996fbf2b8b42cd715fb3adf33548f097970211e7a26eb9ccc5b073a78014eecbd10d40fc0451ff9cc7c92e23ed21582fc082d64e1f62b3714e4d9640c975f)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME vtk_rectilinear_grid_writer.tar.gz SHA512 9fef02b5269609503d03dd0126cc635cc1c1156894cff18b0184b334d705b850ca1a06ae0d1c66a352a32dd9ad9fb74f24255c7de1399b06bbec7d2e2b41941b)
download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME 7_0_SurfaceMesh_Test_Files.tar.gz SHA512 d6205401a7ed1b0b5e3d1af6310c828595c089d6788097526607d98d077285061e16271d19aa64318a4da7610eb73444560604d6093f2178798036933a28f408)

download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME scan_path_test_data_v2.tar.gz SHA512 79eb796b16c23d5094b7f65b3069c84118cc557be7e9115c518724c7f1f3e40c0e17599a8bd858fff4d0a45a91ab70a242876fcc14bde86c34df7afa94e8f748)


endif()

# -----------------------------------------------------------------------------
Expand Down
24 changes: 11 additions & 13 deletions src/Plugins/SimplnxCore/test/CreateAMScanPathsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,26 @@ using namespace nx::core::UnitTest;

namespace
{
const nx::core::DataPath k_ExemplarEdgeGeometryPath = DataPath({"Exemplar Edge Geometry"});
const nx::core::DataPath k_ExemplarScanVectorsPath = DataPath({"Exemplar Scan Vectors"});
const nx::core::DataPath k_RegionIdsPath = DataPath({"Exemplar Edge Geometry", "Edge Data", "Region Ids"});
const nx::core::DataPath k_SliceIdsPath = DataPath({"Exemplar Edge Geometry", "Edge Data", "Slice Ids"});
const nx::core::DataPath k_ExemplarEdgeGeometryPath = DataPath({"Exemplar Slice Geometry"});
const nx::core::DataPath k_ExemplarScanVectorsPath = DataPath({"Exemplar Scan Paths Geometry"});
const nx::core::DataPath k_RegionIdsPath = DataPath({"Exemplar Slice Geometry", "Edge Data", "Part Number"});
const nx::core::DataPath k_SliceIdsPath = DataPath({"Exemplar Slice Geometry", "Edge Data", "Slice Ids"});

const nx::core::DataPath k_ComputedScanVectorsPath = DataPath({"Output Scan Vectors"});

const DataObjectNameParameter::ValueType k_EdgeData("Edge Data");
// const DataObjectNameParameter::ValueType k_VertexData("Vertex Data");
const DataObjectNameParameter::ValueType k_Times("Times");
const DataObjectNameParameter::ValueType k_Powers("Powers");
const DataObjectNameParameter::ValueType k_RegionIdsName("Region Ids");
// const DataObjectNameParameter::ValueType k_VertexData("VertexData");
const DataObjectNameParameter::ValueType k_RegionIdsName("Part Number");
} // namespace

TEST_CASE("SimplnxCore::CreateAMScanPathsFilter: Valid Filter Execution", "[SimplnxCore][CreateAMScanPathsFilter]")
{
Application::GetOrCreateInstance()->loadPlugins(unit_test::k_BuildDir.view(), true);

// const nx::core::UnitTest::TestFileSentinel testDataSentinel(nx::core::unit_test::k_CMakeExecutable, nx::core::unit_test::k_TestFilesDir, "scan_path_test_data_v2.tar.gz", "scan_path_test_data");
// auto baseDataFilePath = fs::path(fmt::format("{}/scan_path_test_data_v2/scan_path_test_data.dream3d", nx::core::unit_test::k_TestFilesDir));

auto baseDataFilePath = fs::path("/Users/Shared/Data/7_create_am_scan_paths_test/create_am_scan_paths_test.dream3d");
// Read Exemplar DREAM3D File Filter
const nx::core::UnitTest::TestFileSentinel testDataSentinel(nx::core::unit_test::k_CMakeExecutable, nx::core::unit_test::k_TestFilesDir, "7_0_SurfaceMesh_Test_Files.tar.gz",
"7_0_SurfaceMesh_Test_Files");
auto baseDataFilePath = fs::path(fmt::format("{}/7_0_SurfaceMesh_Test_Files/7_0_SurfaceMesh_Test_Files.dream3d", unit_test::k_TestFilesDir));

DataStructure dataStructure = UnitTest::LoadDataStructure(baseDataFilePath);

Expand All @@ -47,8 +45,8 @@ TEST_CASE("SimplnxCore::CreateAMScanPathsFilter: Valid Filter Execution", "[Simp
Arguments args;

// Create default Parameters for the filter.
args.insertOrAssign(CreateAMScanPathsFilter::k_HatchSpacing_Key, std::make_any<float32>(0.14f));
args.insertOrAssign(CreateAMScanPathsFilter::k_StripeWidth_Key, std::make_any<float32>(7.0f));
args.insertOrAssign(CreateAMScanPathsFilter::k_HatchSpacing_Key, std::make_any<float32>(0.1f));
args.insertOrAssign(CreateAMScanPathsFilter::k_RotationAngle, std::make_any<float32>(67.0f));
args.insertOrAssign(CreateAMScanPathsFilter::k_CADSliceDataContainerPath_Key, std::make_any<DataPath>(k_ExemplarEdgeGeometryPath));
args.insertOrAssign(CreateAMScanPathsFilter::k_CADSliceIdsArrayPath_Key, std::make_any<DataPath>(k_SliceIdsPath));
Expand Down
32 changes: 14 additions & 18 deletions src/Plugins/SimplnxCore/test/RegularGridSampleSurfaceMeshTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ using namespace nx::core;

namespace
{
const std::string k_TriGeomName = "STL-Cylinder";
const std::string k_TriGeomName = "Input Triangle Geometry";
const DataPath k_TriGeomPath = DataPath({k_TriGeomName});
const DataPath k_FaceLabelsPath = k_TriGeomPath.createChildPath(Constants::k_FaceData).createChildPath(Constants::k_FaceLabels);

const std::string k_ExemplarImageGeomName = "RegularGrid";
const std::string k_ExemplarImageGeomName = "Exemplar Sample Triangle Geometry on Regular Grid";
const DataPath k_ExemplarImageGeomPath = DataPath({k_ExemplarImageGeomName});
const DataPath k_ExemplarFeatureIdsPath = k_ExemplarImageGeomPath.createChildPath(Constants::k_CellData).createChildPath(Constants::k_FeatureIds);

Expand All @@ -25,27 +25,24 @@ const DataPath k_GeneratedFeatureIdsPath = k_GeneratedImageGeomPath.createChildP

TEST_CASE("SimplnxCore::RegularGridSampleSurfaceMeshFilter: Valid Filter Execution", "[SimplnxCore][RegularGridSampleSurfaceMeshFilter]")
{
/**
* THe generated test case file for this was generated on a temporary modification of the 6.6 DREAM3D-SIMPL fork where the
* random generation was modified to use the same generator, engine, and distribution used in standard SIMPLNX random generation
* utilizing the standard library. It was seeded with the std::mt19937::default_seed.
*/
Application::GetOrCreateInstance()->loadPlugins(unit_test::k_BuildDir.view(), true);

const nx::core::UnitTest::TestFileSentinel testDataSentinel(nx::core::unit_test::k_CMakeExecutable, nx::core::unit_test::k_TestFilesDir, "6_6_sample_surface_mesh.tar.gz", "6_6_sample_surface_mesh");
// Read Exemplar DREAM3D File Filter
const nx::core::UnitTest::TestFileSentinel testDataSentinel(nx::core::unit_test::k_CMakeExecutable, nx::core::unit_test::k_TestFilesDir, "7_0_SurfaceMesh_Test_Files.tar.gz",
"7_0_SurfaceMesh_Test_Files");
auto baseDataFilePath = fs::path(fmt::format("{}/7_0_SurfaceMesh_Test_Files/7_0_SurfaceMesh_Test_Files.dream3d", unit_test::k_TestFilesDir));

// Read Exemplar DREAM3D File Filter
auto baseDataFilePath = fs::path(fmt::format("{}/6_6_sample_surface_mesh/6_6_grid_sample_surface_mesh.dream3d", unit_test::k_TestFilesDir));
DataStructure dataStructure = UnitTest::LoadDataStructure(baseDataFilePath);
{
// Instantiate the filter, a DataStructure object and an Arguments Object
RegularGridSampleSurfaceMeshFilter filter;
Arguments args;

// Create default Parameters for the filter.
args.insertOrAssign(RegularGridSampleSurfaceMeshFilter::k_Dimensions_Key, std::make_any<VectorUInt64Parameter::ValueType>(std::vector<uint64>{179, 18, 2}));
args.insertOrAssign(RegularGridSampleSurfaceMeshFilter::k_Spacing_Key, std::make_any<VectorFloat32Parameter::ValueType>(std::vector<float32>{1.0f, 1.0f, 1.0f}));
args.insertOrAssign(RegularGridSampleSurfaceMeshFilter::k_Origin_Key, std::make_any<VectorFloat32Parameter::ValueType>(std::vector<float32>{0.25f, 0.25f, 0.25f}));
args.insertOrAssign(RegularGridSampleSurfaceMeshFilter::k_LengthUnit_Key, std::make_any<ChoicesParameter::ValueType>(0ULL));
args.insertOrAssign(RegularGridSampleSurfaceMeshFilter::k_Dimensions_Key, std::make_any<VectorUInt64Parameter::ValueType>(std::vector<uint64>{171, 200, 150}));
args.insertOrAssign(RegularGridSampleSurfaceMeshFilter::k_Origin_Key, std::make_any<VectorFloat32Parameter::ValueType>(std::vector<float32>{1.0f, 1.99f, 0.0f}));
args.insertOrAssign(RegularGridSampleSurfaceMeshFilter::k_Spacing_Key, std::make_any<VectorFloat32Parameter::ValueType>(std::vector<float32>{0.1f, 0.1f, 0.02f}));
args.insertOrAssign(RegularGridSampleSurfaceMeshFilter::k_LengthUnit_Key, std::make_any<ChoicesParameter::ValueType>(6ULL));

args.insertOrAssign(RegularGridSampleSurfaceMeshFilter::k_TriangleGeometryPath_Key, std::make_any<DataPath>(::k_TriGeomPath));
args.insertOrAssign(RegularGridSampleSurfaceMeshFilter::k_SurfaceMeshFaceLabelsArrayPath_Key, std::make_any<DataPath>(::k_FaceLabelsPath));
Expand All @@ -56,11 +53,10 @@ TEST_CASE("SimplnxCore::RegularGridSampleSurfaceMeshFilter: Valid Filter Executi

// Preflight the filter and check result
auto preflightResult = filter.preflight(dataStructure, args);
REQUIRE(preflightResult.outputActions.valid());
SIMPLNX_RESULT_REQUIRE_VALID(preflightResult.outputActions)

// Execute the filter and check the result
auto executeResult = filter.execute(dataStructure, args);
REQUIRE(executeResult.result.valid());
auto result = filter.execute(dataStructure, args);
SIMPLNX_RESULT_REQUIRE_VALID(result.result)
}

// Write the DataStructure out to the file system
Expand Down
28 changes: 14 additions & 14 deletions src/Plugins/SimplnxCore/test/SliceTriangleGeometryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ using namespace nx::core;

namespace
{
const nx::core::DataPath k_InputTriangleGeometryPath = DataPath({"Exemplar Triangle Geometry"});
const nx::core::DataPath k_RegionIdsPath = DataPath({"Exemplar Triangle Geometry", "Face Data", "RegionIds"});
const nx::core::DataPath k_ExemplarEdgeGeometryPath = DataPath({"Exemplar Edge Geometry"});
const nx::core::DataPath k_InputTriangleGeometryPath = DataPath({"Input Triangle Geometry"});
const nx::core::DataPath k_RegionIdsPath = DataPath({"Input Triangle Geometry", "FaceData", "Part Number"});
const nx::core::DataPath k_ExemplarEdgeGeometryPath = DataPath({"Exemplar Slice Geometry"});

const nx::core::DataPath k_ComputedEdgeGeometryPath = DataPath({"Output Edge Geometry"});
const DataObjectNameParameter::ValueType k_EdgeData("Edge Data");
const DataObjectNameParameter::ValueType k_SliceData("Slice Data");
const DataObjectNameParameter::ValueType k_SliceData("Slice Feature Data");
const DataObjectNameParameter::ValueType k_SliceIds("Slice Ids");
const DataObjectNameParameter::ValueType k_RegionIdsName("RegionIds");
const DataObjectNameParameter::ValueType k_RegionIdsName("Part Number");
} // namespace

TEST_CASE("SimplnxCore::SliceTriangleGeometryFilter: Valid Filter Execution", "[SimplnxCore][SliceTriangleGeometryFilter]")
{

/// The test data set was reviewed manually by MAJ and found to be correct in output to the
/// the best of our abilities. This is needed because DREAM.3D did not have
/// this functionality and so we have nothing to compare against.

Application::GetOrCreateInstance()->loadPlugins(unit_test::k_BuildDir.view(), true);
const nx::core::UnitTest::TestFileSentinel testDataSentinel(nx::core::unit_test::k_CMakeExecutable, nx::core::unit_test::k_TestFilesDir, "scan_path_test_data_v2.tar.gz", "scan_path_test_data_v2");
// Read the Small IN100 Data set
auto baseDataFilePath = fs::path(fmt::format("{}/scan_path_test_data_v2/scan_path_test_data.dream3d", nx::core::unit_test::k_TestFilesDir));
// Read Exemplar DREAM3D File Filter
const nx::core::UnitTest::TestFileSentinel testDataSentinel(nx::core::unit_test::k_CMakeExecutable, nx::core::unit_test::k_TestFilesDir, "7_0_SurfaceMesh_Test_Files.tar.gz",
"7_0_SurfaceMesh_Test_Files");
auto baseDataFilePath = fs::path(fmt::format("{}/7_0_SurfaceMesh_Test_Files/7_0_SurfaceMesh_Test_Files.dream3d", unit_test::k_TestFilesDir));

DataStructure dataStructure = UnitTest::LoadDataStructure(baseDataFilePath);

// Instantiate the filter, a DataStructure object and an Arguments Object
Expand All @@ -45,7 +45,7 @@ TEST_CASE("SimplnxCore::SliceTriangleGeometryFilter: Valid Filter Execution", "[
// Create default Parameters for the filter.
args.insertOrAssign(SliceTriangleGeometryFilter::k_Zstart_Key, std::make_any<float32>(0.0f));
args.insertOrAssign(SliceTriangleGeometryFilter::k_Zend_Key, std::make_any<float32>(0.0f));
args.insertOrAssign(SliceTriangleGeometryFilter::k_SliceResolution_Key, std::make_any<float32>(0.075000003f));
args.insertOrAssign(SliceTriangleGeometryFilter::k_SliceResolution_Key, std::make_any<float32>(0.1f));
args.insertOrAssign(SliceTriangleGeometryFilter::k_SliceRange_Key, std::make_any<ChoicesParameter::ValueType>(0));
args.insertOrAssign(SliceTriangleGeometryFilter::k_HaveRegionIds_Key, std::make_any<bool>(true));
args.insertOrAssign(SliceTriangleGeometryFilter::k_TriangleGeometryDataPath_Key, std::make_any<DataPath>(k_InputTriangleGeometryPath));
Expand All @@ -63,12 +63,12 @@ TEST_CASE("SimplnxCore::SliceTriangleGeometryFilter: Valid Filter Execution", "[
auto result = filter.execute(dataStructure, args);
SIMPLNX_RESULT_REQUIRE_VALID(result.result)

// Write the DataStructure out to the file system
// #ifdef SIMPLNX_WRITE_TEST_OUTPUT
// Write the DataStructure out to the file system
#ifdef SIMPLNX_WRITE_TEST_OUTPUT
fs::path testFileOutputPath(fmt::format("{}/slice_triangle_geometry.dream3d", unit_test::k_BinaryTestOutputDir));
std::cout << "Writing Output file: " << testFileOutputPath << std::endl;
UnitTest::WriteTestDataStructure(dataStructure, testFileOutputPath);
// #endif
#endif

// Compare the exemplar and the computed outputs
{
Expand Down
4 changes: 1 addition & 3 deletions src/simplnx/Utilities/GeometryUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,7 @@ GeometryUtilities::SliceTriangleReturnType GeometryUtilities::SliceTriangleGeome
edgeCounter++;
}
} // END TRIANGLE LOOP

sliceIndex++;
} // END SLICE LOOP
} // END SLICE LOOP

return {std::move(slicedVerts), std::move(sliceIds), std::move(regionIds), numberOfSlices};
}

0 comments on commit e0a7ccf

Please sign in to comment.