Skip to content

BUG: Combine the EBSD fixes that need the next EbsdLib release - #1973

Open
imikejackson wants to merge 14 commits into
BlueQuartzSoftware:developfrom
imikejackson:topic/next_ebsdlib_fixes
Open

imikejackson wants to merge 14 commits into
BlueQuartzSoftware:developfrom
imikejackson:topic/next_ebsdlib_fixes

Conversation

@imikejackson

@imikejackson imikejackson commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This branch combines the simplnx pull requests that are tied to the next EbsdLib release into one branch, so that simplnx and EbsdLib each have one branch to build and test together. It builds and passes its tests against BlueQuartzSoftware/EbsdLib#86 (branch topic/next_release_fixes).

Each original pull request is merged with --no-ff, so its commits and history are kept. The original pull requests are closed with a link to this one.

CI will fail until the EbsdLib release is in simplnx-registry. This branch uses LaueOps::GetLaueOpsFromSpaceGroupNumber and other API that EbsdLib 3.1.3 does not have. Merge order: EbsdLib#86, EbsdLib release, simplnx-registry update, simplnx vcpkg update, then this pull request.

Merged pull requests

PR Title Closes
#1967 BUG: Validate EBSD reader headers, scans and slice ranges #1882, #1906
#1962 BUG: Use one EbsdLib space-group mapping in Read GrainMapper3D #1953
#1965 BUG: Fix input validation in four EBSD and mesh filters #1882, #1906, #1946, #1957
#1968 BUG: Return child preflight errors from ReadH5Ebsd without a crash
#1969 BUG: Reject zero and nonfinite misorientation axes and loading directions
#1970 BUG: Check the Phase of Interest and its crystal structure in Write GBCD GMT
#1971 BUG: Report an error for an empty or malformed EBSD phase table
#1972 BUG: Clamp cosines before acos in Compute Twin Boundaries
#1961 COMP: Rename the simplnx HDF5 lock macro to remove a name conflict

Closes #1953
Closes #1882
Closes #1906
Closes #1946
Closes #1957

Conflict resolutions and decisions

