Skip to content

BUG: Reject zero and nonfinite misorientation axes and loading directions - #1969

Closed
imikejackson wants to merge 1 commit into
BlueQuartzSoftware:developfrom
imikejackson:fix/orientation-axis-direction-validation
Closed

imikejackson wants to merge 1 commit into
BlueQuartzSoftware:developfrom
imikejackson:fix/orientation-axis-direction-validation

Conversation

@imikejackson

@imikejackson imikejackson commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Five OrientationAnalysis filters accepted an axis or direction parameter of [0, 0, 0], or with a NaN or infinite component. They normalized it to NaN (or Eigen left it as a zero vector), passed it to the EbsdLib AxisAngle conversions or the LaueOps metrics, and reported success with wrong output:

  • Compute Misorientation: a zero Reference Axis-Angle axis gave a non-unit reference quaternion.
  • Compute GBCD Pole Figure: a zero or NaN axis gave a NaN misorientation matrix and an all-zero MRD image (Direct and Scanline).
  • Write GBCD Pole Figure (GMT 5): the default axis was [0, 0, 0], so the default parameters wrote NaN for every point.
  • Compute GBCD (Metric-Based Approach): the axis check rejected only exact zero; NaN or infinite components passed. A NaN angle also passed the (0, 180] check.
  • Compute Feature Boundary Strength Metrics: the Loading Direction (XYZ) default was [0, 0, 0]; Vec3::normalize() made it NaN, so the m', F1, F1spt and F7 outputs were NaN.

Changes:

  • Each algorithm has a static check that preflightImpl() and the algorithm's operator()() both call, so the algorithm also rejects the value when it runs without its filter. The message names the parameter and the value and suggests a valid axis.
  • New OrientationUtilities::NormalizeDirection() (header-only, OrientationAnalysis) rejects nonfinite and zero vectors and normalizes after scaling by the largest component, in double precision. Compute GBCD Pole Figure and Write GBCD Pole Figure (GMT 5) normalized in float32, so a finite axis such as [1e20, 1e20, 1e20] overflowed to a zero axis; it now gives the same result as [1, 1, 1].
  • Defaults: Loading Direction (XYZ) changes from [0, 0, 0] to [1, 1, 1], which is the DREAM3D 6.5 FindBoundaryStrengths default. Misorientation Axis-Angle of Write GBCD Pole Figure (GMT 5) changes from [0, 0, 0, 0] to 60 degrees about [1, 1, 1] (the Σ3 twin, the default of Compute GBCD Pole Figure). DREAM3D 6.5 VisualizeGBCDGMT also defaulted to all zeros, so there is no valid legacy default to restore. SIMPL pipeline conversion always sets these values from the file, so only new filter instances see the new defaults. A saved pipeline that still holds a zero vector now fails preflight instead of writing NaN.
  • Filter documentation states the requirement and the error code.
Code Filter Failure
-68005 Compute Misorientation Reference Axis-Angle axis is zero or nonfinite (only in the Use Reference Axis Angle mode)
-34646 Compute GBCD Pole Figure Misorientation Angle-Axis axis is zero or nonfinite
-96714 Write GBCD Pole Figure (GMT 5) Misorientation Axis-Angle axis is zero or nonfinite
-94744 Compute Feature Boundary Strength Metrics Loading Direction is zero or nonfinite
-7231 (existing) Compute GBCD (Metric-Based Approach) Fixed Misorientation axis is zero or nonfinite (was zero only)
-7230 (existing) Compute GBCD (Metric-Based Approach) Fixed Misorientation angle outside (0, 180], now including NaN

Valid input gives the same output as before: every existing test of the five filters passes unchanged.

Overlap with open pull requests

Existing branches

