fix(io): crash when deserialising an empty image
Description
Since some changes due to DICOM integration in sight, some silent bugs was introduced.
For example, when trying to deserialize an empty image it crash, this was due to a call to a specific call of image->resize()
in deserialize code.
With this MR we add additional tests in io::sessionTest
in order to test writing/reading of empty data (usually just created by a New()).
By doing this we saw that others data wasn't able to serialize/deserialize them if they were empty, appropriate changes were made.
In details:
-
Data::Mesh
- do not resize if mesh has no points / cells
- Add VTK_EMPTY_CELLS in switch case to avoid throwing an error if reading an empty mesh.
-
Data::Array
- do not resize if deserialized array is empty
-
Data::Image / ImageSeries
- initialize Image
m_windowCenter
andm_windowWidth
to empty vectors
- initialize Image
-
Data::TransfertFunction
- correct the operator== (returning false)
- test each pieces in the m_pieces vector
- creation of operator!=
- Misc
- Remove
Graph
,Node
,Edge
,Port
,ReconstructionTraits
,ROITraits
Data since they are not used anywhere and serialization was failing. - Use
data::Object::operator==
to compare all data insessionTest
and remove heavy compare code.
- Remove
Closes #979 (closed)
How to test it?
- Launch all unit tests
- Test to save / load session