BUG: Avizo binary export inserts bytes inside the coordinate block
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 75/100
Direzione di ricerca
Il bug si trova in writeData di src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAvizoRectilinearCoordinate.cpp, dove fprintf(outputFile, "\n") viene eseguito all'interno del ciclo sugli assi tra le chiamate a fwrite, intorno alle righe 144-155. Inizia da lì e fai in modo che i tre array binari degli assi vengano scritti in modo contiguo, con eventuale newline dopo l'intero blocco di coordinate. Aggiungi il test fornito a src/Plugins/SimplnxCore/test/WriteAvizoRectilinearCoordinateTest.cpp ed esegui il tag [AvizoRectilinearBinary]. È completato quando i sei float binari corrispondono ai valori ASCII.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
WriteAvizoRectilinearCoordinateFilter declares one contiguous float coordinate array but inserts newline bytes between its X, Y, and Z portions. A reader consumes these bytes as float data and decodes incorrect Y/Z coordinates. The ASCII and binary forms of the same input disagree.
Reproduced at fe6c4a15e5a5bffef2523f52cec01be33b1e62a9 using Windows x64, MSVC 19.44, Release, in-memory stores.
The fixture declares six float coordinates, or 24 payload bytes. A contiguous decode agrees with ASCII for the three X values, then disagrees for both Y values and the Z value. This test isolates encoding equivalence; it does not certify the coordinate convention.
Steps to Reproduce
- Create an ImageGeom with dimensions
[3,2,1], origin[10,-5,2], and spacing[2,3,4]. - Attach scalar Int32 cell labels
[101,102,103,104,105,106]in X-fastest order, with tuple shape[1,2,3]. - Preflight and execute the writer with units
microns. The test below selects the required encoding(s). - Inspect the coordinate metadata/payload against the expectations above. Preflight and execution both succeed.
Cause
src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAvizoRectilinearCoordinate.cpp, lines 144-155 calls fprintf(outputFile, "\n") inside the axis loop, after each fwrite. Lines 47 and 67 declare a single @2 array of nx + ny + nz floats. The AmiraMesh format manual, printed page 197 / PDF page 199 specifies a fixed number of binary bytes immediately after the marker line; separators cannot occur inside this payload.
Verification Unit Test
Add this case and its local helpers to src/Plugins/SimplnxCore/test/WriteAvizoRectilinearCoordinateTest.cpp. It creates its own input and requires no dataset download. The following complete source was compiled and run in an isolated Catch2 harness linked to the matching Release simplnx and SimplnxCore libraries. No production source was changed.
#include "SimplnxCore/Filters/WriteAvizoRectilinearCoordinateFilter.hpp"
#include "SimplnxCore/Filters/WriteAvizoUniformCoordinateFilter.hpp"
#include "simplnx/Common/Bit.hpp"
#include "simplnx/DataStructure/AttributeMatrix.hpp"
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/DataStructure/Geometry/ImageGeom.hpp"
#include "simplnx/Parameters/FileSystemPathParameter.hpp"
#include "simplnx/UnitTest/UnitTestCommon.hpp"
#include <catch2/catch.hpp>
#include <array>
#include <cstring>
#include <filesystem>
#include <fstream>
#include <iterator>
#include <sstream>
using namespace nx::core;
namespace
{
template <class FilterT>
std::string writeFixture(bool binary, const std::string& name)
{
UnitTest::LoadPlugins();
DataStructure dataStructure;
auto* image = ImageGeom::Create(dataStructure, "Image");
REQUIRE(image != nullptr);
image->setDimensions({3, 2, 1});
image->setOrigin({10.0f, -5.0f, 2.0f});
image->setSpacing({2.0f, 3.0f, 4.0f});
auto* cells = AttributeMatrix::Create(dataStructure, "Cells", {1, 2, 3}, image->getId());
REQUIRE(cells != nullptr);
image->setCellData(*cells);
auto* labels = Int32Array::CreateWithStore<Int32DataStore>(dataStructure, "FeatureIds", {1, 2, 3}, {1}, cells->getId());
REQUIRE(labels != nullptr);
for(usize index = 0; index < 6; ++index)
{
(*labels)[index] = static_cast<int32>(101 + index);
}
UnitTest::CheckArraysInheritTupleDims(dataStructure);
const auto path = std::filesystem::current_path() / name;
FilterT filter;
auto args = filter.getDefaultArguments();
args.insertOrAssign(FilterT::k_OutputFile_Key, std::make_any<FileSystemPathParameter::ValueType>(path));
args.insertOrAssign(FilterT::k_WriteBinaryFile_Key, std::make_any<bool>(binary));
args.insertOrAssign(FilterT::k_GeometryPath_Key, std::make_any<DataPath>(DataPath({"Image"})));
args.insertOrAssign(FilterT::k_FeatureIdsArrayPath_Key, std::make_any<DataPath>(DataPath({"Image", "Cells", "FeatureIds"})));
args.insertOrAssign(FilterT::k_Units_Key, std::make_any<std::string>("microns"));
const auto preflight = filter.preflight(dataStructure, args);
SIMPLNX_RESULT_REQUIRE_VALID(preflight.outputActions);
const auto execution = filter.execute(dataStructure, args);
SIMPLNX_RESULT_REQUIRE_VALID(execution.result);
std::ifstream stream(path, std::ios::binary);
REQUIRE(stream.is_open());
return {std::istreambuf_iterator<char>(stream), std::istreambuf_iterator<char>()};
}
usize payloadOffset(const std::string& contents, const std::string& marker)
{
const auto position = contents.find("\n" + marker);
REQUIRE(position != std::string::npos);
const auto newline = contents.find('\n', position + 1);
REQUIRE(newline != std::string::npos);
return newline + 1;
}
} // namespace
TEST_CASE("Avizo rectilinear binary coordinates match ASCII encoding", "[AvizoRectilinearBinary]")
{
const auto ascii = writeFixture<WriteAvizoRectilinearCoordinateFilter>(false, "rect_ascii.am");
const auto binary = writeFixture<WriteAvizoRectilinearCoordinateFilter>(true, "rect_binary.am");
REQUIRE(binary.find("define Coordinates 6") != std::string::npos);
REQUIRE(binary.find("Coordinates { float xyz } = @2") != std::string::npos);
const auto offset = payloadOffset(binary, "@2");
REQUIRE(binary.size() - offset >= 6 * sizeof(float32));
std::istringstream expectedValues(ascii.substr(payloadOffset(ascii, "@2")));
// Encoding must preserve the same six floats, independently of coordinate semantics.
for(usize component = 0; component < 6; ++component)
{
float32 expected = 0.0f;
REQUIRE(static_cast<bool>(expectedValues >> expected));
float32 actual = 0.0f;
std::memcpy(&actual, binary.data() + offset + component * sizeof(float32), sizeof(float32));
CAPTURE(component);
CHECK(actual == expected);
}
}
The executed harness registered AvizoRectilinearBinary with the Catch2 selector [AvizoRectilinearBinary] and ran:
ctest --test-dir <AvizoContractRepro-build> -C Release -j 1 -R "^AvizoRectilinearBinary$" --output-on-failure
For a standard plugin test build, register the same selector if it is not discovered automatically:
add_test(NAME AvizoRectilinearBinary COMMAND SimplnxCoreUnitTest "[AvizoRectilinearBinary]" --reporter compact)
Observed failure excerpt:
actual == expected: -0.0f == -5.0f (component 3)
actual == expected: 0.0f == -2.0f (component 4)
actual == expected: 0.0f == 2.0f (component 5)
Failed 1 test case, failed 3 assertions.
An independent native control passed for all four writer/encoding combinations: every label, dimension and units string was preserved. Output-overwrite warnings occurred because cases shared their generated filenames; the failures above are numeric assertions, not preflight or file-open failures.
Proposed Fix
In WriteAvizoRectilinearCoordinate::writeData, write all three binary axis arrays contiguously. Put any terminating newline after the complete coordinate block. Keep the declared count, element type and endian marker consistent. Test all X/Y/Z values against the ASCII representation and test the label block separately.
Notes
Fixes belong on a separate source branch. No fix was applied or tested. Actual Avizo application behavior, other platforms and OOC storage were not tested. This defect blocks a proposed faithful-coordinate export comparison using the existing measured Gille LabDCT ROI.
- Lingua principale
- C++
- Stelle
- 18
- Fork
- 15
- Merge medio
- 3g 13h
- PR unite (30g)
- 19
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di BlueQuartzSoftware/simplnx
-
bug Filter
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
BlueQuartzSoftware/simplnx#1824 ·
I maintainer di solito rispondono entro 3 giorni
-
bug Filter
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
BlueQuartzSoftware/simplnx#1823 ·
I maintainer di solito rispondono entro 3 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
BlueQuartzSoftware/simplnx#1818 ·
I maintainer di solito rispondono entro 3 giorni
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
BlueQuartzSoftware/simplnx#1815 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
bug
Difficoltà 2/5 Mezza giornata Idoneità per principianti 72/100
BlueQuartzSoftware/simplnx#1813 ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di BlueQuartzSoftware/simplnx
Issue simili
-
backlog bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
EchoTools/nevr-runtime#653 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
InfiniTimeOrg/InfiniTime#2492 ·
-
accessibility good first issue hacktoberfest help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
OpenChemistry/avogadrolibs#3184 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Tracktion/tracktion_engine#475 ·
I maintainer di solito rispondono entro 1 giorno