-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: AppendImageGeometryZSliceFilter -> AppendImageGeometryFilter (#1041
) * Renamed AppendImageGeometryZSliceFilter to AppendImageGeometryFilter. * Added the ability to append image geometries in the X and Y directions in addition to the Z direction. * Added the ability to append multiple image geometries at once. * Updated unit test to test the X and Y directions. * Updated the documentation. Signed-off-by: Joey Kleingers <[email protected]>
- Loading branch information
1 parent
e473c9a
commit 6a4de83
Showing
19 changed files
with
16,266 additions
and
15,878 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Append Image Geometry | ||
|
||
## Group (Subgroup) | ||
|
||
Sampling (Memory/Management) | ||
|
||
## Description | ||
|
||
This filter allows the user to append one or multiple image geometries to a given image geometry, in any direction (X,Y,Z). The input and | ||
destination **ImageGeometry** objects must have the same dimensions in the directions that are NOT chosen. If the X direction is chosen, the geometries must match in Y & Z. If the Y direction is chosen, the geometries must match in X & Z. If the Z direction is chosen, the geometries must match in X & Y. Optional checks for equal **Resolution** values can also be performed. | ||
|
||
For the X direction example, if the user has an already existing **Image Geometry** that is 100 voxels in the *Y* direction by 300 pixels in the | ||
*Z* direction and composed of 10 *X* slices, then if the user appends another three data sets in the X direction that are the same dimensions in Y & Z but contain | ||
20 *X* slices each, the resulting **Image Geometry** will have a total of 70 *X* slices. | ||
|
||
For the Y direction example, if the user has an already existing **Image Geometry** that is 400 voxels in the *X* direction by 200 pixels in the | ||
*Z* direction and composed of 50 *Y* slices, then if the user appends another two data sets in the Y direction that are the same dimensions in X & Z but contain | ||
40 *Y* slices each, the resulting **Image Geometry** will have a total of 130 *Y* slices. | ||
|
||
For the Z direction example, if the user has an already existing **Image Geometry** that is 100 voxels in the *X* direction by 200 pixels in the | ||
*Y* direction and composed of 5 *Z* slices, then if the user appends one other data set in the Z direction that is the same dimensions in X & Y but contains | ||
10 *Z* slices, the resulting **Image Geometry** will have a total of 15 *Z* slices. | ||
|
||
% Auto generated parameter table will be inserted here | ||
|
||
## Example Pipelines | ||
|
||
## License & Copyright | ||
|
||
Please see the description file distributed with this **Plugin** | ||
|
||
## DREAM3D-NX Help | ||
|
||
If you need help, need to file a bug report or want to request a new feature, please head over to the [DREAM3DNX-Issues](https://github.com/BlueQuartzSoftware/DREAM3DNX-Issues/discussions) GitHub site where the community of DREAM3D-NX users can help answer your questions. |
27 changes: 0 additions & 27 deletions
27
src/Plugins/SimplnxCore/docs/AppendImageGeometryZSliceFilter.md
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/AppendImageGeometry.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
#include "AppendImageGeometry.hpp" | ||
|
||
#include "simplnx/DataStructure/Geometry/ImageGeom.hpp" | ||
#include "simplnx/DataStructure/IArray.hpp" | ||
#include "simplnx/Utilities/DataArrayUtilities.hpp" | ||
#include "simplnx/Utilities/ParallelTaskAlgorithm.hpp" | ||
|
||
using namespace nx::core; | ||
|
||
// ----------------------------------------------------------------------------- | ||
AppendImageGeometry::AppendImageGeometry(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, AppendImageGeometryInputValues* inputValues) | ||
: m_DataStructure(dataStructure) | ||
, m_InputValues(inputValues) | ||
, m_ShouldCancel(shouldCancel) | ||
, m_MessageHandler(mesgHandler) | ||
{ | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
AppendImageGeometry::~AppendImageGeometry() noexcept = default; | ||
|
||
// ----------------------------------------------------------------------------- | ||
const std::atomic_bool& AppendImageGeometry::getCancel() | ||
{ | ||
return m_ShouldCancel; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
Result<> AppendImageGeometry::operator()() | ||
{ | ||
Result<> results = {}; | ||
|
||
auto& destGeometry = m_DataStructure.getDataRefAs<ImageGeom>(m_InputValues->DestinationGeometryPath); | ||
AttributeMatrix* destCellData = destGeometry.getCellData(); | ||
const DataPath destCellDataPath = m_InputValues->DestinationGeometryPath.createChildPath(destCellData->getName()); | ||
DataPath newCellDataPath = destCellDataPath; | ||
AttributeMatrix* newCellData = destCellData; | ||
SizeVec3 destGeomDims = destGeometry.getDimensions(); | ||
|
||
if(m_InputValues->SaveAsNewGeometry) | ||
{ | ||
newCellData = m_DataStructure.getDataRefAs<ImageGeom>(m_InputValues->NewGeometryPath).getCellData(); | ||
newCellDataPath = m_InputValues->NewGeometryPath.createChildPath(newCellData->getName()); | ||
} | ||
else | ||
{ | ||
auto newDestGeomDims = destGeomDims; | ||
auto dim = to_underlying(m_InputValues->Direction); | ||
for(const auto& inputGeometryPath : m_InputValues->InputGeometriesPaths) | ||
{ | ||
const auto& inputGeometry = m_DataStructure.getDataRefAs<ImageGeom>(inputGeometryPath); | ||
SizeVec3 inputGeomDims = inputGeometry.getDimensions(); | ||
newDestGeomDims[dim] = newDestGeomDims[dim] + inputGeomDims[dim]; | ||
} | ||
destGeometry.setDimensions(newDestGeomDims); | ||
const std::vector<size_t> newDims = {newDestGeomDims[2], newDestGeomDims[1], newDestGeomDims[0]}; | ||
destCellData->resizeTuples(newDims); | ||
} | ||
|
||
ParallelTaskAlgorithm taskRunner; | ||
for(const auto& [dataId, dataObject] : *newCellData) | ||
{ | ||
if(getCancel()) | ||
{ | ||
return {}; | ||
} | ||
|
||
const std::string name = dataObject->getName(); | ||
|
||
auto* newDataArray = m_DataStructure.getDataAs<IArray>(newCellDataPath.createChildPath(name)); | ||
auto* destDataArray = m_DataStructure.getDataAs<IArray>(destCellDataPath.createChildPath(name)); | ||
if(destDataArray == nullptr || newDataArray == nullptr) | ||
{ | ||
continue; | ||
} | ||
|
||
std::vector<const IArray*> inputDataArrays; | ||
std::vector<std::vector<usize>> inputTupleShapes; | ||
if(m_InputValues->SaveAsNewGeometry) | ||
{ | ||
inputDataArrays.push_back(destDataArray); | ||
|
||
auto tupleShape = destGeometry.getDimensions().toContainer<std::vector<usize>>(); | ||
std::reverse(tupleShape.begin(), tupleShape.end()); | ||
inputTupleShapes.push_back(tupleShape); | ||
} | ||
|
||
for(const auto& inputGeometryPath : m_InputValues->InputGeometriesPaths) | ||
{ | ||
const auto& inputGeometry = m_DataStructure.getDataRefAs<ImageGeom>(inputGeometryPath); | ||
const DataPath inputCellDataPath = inputGeometryPath.createChildPath(inputGeometry.getCellData()->getName()); | ||
|
||
auto tupleShape = inputGeometry.getDimensions().toContainer<std::vector<usize>>(); | ||
std::reverse(tupleShape.begin(), tupleShape.end()); | ||
inputTupleShapes.push_back(tupleShape); | ||
|
||
if(m_DataStructure.getData(inputCellDataPath.createChildPath(name)) == nullptr) | ||
{ | ||
results = MergeResults( | ||
results, | ||
MakeWarningVoidResult( | ||
-8213, fmt::format("Data object {} does not exist in the input geometry cell data attribute matrix. Cannot append data so the resulting data object will likely contain invalid data!", | ||
name))); | ||
continue; | ||
} | ||
|
||
auto* inputDataArray = m_DataStructure.getDataAs<IArray>(inputCellDataPath.createChildPath(name)); | ||
if(inputDataArray == nullptr) | ||
{ | ||
continue; | ||
} | ||
inputDataArrays.push_back(inputDataArray); | ||
} | ||
|
||
if(m_InputValues->SaveAsNewGeometry) | ||
{ | ||
m_MessageHandler(fmt::format("Combining data into array {}", newCellDataPath.createChildPath(name).toString())); | ||
CopyFromArray::RunParallelCombine(*newDataArray, taskRunner, inputDataArrays, inputTupleShapes, m_InputValues->Direction); | ||
} | ||
else | ||
{ | ||
m_MessageHandler(fmt::format("Appending data into array {}", newCellDataPath.createChildPath(name).toString())); | ||
auto destGeomDimsVec = destGeomDims.toContainer<std::vector<usize>>(); | ||
std::reverse(destGeomDimsVec.begin(), destGeomDimsVec.end()); | ||
CopyFromArray::RunParallelAppend(*destDataArray, taskRunner, inputDataArrays, inputTupleShapes, destGeomDimsVec, m_InputValues->Direction); | ||
} | ||
} | ||
taskRunner.wait(); // This will spill over if the number of DataArrays to process does not divide evenly by the number of threads. | ||
|
||
return results; | ||
} |
50 changes: 50 additions & 0 deletions
50
src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/AppendImageGeometry.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include "SimplnxCore/SimplnxCore_export.hpp" | ||
|
||
#include "simplnx/DataStructure/DataPath.hpp" | ||
#include "simplnx/DataStructure/DataStructure.hpp" | ||
#include "simplnx/Filter/IFilter.hpp" | ||
#include "simplnx/Parameters/DataGroupSelectionParameter.hpp" | ||
#include "simplnx/Utilities/DataArrayUtilities.hpp" | ||
|
||
namespace nx::core | ||
{ | ||
|
||
struct SIMPLNXCORE_EXPORT AppendImageGeometryInputValues | ||
{ | ||
std::vector<DataPath> InputGeometriesPaths; | ||
DataPath DestinationGeometryPath; | ||
DataPath NewGeometryPath; | ||
bool CheckResolution; | ||
bool SaveAsNewGeometry; | ||
CopyFromArray::Direction Direction; | ||
}; | ||
|
||
/** | ||
* @class AppendImageGeometry | ||
* @brief This filter allows the user to append an Image Geometry onto the "end" of another Image Geometry. | ||
*/ | ||
class SIMPLNXCORE_EXPORT AppendImageGeometry | ||
{ | ||
public: | ||
AppendImageGeometry(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, AppendImageGeometryInputValues* inputValues); | ||
~AppendImageGeometry() noexcept; | ||
|
||
AppendImageGeometry(const AppendImageGeometry&) = delete; | ||
AppendImageGeometry(AppendImageGeometry&&) noexcept = delete; | ||
AppendImageGeometry& operator=(const AppendImageGeometry&) = delete; | ||
AppendImageGeometry& operator=(AppendImageGeometry&&) noexcept = delete; | ||
|
||
Result<> operator()(); | ||
|
||
const std::atomic_bool& getCancel(); | ||
|
||
private: | ||
DataStructure& m_DataStructure; | ||
const AppendImageGeometryInputValues* m_InputValues = nullptr; | ||
const std::atomic_bool& m_ShouldCancel; | ||
const IFilter::MessageHandler& m_MessageHandler; | ||
}; | ||
|
||
} // namespace nx::core |
100 changes: 0 additions & 100 deletions
100
src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/AppendImageGeometryZSlice.cpp
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.