Skip to content

BUG: Fix input validation in four EBSD and mesh filters - #1965

Closed
imikejackson wants to merge 5 commits into
BlueQuartzSoftware:developfrom
imikejackson:topic/hex_to_square_ang_extension_case
Closed

imikejackson wants to merge 5 commits into
BlueQuartzSoftware:developfrom
imikejackson:topic/hex_to_square_ang_extension_case

Conversation

@imikejackson

@imikejackson imikejackson commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This change fixes four reader and filter defects in the OrientationAnalysis and SimplnxCore plugins. Convert Hexagonal Grid Data to Square Grid Data accepts the .ang extension in any letter case. Read EDAX OIMAnalysis Data (.h5) and Read Bruker Nano Esprit Data (.h5) reject scans with different dimensions. Hierarchical Smoothing stops when its reference length is not valid. Write Pole Figure accepts only supported sampling dimensions and uses less memory in preflight. Each fix is a separate commit. 20 files changed, +889 / −48 lines.

1. Convert Hexagonal Grid Data to Square Grid Data (TSL - .ang)

  • src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ConvertHexGridToSquareGrid.cpp — IsAngFile helper, used in preflight and execute.
  • src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ConvertHexGridToSquareGridFilter.cpp — extension checks and messages.

The filter accepts .ang, .Ang, .ANG and other letter cases, in preflight and execute, for one file and for a file list. The output file keeps the letter case of the input name. A .ctf extension in any letter case still gives error -44601. Error -44602 names the file, the extension found and the accepted extension. Error code -446003 is corrected to -44603. The #1867 item for this filter also asks to share the extension dispatch with EbsdToH5Ebsd; that part is not in this change.

2. Read EDAX OIMAnalysis Data (.h5) and Read Bruker Nano Esprit Data (.h5)

  • src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5OimDataFilter.cpp and ReadH5EspritDataFilter.cpp — preflight reads the header of every selected scan.
  • src/Plugins/OrientationAnalysis/src/OrientationAnalysis/utilities/IEbsdOemReader.hpp — execute check before each scan is copied.
  • docs/Coding_Knowledge_Base.md — the "Check tuple counts in preflight" entry now requires a check of every scan, per axis.

Preflight compares the columns and the rows of each selected scan with the first scan. A mismatch gives -9592 (EDAX) or -9684 (Esprit), and the message names both scans and their dimensions. The shared execute loop checks each scan against the Image Geometry before it copies the scan (-8972). This also covers a file that changes between preflight and execute, and it applies to the Oxford Instruments reader too. A header-read failure of a later scan names the scan and the file (-9582 / -9682). The reader message in these errors is empty because of an EbsdLib defect: BlueQuartzSoftware/EbsdLib#69. This fixes the #1867 items ReadH5EspritDataFilter#1 and the dimension part of ReadH5OimDataFilter#2; the part about more phases in a later scan stays open.

3. Hierarchical Smoothing

  • src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/HierarchicalSmooth.cpp — reference-length check.
  • src/Plugins/SimplnxCore/docs/HierarchicalSmoothFilter.md — Error Threshold section.

The filter stops with error -19460 when the reference length from the first triangle is zero or not finite (coincident nodes, or NaN or infinite coordinates). The check runs before any smoothing, so the input vertices do not change. The message names face 0, its nodes, their coordinates and the reference length. The documented first-triangle convention does not change.

4. Write Pole Figure

  • src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/WritePoleFigureFilter.cpp — sampling-dimension checks and text measurement.
  • src/Plugins/OrientationAnalysis/docs/WritePoleFigureFilter.md, vv/WritePoleFigureFilter.md, vv/deviations/WritePoleFigureFilter.md — ranges and deviation WritePoleFigureFilter-D6.

Preflight accepts Image Size 128 to 8000 (-680002). For Color Intensity only, it accepts Lambert Image Size 16 to 1024 (-680004) and Number of Colors 4 to 256 (-680005). Preflight reports every value that is out of range, before it calculates the canvas. At the maximum values every int32 product in the canvas and image arithmetic stays in range. The limits do not bound memory: at Image Size 8000 the composite needs about 6.4 GB.

Preflight measures the width of the letter X on a 1x1 canvas. Before, it used a canvas as large as the output image (about 1 GB at Image Size 8000). The measured width depends only on the font and the font size, so the output dimensions do not change. The same change for the execute path is in the EbsdLib pull request listed below.

DREAM.3D 6.5.171 did not check these values. A converted legacy pipeline with a value outside the ranges now fails preflight. Deviation WritePoleFigureFilter-D6 records this. Both versions set the label font size to Image Size / 16, so a small Image Size gave labels that are difficult to read in legacy too. This resolves items L89 and L90 of #1908.

Companion pull request: BlueQuartzSoftware/EbsdLib#71 removes the same image-sized canvas from the pole-figure compositor that execute uses. This pull request does not depend on it.

