Repository navigation
BUG: Validate geometry transform values and rotation axes - #1952
joeykleingers wants to merge 4 commits into
Conversation
jmarquisbq
left a comment
There was a problem hiding this comment.
Reviewed simplnx #1952 at f151d087115a8e9e40230f0d2c0c74b4c8be997d. Coverage includes all 37 changed files.
Please address the two small corrections below. No Critical or Important implementation defects were found.
- Nit — Match the UI labels (CONFIRMED; documentation). In SetImageGeomOriginScalingFilter.md:41, replace Change Spacing with Set Spacing and both instances of Change Origin with Set Origin. The current wording names controls that differ from the labels in
parameters(). - Nit — Include the standard header for the new API type (CONFIRMED; C++ practice). ImageRotationUtilities.hpp:37 introduces
std::string_viewin the public validation API. Add#include <string_view>directly to this header instead of relying on transitive includes.
Optional future V&V note: During the planned V&V rewrite, map the new rotation validation branches and tests into the coverage tables. The validation change note records the change, but the tables do not yet map errors -86051 through -86053. V&V updates are intentionally deferred. This note does not block this PR, and no V&V update is requested here.
The rotation normalization, checked padding arithmetic and action cloning checked out. The affected filter, action and reader consumers were traced. The architecture and implementation were examined through all seven review lenses. No actionable architectural concerns were found.
Validation on this head:
- The Linux Release aggregate build passed.
- Serial CTest passed 136/136 selected entries, including all 35 new test cases, with zero skipped.
- Clang-format 19.1.1 passed all 28 changed C/C++ files.
- Scoped clang-tidy 19.1.0 was not clean on style/include diagnostics. There were no parse failures. Updated translation units were checked again after the final commit; applicable evidence was reused for unchanged code.
- Debug and real out-of-core execution were not independently rerun. CI results from the preceding head do not validate this head.
REQUEST CHANGES for the two small corrections above. The V&V note is optional and deferred.
|
Both items are fixed in 23ab28f:
The affected tests pass on macOS Release (161/161). The V&V coverage-table note is left for the planned V&V rewrite, as you suggested. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
jmarquisbq
left a comment
There was a problem hiding this comment.
Reviewed simplnx PR #1952 at 23ab28ffa9ac85b1f1c3c0e933b84d13dee12fb3. Coverage includes all 37 changed files.
1. Findings
No actionable findings. Both corrections from the previous review are complete: the documentation uses the on-screen option labels, and ImageRotationUtilities.hpp directly includes <string_view>.
2. Architecture and correctness
All seven review lenses covered implementation and architecture. No actionable architectural concerns were found. The review checked rotation normalization, checked padding arithmetic, deferred metadata validation, action cloning, and affected filter, reader and Python consumers.
The regression assertions use hand-computed rotation matrices, padding extents and expected output values. The new parameter checks use values available in preflight. Checks that depend on geometry metadata that upstream filters can change remain deferred to execution.
3. Validation and limits
- 3.1 New checks: clang-format 19.1.1 passed all 28 changed C/C++ files. The diff whitespace check passed. The comment audit reported 56 diagnostics, none on added lines; manual review found no actionable documentation issue introduced by this PR.
- 3.2 Current-head CI: GitHub reports successful Linux, Windows, macOS and formatting checks. Azure log retrieval failed, so the CI test counts were not independently inspected.
- 3.3 Reused evidence: the earlier Linux Release build and serial CTest run passed 136/136 selected entries, including all 35 new test cases, at
f151d087115a8e9e40230f0d2c0c74b4c8be997d. Changes after that commit correct documentation labels and add the direct include; runtime code is unchanged. - 3.4 Remaining limits: no new build or runtime tests were run for this follow-up review. Debug and real out-of-core execution remain independently unverified. Clang-tidy was not rerun; the earlier scoped run had style/include diagnostics and no parse failures.
- 3.5 Deferred V&V: the coverage-table mapping remains optional and deferred to the planned V&V rewrite. No V&V update is requested in this PR.
4. Verdict
APPROVE — no actionable findings within the reviewed scope.
23ab28f to
0f28142
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
0f28142 to
792163b
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
The axis-angle rotation matrix normalized its axis in float32 without a
check. A zero axis produced NaN, a large finite axis such as
{0,0,1e20} overflowed the squared norm, and a tiny axis such as
{1e-22,0,0} underflowed it, so valid rotations produced wrong matrices.
A vector shorter than four values was read out of bounds.
- Add ImageRotationUtilities::ValidateRotationAxisAngle(): four values,
a finite nonzero axis and a finite angle, each with its own error.
- GenerateRotationTransformationMatrix() keeps its signature. It scales
the axis by its largest component and normalizes it in float64; the
angle arithmetic is unchanged. Invalid input returns an all-NaN matrix
instead of undefined behavior.
- RotateSampleRefFrame validates the Axis-Angle value in preflight and
at algorithm entry. Zero or nonfinite axes now report the axis or
angle error instead of the non-principal-rotation error, and large
axes such as {0,0,1e20} at 90 degrees are accepted.
Matrices for ordinary axes are unchanged to within 2e-6.
Part of BlueQuartzSoftware#1873.
Signed-off-by: Joey Kleingers <joey.kleingers@bluequartz.net>
Image Geometry creation and transform filters accepted zero, negative, NaN or infinite spacing, origins, scales and cell lengths, and negative padding, producing invalid geometry, division by zero or unsigned wrap. - Add GeometryUtilities::ValidateFiniteVector(), ValidatePositiveFiniteVector() and ComputePaddedDimensions(). - CreateGeometry, CreateImageGeometry and SetImageGeomOriginScaling require positive finite spacing and finite origins; PartitionGeometry checks Advanced Cell Length and Partition Grid Origin before its geometry branch, so RectGrid and node geometries are covered too. - ApplyTransformationToGeometry validates the selected Translation, Scale or Rotation in preflight and at algorithm entry through ValidateTransformationParameters(). Image Geometry scale must be positive; node geometries keep zero and negative scale. - PadImageGeometry rejects negative padding and computes padded dimensions with widened, checked arithmetic in preflight and at algorithm entry. - Results that depend on existing geometry metadata (scaled spacing, translated, padded or centered origins, padded dimensions) are checked when the filter executes, before the geometry changes; preflight only warns, because the metadata can still change upstream. UpdateImageGeomAction gains an opt-in check for this. - UpdateImageGeomAction::clone() now keeps the Center Origin flag, and Center Origin places negative or mixed-sign origins at the geometry's center as documented. Apart from the two Center Origin corrections above, output for every previously valid value with a representable result is unchanged. Part of BlueQuartzSoftware#1873. Signed-off-by: Joey Kleingers <joey.kleingers@bluequartz.net>
…eflight Filter preflight is the one place a filter's inputs are checked; the algorithm classes do not repeat those checks. - ApplyTransformationToGeometry, PadImageGeometry and RotateSampleRefFrame no longer re-validate Translation, Scale, Rotation, padding signs or the rotation axis-angle at algorithm entry. ValidateTransformationParameters() and the padding sign check now live with their filters' preflight. - PadImageGeometry still checks, when it executes, the padded dimensions and origin it computes from the final geometry, because those can differ from what preflight sees. - Tests that called the algorithms directly to reach these errors now run the filters. Value checks keep their codes; wrong-length vectors now fail parameter validation (-1, naming the expected size), and a malformed inactive vector is accepted. Signed-off-by: Joey Kleingers <joey.kleingers@bluequartz.net>
- The Set Image Geom Origin Scaling documentation names the Set Spacing and Set Origin options by their on-screen labels. - ImageRotationUtilities.hpp includes <string_view> for its public validation function instead of relying on a transitive include. Signed-off-by: Joey Kleingers <joey.kleingers@bluequartz.net>
792163b to
f438170
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Summary
Geometry creation and transformation filters now reject spacing, origin, scale, cell-length, padding and rotation values outside their domain, instead of producing NaN or infinite geometry, dividing by zero, or wrapping unsigned arithmetic. The axis-angle rotation matrix normalizes large and tiny finite axes correctly. Results that depend on the geometry's current metadata are checked when the filter executes, before anything changes. 37 files changed, +1840 / −96 lines.
1. Rotation axes
ImageRotationUtilities::ValidateRotationAxisAngle()requires four values, a finite nonzero axis and a finite angle, with a separate error for each.GenerateRotationTransformationMatrix()keeps its signature. It scales the axis by its largest component and normalizes it infloat64; the angle arithmetic is unchanged. Invalid input returns an all-NaN matrix instead of undefined behavior.The axis was normalized in
float32: a zero axis produced NaN, an axis such as{0,0,1e20}overflowed the squared norm and{1e-22,0,0}underflowed it, so valid rotations produced wrong matrices.2. Spacing, origin, scale, cell length and padding
GeometryUtilities::ValidateFiniteVector(),ValidatePositiveFiniteVector()andComputePaddedDimensions()(widened, checked padded extents and tuple product).usizearithmetic.Preflight is the one place these parameters are checked. The algorithms document the parameter properties they rely on as preconditions; the shared rotation-matrix function keeps its own axis-angle check because Read H5 EBSD also passes it unvalidated file-header values.
3. Results that depend on existing geometry metadata
Scaled spacing, translated, padded and centered origins, and padded dimensions combine a parameter with the geometry's current spacing, origin or dimensions. Those values can still change upstream during execution (for example after a precomputed-matrix transformation), and
IFilter::execute()reruns preflight, so preflight only warns about them. They are rejected when the filter executes, before the geometry changes:UpdateImageGeomActiongains an opt-in check that runs in Execute mode before either setter, and Pad Image Geometry checks at algorithm entry, using source dimensions as placeholders in preflight.4. Center Origin
#1911 fixed the two Center Origin defects this pull request also fixed (the copied action that dropped the flag, and the offset for negative or mixed-sign origins). This pull request keeps that behavior:
UpdateImageGeomActionnow computes the centered origin with the same signed offset before either setter runs, so the execution check can reject a nonfinite result before the geometry changes, andclone()also copies the new validation flag.Changed behavior
{0,0,1e20}at 90°.Family entries fixed
This pull request fixes these entries of #1873; the issue stays open for its other parameter classes:
ImageRotationUtilities.cpp:184, moved from #1875)ApplyTransformationToGeometryFilterscale (GeometryTransformation.cpp:222) and translation (:213)PartitionGeometryFiltercell length (Advanced) and partition grid origin (:206)SetImageGeomOriginScalingFilterspacing (:110) and origin (:107)PadImageGeometryFilterpadding (:152)CreateGeometryFilter/CreateImageGeometryFilterspacing (the spacing part of theCreateImageGeometryAction.cpp:58entry) and origin (:225)It also fixes the Rotate Sample Reference Frame large-axis entry in #1908 (BUG: Fixes silent WRONG_DATA and CRASH bugs); the filter's V&V page has a note.
Not part of this pull request: the Partition Geometry cell-count and Create Geometry dimension parts of those entries, and the Partition Geometry bounding-box relations (later pull requests for #1873); existing geometry metadata that is already invalid (#1875); file-header values (#1877).
Integration notes:
{1,1}, Y{0,0}, nonzero data).Test plan
developwith BUG: Fix 10 WRONG_DATA findings from the filter sweep (#1908) #1910, BUG: Fix 9 crash and wrong-data findings from the filter sweep (#1908) #1911, BUG: Preserve child DataPaths in nested filter outputs #1941, BUG: Validate component shapes and apply masks to whole tuples #1942, ENH: Add 'nxinfo' tool #1745, ENH: Check filter inputs once, in preflight #1959, COMP: Compile each ImageProcessing filter executor once #1963 and BUG: Fix 21 filter defects ported from 'SIMPL' and 'DREAM3D' #1915, 177/177 on macOS.DREAM3DNX_ENABLE_OOC=ON,SIMPLNX_TEST_ALGORITHM_PATH=1) on macOS: 164/164; after the rebase, 182/182.ctest -L "^ooc$" -LE benchmarkwith SimplnxOocdevelop: 1052/1052.Related Issue
Related to #1873