Page MenuHomePhabricator

Do not rely on SNC geometry in mitkPointSetVtkMapper2D
Closed, ResolvedPublic

Description

The above mentioned mapper wants to use the current plane geometry of the slice navigation controller of the renderer. However, depending on how that geometry have been constructed, the SNC may or may not have a plane geometry. In our case, the GetCurrentPlaneGeometry() function returned NULL, and the application crashed.

I suggest to use the GetCurrentWorldGeometry2D function of the renderer, instead. This works fine here. I will send a patch through github.

Event Timeline

@Michael, Basti: Any thoughts on this? What would be appropriate with the new geometry system? Could you take care of this or instruct someone how to solve it?

I'm this week out of office, so i can not look at the issue. I might have a look in two weeks, but without a closer look, the suggested solution sounds valid to me.

The patch seems fine.

In the old version we are using a "PlaneGeometry" and with the patch a "Geometry2D" is used. For this mapper, this makes no difference.

However, it is strange that The SliceNavigationController function "GetCurrentPlaneGeometry" returns you NULL. This should not happen. Can you give me some further information, how you constructed that slicenavigationcontroller?

mitk::TimeStepType numberOfTimeSteps = geometry->CountTimeSteps();

mitk::ProportionalTimeGeometry::Pointer createdTimeGeometry = mitk::ProportionalTimeGeometry::New();
createdTimeGeometry->Initialize();
createdTimeGeometry->Expand(numberOfTimeSteps);

createdTimeSlicedGeometry->SetImageGeometry(false);
createdTimeSlicedGeometry->SetEvenlyTimed(true);

if (inputTimeSlicedGeometry.IsNotNull())
{
createdTimeSlicedGeometry->SetEvenlyTimed(inputTimeSlicedGeometry->GetEvenlyTimed());
createdTimeSlicedGeometry->SetTimeBounds(inputTimeSlicedGeometry->GetTimeBounds());
createdTimeSlicedGeometry->SetBounds(inputTimeSlicedGeometry->GetBounds());
}

// For the PlaneGeometry.
mitk::ScalarType bounds[6] = {
  0,
  static_cast<mitk::ScalarType>(width),
  0,
  static_cast<mitk::ScalarType>(height),
  0,
  1
};

// A SlicedGeometry3D is initialised from a 2D PlaneGeometry, plus the number of slices.
mitk::PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New();
planeGeometry->SetIdentity();
planeGeometry->SetImageGeometry(false);
planeGeometry->SetBounds(bounds);
planeGeometry->SetOrigin(originOfSlice);
planeGeometry->SetMatrixByVectors(rightDV, bottomDV, normal.two_norm());

for (mitk::TimeStepType timeStep = 0; timeStep < numberOfTimeSteps; timeStep++)
{
  // Then we create the SlicedGeometry3D from an initial plane, and a given number of slices.
  mitk::SlicedGeometry3D::Pointer slicedGeometry = mitk::SlicedGeometry3D::New();
  slicedGeometry->SetIdentity();
  slicedGeometry->SetReferenceGeometry(m_Geometry);
  slicedGeometry->SetImageGeometry(false);
  slicedGeometry->InitializeEvenlySpaced(planeGeometry, viewSpacing, slices, isFlipped);

  slicedGeometry->SetTimeBounds(geometry->GetGeometryForTimeStep(timeStep)->GetTimeBounds());
  createdTimeGeometry->SetTimeStepGeometry(slicedGeometry, timeStep);
}
createdTimeGeometry->Update();

sliceNavigationController->SetInputWorldTimeGeometry(createdTimeGeometry);
sliceNavigationController->Update(mitk::SliceNavigationController::Original, true, true, false);
sliceNavigationController->SetViewDirection(viewDirection);

We have our own editor. When a new images is dropped on the editor, the geometry of the SNC of this editor is replaced.

Any update on this?

I want to update our fork after the new MITK release and want to revert our patches that have already be merged to the upstream master, so that we can be as close to the upstream as possible.

This patch is in use for more than a month now, we use the standard MITK display and our custom display, and tested it on the three main platforms, with no problem.

Hi,

any update on this?

Can it be merged to the master before the coming release?

Thanks

User wildes has pushed new remote branch:

bug-16316-pointsetmapper2dGeo

Hi Miklos,

we are now considering to merge your changes into the upcoming release.

[3b39ad]: Merge branch 'bug-16316-pointsetmapper2dGeo'

Merged commits:

2014-03-05 17:49:03 Esther Wild [6f6b2d]
made pointsetmapper2d indepedent from slicenavigationcontroller geometry