I want to select points and add a connecting line through the points on the axial slice. Adding an mouse interaction to the modified code from VTK/ImageProcessing/Python/ImageInteractorReslice.py causes the axial slice not be "static" anymore. Meaning if I hold down the left mouse button and drag my mouse around the mouse pad, I am able to visualize the remaining volume. I would like to prevent this from happening. Is there are workaround to this? (my code below)<br>
<br>class Interaction: public vtkInteractorStyleTrackballCamera<br>{<br> public:<br> static Interaction* New();<br> vtkTypeMacro(Interaction, vtkInteractorStyleTrackballCamera);<br> <br> void Initiliaze(); <br>
<br> virtual void OnLeftButtonDown()<br> {<br> cout << "Picking pixel: " << this->Interactor->GetEventPosition()[0] << " " << this->Interactor->GetEventPosition()[1] << std::endl;<br>
this->Interactor->GetPicker()->Pick(this->Interactor->GetEventPosition()[0], <br> this->Interactor->GetEventPosition()[1], <br> 0, // always zero.<br>
this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer());<br> double picked[3];<br> this->Interactor->GetPicker()->GetPickPosition(picked);<br>
cout << "Picked value: " << picked[0] << " " << picked[1] << " " << picked[2] << std::endl;<br><br> AddSelectedPoint(picked);<br><br>
// code to display the picked values and locations<br>
vtkSmartPointer<vtkRegularPolygonSource> circle = vtkSmartPointer<vtkRegularPolygonSource>::New();<br> circle->SetNumberOfSides(50);<br> circle->SetRadius(1);<br> circle->SetCenter(picked[0], picked[1], picked[2]);<br>
circle->Update();<br><br> vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();<br> mapper->SetInputConnection(circle->GetOutputPort());<br> mapper->Modified();<br>
<br> vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();<br> vtkSmartPointer<vtkProperty> circleProperty = vtkSmartPointer<vtkProperty>::New();<br> circleProperty->SetColor(1, 1, 0);<br>
//circleProperty->SetOpacity(0.0);<br> circleProperty->EdgeVisibilityOn();<br> circleProperty->SetEdgeColor(1, 0, 0);<br> actor->SetMapper(mapper);<br> actor->SetProperty(circleProperty); <br>
this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->AddActor(actor);<br> this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->Render();<br>
<br> // Forward events<br> vtkInteractorStyleTrackballCamera::OnLeftButtonDown();<br> };<br> <br> <br> private:<br> void AddSelectedPoint(double point[]); <br><br><br><br>};<br><br>main.cpp<br>
<br> vtkSmartPointer<Interaction> mouseStyle = vtkSmartPointer<Interaction>::New();<br> mouseStyle->Initiliaze();<br> mouseStyle->SetDefaultRenderer(renderer);<br> <br> iren->SetInteractorStyle( mouseStyle );<br>
<br>Thanks for any help!<br><br>Sahithya<br><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 2, 2012 at 6:03 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Sahithya,<br>
<br>
The following example comes with the VTK source code:<br>
<br>
VTK/ImageProcessing/Python/ImageInteractorReslice.py<br>
<br>
Note that you cannot use SetSlicePlane() together with<br>
SliceFacesCameraOn() and SliceAtFocalPointOn(),<br>
because when the latter two methods are used, the slice<br>
plane will be automatically set from the camera parameters<br>
and any value you set with SetSlicePlane() will be ignored.<br>
<span class="HOEnZb"><font color="#888888"><br>
- David<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Fri, Nov 2, 2012 at 3:39 PM, Sahithya Wintrich <<a href="mailto:s.prakash@csuohio.edu">s.prakash@csuohio.edu</a>> wrote:<br>
> Hello,<br>
><br>
> I am new to VTK and visualization in general. I am trying to extract a 2D<br>
> slice from a 3D volume. The classes I use are as follows:<br>
><br>
> vtkImageReader - reads the stack of 2D CT images<br>
> vtkVolumeTextureMapper2D - Maps the volume<br>
><br>
> in order to get a slice defined by a vtkPlane with origin and normal<br>
> corresponding to the slice of interest, I use:<br>
><br>
> mapper = vtkImageResliceMapper::New();<br>
> mapper->SetInputConnection(<br>
> reader->GetOuputPort());<br>
> mapper->SetSlicePlane(plane);<br>
><br>
> slice = vtkImageSlice::New();<br>
> slice->SetMapper(mapper);<br>
><br>
> renderer->AddViewProp(slice);<br>
><br>
> I understand that the vtkImageSlice is a 3D prop and I tried using<br>
> suggestions to change the position and focal point of the camera. However,<br>
> this is still displayed in a 3D space. I need to display this as a 2D slice<br>
> with a correct view (for oblique slices as well) and prevent the user from<br>
> rotating the slice.<br>
><br>
> Any help would be greatly appreciated!<br>
><br>
> Sahithya<br>
</div></div></blockquote></div><br></div>