Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@
const Int32AbstractDataStore& m_FeatureIds;
MessageHelper& m_MessageHelper;
};

/**
* @brief Adjust the standard neighbors array for x, y, and z directions enabled / disabled.
* @param standardNeighbors
* @param xDir
* @param yDir
* @param zDir
*/
void adjustValidNeighbors(std::array<FaceNeighborType, 6>& standardNeighbors, bool xDir, bool yDir, bool zDir)
{
standardNeighbors[0] &= zDir;

Check warning on line 75 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, v143)

] [D:\a\simplnx\simplnx\build\Plugins\SimplnxCore\SimplnxCore.vcxproj]

Check warning on line 75 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, v143)

_Ty=nx::core::FaceNeighborType [D:\a\simplnx\simplnx\build\Plugins\SimplnxCore\SimplnxCore.vcxproj]

Check warning on line 75 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, v143)

[ [D:\a\simplnx\simplnx\build\Plugins\SimplnxCore\SimplnxCore.vcxproj]

Check warning on line 75 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, v143)

with [D:\a\simplnx\simplnx\build\Plugins\SimplnxCore\SimplnxCore.vcxproj]

Check warning on line 75 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, v143)

'&=': unsafe mix of type '_Ty' and type 'bool' in operation [D:\a\simplnx\simplnx\build\Plugins\SimplnxCore\SimplnxCore.vcxproj]
standardNeighbors[1] &= yDir;

Check warning on line 76 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, v143)

] [D:\a\simplnx\simplnx\build\Plugins\SimplnxCore\SimplnxCore.vcxproj]

Check warning on line 76 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, v143)

_Ty=nx::core::FaceNeighborType [D:\a\simplnx\simplnx\build\Plugins\SimplnxCore\SimplnxCore.vcxproj]

Check warning on line 76 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, v143)

[ [D:\a\simplnx\simplnx\build\Plugins\SimplnxCore\SimplnxCore.vcxproj]

Check warning on line 76 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, v143)

with [D:\a\simplnx\simplnx\build\Plugins\SimplnxCore\SimplnxCore.vcxproj]

Check warning on line 76 in src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp

View workflow job for this annotation

GitHub Actions / build (windows-2022, v143)

'&=': unsafe mix of type '_Ty' and type 'bool' in operation [D:\a\simplnx\simplnx\build\Plugins\SimplnxCore\SimplnxCore.vcxproj]
standardNeighbors[2] &= xDir;
standardNeighbors[3] &= zDir;
standardNeighbors[4] &= yDir;
standardNeighbors[5] &= xDir;
}
} // namespace

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -112,7 +129,9 @@

constexpr FaceNeighborType k_NumFaceNeighbors = VoxelNeighbors<Image3D>::k_FaceNeighborCount;
const std::array<int64, k_NumFaceNeighbors> neighborVoxelIndexOffsets = initializeFaceNeighborOffsets(dims);
constexpr std::array<FaceNeighborType, k_NumFaceNeighbors> faceNeighborInternalIdx = initializeFaceNeighborInternalIdx();
std::array<FaceNeighborType, k_NumFaceNeighbors> faceNeighborInternalIdx = initializeFaceNeighborInternalIdx();
// initializeFaceNeighborInternalIdx() does not take into acccount x/y/z being completely disabled.
adjustValidNeighbors(faceNeighborInternalIdx, m_InputValues->XDirOn, m_InputValues->YDirOn, m_InputValues->ZDirOn);

std::vector<int32> featureCount(numFeatures + 1, 0);

Expand Down Expand Up @@ -204,4 +223,4 @@
}

return {};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "SimplnxCore/Filters/Algorithms/ErodeDilateBadData.hpp"

#include "simplnx/DataStructure/DataPath.hpp"
#include "simplnx/DataStructure/Geometry/ImageGeom.hpp"
#include "simplnx/Parameters/ArraySelectionParameter.hpp"
#include "simplnx/Parameters/AttributeMatrixSelectionParameter.hpp"
#include "simplnx/Parameters/BoolParameter.hpp"
Expand All @@ -18,6 +19,12 @@

using namespace nx::core;

namespace
{
int32 k_NoDirections_Error = -14601;
int32 k_NoGeometryDimensions = -14602;
} // namespace

namespace nx::core
{

Expand Down Expand Up @@ -97,13 +104,29 @@ IFilter::PreflightResult ErodeDilateBadDataFilter::preflightImpl(const DataStruc
auto pOperationValue = filterArgs.value<ChoicesParameter::ValueType>(k_Operation_Key);
auto pFeatureIdsArrayPathValue = filterArgs.value<DataPath>(k_CellFeatureIdsArrayPath_Key);
auto pIgnoredDataArrayPathsValue = filterArgs.value<MultiArraySelectionParameter::ValueType>(k_IgnoredDataArrayPaths_Key);
auto xDirOn = filterArgs.value<bool>(k_XDirOn_Key);
auto yDirOn = filterArgs.value<bool>(k_YDirOn_Key);
auto zDirOn = filterArgs.value<bool>(k_ZDirOn_Key);
auto imageGeometryPath = filterArgs.value<DataPath>(k_SelectedImageGeometryPath_Key);

PreflightResult preflightResult;

nx::core::Result<OutputActions> resultOutputActions;

std::vector<PreflightValue> preflightUpdatedValues;

if(!xDirOn && !yDirOn && !zDirOn)
{
return {MakeErrorResult<OutputActions>(k_NoDirections_Error, "ErodeDilateBadData requires at least one direction to operate over")};
}

auto& imageGeom = dataStructure.getDataRefAs<ImageGeom>(imageGeometryPath);
auto dims = imageGeom.getDimensions();
if(dims[0] == 0 && dims[1] == 0 && dims[2] == 0)
{
return {MakeErrorResult<OutputActions>(k_NoGeometryDimensions, "ErodeDilateBadData requires that the ImageGeom have its dimensions set")};
}

std::string featureModificationWarning = "By modifying the cell level data, any feature data that was previously computed will most likely be invalid at this point. Filters that compute feature "
"level data should be rerun to ensure accurate final results from your pipeline.";
preflightUpdatedValues.emplace_back(PreflightValue{"Feature Data Modification Warning", featureModificationWarning});
Expand Down
Loading
Loading