Test plan

  • ConvertHexGridToSquareGrid: accepted letter cases, rejected extensions in any letter case with -44601 and -44602.
  • ReadH5OimData and ReadH5EspritData: 4x3 against 2x2, 3x4, 4x2 and 2x3 scans fail preflight; equal sizes pass; the execute check rejects 3x4, 4x4 and 5x3 scans.
  • HierarchicalSmooth: coincident first edge, NaN and infinite coordinates give -19460 and leave the vertices unchanged; an unused degenerate edge does not.
  • WritePoleFigure: range boundaries, inactive parameters for Discrete, all three values invalid together, the combined maxima, a minimum-size execute, and composite dimensions against the X width from the Lato Bold font tables.
  • macOS Release, in-core, after a full build: 61/61 tests pass (ConvertHexGridToSquareGrid, ReadH5OimData, ReadH5EspritData, ReadH5OinaData, ReadH5Ebsd, HierarchicalSmooth, WritePoleFigure, TxCopper pipeline and Python examples).
  • CI passes on Windows, Linux and macOS.
  • Out-of-core validation. The reader tests passed 34/34 in an out-of-core build before the last rebase; the full ooc suite was not run on the final branch.

Related Issue

Closes #1906
Closes #1882
Closes #1946
Closes #1957
Related to #1908
Related to #1867

… to Square Grid

Convert Hexagonal Grid Data to Square Grid Data (TSL - .ang) rejected an
input file with the extension .ANG or .Ang. The filter now accepts the
.ang extension in any letter case, in preflight and in execute, for one
file and for a list of files. The output file keeps the letter case of
the input file name. A .ctf extension in any letter case still gives
error -44601.

Error -44602 now names the file, the extension that was found and the
accepted extension. Error code -446003 is corrected to -44603.

Tests: convert .ANG and .Ang copies of the input and compare the output
with the approved exemplar; reject .ctf and .txt extensions in any
letter case.

Closes BlueQuartzSoftware#1906

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
Read EDAX OIMAnalysis Data (.h5) and Read Bruker Nano Esprit Data (.h5)
sized the Image Geometry from the first selected scan only. A later scan
with fewer columns or rows was then copied with the first scan's size,
which read past the end of its arrays.

Preflight now reads the header of every selected scan and compares the
columns and the rows of each scan with the first scan. A mismatch gives
error -9592 (EDAX) or -9684 (Esprit). A header-read failure of a later
scan names the scan and the file (-9582 / -9682).

The shared IEbsdOemReader execute loop compares each scan with the Image
Geometry before it copies the scan, and returns -8972 on a mismatch. This
also covers a file that changes between preflight and execute.

Tests write small two-scan files: mismatches of both axes, of the rows
only, of the columns only, and an equal-size control, for preflight and
for the execute check.

Docs: each filter page states that all selected scans must have the same
dimensions. The knowledge-base entry "Check tuple counts in preflight"
now says to check every scan, per axis.

Closes BlueQuartzSoftware#1882

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
Hierarchical Smoothing divides each vertex displacement by a reference
length. The reference length is sqrt(3) times the shorter of two edges
of the first triangle. When one of these edges has coincident nodes,
or when a node of the first triangle has a NaN or infinite coordinate,
the reference length is zero or not finite. The displacement test then
gives infinity or NaN and does not reject vertices consistently.

The filter now returns error -19460 when the reference length is zero
or not finite. The check runs before any smoothing, so the input
vertices do not change. The message names face 0, its nodes and their
coordinates, and the reference length. The documented first-triangle
convention does not change.

Tests: a coincident first edge, a NaN coordinate, an infinite coordinate
and a control with coincident nodes on the edge that is not used. The
error tests also check that a movable node does not change.

Docs: the Error Threshold section describes the error.

Closes BlueQuartzSoftware#1946

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
Write Pole Figure accepted any positive Image Size and did not check
Lambert Image Size or Number of Colors. Image Size 1 gave invalid
marker indices, very large values overflowed the int32 canvas
arithmetic, and small or large Lambert and color values reached
divisors and allocation shapes without a check.

Preflight now accepts only these inclusive ranges:
- Image Size (Square Pixels): 128 to 8000 (-680002).
- Lambert Image Size (Pixels): 16 to 1024 (-680004).
- Number of Colors: 4 to 256 (-680005).
Lambert Image Size and Number of Colors are checked only for the Color
Intensity algorithm, which is the only algorithm that uses them.
Preflight reports every value that is out of range, before it creates
the canvas. At the maximum values, every int32 product in the canvas
and image arithmetic stays in range.

Tests: each limit, one below it and one above it, for both algorithms
where the value applies; all three values out of range together; the
maximum values together; a run at the minimum values. The hidden block
boundary test now uses Image Size 128 with a recomputed pixel oracle.

Docs: the help text, the filter page and the V&V report give the
ranges. The V&V deviations list a new entry: DREAM.3D 6.5.171 did not
check these values, so a converted legacy pipeline with a value outside
the ranges now fails preflight.

Closes BlueQuartzSoftware#1957

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
…d canvas

Preflight measured the letter X on a canvas as large as the output image.
At Image Size 8000 this canvas used about 1 GB. The measured width depends
only on the font and the font size, so preflight now uses a 1x1 canvas.

Add a test that checks the composite dimensions against the X advance
width read from the Lato Bold font tables.

Add to deviation WritePoleFigureFilter-D6 that a small Image Size also
gave labels that are difficult to read in DREAM.3D 6.5.171.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
@imikejackson imikejackson self-assigned this Nov 12, 2026
@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

1 participant