Enet4 / dicom-rs

Rust implementation of the DICOM standard

Home Page:https://dicom-rs.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

InMemDicomObject with defined Length retains Length value after changes to inner value of object

jmlaka opened this issue · comments

commented

Suppose we have a sequence with defined Length from reading a dicom file.

Parsing the sequence into items yields InMemDicomObjects with defined Length value.
After changes are made to such InMemDicomObject (.remove_element .put ...) it retains it's original Length value.

How I found out:
Constructing file output from such changed InMemDicomObjects results in faulty output.

A workaround is constructing a InMemDicomObject::from_element_iter(vec![original_object]) which sets the Length::UNDEFINED

Can the API be changed so that any changes to internal value of InMemDicomObject will reset the Length to undefined ?

Thank you

Thank you for reporting, @jmlaka. That is right, the byte length is not updated automatically. Recalculating it on every change would be too expensive, but resetting it to undefined sounds good to me!

How I found out:
Constructing file output from such changed InMemDicomObjects results in faulty output.

This sounds more serious though. I had the impression that I had fixed these cases in #172, but as it turns out, it only redetermines the length of primitive data elements, and not of nested data sets. In cases where the length cannot be trusted, it is better to leave the length as implicitly defined upon writing.

Could you work on a pull request? Much appreciated!

Resolved via #364.