Changes needed for the combined EbsdLib

  • Three tests now expect the EbsdLib error, because the combined EbsdLib rejects the input before the simplnx check runs:
    • ReadAngData: HeaderValidation steps: an XSTEP or YSTEP of nan or 1e999 gives -115 from AngReader (EbsdLib#82), not -67602.
    • ReadChannel5Data: Empty phase list: -102300 from CprReader (EbsdLib#75), not -66502.
    • ReadH5Ebsd: Phase table validation, short lattice constants: -50027 (EbsdLib#84), not -50028.
  • The simplnx checks -66502 and -50028 are kept as a fallback.
  • Read H5EBSD error -50027 now includes the reader's error code and message, so the user sees the EbsdLib reason (for example -90350 for a LatticeConstants dataset without 6 values). The test checks for it.

Test Plan

  • Linux x64, Release (ci-linux-x64 preset with SIMPLNX_USE_LOCAL_EBSD_LIB=ON, EbsdLib topic/next_release_fixes, H5Support v1.0.14): full ctest passes serially, 3972/3972. After the last two commits (the -50027 message and the EbsdLib H5CtfVolumeReader fix), the OrientationAnalysis tests pass again, 520/520.
  • No exemplar result changed with the combined EbsdLib, including Bug in Import ASCI Data #60/Feature/MapPointCloudToRegularGrid #61 (ODF sampling) and Save Filter DataStructure on Error #64 (getFZQuat).
  • clang-format 19.1.1: every changed C++ file is clean.
  • Windows x64, Release (MSVC 2022 14.44, Ninja, x64-windows-v143, local EbsdLib#86 and H5Support v1.0.14): all 1478 targets build. The only warnings are 6 existing C4244 warnings in test files that this branch does not change. EbsdLib tests pass 516/516 and ^OrientationAnalysis:: tests pass 496/496, the same count as Linux for that pattern. The full simplnx suite was not run on Windows.
  • macOS build.
  • Out-of-core validation: not run (no out-of-core build on this machine).
  • CI (after the EbsdLib release and the simplnx-registry update).

The bluequartz-skills plugin skills that AGENTS.md lists were not available in this environment; the changes follow docs/Coding_Knowledge_Base.md.

🤖 Generated with Claude Code

@azure-pipelines

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

…Software#1967)

Originally simplnx BlueQuartzSoftware#1967 (branch fix/ebsd-vv-filter-items), combined into this branch for the EbsdLib 3.1.4 update.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
…uartzSoftware#1962)

Originally simplnx BlueQuartzSoftware#1962 (branch topic/gm3d_space_group_laue), combined into this branch for the EbsdLib 3.1.4 update.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
…ftware#1965)

Originally simplnx BlueQuartzSoftware#1965 (branch topic/hex_to_square_ang_extension_case), combined into this branch for the EbsdLib 3.1.4 update.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
…lueQuartzSoftware#1968)

Originally simplnx BlueQuartzSoftware#1968 (branch fix/read_h5ebsd_preflight_errors), combined into this branch for the EbsdLib 3.1.4 update.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
…ions (BlueQuartzSoftware#1969)

Originally simplnx BlueQuartzSoftware#1969 (branch fix/orientation-axis-direction-validation), combined into this branch for the EbsdLib 3.1.4 update.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
…BCD GMT (BlueQuartzSoftware#1970)

Originally simplnx BlueQuartzSoftware#1970 (branch fix/writegbcdgmt-crystal-structure-check), combined into this branch for the EbsdLib 3.1.4 update.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
…QuartzSoftware#1971)

Originally simplnx BlueQuartzSoftware#1971 (branch fix/ebsd-reader-phase-table-checks), combined into this branch for the EbsdLib 3.1.4 update.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
…Software#1972)

Originally simplnx BlueQuartzSoftware#1972 (branch fix/twin-boundaries-acos-clamp), combined into this branch for the EbsdLib 3.1.4 update.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
…lueQuartzSoftware#1961)

Originally simplnx BlueQuartzSoftware#1961 (branch topic/rename_simplnx_h5support_mutex_macro), combined into this branch for the EbsdLib 3.1.4 update.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
- The merge of BlueQuartzSoftware#1962 into the combined branch joined the last BlueQuartzSoftware#1967 test case
  and the first BlueQuartzSoftware#1962 test case without the closing brace between them, so
  ReadGrainMapper3DTest.cpp did not compile.

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

The combined EbsdLib rejects three malformed inputs in the reader, before the
simplnx check that the test expected can run:

- ReadAngData HeaderValidation steps: AngReader reports an XSTEP or YSTEP of
  "nan" or "1e999" as a header parse error (-115, EbsdLib "Report an error when
  an ANG header number cannot be parsed"). The filter check (-67602) still
  rejects -1 and 0.
- ReadChannel5Data Empty phase list: CprReader reports a .cpr file without
  phases (-102300, EbsdLib "Report an error when a .cpr file defines no
  phases") before the filter check (-66502).
- ReadH5Ebsd Phase table validation: EbsdLib rejects a LatticeConstants dataset
  without 6 values, so the volume reader returns no phases (-50027) before the
  lattice-constant check (-50028).

Each input is still rejected with an error that names the file and the value.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
* When EbsdLib returns no phases, error -50027 now gives the reader's
  error code and message, for example the EbsdLib -90350 message for a
  LatticeConstants dataset that does not hold 6 values. Before, the
  message said only that the phase information could not be read.
* The phase-table test checks that the message contains -90350.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
@imikejackson
imikejackson force-pushed the topic/next_ebsdlib_fixes branch from 841677f to 20b4e06 Compare November 14, 2026 19:34
Fill the grayscale pipeline fixture by index instead of growing it with
vector::insert, which triggers a gcc 13 -Wstringop-overflow false positive.
The pixel bytes are unchanged.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
@imikejackson

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

{
using PhaseValuesType = std::vector<std::array<uint32, 2>>;
ini::IniFile inputIni;
inputIni.load(file);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Important] ReadEnsembleFile() can throw in preflight on a malformed INI file

ReadEnsembleInfoFilter::preflightImpl() now calls ReadEnsembleFile(). That function calls inputIni.load(file) (line 101) and .as<int32>() (line 110) from utilities/inicpp.h.

  • The parser throws std::logic_error for a line without =, an unclosed [section, or a field before any section.
  • Convert<int> throws std::invalid_argument for Number_Phases=two or Number_Phases=1.5.

IFilter::preflight() does not convert exceptions to errors, so a malformed .ini can end the GUI. This breaks the knowledge-base rule "Never throw in preflight". as<int32>() also narrows long to int without a check: Number_Phases=4294967297 becomes 1.

Fix: wrap the load and each conversion in try/catch and return new distinct codes (for example -13010 for an INI parse failure that names the line, and -13011 for a Number_Phases value that is not a whole number). Parse Number_Phases with std::from_chars into int64 and range-check it. Add both cases to ReadEnsembleInfo: EBSD regression preflight validation.

// -----------------------------------------------------------------------------
Result<> ComputeGBCDPoleFigureDirect::operator()()
{
if(Result<> axisResult = ComputeGBCDPoleFigureDirect::ValidateMisorientationAxis(m_InputValues->MisorientationRotation); axisResult.invalid())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Minor] Algorithms repeat parameter checks that preflight already makes, and tests call the algorithms to reach them

These new static validators run in both preflightImpl() and operator()():

  • ValidateLoadingDirection (ComputeBoundaryStrengths.cpp:48)
  • ValidateMisorientationRotation (ComputeGBCDMetricBased.cpp:364)
  • ValidateMisorientationAxis (ComputeGBCDPoleFigureDirect.cpp:284, Scanline.cpp:241, WriteGBCDGMTFile.cpp:110, together with ValidatePhaseOfInterest)
  • ValidateReferenceAxis (ComputeMisorientations.cpp:251)

The knowledge-base entry "Run a filter, not its algorithm" names this exact shape as a violation. It also names the matching test shape, which three new test sections use: ComputeGBCDPoleFigureTest, ComputeMisorientationsTest and ReadChannel5DataTest call operator()() to reach an input check.

Fix: keep the validators for preflight. In each algorithm, replace the call with a @pre in its Doxygen (for example @pre MisorientationRotation[1..3] is finite and not (0, 0, 0).) and keep the NormalizeDirection(...).value() call. Remove the algorithm-direct test sections.

// Each phase writes one tuple of the Ensemble arrays at its phase index and reads six lattice constants.
for(const auto& phase : phases)
{
const int32 phaseID = phase->getPhaseIndex();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Minor] The H5EBSD phase-index check runs only in execute, and two fallback codes have no test that reaches them

ReadH5EbsdFilter::preflightImpl() already reads the phases for its preview, but the phase-index check -50029 runs only in LoadInfo during execute. A file with phase index 3 out of 2 phases passes preflight and fails at run time; the test ReadH5Ebsd: Phase table validation calls only execute(). This breaks "Put each check at the earliest point that can see its data".

The target EbsdLib now rejects the inputs for -50028 (lattice constants) and -66502 (Channel5 empty phase list) first, and the tests assert the EbsdLib codes. No test reaches either simplnx branch, which cpp-best-practices requires for each failure branch.

Fix:

  • Move -50029 (and -50028) into a helper that preflight calls. Keep an execute recheck only for a file that changed after preflight.
  • For -50028 and -66502, remove the unreachable branches or add tests that reach them.

if(!std::isfinite(pOriginValue[component]))
{
return MakePreflightErrorResult(
-9592, fmt::format("File '{}' has Origin component '{}' = {}. Set this component to a finite float32 value.", inputFilePath, k_Axes[component], pOriginValue[component]));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Minor] The OINA Origin error says the file holds the value, but Origin is a user parameter

pOriginValue comes from k_Origin_Key, a user parameter, not from the file. The message "File '{}' has Origin component 'x' = nan" sends the user to look in the .h5oina file, and docs/ReadH5OinaDataFilter.md lists the rule under "Header validation".

Fix: use fmt::format("The Origin parameter has component '{}' = {}. Enter a finite value.", k_Axes[component], pOriginValue[component]), and move the doc sentence out of "Header validation" into the parameter discussion.

{
return result;
}
auto first = T::New();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Minor] One code (-8970) for three read failures, and the first scan's header is read again for every scan

-8970 now covers three failures: the current scan's header read (line 163), the first scan's header read (line 176) and readFile() (line 216). This breaks "Give every condition its own error code".

readData() also creates a new reader and calls readHeaderOnly() on the first selected scan once for each scan. A 200-slice import opens and parses the first header 200 extra times.

Fix: read the first scan's header once in execute() before the loop and pass it to readData(). Give the two header-read failures their own named constants.

}
}

TEST_CASE("OrientationAnalysis::ReadAngData: HeaderValidation symmetry", "[OrientationAnalysis][ReadAngData]")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Nit] New test tags differ from the existing tags in the same files

New cases use [ReadAngData], [ReadCtfData], [ReadChannel5Data], [ReadH5Ebsd], [ComputeMisorientations] and [WriteGBCDGMTFile]. The existing cases in the same files use [ReadAngDataFilter], [ReadCtfDataFilter], [WriteGBCDGMTFileFilter] and so on (see ReadAngDataTest.cpp:171). A selection by the existing tag skips the new tests. Use the filter tag that the file already uses.

constexpr int32 k_InvalidAbsorptionVirtualShift = -38617;
constexpr int32 k_InvalidCompletenessInfo = -38618;
constexpr int32 k_InvalidCompletenessRank = -38619;
constexpr int32 k_InvalidSpaceGroup = -67600;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Nit] -67600 is declared twice, and preflight checks the GrainMapper space groups twice

k_InvalidSpaceGroup (GrainMapper3DUtilities.cpp:41) and EbsdReaderUtilities::k_InvalidPhaseSymmetry (EbsdReaderUtilities.hpp:103) both hold -67600, so one of them can drift. ReadGrainMapper3DFilter.cpp:149 validates all space groups, then GeneratePreflightPhaseInformation validates each one again.

Fix: use k_InvalidPhaseSymmetry in ValidateSpaceGroups(), and drop one of the two checks.


TEST_CASE("OrientationAnalysis::ReadH5EspritData: StructuralValidation", "[OrientationAnalysis][ReadH5EspritDataFilter]")
{
const std::string field = GENERATE("columns", "rows", "xstep", "ystep", "phases", "material", "width", "height", "short", "type", "rank", "components");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Nit] Some header-validation test cases return before they assert the expected code

In the OIM and Esprit HeaderValidation tests, the zero-pattern cases return before they assert -9583 or -9683. In the Esprit StructuralValidation case (line 551), the GENERATE list leaves out "missing", so -67609 is tested only through OIM.

Fix: assert the missing-pattern code before the return, and add "missing" to the Esprit list.

ConvertHexGridToSquareGrid& operator=(ConvertHexGridToSquareGrid&&) noexcept = delete;

/** @brief Returns true when the file extension is .ang, regardless of case. */
static bool IsAngFile(const std::filesystem::path& inputPath);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Nit] Doxygen and comment accuracy

  • IsAngFile has no tags. Replace its block with: /** @brief Reports whether a path has the .ang extension in any letter case. @param inputPath Path to test. @return True for .ang, .ANG or another case variant. */
  • The comment at ReadGrainMapper3D.cpp:458 is inaccurate: the converted datasets also reach the switch and fall to default. Replace it with: // The conversion blocks above erased their datasets from the type sets. Those datasets are uint8 or float32 and fall to default, so they are not read again.

other inputs, scan the minimum and maximum. A masked filter checks only the ids it uses, with the same mask and sentinel
rules as execute. A negative value is out of range unless the code skips it before it indexes. An index that comes from
a parameter value (for example **Phase Index**) is checked in preflight.
a parameter value (for example **Phase Index**) is checked in preflight. Header values are also available in preflight.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Nit] Knowledge-base edit: the header-step rule is in the wrong entry

The added sentences about signed dimensions, finite positive steps and format-specific zero defaults describe file values. They are in "Range-check every index that comes from data", which is about array-value indices, and they add no "What to look for" bullet.

Fix: move them to the "Values read from a file" bullet of "Decide NaN and infinity handling by where the value comes from". Add a bullet such as "a header dimension or step passed to CreateImageGeometryAction without a sign and finiteness check".

@joeykleingers joeykleingers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the summary of my review of 2026-11-16. GitHub removed it when the review was submitted, so I post it here.

PR 1973 Code Review

Source: review of commit 841677f (#1973, "BUG: Combine the EBSD fixes that need the next EbsdLib release", author imikejackson, topic/next_ebsdlib_fixes → develop at 1f04ff1). Coverage: all 99 changed files and the complete diff (source, headers, tests, filter docs, V&V files, the knowledge-base edit, CMake, the pipeline and the Python example).

1. Findings

  • 1.1 [Important] ReadEnsembleFile() can throw in preflight on a malformed INI file
    File: src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadEnsembleInfo.cpp:101, :110 (ReadEnsembleInfo::ReadEnsembleFile)
    CONFIRMED. ReadEnsembleInfoFilter::preflightImpl() now calls ReadEnsembleFile(). That function calls inputIni.load(file) and .as<int32>() from utilities/inicpp.h. The parser throws std::logic_error for a line without =, an unclosed [section, or a field before any section (inicpp.h:647/654/673/691). Convert<int> throws std::invalid_argument when Number_Phases=two or Number_Phases=1.5. IFilter::preflight() does not convert exceptions to errors, so in the GUI, editing the file path to a slightly wrong .ini can end the application. The knowledge base forbids this ("Never throw in preflight"). The old preflight had the same calls, but this PR rewrote them as the new validation entry point, and the filter page now says preflight "validates all required phase groups". Also, as<int32>() narrows long to int without a check, so Number_Phases=4294967297 becomes 1.
    Fix: wrap the load and each conversion in try/catch, and return new distinct codes (for example -13010 "File '{}' is not a valid INI file at line {}: {}" and -13011 "Number_Phases '{}' is not a whole number"). Read Number_Phases as a string and parse it with std::from_chars into int64, then range-check it. Add the two cases to ReadEnsembleInfo: EBSD regression preflight validation.

  • 1.2 [Minor] Algorithms repeat parameter checks that preflight already makes, and tests call the algorithms to reach them
    Files: ComputeBoundaryStrengths.cpp:48, ComputeGBCDMetricBased.cpp:364, ComputeGBCDPoleFigureDirect.cpp:284, ComputeGBCDPoleFigureScanline.cpp:241, ComputeMisorientations.cpp:251, WriteGBCDGMTFile.cpp:110 (and its ValidatePhaseOfInterest call)
    CONFIRMED. Each new static Validate*() is called from both preflightImpl() and operator()(). The knowledge base's "Run a filter, not its algorithm" lists this exact shape as a violation ("a static ValidateInputs() that both preflightImpl() and operator()() call"). It also lists the matching test shape: the new sections in ComputeGBCDPoleFigureTest ("Each executor rejects the axis…"), ComputeMisorientationsTest ("The algorithm rejects the axis without the filter") and ReadChannel5DataTest ("The algorithm reports the empty phase list without the filter") call operator()() to reach an input check. Every run checks the inputs twice, and each condition gets a second error path to maintain.
    Fix: keep the static validators for preflight. In each algorithm, replace the call with a @pre in its Doxygen (for example @pre MisorientationRotation[1..3] is finite and not (0, 0, 0).). Keep the NormalizeDirection(...).value() call, which relies on that precondition. Remove the algorithm-direct test sections. File re-reads after preflight (Channel5 fields, OEM headers) are allowed by the rule and can stay.

  • 1.3 [Minor] The H5EBSD phase-index check runs only in execute, and two fallback codes have no test that reaches them
    File: src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5Ebsd.cpp:78 (LoadInfo); ReadChannel5DataFilter.cpp and ReadChannel5Data.cpp (-66502)
    CONFIRMED. Phase indices are header metadata, and ReadH5EbsdFilter::preflightImpl() already reads the phases for its preview. Even so, -50029 (a phase index outside 1..N) fires only in execute: the test ReadH5Ebsd: Phase table validation calls only execute(). A pipeline with such a file passes preflight and fails at run time. This breaks "Put each check at the earliest point that can see its data". The PR also keeps -50028 and -66502 as "fallbacks", but the target EbsdLib rejects those inputs first (-50027/-90350 and -102300), and the tests assert the EbsdLib codes. No test reaches either simplnx branch, which cpp-best-practices requires for each failure branch.
    Fix: move the -50029 check (and -50028) into a helper that preflight calls. Keep an execute recheck only for a file that changed after preflight. For -50028 and -66502, either remove the unreachable branches or add a test that reaches them, for example by constructing a reader result directly.

  • 1.4 [Minor] The OINA Origin error says the file holds the value, but Origin is a user parameter
    File: src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/ReadH5OinaDataFilter.cpp:140
    CONFIRMED. pOriginValue comes from k_Origin_Key, not from the file. The message "File '{}' has Origin component 'x' = nan" sends the user to look in the .h5oina file. docs/ReadH5OinaDataFilter.md also puts this rule under "Header validation".
    Fix: fmt::format("The Origin parameter has component '{}' = {}. Enter a finite value.", k_Axes[component], pOriginValue[component]). Move the doc sentence out of "Header validation" into the parameter discussion.

  • 1.5 [Minor] The main V&V reports do not list the new preflight branches
    Files: src/Plugins/OrientationAnalysis/vv/ReadAngDataFilter.md, vv/ReadCtfDataFilter.md, vv/ReadH5OinaDataFilter.md
    CONFIRMED. simplnx-best-practices requires a V&V row for each new preflight branch. vv/ReadAngDataFilter.md has no rows for -67600, -67601 or -67602 and no entry for D6; only the deviations sidecar changed. vv/ReadCtfDataFilter.md adds -67601 and -67602 but has no code-path row for -67600 (symmetry), and its deviation list stops at D4 (D6 and D7 are missing). vv/ReadH5OinaDataFilter.md lists -9592 and D16 but not the -67600 path or D15.
    Fix: add the code-path rows, the test-inventory rows and the deviation-list entries for those codes and IDs.

  • 1.6 [Minor] One code (-8970) for three read failures, and the first scan's header is read again for every scan
    File: src/Plugins/OrientationAnalysis/src/OrientationAnalysis/utilities/IEbsdOemReader.hpp:163, :170-176, :216
    CONFIRMED. -8970 now covers three failures: the current scan's header read, the first scan's header read and the full readFile(). The knowledge base requires one code per condition ("Give every condition its own error code"). In addition, readData() creates a new reader and calls readHeaderOnly() on the first selected scan once for each scan, so a 200-slice import opens and parses the first header 200 extra times.
    Fix: read the first scan's header once in execute() before the loop and pass it to readData(). Give the two header-read failures their own named constants.

  • 1.7 [Minor] Pre-existing, wrong data: yes. AbsorptionCT spacing and extent reach a size_t cast unchecked
    File: src/Plugins/OrientationAnalysis/src/OrientationAnalysis/utilities/GrainMapper3DUtilities.cpp:351 (GrainMapperReader::readAbsorptionHeader)
    CONFIRMED, pre-existing, surfaced by this PR. The PR validates LabDCT Spacing (finite, positive) and Extent (finite). The sibling /AbsorptionCT block validates only the value counts, then computes static_cast<size_t>(extents[i] / m_AbsorptionCTSpacing[i]). A file with Spacing = [0, 1, 1] or a NaN or negative Extent makes this cast undefined behavior. Preflight then creates an Image Geometry with arbitrary dimensions and zero spacing, without an error. The test ReadGrainMapper3D: EBSD regression finite header returns early for this case ("Inferred absorption dimensions are a separate issue."), but that comment names no issue. The knowledge-base text this PR adds ("require finite, positive steps before geometry creation") covers this path.
    Fix: call EbsdReaderUtilities::ValidateHeaderSpacing() on each AbsorptionCT spacing component. Check that each extent is finite and positive and that each quotient is finite, at least 1 and below std::numeric_limits<usize>::max() before the cast. Then remove the early return in the test. If it stays deferred, put the tracking issue number in the test comment and in the filter documentation.

  • 1.8 [Nit] UnitTest::LoadPlugins() in tests that look up no filter
    Files: src/Plugins/SimplnxCore/test/HierarchicalSmoothTest.cpp:619,626,632,638; ConvertHexGridToSquareGridTest.cpp (Unsupported extensions in any letter case are rejected, line 476); ReadAngDataTest.cpp (HeaderValidation dimensions, line 555); ReadEnsembleInfoTest.cpp (Direct algorithm clears extra tuples, line 273); ReadH5OimDataTest.cpp:708,750; ReadH5EspritDataTest.cpp (Scans With Different Dimensions); ReadGrainMapper3DTest.cpp (Large finite headers can cancel); WritePoleFigureTest.cpp (composite dimensions use the measured X width)
    These tests construct the filter directly. The knowledge base ("Call UnitTest::LoadPlugins() only when the test looks up filters by UUID") says an unneeded call makes a test fail when an unrelated plugin does not load. Remove the calls. The ReadH5Ebsd tests need them and are correct.

  • 1.9 [Nit] Include placement and duplicate includes in the test files
    Files: ReadAngDataTest.cpp:1, ReadCtfDataTest.cpp:1 and ReadH5OinaDataTest.cpp:1 put #include "simplnx/Common/ScopeGuard.hpp" above the file's header comment. ReadH5OimDataTest.cpp includes ReadH5OimData.hpp, ScopeGuard.hpp and three H5Support headers twice. ReadH5EspritDataTest.cpp includes ScopeGuard.hpp and the H5Support headers twice. ConvertHexGridToSquareGridTest.cpp and ReadEnsembleInfoTest.cpp mix the include groups (one include follows namespace fs = …). Group the includes in the simplnx order and remove the duplicates.

  • 1.10 [Nit] New test tags differ from the existing tags in the same files
    New cases use [ReadAngData], [ReadCtfData], [ReadChannel5Data], [ReadH5Ebsd], [ComputeMisorientations] and [WriteGBCDGMTFile]. The existing cases in the same files use [ReadAngDataFilter], [ReadCtfDataFilter], [WriteGBCDGMTFileFilter] and so on (for example ReadAngDataTest.cpp:171 vs :504). A tag filter such as [ReadAngDataFilter] therefore skips the new header-validation tests. Use the filter tag that the file already uses.

  • 1.11 [Nit] -67600 is declared twice, and preflight checks the GrainMapper space groups twice
    Files: GrainMapper3DUtilities.cpp:41 (k_InvalidSpaceGroup = -67600) and EbsdReaderUtilities.hpp:103 (k_InvalidPhaseSymmetry = -67600); ReadGrainMapper3DFilter.cpp:149 and EbsdReaderUtilities.hpp (GeneratePreflightPhaseInformation, GrainMapper branch)
    Two constants hold one value, so one of them can drift. preflightImpl() calls ValidateSpaceGroups() on all phases, then GeneratePreflightPhaseInformation() calls it again on each phase. Use EbsdReaderUtilities::k_InvalidPhaseSymmetry in ValidateSpaceGroups(), and drop the second call or the first.

  • 1.12 [Nit] Some header-validation test cases return before they assert the expected code
    Files: ReadH5OimDataTest.cpp and ReadH5EspritDataTest.cpp (HeaderValidation, the width/height zero cases); ReadH5EspritDataTest.cpp:551
    For zero pattern dimensions, the tests compare the preflight and direct codes and then return without asserting -9583 or -9683, so a wrong shared code would pass. In the Esprit StructuralValidation case, the GENERATE list leaves out "missing", although the fixture and the expected-code map support it. As a result, -67609 is tested only through OIM. Assert field == "width" || field == "height" ? k_*MissingPatternDimensions : … before the return, and add "missing" to the Esprit list.

  • 1.13 [Nit] Doxygen and comment accuracy

    • ConvertHexGridToSquareGrid.hpp (IsAngFile) has no tags. Replace it with:
      /** @brief Reports whether a path has the .ang extension in any letter case. @param inputPath Path to test. @return True for .ang, .ANG or another case variant. */
    • ReadGrainMapper3D.cpp:458: the comment says only the remaining mapped types reach the switch. The converted datasets reach it too, and their uint8/float32 type falls to default. Replace it with:
      // The conversion blocks above erased their datasets from the type sets. Those datasets are uint8 or float32 and fall to default, so they are not read again.
    • The comment-audit script (audit_cpp_comments.py) did not run (no shell; see 3.3).
  • 1.14 [Nit] A raw choice index stays next to the new named-value comparison
    File: src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/WritePoleFigureFilter.cpp (preflightImpl, marker-radius block after the new sampling checks)
    The new code compares with to_underlying(WritePoleFigure::Algorithm::LambertProjection). The next block still compares with == 1ULL (pre-existing), which the knowledge base forbids ("Compare a choice with its named value"). Use the named Discrete enum value for consistency.

  • 1.15 [Nit] Knowledge-base edit: the header-step rule is in the wrong entry
    File: docs/Coding_Knowledge_Base.md ("Range-check every index that comes from data")
    The added sentences "Check signed dimensions before conversion to shapes and require finite, positive steps before geometry creation. Preserve an explicit format-specific zero default…" are about file values that are not indices. That entry is about array-value indices. The text also adds no "What to look for" bullet, so the knowledge-base pass would not find the rule. Move these sentences to the "Values read from a file" bullet of "Decide NaN and infinity handling by where the value comes from". Add a "What to look for" bullet such as "a header dimension or step passed to CreateImageGeometryAction without a sign and finiteness check". The addition to "Check tuple counts in preflight" (stacked scans) is accurate and well placed.

2. C++, tests and documentation

The checks covered correctness, CPU and memory, language practice, design, defensive programming, maintainability, generated-code failures, tests and documentation. Their findings are in section 1. The thread-safety and out-of-core checks found nothing beyond the questions in 3.6 and 3.7.

Check 12 (where each check runs): every check that this PR adds to preflight reads either a parameter or file metadata: the axis and loading-direction validators, the WritePoleFigure ranges, the reader header grid, symmetry, slice-range, sample-transform, pattern-dataset and scan-compatibility checks, the ReadEnsembleInfo file checks, the ConvertHexGrid output path, and the WriteGBCDGMT phase bounds. The WriteGBCDGMT phase bounds use the tuple counts of the GBCD and Crystal Structures arrays. Readers size those ensemble matrices from file headers in preflight, so the counts are final, not placeholders. No new preflight check rejects a placeholder count.

Knowledge-base pass: the review checked each entry's "What to look for" list. It found matches for "Run a filter, not its algorithm" (1.2), "Put each check at the earliest point" (1.3), "Never throw in preflight" (1.1), "Give every condition its own error code" (1.6), "Call UnitTest::LoadPlugins() only when…" (1.8) and "Compare a choice with its named value" (1.14). "Never drop a Result" is now satisfied in ReadH5Ebsd::operator()() (see 4.6).

3. Missing or failed evidence

  • 3.1 No build, test or clang-tidy run was possible in this review: read-only tools only, no shell. clang-format.txt reports every changed C/C++ file clean. clang-tidy did not run.
  • 3.2 The PR depends on EbsdLib#86, which is not in this checkout. The review could not verify these EbsdLib APIs or their behavior: LaueOps::GetLaueOpsFromSpaceGroupNumber, GetLaueOpsIndexFromSpaceGroupNumber, CprReader::createFieldParsers, the -115, -102300 and -90350 reader codes, and phaseInfo->getIT(). As the PR says, CI will fail until the EbsdLib release reaches simplnx-registry.
  • 3.3 audit_cpp_comments.py and the ASD-STE100 check were not run (no shell). The prose was checked by reading only.
  • 3.4 Validation that the author deferred, as stated in the PR: no macOS build, no out-of-core run, the full suite not run on Windows, and the WritePoleFigure 128×128 out-of-core oracle not re-run (as vv/WritePoleFigureFilter.md states). Pending validation is not a pass.
  • 3.5 Test results quoted in the PR (3972/3972 on Linux, 496/496 on Windows) were reported by the author and were not observed here.
  • 3.6 Question: the PUBLIC compile definition changed from H5Support_USE_MUTEX to SIMPLNX_H5Support_USE_MUTEX. No old name is left in this repository (verified by search). Do SimplnxOoc, DREAM3D-NX or the vendored H5Support headers test the old macro? A consumer that does will silently lose its lock.
  • 3.7 Question: H5Support.hpp says "Direct HDF5 call sites must explicitly acquire the same mutex". EbsdReaderUtilities::ValidateOemPatternDataset() adds direct H5Dopen2/H5Dget_type/H5Sget_* calls in preflight without ApiLock(). The other plugin readers make direct HDF5 calls without the lock too (pre-existing), so is this an accepted plugin-wide gap with a tracking issue?
  • 3.8 Question: WritePoleFigureTest composite dimensions use the measured X width asserts preflight dimensions {1, 176, 565}. The test itself says these differ from the executed {580, 176, 1} (issue #1867). The test therefore pins a known preflight/execute mismatch. Consider asserting only the X-width oracle value.

4. Confirmed correct

  • 4.1 OrientationUtilities::NormalizeDirection() rejects nonfinite and all-zero vectors. It scales by the largest absolute component before the square root, so finite float32 inputs such as 1e20 do not overflow. The Misorientation Axis Scale tests compare these inputs with the unit-axis output on both the Direct and Scanline paths.
  • 4.2 In ComputeTwinBoundaries, the clamps before std::acos are correct for both cosines. The test Exact Sigma 3 Twin With Parallel Normal uses a hand-derived oracle: twin flag 1 and incoherence 0.
  • 4.3 WriteGBCDGMTFile checks the Laue index against GetAllOrientationOps().size() before it indexes (-96717). The phase checks run in preflight and cover the GBCD and Crystal Structures counts separately (-96712 and -96716).
  • 4.4 WritePoleFigureFilter::GetXCharWidth() now measures on a 1×1 canvas. Before, preflight allocated an imageSize² canvas, up to 8000² RGBA. The new sampling ranges are tested at, below and above both limits for both algorithms.
  • 4.5 HierarchicalSmooth checks the reference length before any smoothing or write-back. The test confirms that the vertex coordinates stay unchanged on error and that the face-0 node ids in the message are correct.
  • 4.6 ReadH5Ebsd::operator()() now returns a child filter's preflight errors with nonstd::make_unexpected(...). Before, it pushed them into a valid Result<>, a pattern the knowledge base forbids ("Never pass result.errors() of a valid Result").
  • 4.7 ConvertHexGridToSquareGrid now returns the single-file converter's Result, which the old code discarded. ValidateHexOutputPath() compares weakly_canonical paths and also calls std::filesystem::equivalent, so a relative or symlinked output that is the input is rejected in both preflight and execute.
  • 4.8 The new -676xx codes and -38609 to -38619 are unique in the repository. The H5Support macro rename is complete in the repository.
  • 4.9 The OIM and Esprit readers validate every selected scan in preflight. They recheck each loaded scan against the destination geometry, the pattern array and the ensemble arrays before they copy (-67616 to -67618). The tests cover a file that changes after preflight.
  • 4.10 ImportEdaxOIMData.d3dpipeline now reads Data/OrientationAnalysis/EdaxOIMData.h5, which OrientationAnalysis/CMakeLists.txt:428-435 extracts from the existing 6_6_ImportH5Data archive. Its registration in PREBUILT_PIPELINE_NAMES is therefore satisfied.

5. Verdict

REQUEST CHANGES: finding 1.1 (Important) is open. The new ReadEnsembleFile() preflight path can throw on a malformed INI file, which can end the application. Findings 1.2 to 1.15 are Minor or Nit. The verdict covers only commit 841677f. The checks that depend on EbsdLib#86 (3.2) and the deferred platform and out-of-core runs (3.4) are still open.

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

Labels

None yet

Projects

None yet

2 participants