Hi again, maybe I actually did something similar. Found a code snippet in my
Dropbox, which I called "InitViewWithoutCameraReset":
typedef mitk::RenderingManager::RenderWindowVector RenderWindowVector;
mitk::RenderingManager* renderingManager =
mitk::RenderingManager::GetInstance();
const RenderWindowVector& renderWindows =
renderingManager->GetAllRegisteredRenderWindows();
RenderWindowVector::const_iterator end = renderWindows.end();
for (RenderWindowVector::const_iterator it = renderWindows.begin(); it !=
end; ++it)
{
mitk::BaseRenderer* renderer = mitk::BaseRenderer::GetInstance(*it);
mitk::SliceNavigationController* sliceNavigationController =
renderer->GetSliceNavigationController();
sliceNavigationController->SetInputWorldGeometry(m_TubeSurface->GetGeometry());
sliceNavigationController->Update();
if (renderer->GetMapperID() == mitk::BaseRenderer::Standard2D)
{
mitk::Stepper* slice = sliceNavigationController->GetSlice();
slice->SetPos(slice->GetSteps() / 2);
}
renderer->GetDisplayGeometry()->Fit();
}
From: Dinkelacker, Stefan [mailto:s.dinkelac...@dkfz-heidelberg.de]
Sent: Mittwoch, 19. April 2017 12:55
To: 'Daphné Wallach'; mitk-users@lists.sourceforge.net
Subject: Re: [mitk-users] Cropped planes with curved MPR
Hi, sorry, never did this. Maybe you can look into InitializeViews() and
isolate the code that you actually want to execute from the slice reset? Best,
Stefan
From: Daphné Wallach [mailto:daphne.wall...@hrv-simulation.com]
Sent: Mittwoch, 19. April 2017 11:41
To: Dinkelacker, Stefan;
mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>
Subject: [mitk-users] Cropped planes with curved MPR
Dear Stefan,
I am now using something very similar to the code you sent, and everything is
working perfectly except for one thing: the planar views are cropped.
I implemented a class similar to QmitkStdMultiWidget, where each individual
viewer belongs to a class inheriting QmitkRenderWindow. I reimplemented the
wheelEvent method to scroll along a curve. The planes in the 3D viewer are
normal, but the images in the individual viewers are cropped (see attached
image).
I tried to call a reinit, which solves the cropping problem, but this
unfortunately also resets the slicing to the default one.
This is the code I use to reinitialize the views:
mitk::DataNode::Pointer originalImageNode =
_dataStorage->GetNamedNode("originalImage");
mitk::RenderingManager::GetInstance()->InitializeViews(originalImageNode->GetData()->GetTimeGeometry(),
mitk::RenderingManager::REQUEST_UPDATE_ALL, true);
Do you know how I could recenter the views on my image, without resetting the
slicing?
Best regards,
Daphné
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
Le 07/03/2017 à 15:54, Dinkelacker, Stefan a écrit :
Hi Daphné,
Sorry for the late answer. We asked around to check if really nobody is/was
using the curved geometry stuff. Unfortunately not. However, I remember that I
once implemented a slider in a plugin which was supposed to slide through
slices along a curved path. The path was defined by points (center + 2 points
for axes) per slice. And here is the snippet (quite old, but shouldn't be too
hard to adapt, if necessary at all):
#include <QmitkRenderWindow.h>
void QmitkMyPrototypeView::OnSliderValueChanged(int value)
{
if (value >= m_SliceOrientations.size())
return;
vtkSmartPointer<vtkSphereSource> originSource =
vtkSmartPointer<vtkSphereSource>::New();
originSource->SetCenter(
m_SliceOrientations[value].Origin[0],
m_SliceOrientations[value].Origin[1],
m_SliceOrientations[value].Origin[2]);
originSource->SetRadius(1.0);
originSource->SetThetaResolution(32);
originSource->SetPhiResolution(32);
vtkSmartPointer<vtkSphereSource> xAxisSource =
vtkSmartPointer<vtkSphereSource>::New();
xAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] + m_SliceOrientations[value].XAxis[0]
* (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[1] + m_SliceOrientations[value].XAxis[1]
* (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[2] + m_SliceOrientations[value].XAxis[2]
* (0.5 * m_TubeMajorAxis));
xAxisSource->SetRadius(0.5);
xAxisSource->SetThetaResolution(32);
xAxisSource->SetPhiResolution(32);
vtkSmartPointer<vtkSphereSource> zAxisSource =
vtkSmartPointer<vtkSphereSource>::New();
zAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] + m_SliceOrientations[value].ZAxis[0]
* (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[1] + m_SliceOrientations[value].ZAxis[1]
* (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[2] + m_SliceOrientations[value].ZAxis[2]
* (0.5 * m_TubeMinorAxis));
zAxisSource->SetRadius(0.5);
zAxisSource->SetThetaResolution(32);
zAxisSource->SetPhiResolution(32);
vtkSmartPointer<vtkAppendPolyData> appendPolyData =
vtkSmartPointer<vtkAppendPolyData>::New();
appendPolyData->AddInputConnection(originSource->GetOutputPort(0));
appendPolyData->AddInputConnection(xAxisSource->GetOutputPort(0));
appendPolyData->AddInputConnection(zAxisSource->GetOutputPort(0));
appendPolyData->Update();
m_Surface->SetVtkPolyData(static_cast<vtkPolyData*>(appendPolyData->GetOutputDataObject(0)));
// this->RequestRenderWindowUpdate();
this->GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin +
mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));
this->GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin +
mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));
this->GetRenderWindowPart()->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()->ReorientSlices(
m_SliceOrientations[value].Origin +
mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()),
m_SliceOrientations[value].XAxis,
m_SliceOrientations[value].ZAxis);
}
From: Daphné Wallach [mailto:daphne.wall...@hrv-simulation.com]
Sent: Freitag, 3. März 2017 16:50
To: mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>
Subject: Re: [mitk-users] Curved MPR
Dear Mitk users,
I am still struggling with displaying a curved MPR, based on a set of points
placed on the axial view by the user.
I wrote a piece of code similar to the one presented in a quite old thread
(http://mitk-users.1123740.n5.nabble.com/Curved-MPR-is-cropped-for-some-reason-td2823.html,
dating back from 2011). The workflow is the following:
- create a ThinPlateSplineCurvedGeometry
- give a frameGeometry (the same one as the dicom image) and a
referenceGeometry to it
- create a PlaneLandmarkProjector
- give a projection plane and the landmarks to it
- give the projector and the landmark to the ThinPlateSplineCurvedGeometry
- compute the geometry of the ThinPlateSplineCurvedGeometry
- give the ThinPlateSplineCurvedGeometry to the multiWidget through
SetWorldGeometry3D.
However, the code crashes on the last instruction (SetWorldGeometry3D) with a
cryptic message ("0xC0000005: Access violation reading...").
First, is this workflow correct? I saw other examples, where the
ThinPlateSplineCurvedGeometry was also added to the datastorage (I tried it,
and the same crash appears).
Second, I also looked at the code for the curvedmpr pluging (at
http://mitk.org/git/?p=MITK.git;a=shortlog;h=refs/heads/bug-10719-curved-mpr-master-integration),
and I have the impression that the main difference with the workflow I use is
that the ThinPlateSplineCurvedGeometry is added to the datastorage. Moreover,
it seems like development was stopped in 2014, is that correct?
I would greatly appreciate any help about the correct workflow to display a
curved MPR, or comments about my code below.
Best regards,
Daphné
Code snippet:
mitk::DataNode::Pointer originalImageNode =
_ds->GetNamedNode("originalImage");
const mitk::PointSet::DataType::PointsContainer::Pointer splineLandmarks =
mitk::PointSet::DataType::PointsContainer::New();
// Get landmarks...
if (splineLandmarks->Size() != 0 && originalImageNode->GetData())
{
mitk::ThinPlateSplineCurvedGeometry::Pointer tpsGeometry =
mitk::ThinPlateSplineCurvedGeometry::New();
const mitk::PlaneGeometry *plane =
_dataView->GetRenderWindow2()->GetSliceNavigationController()->GetCurrentPlaneGeometry();
// Set a reference 3D geometry (e.g. Geometry3D of an existing image
volume)
tpsGeometry->SetFrameGeometry(originalImageNode->GetData()->GetGeometry());
tpsGeometry->SetReferenceGeometry(plane->GetReferenceGeometry());
// Create projector class; target landmarks will be projected on
// a plane to create source landmarks for thin plate spline
// (plane is a mitk::PlaneGeometry, e.g. one of the standard
// coronal, sagittal, or transversal planes)
mitk::PlaneLandmarkProjector::Pointer planeLandmarkProjector =
mitk::PlaneLandmarkProjector::New();
planeLandmarkProjector->SetProjectionPlane(plane);
planeLandmarkProjector->ProjectLandmarks(splineLandmarks);
// Initialize TPS geometry with projector
tpsGeometry->SetLandmarkProjector(planeLandmarkProjector);
tpsGeometry->SetTargetLandmarks(splineLandmarks);
tpsGeometry->ComputeGeometry();
mitk::BaseRenderer* mappingRenderer =
mitk::BaseRenderer::GetInstance(_dataView->mitkWidget2->GetRenderWindow());
mappingRenderer->SetWorldGeometry3D(tpsGeometry); // Crash happens here
}
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
Le 02/03/2017 à 14:44, Daphné Wallach a écrit :
Dear MITK users,
I am developping an application using MITK as a library, and I am currently
trying to display a curved MPR, based on a set of points placed on the axial
view by the user.
I saw two related questions in the mailing list, but both answers were quite
dated (2010 and 2014), so things might have changed since then. The most recent
answer referred to a "Curved MPR" plugin, and mentionned it was under
developpement.
Does anybody have news about this plugin?
Best regards,
Daphné
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mitk-users mailing list
mitk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mitk-users