Hi Thomas,

 

thank you very much for your reply. I will try to substitute both classes
with MITK classes and will report the results afterwards.

 

Best regards,

 

Hendrik 

 

Von: Kilgus, Thomas [mailto:[email protected]] 
Gesendet: Mittwoch, 13. Juni 2012 09:53
An: [email protected]
Betreff: Re: [mitk-users] Geometry issues on rendering a vtkContourWidget in
a QmitkStdMultiWidget

 

Hi Hendrik,

 

one point I am not quite sure about is that you are using some of VTK’s
rendering methods which are usually not used inside MITK. 

 

The following VTK Classes have a kind of “alternative” in MITK:

-vtkImageActor (a combination of mapper and actor meant image rendering) à
mitkImageVtkMapper2D does this job specialized for our purposes

-vtkRenderWindowInteractor and vtkInteractorStyleImage à We have our own
mitkVtkInteractorStyle which should be used to enable proper MITK
interaction

 

 

I am a little surprised that you are able to render everything correctly
this way. Maybe you could try to render everything using our replacements?

 

Furthermore, there is currently a bug regarding outline binary (contours)
shifts: http://bugs.mitk.org/show_bug.cgi?id=10996

This could be related to your issues.

 

Regards

Thomas

 

 

[mitk-users] Geometry issues on rendering a vtkContourWidget in a
QmitkStdMultiWidget

 

Hendrik Hachmann

Wed, 30 May 2012 00:54:52 -0700

 

Hi

 

 

 

I am trying to use the vtkContourWidget combined with a live wire algorithm

in a QmitkStdMultiWidget.

 

Thus I added the vtkContourWidget via a mitk::VtkWidgetRepresentation to the

data storage.

 

This is what I have done so far:

 

 

 

// Calculate a cost image from an slice extracted by the

mitk::ExtractImageFilter 

 

// Get existing renderer from QmitkStdMultiWidget

 

vtkRenderWindow *renderWindow =

m_Ext->GetMitkView()->GetRenderWindow1()->GetVtkRenderWindow();

 

vtkRenderer *renderer =

m_Ext->GetMitkView()->GetRenderWindow1()->GetRenderer()->GetVtkRenderer();

 

 

 

vtkImageActor *actor = vtkImageActor::New();

 

actor->SetInput( image );

 

actor->SetDisplayExtent( 0, 511, 0, 511, 0, 0 );  

 

 

 

vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();

 

iren->SetRenderWindow( renderWindow );

 

vtkInteractorStyleImage* style = vtkInteractorStyleImage::New();

 

iren->SetInteractorStyle( style );

 

style->Delete();

 

 

 

// Contour widget for interactive path definition

 

vtkContourWidget *contourWidget = vtkContourWidget::New();

 

contourWidget->SetInteractor(iren);

 

contourWidget->SetFollowCursor(1);

 

 

 

mitk::VtkWidgetRendering::Pointer mWidget = mitk::VtkWidgetRendering::New();

 

mWidget->SetVtkWidget(contourWidget);

 

mWidget->Initialize();

 

mWidget->SetRenderWindow(m_Ext->GetMitkView()->GetRenderWindow1()->GetVtkRen

derWindow());

 

mWidget->Enable();

 

mWidget->Update();

 

 

 

mitk::DataNode::Pointer widgetNode = mitk::DataNode::New();

 

widgetNode->SetData(mWidget);

 

widgetNode->SetName("VtkContour");

 

m_Ext->GetDataStorage()->Add(widgetNode);

 

widgetNode->Update();

 

 

 

vtkOrientedGlyphContourRepresentation *rep =

vtkOrientedGlyphContourRepresentation::New();

 

contourWidget->SetRepresentation( rep );

 

contourWidget->SetFollowCursor( followCursor );

 

rep->GetLinesProperty()->SetColor(1, 0.2, 0);

 

rep->GetProperty()->SetColor(0, 0.2, 1);

 

rep->GetLinesProperty()->SetLineWidth( 3 );

 

 

 

// The contour rep requires a suitable point placer

 

vtkImageActorPointPlacer *placer = vtkImageActorPointPlacer::New();

 

placer->SetImageActor( actor );

 

rep->SetPointPlacer( placer );

 

 

 

// The line interpolator defines how intermediate points are

 

// generated between the representations nodes.  This 

 

// interpolator uses Dijkstra's shortest path algorithm.

 

vtkDijkstraImageContourLineInterpolator *interpolator =

vtkDijkstraImageContourLineInterpolator::New();

 

interpolator->SetCostImage( vCostImage );

 

vtkDijkstraImageGeodesicPath* path =

interpolator->GetDijkstraImageGeodesicPath();

 

path->StopWhenEndReachedOn();

 

// prevent contour segments from overlapping

 

path->RepelPathFromVerticesOn();

 

// weights are scaled from 0 to 1 as are associated cost

 

// components

 

path->SetCurvatureWeight( 0.15 );

 

path->SetEdgeLengthWeight( 0.8 );

 

path->SetImageWeight( 1.0 );

 

 

 

rep->SetLineInterpolator( interpolator );

 

contourWidget->EnabledOn();

 

renderWindow->Render();

 

renderer->ResetCamera();

 

iren->Initialize();

 

 

 

The code basically works. However, I encountered geometry issues. The region

in which the contour works as expected is shifted to the upper right and the

region is way to large.

 

In the mitkVtkWidgetRendering documentation is says: "Note: this class only

provides a basic mechanism for adding widget; all widget configuration such

as placement, size, and en-/disabling of interaction mechanisms need to be

done in the vtkWidget object."

 

 

 

The problem is I cannot find a geometry at the vtkWidget. I tried scaling

and shifting the actor as well as the vCostImage or changing the spacings

without success. Furthermore I tried to setup a geometry for the

mitk::VtkWidgetRendering.

 

 

 

So, how can I set the geometry correctly?

 

 

 

Can anyone help me?

 

 

 

Best regard,

 

 

 

Hendrik

 

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to