From f36ca6c755c6d87269fdf7f7b6eb1d84164372d7 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Sun, 24 Nov 2024 12:18:05 -0500 Subject: [PATCH] BUG: Fixes issue where any component shape was allowed for ComputeTriangleGeometrySizes (#1134) * BUG: Fixes issue where any component shape were allowed for ComputeTriangleGeometrySizes.cpp * Fix all instances of "Face Labels" are only allowed to use 2 component input arrays * ComputeTriangleGeomVolumes - fix possible walking off the end of the array. A negative value for the face label when used as an index will cast into an unsigned value and bad things are going to happen. * BUG: Fixes negative volumes produced from calculations --------- Signed-off-by: Michael Jackson --- .../ComputeTriangleGeomShapesFilter.cpp | 2 +- src/Plugins/SimplnxCore/CMakeLists.txt | 4 +- ...md => ComputeTriangleGeomVolumesFilter.md} | 5 -- .../Algorithms/ComputeTriangleGeomSizes.hpp | 50 ------------------- ...zes.cpp => ComputeTriangleGeomVolumes.cpp} | 33 +++++++----- .../Algorithms/ComputeTriangleGeomVolumes.hpp | 45 +++++++++++++++++ .../ComputeTriangleGeomCentroidsFilter.cpp | 2 +- ...p => ComputeTriangleGeomVolumesFilter.cpp} | 42 ++++++++-------- ...p => ComputeTriangleGeomVolumesFilter.hpp} | 16 +++--- .../Filters/FeatureFaceCurvatureFilter.cpp | 2 +- .../SimplnxCore/Filters/ReadStlFileFilter.cpp | 2 +- .../RegularGridSampleSurfaceMeshFilter.cpp | 2 +- .../Filters/SharedFeatureFaceFilter.cpp | 2 +- ...tainRegularGridSampleSurfaceMeshFilter.cpp | 2 +- src/Plugins/SimplnxCore/test/CMakeLists.txt | 2 +- ...cpp => ComputeTriangleGeomVolumesTest.cpp} | 26 +++++++--- 16 files changed, 123 insertions(+), 114 deletions(-) rename src/Plugins/SimplnxCore/docs/{ComputeTriangleGeomSizesFilter.md => ComputeTriangleGeomVolumesFilter.md} (79%) delete mode 100644 src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomSizes.hpp rename src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/{ComputeTriangleGeomSizes.cpp => ComputeTriangleGeomVolumes.cpp} (76%) create mode 100644 src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomVolumes.hpp rename src/Plugins/SimplnxCore/src/SimplnxCore/Filters/{ComputeTriangleGeomSizesFilter.cpp => ComputeTriangleGeomVolumesFilter.cpp} (75%) rename src/Plugins/SimplnxCore/src/SimplnxCore/Filters/{ComputeTriangleGeomSizesFilter.hpp => ComputeTriangleGeomVolumesFilter.hpp} (83%) rename src/Plugins/SimplnxCore/test/{ComputeTriangleGeomSizesTest.cpp => ComputeTriangleGeomVolumesTest.cpp} (70%) diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ComputeTriangleGeomShapesFilter.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ComputeTriangleGeomShapesFilter.cpp index cec6254079..8f96dd20da 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ComputeTriangleGeomShapesFilter.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ComputeTriangleGeomShapesFilter.cpp @@ -52,7 +52,7 @@ Parameters ComputeTriangleGeomShapesFilter::parameters() const GeometrySelectionParameter::AllowedTypes{IGeometry::Type::Triangle})); params.insertSeparator(Parameters::Separator{"Input Triangle Face Data"}); params.insert(std::make_unique(k_FaceLabelsArrayPath_Key, "Face Labels", "The DataPath to the FaceLabels values.", DataPath{}, - ArraySelectionParameter::AllowedTypes{nx::core::DataType::int32})); + ArraySelectionParameter::AllowedTypes{nx::core::DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{{2}})); params.insertSeparator(Parameters::Separator{"Input Face Feature Data"}); params.insert(std::make_unique(k_FeatureAttributeMatrixPath_Key, "Face Feature Attribute Matrix", diff --git a/src/Plugins/SimplnxCore/CMakeLists.txt b/src/Plugins/SimplnxCore/CMakeLists.txt index 3c3bdb311f..65cfeb1df4 100644 --- a/src/Plugins/SimplnxCore/CMakeLists.txt +++ b/src/Plugins/SimplnxCore/CMakeLists.txt @@ -76,7 +76,7 @@ set(FilterList ComputeBiasedFeaturesFilter ComputeBoundaryCellsFilter ComputeBoundaryElementFractionsFilter - ComputeTriangleGeomSizesFilter + ComputeTriangleGeomVolumesFilter FlyingEdges3DFilter CreateColorMapFilter IdentifySampleFilter @@ -188,7 +188,7 @@ set(AlgorithmList ComputeBiasedFeatures ComputeBoundaryCells FindNRingNeighbors - ComputeTriangleGeomSizes + ComputeTriangleGeomVolumes FlyingEdges3D CreateColorMap InitializeData diff --git a/src/Plugins/SimplnxCore/docs/ComputeTriangleGeomSizesFilter.md b/src/Plugins/SimplnxCore/docs/ComputeTriangleGeomVolumesFilter.md similarity index 79% rename from src/Plugins/SimplnxCore/docs/ComputeTriangleGeomSizesFilter.md rename to src/Plugins/SimplnxCore/docs/ComputeTriangleGeomVolumesFilter.md index 2829946fdc..5085e66723 100644 --- a/src/Plugins/SimplnxCore/docs/ComputeTriangleGeomSizesFilter.md +++ b/src/Plugins/SimplnxCore/docs/ComputeTriangleGeomVolumesFilter.md @@ -18,11 +18,6 @@ Labels_ array. The volume of any generic polyhedron can be computed using the fo 4. Compute the signed volume of each tetrahedron 5. Sum the signed tetrahedra volumes to obtain the volume of the enclosing polyhedron -This computation is _not_ the same as the Find Feature Sizes for **Triangle Geometries**, which computes the sum of the -unit element sizes for a set of **Features** (thus, the Find Feature Sizes would compute the _area_ -of **Features** in a **Triangle Geometry**, whereas this **Filter** is specialized to compute the enclosed volumes of ** -Features** in a surface mesh). - % Auto generated parameter table will be inserted here ## Example Pipelines diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomSizes.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomSizes.hpp deleted file mode 100644 index 7778c83535..0000000000 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomSizes.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once - -#include "SimplnxCore/SimplnxCore_export.hpp" - -#include "simplnx/DataStructure/DataPath.hpp" -#include "simplnx/DataStructure/DataStructure.hpp" -#include "simplnx/Filter/IFilter.hpp" - -/** -* This is example code to put in the Execute Method of the filter. - -*/ - -namespace nx::core -{ - -struct SIMPLNXCORE_EXPORT ComputeTriangleGeomSizesInputValues -{ - DataPath TriangleGeometryPath; - DataPath FaceLabelsArrayPath; - DataPath FeatureAttributeMatrixPath; - DataPath VolumesArrayPath; -}; - -/** - * @class - */ -class SIMPLNXCORE_EXPORT ComputeTriangleGeomSizes -{ -public: - ComputeTriangleGeomSizes(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, ComputeTriangleGeomSizesInputValues* inputValues); - ~ComputeTriangleGeomSizes() noexcept; - - ComputeTriangleGeomSizes(const ComputeTriangleGeomSizes&) = delete; - ComputeTriangleGeomSizes(ComputeTriangleGeomSizes&&) noexcept = delete; - ComputeTriangleGeomSizes& operator=(const ComputeTriangleGeomSizes&) = delete; - ComputeTriangleGeomSizes& operator=(ComputeTriangleGeomSizes&&) noexcept = delete; - - Result<> operator()(); - - const std::atomic_bool& getCancel(); - -private: - DataStructure& m_DataStructure; - const ComputeTriangleGeomSizesInputValues* m_InputValues = nullptr; - const std::atomic_bool& m_ShouldCancel; - const IFilter::MessageHandler& m_MessageHandler; -}; - -} // namespace nx::core diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomSizes.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomVolumes.cpp similarity index 76% rename from src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomSizes.cpp rename to src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomVolumes.cpp index 6bd871b2d6..e238b5304a 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomSizes.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomVolumes.cpp @@ -1,4 +1,4 @@ -#include "ComputeTriangleGeomSizes.hpp" +#include "ComputeTriangleGeomVolumes.hpp" #include "simplnx/DataStructure/DataArray.hpp" #include "simplnx/DataStructure/DataGroup.hpp" @@ -38,8 +38,8 @@ T FindTetrahedronVolume(const std::array& vertIds, const AbstractDataS } // namespace // ----------------------------------------------------------------------------- -ComputeTriangleGeomSizes::ComputeTriangleGeomSizes(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, - ComputeTriangleGeomSizesInputValues* inputValues) +ComputeTriangleGeomVolumes::ComputeTriangleGeomVolumes(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, + ComputeTriangleGeomVolumesInputValues* inputValues) : m_DataStructure(dataStructure) , m_InputValues(inputValues) , m_ShouldCancel(shouldCancel) @@ -48,16 +48,16 @@ ComputeTriangleGeomSizes::ComputeTriangleGeomSizes(DataStructure& dataStructure, } // ----------------------------------------------------------------------------- -ComputeTriangleGeomSizes::~ComputeTriangleGeomSizes() noexcept = default; +ComputeTriangleGeomVolumes::~ComputeTriangleGeomVolumes() noexcept = default; // ----------------------------------------------------------------------------- -const std::atomic_bool& ComputeTriangleGeomSizes::getCancel() +const std::atomic_bool& ComputeTriangleGeomVolumes::getCancel() { return m_ShouldCancel; } // ----------------------------------------------------------------------------- -Result<> ComputeTriangleGeomSizes::operator()() +Result<> ComputeTriangleGeomVolumes::operator()() { using MeshIndexType = IGeometry::MeshIndexType; using SharedVertexListType = AbstractDataStore; @@ -85,28 +85,35 @@ Result<> ComputeTriangleGeomSizes::operator()() auto& featAttrMat = m_DataStructure.getDataRefAs(m_InputValues->FeatureAttributeMatrixPath); featAttrMat.resizeTuples(tDims); auto& volumes = m_DataStructure.getDataAs(m_InputValues->VolumesArrayPath)->getDataStoreRef(); + volumes.fill(0.0f); // Initialize all volumes to ZERO std::array faceVertexIndices = {0, 0, 0}; - for(MeshIndexType i = 0; i < numTriangles; i++) { triangleGeom.getFacePointIds(i, faceVertexIndices); - if(faceLabels[2 * i + 0] == -1) + int32 faceLabel0 = faceLabels[2 * i + 0]; + int32 faceLabel1 = faceLabels[2 * i + 1]; + + if(faceLabel0 < 0 && faceLabel1 >= 0) { std::swap(faceVertexIndices[2], faceVertexIndices[1]); - volumes[faceLabels[2 * i + 1]] += FindTetrahedronVolume(faceVertexIndices, vertexCoords); + volumes[faceLabel1] += FindTetrahedronVolume(faceVertexIndices, vertexCoords); } - else if(faceLabels[2 * i + 1] == -1) + else if(faceLabel1 < 0 && faceLabel0 >= 0) { - volumes[faceLabels[2 * i + 0]] += FindTetrahedronVolume(faceVertexIndices, vertexCoords); + volumes[faceLabel0] += FindTetrahedronVolume(faceVertexIndices, vertexCoords); } else { - volumes[faceLabels[2 * i + 0]] += FindTetrahedronVolume(faceVertexIndices, vertexCoords); + volumes[faceLabel0] += FindTetrahedronVolume(faceVertexIndices, vertexCoords); std::swap(faceVertexIndices[2], faceVertexIndices[1]); - volumes[faceLabels[2 * i + 1]] += FindTetrahedronVolume(faceVertexIndices, vertexCoords); + volumes[faceLabel1] += FindTetrahedronVolume(faceVertexIndices, vertexCoords); } } + for(size_t i = 0; i < tDims[0]; i++) + { + volumes[i] = std::abs(volumes[i]); + } return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomVolumes.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomVolumes.hpp new file mode 100644 index 0000000000..614def6786 --- /dev/null +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomVolumes.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include "SimplnxCore/SimplnxCore_export.hpp" + +#include "simplnx/DataStructure/DataPath.hpp" +#include "simplnx/DataStructure/DataStructure.hpp" +#include "simplnx/Filter/IFilter.hpp" + +namespace nx::core +{ + +struct SIMPLNXCORE_EXPORT ComputeTriangleGeomVolumesInputValues +{ + DataPath TriangleGeometryPath; + DataPath FaceLabelsArrayPath; + DataPath FeatureAttributeMatrixPath; + DataPath VolumesArrayPath; +}; + +/** + * @class + */ +class SIMPLNXCORE_EXPORT ComputeTriangleGeomVolumes +{ +public: + ComputeTriangleGeomVolumes(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, ComputeTriangleGeomVolumesInputValues* inputValues); + ~ComputeTriangleGeomVolumes() noexcept; + + ComputeTriangleGeomVolumes(const ComputeTriangleGeomVolumes&) = delete; + ComputeTriangleGeomVolumes(ComputeTriangleGeomVolumes&&) noexcept = delete; + ComputeTriangleGeomVolumes& operator=(const ComputeTriangleGeomVolumes&) = delete; + ComputeTriangleGeomVolumes& operator=(ComputeTriangleGeomVolumes&&) noexcept = delete; + + Result<> operator()(); + + const std::atomic_bool& getCancel(); + +private: + DataStructure& m_DataStructure; + const ComputeTriangleGeomVolumesInputValues* m_InputValues = nullptr; + const std::atomic_bool& m_ShouldCancel; + const IFilter::MessageHandler& m_MessageHandler; +}; + +} // namespace nx::core diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomCentroidsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomCentroidsFilter.cpp index b63e0acd74..c0f60ba2db 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomCentroidsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomCentroidsFilter.cpp @@ -53,7 +53,7 @@ Parameters ComputeTriangleGeomCentroidsFilter::parameters() const GeometrySelectionParameter::AllowedTypes{IGeometry::Type::Triangle})); params.insertSeparator(Parameters::Separator{"Input Triangle Face Data"}); params.insert(std::make_unique(k_FaceLabelsArrayPath_Key, "Face Labels", "The DataPath to the FaceLabels values.", DataPath{}, - ArraySelectionParameter::AllowedTypes{nx::core::DataType::int32})); + ArraySelectionParameter::AllowedTypes{nx::core::DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{{2}})); params.insertSeparator(Parameters::Separator{"Input Face Feature Data"}); params.insert(std::make_unique(k_FeatureAttributeMatrixPath_Key, "Face Feature Attribute Matrix", "The DataPath to the AttributeMatrix that holds feature data for the faces", DataPath({"TriangleDataContainer", "Face Feature Data"}), diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomSizesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomVolumesFilter.cpp similarity index 75% rename from src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomSizesFilter.cpp rename to src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomVolumesFilter.cpp index 3f3afd5341..ac871a44e3 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomSizesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomVolumesFilter.cpp @@ -1,6 +1,6 @@ -#include "ComputeTriangleGeomSizesFilter.hpp" +#include "ComputeTriangleGeomVolumesFilter.hpp" -#include "SimplnxCore/Filters/Algorithms/ComputeTriangleGeomSizes.hpp" +#include "SimplnxCore/Filters/Algorithms/ComputeTriangleGeomVolumes.hpp" #include "simplnx/Common/Types.hpp" #include "simplnx/DataStructure/AttributeMatrix.hpp" @@ -16,37 +16,37 @@ using namespace nx::core; namespace nx::core { //------------------------------------------------------------------------------ -std::string ComputeTriangleGeomSizesFilter::name() const +std::string ComputeTriangleGeomVolumesFilter::name() const { - return FilterTraits::name.str(); + return FilterTraits::name.str(); } //------------------------------------------------------------------------------ -std::string ComputeTriangleGeomSizesFilter::className() const +std::string ComputeTriangleGeomVolumesFilter::className() const { - return FilterTraits::className; + return FilterTraits::className; } //------------------------------------------------------------------------------ -Uuid ComputeTriangleGeomSizesFilter::uuid() const +Uuid ComputeTriangleGeomVolumesFilter::uuid() const { - return FilterTraits::uuid; + return FilterTraits::uuid; } //------------------------------------------------------------------------------ -std::string ComputeTriangleGeomSizesFilter::humanName() const +std::string ComputeTriangleGeomVolumesFilter::humanName() const { return "Compute Feature Volumes from Triangle Geometry"; } //------------------------------------------------------------------------------ -std::vector ComputeTriangleGeomSizesFilter::defaultTags() const +std::vector ComputeTriangleGeomVolumesFilter::defaultTags() const { return {className(), "Generic", "Morphological", "SurfaceMesh", "Statistics", "Triangle"}; } //------------------------------------------------------------------------------ -Parameters ComputeTriangleGeomSizesFilter::parameters() const +Parameters ComputeTriangleGeomVolumesFilter::parameters() const { Parameters params; // Create the parameter descriptors that are needed for this filter @@ -54,7 +54,7 @@ Parameters ComputeTriangleGeomSizesFilter::parameters() const GeometrySelectionParameter::AllowedTypes{IGeometry::Type::Triangle})); params.insertSeparator(Parameters::Separator{"Input Triangle Face Data"}); params.insert(std::make_unique(k_FaceLabelsArrayPath_Key, "Face Labels", "The DataPath to the FaceLabels values.", DataPath{}, - ArraySelectionParameter::AllowedTypes{nx::core::DataType::int32})); + ArraySelectionParameter::AllowedTypes{DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{{2}})); params.insertSeparator(Parameters::Separator{"Input Face Feature Data"}); params.insert(std::make_unique(k_FeatureAttributeMatrixPath_Key, "Face Feature Attribute Matrix", "The DataPath to the AttributeMatrix that holds feature data for the faces", DataPath({"TriangleDataContainer", "Face Feature Data"}), @@ -66,20 +66,20 @@ Parameters ComputeTriangleGeomSizesFilter::parameters() const } //------------------------------------------------------------------------------ -IFilter::VersionType ComputeTriangleGeomSizesFilter::parametersVersion() const +IFilter::VersionType ComputeTriangleGeomVolumesFilter::parametersVersion() const { return 1; } //------------------------------------------------------------------------------ -IFilter::UniquePointer ComputeTriangleGeomSizesFilter::clone() const +IFilter::UniquePointer ComputeTriangleGeomVolumesFilter::clone() const { - return std::make_unique(); + return std::make_unique(); } //------------------------------------------------------------------------------ -IFilter::PreflightResult ComputeTriangleGeomSizesFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, - const std::atomic_bool& shouldCancel) const +IFilter::PreflightResult ComputeTriangleGeomVolumesFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, + const std::atomic_bool& shouldCancel) const { auto pFaceLabelsArrayPath = filterArgs.value(k_FaceLabelsArrayPath_Key); auto pFeatureAttributeMatrixPath = filterArgs.value(k_FeatureAttributeMatrixPath_Key); @@ -112,10 +112,10 @@ IFilter::PreflightResult ComputeTriangleGeomSizesFilter::preflightImpl(const Dat } //------------------------------------------------------------------------------ -Result<> ComputeTriangleGeomSizesFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, - const std::atomic_bool& shouldCancel) const +Result<> ComputeTriangleGeomVolumesFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, + const std::atomic_bool& shouldCancel) const { - ComputeTriangleGeomSizesInputValues inputValues; + ComputeTriangleGeomVolumesInputValues inputValues; inputValues.TriangleGeometryPath = filterArgs.value(k_TriGeometryDataPath_Key); inputValues.FaceLabelsArrayPath = filterArgs.value(k_FaceLabelsArrayPath_Key); inputValues.FeatureAttributeMatrixPath = filterArgs.value(k_FeatureAttributeMatrixPath_Key); @@ -123,6 +123,6 @@ Result<> ComputeTriangleGeomSizesFilter::executeImpl(DataStructure& dataStructur auto volumesArrayNameValue = filterArgs.value(k_VolumesArrayName_Key); inputValues.VolumesArrayPath = inputValues.FeatureAttributeMatrixPath.createChildPath(volumesArrayNameValue); - return ComputeTriangleGeomSizes(dataStructure, messageHandler, shouldCancel, &inputValues)(); + return ComputeTriangleGeomVolumes(dataStructure, messageHandler, shouldCancel, &inputValues)(); } } // namespace nx::core diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomSizesFilter.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomVolumesFilter.hpp similarity index 83% rename from src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomSizesFilter.hpp rename to src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomVolumesFilter.hpp index aecb7a3594..960c4349ac 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomSizesFilter.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleGeomVolumesFilter.hpp @@ -11,17 +11,17 @@ namespace nx::core * @class ComputeTriangleGeomSizesFilter * @brief This filter will .... */ -class SIMPLNXCORE_EXPORT ComputeTriangleGeomSizesFilter : public IFilter +class SIMPLNXCORE_EXPORT ComputeTriangleGeomVolumesFilter : public IFilter { public: - ComputeTriangleGeomSizesFilter() = default; - ~ComputeTriangleGeomSizesFilter() noexcept override = default; + ComputeTriangleGeomVolumesFilter() = default; + ~ComputeTriangleGeomVolumesFilter() noexcept override = default; - ComputeTriangleGeomSizesFilter(const ComputeTriangleGeomSizesFilter&) = delete; - ComputeTriangleGeomSizesFilter(ComputeTriangleGeomSizesFilter&&) noexcept = delete; + ComputeTriangleGeomVolumesFilter(const ComputeTriangleGeomVolumesFilter&) = delete; + ComputeTriangleGeomVolumesFilter(ComputeTriangleGeomVolumesFilter&&) noexcept = delete; - ComputeTriangleGeomSizesFilter& operator=(const ComputeTriangleGeomSizesFilter&) = delete; - ComputeTriangleGeomSizesFilter& operator=(ComputeTriangleGeomSizesFilter&&) noexcept = delete; + ComputeTriangleGeomVolumesFilter& operator=(const ComputeTriangleGeomVolumesFilter&) = delete; + ComputeTriangleGeomVolumesFilter& operator=(ComputeTriangleGeomVolumesFilter&&) noexcept = delete; // Parameter Keys static inline constexpr StringLiteral k_FaceLabelsArrayPath_Key = "face_labels_array_path"; @@ -104,4 +104,4 @@ class SIMPLNXCORE_EXPORT ComputeTriangleGeomSizesFilter : public IFilter }; } // namespace nx::core -SIMPLNX_DEF_FILTER_TRAITS(nx::core, ComputeTriangleGeomSizesFilter, "a979bd9b-834e-4497-84b0-ab7a8add341a"); +SIMPLNX_DEF_FILTER_TRAITS(nx::core, ComputeTriangleGeomVolumesFilter, "a979bd9b-834e-4497-84b0-ab7a8add341a"); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FeatureFaceCurvatureFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FeatureFaceCurvatureFilter.cpp index ae01828301..9f3547f852 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FeatureFaceCurvatureFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FeatureFaceCurvatureFilter.cpp @@ -70,7 +70,7 @@ Parameters FeatureFaceCurvatureFilter::parameters() const params.insertSeparator(Parameters::Separator{"Input Triangle Face Data"}); params.insert(std::make_unique(k_FaceAttribMatrixPath_Key, "Face Attribute Matrix", "The AttributeMatrix that holds the triangle face data.", DataPath())); params.insert(std::make_unique(k_FaceLabelsPath_Key, "Face Labels", "The DataPath to the 'Face Labels' DataArray", DataPath(), - ArraySelectionParameter::AllowedTypes{DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{IArray::ShapeType{2}})); + ArraySelectionParameter::AllowedTypes{DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{{2}})); params.insert(std::make_unique(k_FeatureFaceIdsPath_Key, "Feature Face Ids", "The DataPath to the 'FeatureIds' DataArray", DataPath(), ArraySelectionParameter::AllowedTypes{DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{IArray::ShapeType{1}})); params.insert(std::make_unique(k_FaceNormalsPath_Key, "Face Normals", "The DataPath to the 'Feature Normals' DataArray", DataPath(), diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadStlFileFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadStlFileFilter.cpp index 69c1b6186e..7f00066725 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadStlFileFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadStlFileFilter.cpp @@ -77,7 +77,7 @@ Parameters ReadStlFileFilter::parameters() const params.insertSeparator(Parameters::Separator{"Output Face Data"}); params.insert(std::make_unique(k_FaceAttributeMatrixName_Key, "Face Data [AttributeMatrix]", "The name of the AttributeMatrix where the Face Data of the Triangle Geometry will be created", INodeGeometry2D::k_FaceDataName)); - params.insert(std::make_unique(k_FaceNormalsName_Key, "Face Labels", "The name of the triangle normals data array", "Face Normals")); + params.insert(std::make_unique(k_FaceNormalsName_Key, "Face Normals", "The name of the triangle normals data array", "Face Normals")); return params; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RegularGridSampleSurfaceMeshFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RegularGridSampleSurfaceMeshFilter.cpp index 82f0f5fc4d..ec722116a6 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RegularGridSampleSurfaceMeshFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RegularGridSampleSurfaceMeshFilter.cpp @@ -70,7 +70,7 @@ Parameters RegularGridSampleSurfaceMeshFilter::parameters() const params.insert(std::make_unique(k_TriangleGeometryPath_Key, "Triangle Geometry", "The geometry to be sampled onto grid", DataPath{}, GeometrySelectionParameter::AllowedTypes{GeometrySelectionParameter::AllowedType ::Triangle})); params.insert(std::make_unique(k_SurfaceMeshFaceLabelsArrayPath_Key, "Face Labels", "Array specifying which Features are on either side of each Face", DataPath{}, - ArraySelectionParameter::AllowedTypes{nx::core::DataType::int32})); + ArraySelectionParameter::AllowedTypes{nx::core::DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{{2}})); params.insertSeparator(Parameters::Separator{"Output Image Geometry"}); params.insert(std::make_unique(k_ImageGeomPath_Key, "Image Geometry", "The name and path for the image geometry to be created", DataPath{})); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SharedFeatureFaceFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SharedFeatureFaceFilter.cpp index cffc1e2e0f..0dce205c28 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SharedFeatureFaceFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SharedFeatureFaceFilter.cpp @@ -56,7 +56,7 @@ Parameters SharedFeatureFaceFilter::parameters() const params.insert(std::make_unique(k_TriGeometryDataPath_Key, "Triangle Geometry", "The complete path to the Geometry for which to calculate the normals", DataPath{}, GeometrySelectionParameter::AllowedTypes{IGeometry::Type::Triangle})); params.insert(std::make_unique(k_FaceLabelsArrayPath_Key, "Face Labels", "The DataPath to the FaceLabels values.", DataPath{}, - ArraySelectionParameter::AllowedTypes{nx::core::DataType::int32})); + ArraySelectionParameter::AllowedTypes{nx::core::DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{{2}})); params.insertSeparator(Parameters::Separator{"Output Face Data"}); params.insert(std::make_unique(k_FeatureFaceIdsArrayName_Key, "Feature Face Ids", "The name of the calculated Feature Face Ids DataArray", "SharedFeatureFaceId")); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp index f17329f1c4..1c39475fc9 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp @@ -78,7 +78,7 @@ Parameters UncertainRegularGridSampleSurfaceMeshFilter::parameters() const params.insert(std::make_unique(k_TriangleGeometryPath_Key, "Triangle Geometry", "The geometry to be sampled onto grid", DataPath{}, GeometrySelectionParameter::AllowedTypes{GeometrySelectionParameter::AllowedType ::Triangle})); params.insert(std::make_unique(k_SurfaceMeshFaceLabelsArrayPath_Key, "Face Labels", "Array specifying which Features are on either side of each Face", DataPath{}, - nx::core::GetAllDataTypes())); + ArraySelectionParameter::AllowedTypes{DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{{2}})); params.insertSeparator(Parameters::Separator{"Output Image Geometry"}); params.insert(std::make_unique(k_ImageGeomPath_Key, "Image Geometry", "The name and path for the image geometry to be created", DataPath{})); diff --git a/src/Plugins/SimplnxCore/test/CMakeLists.txt b/src/Plugins/SimplnxCore/test/CMakeLists.txt index d382927785..3205426c19 100644 --- a/src/Plugins/SimplnxCore/test/CMakeLists.txt +++ b/src/Plugins/SimplnxCore/test/CMakeLists.txt @@ -77,7 +77,7 @@ set(${PLUGIN_NAME}UnitTest_SRCS ComputeBiasedFeaturesTest.cpp ComputeBoundaryCellsTest.cpp ComputeBoundaryElementFractionsTest.cpp - ComputeTriangleGeomSizesTest.cpp + ComputeTriangleGeomVolumesTest.cpp FlyingEdges3DTest.cpp CreateColorMapTest.cpp IdentifySampleTest.cpp diff --git a/src/Plugins/SimplnxCore/test/ComputeTriangleGeomSizesTest.cpp b/src/Plugins/SimplnxCore/test/ComputeTriangleGeomVolumesTest.cpp similarity index 70% rename from src/Plugins/SimplnxCore/test/ComputeTriangleGeomSizesTest.cpp rename to src/Plugins/SimplnxCore/test/ComputeTriangleGeomVolumesTest.cpp index 33b890afcf..18ca9bae8d 100644 --- a/src/Plugins/SimplnxCore/test/ComputeTriangleGeomSizesTest.cpp +++ b/src/Plugins/SimplnxCore/test/ComputeTriangleGeomVolumesTest.cpp @@ -1,4 +1,4 @@ -#include "SimplnxCore/Filters/ComputeTriangleGeomSizesFilter.hpp" +#include "SimplnxCore/Filters/ComputeTriangleGeomVolumesFilter.hpp" #include "SimplnxCore/SimplnxCore_test_dirs.hpp" #include "simplnx/Parameters/ArrayCreationParameter.hpp" @@ -37,15 +37,15 @@ TEST_CASE("SimplnxCore::ComputeTriangleGeomSizes", "[SimplnxCore][ComputeTriangl { // Instantiate the filter and an Arguments Object - ComputeTriangleGeomSizesFilter filter; + ComputeTriangleGeomVolumesFilter filter; Arguments args; // Create default Parameters for the filter. - args.insertOrAssign(ComputeTriangleGeomSizesFilter::k_TriGeometryDataPath_Key, std::make_any(k_GeometryPath)); - args.insertOrAssign(ComputeTriangleGeomSizesFilter::k_FaceLabelsArrayPath_Key, std::make_any(k_FaceLabelsPath)); - args.insertOrAssign(ComputeTriangleGeomSizesFilter::k_FeatureAttributeMatrixPath_Key, std::make_any(k_FeatureAttributeMatrixPath)); + args.insertOrAssign(ComputeTriangleGeomVolumesFilter::k_TriGeometryDataPath_Key, std::make_any(k_GeometryPath)); + args.insertOrAssign(ComputeTriangleGeomVolumesFilter::k_FaceLabelsArrayPath_Key, std::make_any(k_FaceLabelsPath)); + args.insertOrAssign(ComputeTriangleGeomVolumesFilter::k_FeatureAttributeMatrixPath_Key, std::make_any(k_FeatureAttributeMatrixPath)); // Output Path - args.insertOrAssign(ComputeTriangleGeomSizesFilter::k_VolumesArrayName_Key, std::make_any(k_VolumesArrayName)); + args.insertOrAssign(ComputeTriangleGeomVolumesFilter::k_VolumesArrayName_Key, std::make_any(k_VolumesArrayName)); // Preflight the filter and check result auto preflightResult = filter.preflight(dataStructure, args); @@ -62,8 +62,20 @@ TEST_CASE("SimplnxCore::ComputeTriangleGeomSizes", "[SimplnxCore][ComputeTriangl const DataPath kNxArrayPath = k_FeatureAttributeMatrixPath.createChildPath(k_VolumesArrayName); const auto& kExemplarsArray = dataStructure.getDataRefAs(kExemplarArrayPath); - const auto& kNxArray = dataStructure.getDataRefAs(kNxArrayPath); + // The corrected version of the filter ensures there are no negative values. instead of + // uploading a new test file, we can just safely ensure the same applies to the + // exemplar data. + auto& exemplarData = dataStructure.getDataRefAs(kExemplarArrayPath); + auto& resultStore = exemplarData.getIDataStoreRefAs>(); + for(auto& value : resultStore) + { + if(value < 0) + { + value = std::abs(value); + } + } + const auto& kNxArray = dataStructure.getDataRefAs(kNxArrayPath); CompareDataArrays(kExemplarsArray, kNxArray); }