Repository navigation
BUG: Validate sampling, resampling and geometry count values - #1964
Open
joeykleingers wants to merge 7 commits into
Open
joeykleingers wants to merge 7 commits into
joeykleingers wants to merge 7 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
3 of 4 tasks
joeykleingers
force-pushed
the
bug/c14-sampling-resampling
branch
from
November 13, 2026 19:38
4b7d655 to
8e77db8
Compare
Contributor
Author
|
/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>
Sampling, resampling and scan-path filters accepted zero, negative, NaN or infinite spacing, resolutions, sigmas, origins, angles and coordinates, which led to division by zero, loops that never end, float-to-integer conversions of nonfinite values and NaN output. - Preflight rejects invalid active values in Create AM Scan Paths, Point Sample Edge Geometry, Resample Image Geom, Approximate Point Cloud Hull, Uncertain Regular Grid Sample Surface Mesh, Interpolate Point Cloud To Regular Grid (Gaussian sigmas), Compute Coordinate Threshold (sphere), Extract Feature Boundaries 2D (custom Z) and Regular Grid Sample Surface Mesh (origin). Inactive options are not checked. - Values derived from the final geometry (resampled spacing and dimensions, hull grid bounds, edge sample counts, resampling axis maps) are checked when the filter executes, before any conversion or allocation; preflight warns and uses safe placeholders when the current geometry gives an unrepresentable layout. - Add ValidateResamplingParameters() and ComputeResampledImageLayout() for the shared resampling code. Output for every previously valid value is unchanged. Part of BlueQuartzSoftware#1873. Signed-off-by: Joey Kleingers <joey.kleingers@bluequartz.net>
Geometry-creation, partitioning, resampling, curvature, point-sampling and interpolation filters accepted zero or negative counts, signed values that wrapped to huge unsigned dimensions, nonfinite kernel sizes and dimension products that overflow, which led to empty or corrupt geometries, division by zero, huge allocations and float-to-integer conversions that are undefined behavior. - Preflight rejects negative Partition Geometry counts, partition products and ID ranges that cannot be represented (Basic, Advanced and Bounding Box modes), zero dimensions in Create Geometry (Image), Create Image Geometry, Resample Image Geom (Exact Dimensions) and Resample Rect Grid To Image Geom, Neighborhood Ring Count below 1 in Feature Face Curvature, negative Number of Sample Points in Point Sample Triangle Geometry and nonfinite Kernel Size in Interpolate Point Cloud To Regular Grid. Inactive options are not checked. - Values derived from final geometry are checked when the filter executes, before conversion or allocation: an existing partition grid's metadata, product and ID range, each coordinate-to-partition index conversion, and the interpolation kernel radius, size and storage. Preflight warns when the current geometry gives an unrepresentable kernel. - Add GeometryUtilities::ValidateImageDimensions() for the shared positive-dimension check. - A zero sample count now returns an empty vertex geometry without drawing samples; masked vertices are skipped before their coordinates are converted. Output for every previously valid value is unchanged. Part of BlueQuartzSoftware#1873. Signed-off-by: Joey Kleingers <joey.kleingers@bluequartz.net>
Read Image Stack accepted zero Exact 2D Dimensions and nonfinite Scaling, and read the Exact 2D Dimensions vector even when another resampling mode was selected. Zero dimensions produced infinite spacing in the resampled slices. - Preflight checks only the active resampling option, before reading slice metadata or creating output actions: Exact 2D Dimensions must be at least 1 with a representable product, and Scaling must be finite and at least 1 percent. These use the shared resampling checks. - Inactive resampling options are no longer read or checked. Output for every previously valid value is unchanged. Part of BlueQuartzSoftware#1873. Signed-off-by: Joey Kleingers <joey.kleingers@bluequartz.net>
joeykleingers
force-pushed
the
bug/c14-sampling-resampling
branch
from
November 14, 2026 15:13
8e77db8 to
93e1900
Compare
joeykleingers
marked this pull request as ready for review
November 14, 2026 15:18
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sampling, resampling, scan-path and geometry-creation filters now reject spacing, resolution, sigma, origin, angle, count and dimension values outside their domain in preflight, instead of looping forever, dividing by zero, converting NaN or infinite values to integers, or wrapping signed counts to huge unsigned sizes. Values that depend on the final geometry (resampled layouts, hull grids, edge sample counts, partition indices, interpolation kernels) are checked when the filter executes, before any conversion or allocation. 79 files changed, +4961 / −299 lines.
Dependency: stacked on #1952 (BUG: Validate geometry transform values and rotation axes), which adds the shared
GeometryUtilities::ValidateFiniteVector()andValidatePositiveFiniteVector()used here. Until #1952 merges, the diff againstdevelopalso shows its commits; review the last three commits. This pull request stays a draft until then.1. Spatial sampling and resampling values
src/simplnx/Utilities/ImageProcessing/ImageGeometryResample.{hpp,cpp}—ValidateResamplingParameters(),ComputeResampledImageLayout()and checked resampling axis mapssrc/Plugins/SimplnxCore/src/SimplnxCore/Filters/*Filter.cpp— per-filter preflight checkstest/ImageGeometryResampleTest.cpp— core tests for the shared resampling codePreflight rejects active values outside their domain:
float32square (Gaussian only).Inactive options are not checked or read. Resampled spacing, dimensions and tuple products, the hull's voxel bounds and grid product, and each edge's sample count depend on the final geometry. Preflight warns and uses unit placeholder dimensions and spacing when the current geometry gives a layout that cannot be represented; execution recomputes the layout from the final metadata and returns an error before converting or allocating.
The hull check covers the grid with the one-voxel empty border that #1910/#1911 added. The border is added in integer arithmetic after the check, so it is kept for voxel indices beyond 2^53, where
float64cannot represent ±1.2. Geometry and sampling counts
src/simplnx/Utilities/GeometryUtilities.{hpp,cpp}—ValidateImageDimensions()(positive dimensions with a representable product)src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/PartitionGeometry*.cpp— final-grid checks and checked coordinate-to-partition conversionsrc/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InterpolatePointCloudToRegularGrid.{hpp,cpp}—ComputeKernelLayout()Preflight rejects:
usizebefore the<= 0check, products that overflow, and partition IDs that do not fitint32from Starting Feature ID. Existing Partition Grid mode ignores the counts.Checked during execution:
3. Read Image Stack resampling
src/Plugins/NXImageProcessing/src/NXImageProcessing/Filters/ReadImageStackFilter.cppPreflight checks only the selected resampling option, before reading slice metadata: Exact 2D Dimensions must be at least 1 with a representable product, and Scaling must be finite and at least 1 percent, through the shared resampling checks. Exact 2D Dimensions is no longer read when another mode is selected.
Preflight is the one place these parameters are checked. The algorithms state the properties they rely on as
@preconditions and check only values that preflight cannot know.Changed behavior
Family entries fixed
This pull request fixes these entries of #1873; the issue stays open for its other parameter classes:
CreateAMScanPathsFilterhatch spacing (CreateAMScanPaths.cpp:190) and rotation angle (:421)PointSampleEdgeGeometryFiltersampling spacing (PointSampleEdgeGeometry.cpp:73)ResampleImageGeomFilterspacing and exact dimensions (ImageGeometryResample.cpp:260)ApproximatePointCloudHullFiltergrid resolution (ApproximatePointCloudHullFilter.cpp:86) and empty-neighbor maximum (ApproximatePointCloudHull.cpp:178)UncertainRegularGridSampleSurfaceMeshFilterspacing, origin and uncertainty (:138)InterpolatePointCloudToRegularGridFilterGaussian sigmas (:172) and kernel size (InterpolatePointCloudToRegularGrid.cpp:417)ComputeCoordinateThresholdFiltersphere (:165)ExtractFeatureBoundaries2DFiltercustom Z (ExtractFeatureBoundaries2D.cpp:265)RegularGridSampleSurfaceMeshFilterorigin (:200)PartitionGeometryFiltercell counts (the count part of the:550entry)ResampleRectGridToImageGeomFilterdimensions (:113)CreateGeometryFilter/CreateImageGeometryFilterdimensions (the dimension part of theCreateImageGeometryAction.cpp:58entry)FeatureFaceCurvatureFilterring count (:58)PointSampleTriangleGeometryFiltersample count (PointSampleTriangleGeometry.cpp:64)ReadImageStackFilterexact 2D dimensions (:302)Not part of this pull request: the Partition Geometry bounding-box and Compute Coordinate Threshold rectangle relations, and the Read Image Stack origin and spacing overrides (later pull requests for #1873); cancellation in the Create AM Scan Paths hatch loop (#1876); and results that overflow
float32from finite values (#1874). Until the bounding-box entry is fixed, the execution check of the partition grid's origin and spacing is what rejects a nonfinite bounding box.Test plan
developwhere that is safe (accepted invalid spacing, sigmas, origins, angles, counts and dimensions; zero exact dimensions that give infinite spacing) and pass with the fix. Cases wheredevelopreaches undefined behavior (nonfinite-to-integer conversions, non-terminating loops, oversized allocations) are tested against the fixed code only. Controls check inactive options, valid boundaries, zero sample points, provisional pipeline geometry that becomes valid during execution, and both Direct and Scanline partition paths. Malformed vectors assert the parameter and the required and received lengths.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, 344/344 on macOS (this run also includes the tests of BUG: Validate geometry transform values and rotation axes #1952).DREAM3DNX_ENABLE_OOC=ON,SIMPLNX_TEST_ALGORITHM_PATH=1) on macOS: 296/296; after the rebase, 353/353.ctest -L "^ooc$" -LE benchmark: 1050/1050; after the rebase, 1051/1052. The one failure, DREAM3D-NX'sNXVtkLibImportedHistogramTests, is timing-sensitive under load and fails the same way in the BUG: Validate geometry transform values and rotation axes #1952 build.Related Issue
Related to #1873