[vtkusers] vtkImageResliceMapper problems

David Gobbi david.gobbi at gmail.com
Mon Oct 19 10:57:12 EDT 2015


Hi Ang,

I tried your code with the VTK master branch and I didn't see any problem.
When I clicked on the image and moved the mouse, the image did not jump
to a new position.  I can try this again with VTK 6.3, but probably not
today.

You expect the image to stay centered in the window, correct?

 - David


On Thu, Oct 15, 2015 at 8:21 PM, Ang <ysa0829 at gmail.com> wrote:

> Hi Cory,
>
> Below is my example .
>
> In vtk 6.0, click right mouse down and move mouse the image position is
> still in the center,
>
> but do the same thing in vtk 6.3, the image position will be changed when
> you click down and move.
>
> Please have a check, thanks for your  assistance.
>
>
> //////////////////////////////////////////////////////////////////////////////////////////////
>
>         vtkRenderWindow *renWin = vtkRenderWindow::New();
>         vtkRenderWindowInteractor *interactor =
> vtkRenderWindowInteractor::New();
>         vtkRenderer *renderer = vtkRenderer::New();
>         vtkInteractorStyleImage *styleImage =
> vtkInteractorStyleImage::New();
>         styleImage->SetInteractionModeToImageSlicing();
>         interactor->SetInteractorStyle(styleImage);
>         renWin->SetInteractor(interactor);
>         renWin->AddRenderer(renderer);
>         renderer->SetBackground(1, 0, 0);
>
>
>         vtkImageResliceMapper *resliceMapper =
> vtkImageResliceMapper::New();
>         vtkImageSlice *imageSlice = vtkImageSlice::New();
>         vtkImageData *img = vtkImageData::New();
>         img->SetDimensions(50, 50, 50);
>         img->AllocateScalars(VTK_UNSIGNED_CHAR, 1);
>         img->SetSpacing(1, 1, 1);
>
>         for (int z = 0; z < img->GetDimensions()[2]; z++)
>         {
>                 for (int x = 0; x < img->GetDimensions()[0]; x++)
>                 {
>                         for (int y = 0; y < img->GetDimensions()[1]; y++)
>                         {
>                                 unsigned char *pixel = static_cast<unsigned
> char*>(img->GetScalarPointer(x, y, z));
>
>                                 int c0 = img->GetDimensions()[0] / 2;
>                                 int c1 = img->GetDimensions()[1] / 2;
>                                 int c2 = img->GetDimensions()[2] / 2;
>                                 double pointX = (x - c0)*(x - c0);
>                                 double pointY = (y - c1)*(y - c1);
>                                 double pointZ = (z - c2)*(z - c2);
>                                 if (pointX + pointY + pointZ < 15 * 15)
>                                 {
>                                         *pixel = 255;
>                                 }
>                                 else
>                                 {
>                                         *pixel = 0;
>                                 }
>                         }
>                 }
>         }
>
>
>
>         imageSlice->SetMapper(resliceMapper);
>         resliceMapper->SetInputData(img);
>         //set reslice plane to sagittal
>         resliceMapper->GetSlicePlane()->SetNormal(1, 0, 0);
>         resliceMapper->GetSlicePlane()->SetOrigin(25, 0, 0); // set plane
> to middle
>
>         //set camera to sagittal orientation
>         renderer->GetActiveCamera()->SetFocalPoint(0, 25, 25);
>         renderer->GetActiveCamera()->SetPosition(200, 25, 25);
>         renderer->GetActiveCamera()->SetViewUp(0, 0, 1);
>         renderer->GetActiveCamera()->SetParallelScale(75);
>         renderer->GetActiveCamera()->ParallelProjectionOn();
>
>         renderer->AddActor(imageSlice);
>
>         renWin->Render();
>         interactor->Start();
>
> ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151019/f4f5aeac/attachment.html>


More information about the vtkusers mailing list