Page MenuHomePhabricator

Correctly initialize data objects (and reinitialize after clear)
Closed, ResolvedPublic

Description

When calling Clear() on an mitk::PointSet, the previously contained data is released and the object's Initialized flag (from BaseData) is set to false. It is possible to work with the object afterwards and e.g. fill it with new points, but the Initialized flag remains false. This can lead to an error in rendering, since un-initialized data objects are treated as invalid and lead to a time step of -1.

Event Timeline

This is actually the correct behaviour (for BaseData).

Subclasses should reimplement the Clear() method, and Reinitialize themselves afterwards. If not initialized, they do not have a geometry and therefor throw an exception while rendering.

Subclasses are supposed to be always at least in an initialized, empty state.
In detail, subclasses are supposed to call BaseData::InitializeTimeSlicedGeometry() in their constructor and after emptying them to regain a healthy state.

Will implement this for Surface and PointSet.
Mathias, where else would it be necessary?

Renamed because the problem is a bit more complex;
Many data objects are not correctly initialized.
All data objects that require "normal" Geometry3D's should use the method BaseData::InitializeTimeSlicedGeometry() and not their own.

Cannot commit momentary; Changes made to public MITK are:

Introduced Clear() and InitializeEmpty() methods to:

  • PointSet, Surface, UnstructuredGrid

Made Clear() method protected for mitk::Image (should not be called by user)

Use correct init method in Contour