I checked every branch on origin and fork for commits not in develop that touch the changed files. None fixes these items. The only other branch that touches them is fix/writegbcdgmt-crystal-structure-check (#1970, Write GBCD GMT files, different hunks). The branches of #1919 and #1859 are not on those remotes; their diffs were checked above.

Test Plan

  • New tests fail on develop (0cd2009) and pass with this change. On develop, preflight and execute returned success for every invalid axis, the default-value tests failed, and the scaled-axis pole figure differed (40.0 == Approx(48.083)):
    • OrientationAnalysis::ComputeMisorientationsFilter: Invalid Reference Axis (filter and algorithm without filter; Use Arrays mode ignores the axis)
    • OrientationAnalysis::ComputeGBCDPoleFigureFilter: Invalid Misorientation Axis (filter, Direct and Scanline executors)
    • OrientationAnalysis::ComputeGBCDPoleFigureFilter: Misorientation Axis Scale (both algorithm paths)
    • OrientationAnalysis::WriteGBCDGMTFileFilter: Invalid Misorientation Axis
    • OrientationAnalysis::WriteGBCDGMTFileFilter: Default Misorientation Axis-Angle
    • OrientationAnalysis::WriteGBCDGMTFileFilter: Misorientation Axis Scale
    • OrientationAnalysis::ComputeGBCDMetricBasedFilter: Nonfinite Fixed Misorientation
    • OrientationAnalysis::ComputeBoundaryStrengthsFilter: Invalid Loading Direction
    • OrientationAnalysis::ComputeBoundaryStrengthsFilter: Default Loading Direction
  • Full test sets of the changed filters pass, 27/27: ctest -R "OrientationAnalysis::(ComputeMisorientationsFilter|ComputeGBCDPoleFigureFilter|WriteGBCDGMTFileFilter|ComputeGBCDMetricBasedFilter|ComputeBoundaryStrengthsFilter)".
  • Linux x64, Release, Ninja, in-core build (SIMPLNX_TEST_ALGORITHM_PATH=0). New tests use synthetic data written by the test; the Metric-Based test uses the existing compute_gbcd_metric_based archive. No new data archives.
  • Out-of-core validation NOT run (no out-of-core build on this machine). A maintainer needs to run the dual-build protocol.
  • Skills that could not be loaded (not available in this environment): bluequartz-skills:cpp-best-practices, bluequartz-skills:simplnx-best-practices, filter-implementation, implement-filter-tests, error-messages, dual-build-protocol, clang-format, github-workflow. docs/Coding_Knowledge_Base.md was followed instead.

Related Issue

Related to #1873 (items ComputeMisorientationsFilter#2, ComputeGBCDPoleFigureFilter#5, WriteGBCDGMTFileFilter#1, ComputeGBCDMetricBasedFilter lines 149 and 154, ComputeBoundaryStrengthsFilter#2) and the default-value decision in #1875.

🤖 Generated with Claude Code

…ions

- Compute Misorientation, Compute GBCD Pole Figure, Write GBCD Pole Figure (GMT 5),
  Compute GBCD (Metric-Based Approach) and Compute Feature Boundary Strength
  Metrics accepted an axis or direction of [0, 0, 0] or with a NaN or infinite
  component. The filters then normalized it to NaN or to a zero vector and wrote
  wrong data with no error.
- Each algorithm now has a static check that preflight and the algorithm both
  call: -68005, -34646 (Direct and Scanline), -96714, -94744. Compute GBCD
  (Metric-Based Approach) keeps -7231 for the axis, now also for NaN and
  infinity, and -7230 now also rejects a NaN angle.
- The axes are normalized with OrientationUtilities::NormalizeDirection(), which
  scales by the largest component in double precision, so a large finite axis
  such as [1e20, 1e20, 1e20] no longer overflows float32 to a zero axis.
- The Loading Direction default changes from [0, 0, 0] to [1, 1, 1] (the
  DREAM3D 6.5 default). The Misorientation Axis-Angle default of Write GBCD
  Pole Figure (GMT 5) changes from [0, 0, 0, 0] to 60 degrees about [1, 1, 1].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@imikejackson

Copy link
Copy Markdown
Contributor Author

Closed in favor of #1973, which merges this branch (with its history) together with the other EBSD fixes that need the next EbsdLib release (BlueQuartzSoftware/EbsdLib#86). The branch is kept.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant