Skip to content

Commit 6406635

Browse files
authored
ENH: ApplyTransformationToGeometry: Better error messages, Update documentation. (BlueQuartzSoftware#835)
Signed-off-by: Michael Jackson <[email protected]>
1 parent 18498ae commit 6406635

File tree

2 files changed

+40
-31
lines changed

2 files changed

+40
-31
lines changed

src/Plugins/SimplnxCore/docs/ApplyTransformationToGeometryFilter.md

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,37 @@
22

33
## Group (Subgroup)
44

5-
Rotation & Transformation
5+
Rotation, Scale & Transformation
66

77
## Description
88

9-
This **Filter** applies a spatial transformation to either and unstructured **Geometry** or an ImageGeometry. An "
10-
unstructured" **Geometry** is any geometry that requires explicit definition of **Vertex** positions. Specifically, *
11-
*Vertex**, **Edge**, **Triangle**, **Quadrilateral**, and **Tetrahedral** **Geometries** may be transformed by this *
12-
*Filter**. The transformation is applied in place, so the input **Geometry** will be modified.
9+
### Unstructured Grid Geometries
1310

14-
If the user selects an **Image Geometry** then they will need to select which kind of **Interpolation Method* will be
15-
used when transferring the data from the old geometry to the newly transformed geometry. If the user selects *any other*
16-
kind of geometry then the user should select the "No Interpolation" selection to disable the requirement for a *Cell Attribute Matrix*.
11+
This **Filter** applies a spatial transformation to either and unstructured **Geometry** or an **Image Geometry**. An "unstructured" **Geometry** is any geometry that requires explicit definition of **Vertex** positions. Specifically, **Vertex**, **Edge**, **Triangle**, **Quadrilateral**, and **Tetrahedral** **Geometries** may be transformed by this **Filter**. The transformation is applied in place, so the input **Geometry** will be modified.
12+
13+
- **NO** interpolation will take place as the only changes that take place are the actual coordinates of the vertices.
14+
15+
### Image Geometry
16+
17+
If the user selects an **Image Geometry** then there are 2 additional required filter parameters that need to be set:
18+
19+
- **Interpolation Method**: This will be used when transferring the data from the old geometry to the newly transformed geometry.
20+
- **Cell Attribute Matrix**: This Attribute Matrix holds the data that is associated with each cell of the image geometry.
1721

1822
The linear/Bi-Linear/Tri-Linear Interpolation is adapted from the equations presented
1923
in [https://www.cs.purdue.edu/homes/cs530/slides/04.DataStructure.pdf, page 36}](https://www.cs.purdue.edu/homes/cs530/slides/04.DataStructure.pdf)
2024

2125
### Caveats
2226

23-
- If the user selects an **unstructured** based geometry, **NO** interpolation will take place as the only changes that
24-
take place are the actual coordinates of the vertices.
25-
26-
- If the user selects an **Image Geometry** then the user should select one of the *Interpolation* methods and then also
27-
select the appropriate *Cell Attribute Matrix*.
28-
29-
The **Scale** and **Rotation** transformation types will automatically translate the volume to (0, 0, 0), apply the scaling/rotation,
30-
and then translate the volume back to its original location. If the **Manual Transformation Matrix** or **Pre-Computed Transformation
31-
Matrix** types are selected, then it is up to the user to make sure that those translations are included, if necessary.
27+
- The **Scale** and **Rotation** transformation types will automatically translate the volume to (0, 0, 0), apply the scaling/rotation, and then translate the volume back to its original location. If the **Manual Transformation Matrix** or **Pre-Computed Transformation Matrix** types are selected, then it is up to the user to make sure that those translations are included, if necessary.
3228

33-
## Example Transformations
29+
## Example Image Geometry Transformations
3430

3531
| Description | Example Output Image |
3632
|-------------|----------------------|
37-
| Untransformed | ![](Images/ApplyTransformation_AsRead.png) |
38-
| After Rotation of <001> 45 Degrees | ![](Images/ApplyTransformation_Rotated.png) |
39-
| Scaled (2.0, 2.0, 1.0) | ![](Images/ApplyTransformation_Scaled.png) |
33+
| Input Image | ![Input Image](Images/ApplyTransformation_AsRead.png) |
34+
| After Rotation of 45 Degrees around the <001> axis | ![Rotation of 45 Degrees around the <0,0,1> axis](Images/ApplyTransformation_Rotated.png) |
35+
| Scaled by 2x in the X and Y axis | ![Scaled by 2x in the X and Y axis.](Images/ApplyTransformation_Scaled.png) |
4036

4137
## Transformation Information
4238

@@ -55,9 +51,9 @@ The user may select from a variety of options for the type of transformation to
5551

5652
## Example Pipelines
5753

58-
+ Pipelines/SimplnxCore/Examples/apply_transformation_basic.d3dpipeline
59-
+ Pipelines/SimplnxCore/Examples/apply_transformation_image.d3dpipeline
60-
+ Pipelines/SimplnxCore/Examples/apply_transformation_node.d3dpipeline
54+
- Pipelines/SimplnxCore/Examples/apply_transformation_basic.d3dpipeline
55+
- Pipelines/SimplnxCore/Examples/apply_transformation_image.d3dpipeline
56+
- Pipelines/SimplnxCore/Examples/apply_transformation_node.d3dpipeline
6157

6258
## License & Copyright
6359

src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ApplyTransformationToGeometryFilter.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ std::string ApplyTransformationToGeometryFilter::humanName() const
6868
//------------------------------------------------------------------------------
6969
std::vector<std::string> ApplyTransformationToGeometryFilter::defaultTags() const
7070
{
71-
return {className(), "DREAM3D Review", "Rotation/Transforming"};
71+
return {className(), "Scale", "Flip", "Mirror", "Rotation", "Transforming"};
7272
}
7373

7474
//------------------------------------------------------------------------------
@@ -171,8 +171,9 @@ IFilter::PreflightResult ApplyTransformationToGeometryFilter::preflightImpl(cons
171171
{
172172
case k_NoTransformIdx: // No-Op
173173
{
174-
resultOutputActions.warnings().push_back(Warning{82001, "No transformation has been selected, so this filter will perform no operations"});
174+
resultOutputActions.warnings().push_back(Warning{82001, "No transformation has been selected. This filter will NOT modify any data."});
175175
transformationMatrixDesc = "No transformation matrix selected.";
176+
break;
176177
}
177178
case k_PrecomputedTransformationMatrixIdx: // Transformation matrix from array
178179
{
@@ -237,16 +238,28 @@ IFilter::PreflightResult ApplyTransformationToGeometryFilter::preflightImpl(cons
237238

238239
preflightUpdatedValues.push_back({"Generated Transformation Matrix", transformationMatrixDesc});
239240

241+
std::stringstream errorMessage;
242+
errorMessage << "You have selected to transform an 'Image Geometry', please correct the following issues:\n";
243+
bool imageGeomInterpolationError = false;
244+
240245
auto pInterpolationTypeValue = filterArgs.value<ChoicesParameter::ValueType>(k_InterpolationType_Key);
241-
// auto pDataArraySelectionValue = filterArgs.value<MultiArraySelectionParameter::ValueType>(k_DataArraySelection_Key);
246+
if(pInterpolationTypeValue == k_NoInterpolationIdx)
247+
{
248+
errorMessage << "* Select either 'Nearest Neighbor Resampling' or 'Linear Interpolation' from the 'Image Geometry Resampling/Interpolation' parameter section.\n";
249+
imageGeomInterpolationError = true;
250+
}
242251

243-
// For nearest neighbor we can use any data array as we are only going to copy from a hit cell, no interpolation
244252
const auto* srcCellAttrMatrixPtr = dataStructure.getDataAs<AttributeMatrix>(pCellAttributeMatrixPath);
245253
if(nullptr == srcCellAttrMatrixPtr)
246254
{
247-
return {MakeErrorResult<OutputActions>(
248-
-82006, fmt::format("DataPath '{}' is not an Cell AttributeMatrix. Please select the Cell level AttributeMatrix of the Image Geometry", pCellAttributeMatrixPath.toString()))};
255+
errorMessage << "* Select the Image Geometry's cell level Attribute Matrix. This will contain all the data that will be interpolated onto the new Image Geometry.";
256+
imageGeomInterpolationError = true;
249257
}
258+
if(imageGeomInterpolationError)
259+
{
260+
return {MakeErrorResult<OutputActions>(-82006, errorMessage.str())};
261+
}
262+
250263
std::vector<std::string> selectedCellArrayNames = srcCellAttrMatrixPtr->getDataMap().getNames();
251264

252265
if(pInterpolationTypeValue == k_LinearInterpolationIdx)
@@ -417,7 +430,7 @@ IFilter::PreflightResult ApplyTransformationToGeometryFilter::preflightImpl(cons
417430
// An image geometry was not chosen, so throw a warning communicating to the user that the cell attribute matrix will not be used
418431
if(!pCellAttributeMatrixPath.getTargetName().empty())
419432
{
420-
auto warning = Warning{-5555, fmt::format("The Selected Geometry is not an image geometry, so the Attribute Matrix '{}' will not be used when applying this transformation.",
433+
auto warning = Warning{-5555, fmt::format("The selected geometry is not an 'Image Geometry'. NO interpolation is performed on the data. The 'Cell Attribute Matrix' DataPath can be empty.",
421434
pCellAttributeMatrixPath.getTargetName())};
422435
resultOutputActions.warnings().push_back(warning);
423436
}

0 commit comments

Comments
 (0)