[vtkusers] Outline of a result from a vtkimagereslicemapper

Doug Hoppes dhoppes at mbfbioscience.com
Thu Sep 25 10:40:10 EDT 2014


Thanks for the reply, David.  I still think that I'm missing something obvious (once I get the outline working, I'll add the tube filter).

Here's the pipeline that I'm trying to implement but the outlines seems to be a small box in the upper corner of my volume rather than outlining the slice.

------------
// Create the plane to cut into the volume
m_pSlicePlane = vtkSmartPointer<vtkPlane>::New();

// the slice mapper extracts a slice from the volume
m_pSliceMapper = vtkSmartPointer<vtkImageResliceMapper>::New();
m_pSliceMapper->SetInputData(GetImageDefinition()->GetImage()->GetImageData());
m_pSliceMapper->SetSlicePlane(m_pSlicePlane);

// Set it up so that the slice is not affected by the current lighting situation
vtkSmartPointer<vtkImageProperty> m_sliceProperty = vtkSmartPointer<vtkImageProperty>::New();
m_sliceProperty->SetAmbient(1.0);
m_sliceProperty->SetDiffuse(0.0);
m_sliceProperty->SetOpacity(1.0);
m_sliceProperty->SetInterpolationTypeToLinear();

// Create the mapper to display the slice
m_pSliceActor = vtkSmartPointer<vtkImageSlice>::New();
m_pSliceActor->SetMapper(m_pSliceMapper);
m_pSliceActor->SetProperty(m_sliceProperty);

// Add the slice to the scene
m_pSceneManager->AddActor(m_pSliceActor);

// Cut the slice plane so that we can put an outline around it
vtkSmartPointer<vtkCutter> pCutter = vtkSmartPointer<vtkCutter>::New();
pCutter->SetCutFunction(m_pSliceMapper->GetSlicePlane());
pCutter->SetInputConnection(m_pSliceMapper->GetOutputPort());

// setup the outline actor
vtkSmartPointer<vtkOutlineFilter> pOutlineFilter = vtkSmartPointer<vtkOutlineFilter>::New();
pOutlineFilter->GenerateFacesOn();
pOutlineFilter->SetInputConnection(pCutter->GetOutputPort());

// Create the mapper to display the outline
vtkSmartPointer<vtkPolyDataMapper> pOutlineMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
pOutlineMapper->SetInputConnection(pOutlineFilter->GetOutputPort());

// Create the actor to display the outline
m_pOutlineActor = vtkSmartPointer<vtkActor>::New();
m_pOutlineActor->GetProperty()->SetColor(1.0,1,0);
m_pOutlineActor->GetProperty()->SetLineWidth(10);
m_pOutlineActor->SetMapper(pOutlineMapper);

// Add the actor to the scene
m_pSceneManager->AddActor(m_pOutlineActor);
------------

From: David Gobbi [mailto:david.gobbi at gmail.com]
Sent: Thursday, September 18, 2014 4:22 PM
To: Doug Hoppes
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Outline of a result from a vtkimagereslicemapper

Hi Doug,

In order to create a polydata that outlines the slice, you'll need
to use the vtkCutter:

1) use GenerateFacesOn() on the vtkOutlineFilter to make it create
a closed box

2) use vtkCutter to cut the box with the slice plane from the mapper
(mapper->GetSlicePlane() or mapper->GetSlicePlaneInDataCoords())
in order to create a polyline that outlines the slice

3) I also recommend passing the polyline through vtkTubeFilter in
order to give the outline a finite thickness

 - David



On Thu, Sep 18, 2014 at 1:00 PM, Doug Hoppes <dhoppes at mbfbioscience.com<mailto:dhoppes at mbfbioscience.com>> wrote:
Hi all,

                I've gotten the image reslice mapper working beautifully for my image volume.  However, I'm trying to get the outline filter to work so that I can show a bound region around my image slice.  All I'm showing is a small square in the upper left corner:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140925/90d6c7a4/attachment.html>


More information about the vtkusers mailing list