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