Skip to content

Commit

Permalink
ENH: Create DataModifiedAction that marks DataObjects as being modifi…
Browse files Browse the repository at this point in the history
…ed by a filter

Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Oct 9, 2023
1 parent 7f66507 commit 2b3526b
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ std::string RemoveMinimumSizeFeaturesFilter::humanName() const
//------------------------------------------------------------------------------
std::vector<std::string> RemoveMinimumSizeFeaturesFilter::defaultTags() const
{
return {className(), "Processing", "Cleanup", "MinSize"};
return {className(), "Processing", "Cleanup", "MinSize", "Feature Removal"};
}

Parameters RemoveMinimumSizeFeaturesFilter::parameters() const
Expand Down Expand Up @@ -386,6 +386,20 @@ IFilter::PreflightResult RemoveMinimumSizeFeaturesFilter::preflightImpl(const Da
outputActions.appendAction(std::move(action));
}

result = complex::GetAllChildDataPaths(data, featureGroupDataPath);
if(!result.has_value())
{
return {nonstd::make_unexpected(
std::vector<Error>{Error{k_FetchChildArrayError, fmt::format("Errors were encountered trying to retrieve the children of DataGroup '{}'", featureGroupDataPath.toString())}})};
}
std::vector<DataPath> featureDataGroupChildren = result.value();
for(const auto& child : featureDataGroupChildren)
{
auto action = std::make_unique<DataModifiedAction>(child);
outputActions.appendAction(std::move(action));
}

Check failure on line 400 in src/Plugins/ComplexCore/src/ComplexCore/Filters/RemoveMinimumSizeFeaturesFilter.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

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


Check warning on line 402 in src/Plugins/ComplexCore/src/ComplexCore/Filters/RemoveMinimumSizeFeaturesFilter.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

[clang-format] reported by reviewdog 🐶 Raw Output: src/Plugins/ComplexCore/src/ComplexCore/Filters/RemoveMinimumSizeFeaturesFilter.cpp:402:-
preflightResult.outputActions.warnings().push_back(Warning{k_NeighborListRemoval, ss});

return preflightResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ TEST_CASE("OrientationAnalysis::EBSDSegmentFeatures: Valid Execution", "[Orienta
auto preflightResult = filter.preflight(dataStructure, args);
COMPLEX_RESULT_REQUIRE_VALID(preflightResult.outputActions);

Check failure on line 79 in src/Plugins/OrientationAnalysis/test/EBSDSegmentFeaturesFilterTest.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

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


Check warning on line 81 in src/Plugins/OrientationAnalysis/test/EBSDSegmentFeaturesFilterTest.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

[clang-format] reported by reviewdog 🐶 Raw Output: src/Plugins/OrientationAnalysis/test/EBSDSegmentFeaturesFilterTest.cpp:81:-
auto preflightAcctions = preflightResult.outputActions.value().actions;

for(const auto& action : preflightAcctions)
{
const IDataCreationAction* creationActionPtr = dynamic_cast<const IDataCreationAction*>(action.get());
std::cout << creationActionPtr->getCreatedPath().toString() << "\n";
}

// Execute the filter and check the result
auto executeResult = filter.execute(dataStructure, args);
COMPLEX_RESULT_REQUIRE_VALID(executeResult.result);
Expand Down
39 changes: 39 additions & 0 deletions src/complex/Filter/Output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,45 @@ class COMPLEX_EXPORT IDataCreationAction : public IDataAction
DataPath m_CreatedPath;
};

class COMPLEX_EXPORT DataModifiedAction : public IDataAction
{
public:
DataModifiedAction(const DataPath& modifiedPath)
: m_ModifiedPath(modifiedPath)
{
}
~DataModifiedAction() noexcept override = default;

DataModifiedAction(const DataModifiedAction&) = delete;
DataModifiedAction(DataModifiedAction&&) noexcept = delete;
DataModifiedAction& operator=(const DataModifiedAction&) = delete;
DataModifiedAction& operator=(DataModifiedAction&&) noexcept = delete;

/**
* @brief Returns the DataPath of the top level object to be created.
* @return DataPath
*/
DataPath getModifiedPath() const
{
return m_ModifiedPath;
}

Result<> apply(DataStructure& dataStructure, Mode mode) const

Check warning on line 133 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

'apply' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 133 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

'apply' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 133 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

'apply' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 133 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

'apply' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 133 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

'apply' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 133 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

'apply' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 133 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

'apply' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 133 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

'apply' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 133 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

'apply' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 133 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

'apply' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
{
return {};
}
UniquePointer clone() const

Check warning on line 137 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

'clone' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 137 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

'clone' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 137 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

'clone' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 137 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

'clone' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 137 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (macos-11)

'clone' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 137 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

'clone' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 137 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

'clone' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 137 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

'clone' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 137 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

'clone' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Check warning on line 137 in src/complex/Filter/Output.hpp

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, clang++-10)

