[vtkusers] vtkImageResliceMapper problems
Ang
ysa0829 at gmail.com
Thu Oct 15 22:21:51 EDT 2015
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();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkImageResliceMapper-problems-tp5734423p5734444.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list