Skip to content

Commit

Permalink
Start to debug unit test failure for Slice Triangle Geometry
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Dec 3, 2024
1 parent 5bb71bd commit b8f6319
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Result<> SliceTriangleGeometry::operator()()
float zStart = m_InputValues->Zstart;
float zEnd = m_InputValues->Zend;

if(m_InputValues->SliceRange == 0)
if(m_InputValues->SliceRange == slice_triangle_geometry::constants::k_FullRange)
{
auto boundingBox = triangle.getBoundingBox();
zStart = boundingBox.getMinPoint()[2];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
namespace nx::core
{

namespace slice_triangle_geometry::constants
{

Check failure on line 18 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SliceTriangleGeometry.hpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

code should be clang-formatted [-Wclang-format-violations]
constexpr ChoicesParameter::ValueType k_FullRange = 0;

Check failure on line 19 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SliceTriangleGeometry.hpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

code should be clang-formatted [-Wclang-format-violations]
constexpr ChoicesParameter::ValueType k_UserDefinedRange = 1;
}

Check failure on line 21 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SliceTriangleGeometry.hpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

code should be clang-formatted [-Wclang-format-violations]

struct SIMPLNXCORE_EXPORT SliceTriangleGeometryInputValues
{
// VectorFloat32Parameter::ValueType SliceDirection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "simplnx/Filter/Actions/CreateAttributeMatrixAction.hpp"
#include "simplnx/Filter/Actions/CreateGeometry1DAction.hpp"
#include "simplnx/Filter/Actions/CreateImageGeometryAction.hpp"
#include "simplnx/Filter/Actions/DeleteDataAction.hpp"
#include "simplnx/Parameters/ArraySelectionParameter.hpp"
#include "simplnx/Parameters/BoolParameter.hpp"
#include "simplnx/Parameters/ChoicesParameter.hpp"
Expand Down Expand Up @@ -143,17 +144,17 @@ IFilter::PreflightResult RegularGridSampleSurfaceMeshFilter::preflightImpl(const

float32 vol = (pDimensionsValue[0] * pSpacingValue[0]) * (pDimensionsValue[1] * pSpacingValue[1]) * (pDimensionsValue[2] * pSpacingValue[2]);

boxDimensions << "Volume: " << std::setprecision(8) << std::noshowpoint << vol << " " << lengthUnit << "s ^3"
<< "\n";
boxDimensions << "Volume: " << std::setprecision(8) << std::noshowpoint << vol << " " << lengthUnit << "s ^3" << "\n";

Check failure on line 147 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RegularGridSampleSurfaceMeshFilter.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

code should be clang-formatted [-Wclang-format-violations]

preflightUpdatedValues.push_back({"BoxDimensions", boxDimensions.str()});

/////////////////////////////////////////////////////////////////////////////
// CREATE THE EDGE GEOMETRY THAT WILL BE USED FOR THE POLYGONS
// This Geometry will be deleted after the filter is completed
{
DataPath pSliceDataContainerNameValue({fmt::format(".{}_sliced", triangleGeometryPath.getTargetName())});
std::string pEdgeAttributeMatrixNameValue("EdgeAttributeMatrix");
std::string pSliceIdArrayNameValue("SliceIds");
// bool pHaveRegionIdsValue = false;
DataPath pRegionIdArrayPathValue({"NOT USED"});
std::string pSliceAttributeMatrixNameValue("SliceAttributeMatrix");
// create the edge geometry
Expand All @@ -171,19 +172,16 @@ IFilter::PreflightResult RegularGridSampleSurfaceMeshFilter::preflightImpl(const
resultOutputActions.value().appendAction(std::move(createArray));
}

// if(pHaveRegionIdsValue)
// {
// DataPath path = pSliceDataContainerNameValue.createChildPath(pEdgeAttributeMatrixNameValue).createChildPath(pRegionIdArrayPathValue.getTargetName());
// auto createArray = std::make_unique<CreateArrayAction>(DataType::int32, tDims, compDims, path);
// resultOutputActions.value().appendAction(std::move(createArray));
// }

DataPath featureSliceAttrMatPath = pSliceDataContainerNameValue.createChildPath(pSliceAttributeMatrixNameValue);
{
auto createAttributeMatrixAction = std::make_unique<CreateAttributeMatrixAction>(featureSliceAttrMatPath, tDims);
resultOutputActions.value().appendAction(std::move(createAttributeMatrixAction));
}

auto deferredDeleteGeometryAction = std::make_unique<DeleteDataAction>(pSliceDataContainerNameValue);
resultOutputActions.value().appendDeferredAction(std::move(deferredDeleteGeometryAction));
}
/////////////////////////////////////////////////////////////////////////////

// Return both the resultOutputActions and the preflightUpdatedValues via std::move()
return {std::move(resultOutputActions), std::move(preflightUpdatedValues)};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using namespace nx::core;

namespace
{
constexpr ChoicesParameter::ValueType k_UserDefinedRange = 1;

} // namespace

namespace nx::core
Expand Down Expand Up @@ -51,7 +51,7 @@ std::string SliceTriangleGeometryFilter::humanName() const
//------------------------------------------------------------------------------
std::vector<std::string> SliceTriangleGeometryFilter::defaultTags() const
{
return {className(), "Sampling", "Geometry"};
return {className(), "Sampling", "Geometry", "Slice", "Scan Vectors"};
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -88,8 +88,8 @@ Parameters SliceTriangleGeometryFilter::parameters() const
// Associate the Linkable Parameter(s) to the children parameters that they control
params.linkParameters(k_HaveRegionIds_Key, k_RegionIdArrayPath_Key, true);

params.linkParameters(k_SliceRange_Key, k_Zstart_Key, k_UserDefinedRange);
params.linkParameters(k_SliceRange_Key, k_Zend_Key, k_UserDefinedRange);
params.linkParameters(k_SliceRange_Key, k_Zstart_Key, slice_triangle_geometry::constants::k_FullRange);
params.linkParameters(k_SliceRange_Key, k_Zend_Key, slice_triangle_geometry::constants::k_UserDefinedRange);
return params;
}

Expand Down Expand Up @@ -122,11 +122,11 @@ IFilter::PreflightResult SliceTriangleGeometryFilter::preflightImpl(const DataSt

Result<OutputActions> resultOutputActions;

if(pSliceRangeValue == k_UserDefinedRange)
if(pSliceRangeValue == slice_triangle_geometry::constants::k_UserDefinedRange)
{
if(pZStartValue >= pZEndValue)
{
return MakePreflightErrorResult(-62100, "Z end must be larger than Z start.");
return MakePreflightErrorResult(-62100, "Z end range must be larger than Z start range.");
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/Plugins/SimplnxCore/test/SliceTriangleGeometryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ TEST_CASE("SimplnxCore::SliceTriangleGeometryFilter: Valid Filter Execution", "[

// Write the DataStructure out to the file system
// #ifdef SIMPLNX_WRITE_TEST_OUTPUT
UnitTest::WriteTestDataStructure(dataStructure, fs::path(fmt::format("{}/slice_triangle_geometry.dream3d", unit_test::k_BinaryTestOutputDir)));
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

// Compare the exemplar and the computed outputs
Expand Down
11 changes: 8 additions & 3 deletions test/UnitTestCommon/include/simplnx/UnitTest/UnitTestCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,14 @@ inline void CompareImageGeometry(const ImageGeom* exemplarGeom, const ImageGeom*
*/
inline bool CompareIGeometry(const IGeometry* geom1, const IGeometry* geom2)
{
return (geom1->getGeomType() == geom2->getGeomType()) && (geom1->getSpatialDimensionality() == geom2->getSpatialDimensionality()) &&
(geom1->getUnitDimensionality() == geom2->getUnitDimensionality()) && (geom1->getNumberOfCells() == geom2->getNumberOfCells()) &&
(geom1->findAllChildrenOfType<IArray>().size() == geom2->findAllChildrenOfType<IArray>().size()) && (geom1->getParametricCenter() == geom2->getParametricCenter());
REQUIRE(geom1->getGeomType() == geom2->getGeomType());
REQUIRE(geom1->getSpatialDimensionality() == geom2->getSpatialDimensionality());
REQUIRE(geom1->getUnitDimensionality() == geom2->getUnitDimensionality());
REQUIRE(geom1->getNumberOfCells() == geom2->getNumberOfCells());
REQUIRE(geom1->findAllChildrenOfType<IArray>().size() == geom2->findAllChildrenOfType<IArray>().size());
REQUIRE(geom1->getParametricCenter() == geom2->getParametricCenter());

return true;
}

/**
Expand Down

0 comments on commit b8f6319

Please sign in to comment.