'clone' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
{
return std::make_unique<DataModifiedAction>(m_ModifiedPath);
}

protected:
DataModifiedAction() = default;

private:
DataPath m_ModifiedPath;
};

/**
* @brief Container for IDataActions
*/
Expand Down
20 changes: 16 additions & 4 deletions src/complex/Pipeline/PipelineFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,32 @@ bool PipelineFilter::preflight(DataStructure& data, RenamedPaths& renamedPaths,
}

std::vector<DataPath> newCreatedPaths;
std::vector<DataPath> newModifiedPaths;
for(const auto& action : result.outputActions.value().actions)
{
if(const auto* creationAction = dynamic_cast<const IDataCreationAction*>(action.get()); creationAction != nullptr)
if(const auto* creationActionPtr = dynamic_cast<const IDataCreationAction*>(action.get()); creationActionPtr != nullptr)
{
auto allCreatedPaths = creationAction->getAllCreatedPaths();
auto allCreatedPaths = creationActionPtr->getAllCreatedPaths();
newCreatedPaths.insert(newCreatedPaths.end(), allCreatedPaths.begin(), allCreatedPaths.end());
}
if(const auto* modifiedActionPtr = dynamic_cast<const DataModifiedAction*>(action.get()); modifiedActionPtr != nullptr)
{
newModifiedPaths.emplace_back(modifiedActionPtr->getModifiedPath());
}

Check failure on line 154 in src/complex/Pipeline/PipelineFilter.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

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

Check warning on line 155 in src/complex/Pipeline/PipelineFilter.cpp

View workflow job for this annotation

GitHub Actions / clang_format_pr

[clang-format] reported by reviewdog 🐶 Raw Output: src/complex/Pipeline/PipelineFilter.cpp:155:-
}
for(const auto& action : result.outputActions.value().deferredActions)
{
if(const auto* creationAction = dynamic_cast<const IDataCreationAction*>(action.get()); creationAction != nullptr)
if(const auto* creationActionPtr = dynamic_cast<const IDataCreationAction*>(action.get()); creationActionPtr != nullptr)
{
auto allCreatedPaths = creationAction->getAllCreatedPaths();
auto allCreatedPaths = creationActionPtr->getAllCreatedPaths();
newCreatedPaths.insert(newCreatedPaths.end(), allCreatedPaths.begin(), allCreatedPaths.end());
}
}

// Do not clear the created paths unless the preflight succeeded
m_CreatedPaths = newCreatedPaths;
m_ModifiedPaths = newModifiedPaths;

setPreflightStructure(data);
sendFilterFaultMessage(m_Index, getFaultState());
Expand Down Expand Up @@ -219,6 +226,11 @@ std::vector<DataPath> PipelineFilter::getCreatedPaths() const
return m_CreatedPaths;
}

std::vector<DataPath> PipelineFilter::getModifieldPaths() const
{
return m_ModifiedPaths;
}

namespace
{
/**
Expand Down
7 changes: 7 additions & 0 deletions src/complex/Pipeline/PipelineFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ class COMPLEX_EXPORT PipelineFilter : public AbstractPipelineNode
*/
std::vector<DataPath> getCreatedPaths() const;

/**
* @brief Returns a vector of DataPaths that would be modified when executing the node
* @return std::vector<DataPath>
*/
std::vector<DataPath> getModifieldPaths() const;

/**
* @brief Returns a collection of warnings returned by the target filter.
* This collection is cleared when the node is preflighted or executed.
Expand Down Expand Up @@ -220,5 +226,6 @@ class COMPLEX_EXPORT PipelineFilter : public AbstractPipelineNode
std::vector<complex::Error> m_Errors;
std::vector<IFilter::PreflightValue> m_PreflightValues;
std::vector<DataPath> m_CreatedPaths;
std::vector<DataPath> m_ModifiedPaths;
};
} // namespace complex

0 comments on commit 2b3526b

Please sign in to comment.