[vtkusers] changing the position of an actor

Steffen Oeltze Steffen.Oeltze at Student.Uni-Magdeburg.DE
Thu Oct 31 03:51:52 EST 2002


Hi David,

I still have some problem with placing my actors. I would be very 
grateful if you
could have a look at my source code below:

vtkImageChangeInformation *imgChg = vtkImageChangeInformation::New();
        imgChg->SetInput(reader->GetOutput());
        imgChg->CenterImageOn();

vtkTransform *transform = vtkTransform::New();
        transform->SetMatrix(ResultMatrix);  // matrix rotates the 
volume about 90° and reflects it on the y-axes

vtkImageReslice *imgReslice = vtkImageReslice::New();
        imgReslice->SetInput(imgChg->GetOutput());
        imgReslice->SetResliceAxesDirectionCosines(1, 0, 0,  0, 1, 0,  
0, 0, 1);
        imgReslice->SetResliceTransform(transform);

...

vtkActor *aPolyLineActor = vtkActor::New();
        aPolyLineActor->SetMapper(aPolyLineMapper);
        aPolyLineActor->SetOrigin(0.0,0.0,0.0);
        aPolyLineActor->SetScale(1.09,1.09,3.0);
        (aPolyLineActor->GetProperty())->SetDiffuseColor(1,0,0);

vtkAbstractTransform *trans1;
        trans1 = imgReslice->GetResliceTransform();

vtkLinearTransform *trans2 = vtkLinearTransform::SafeDownCast(trans1);
        trans2 = trans2->GetLinearInverse();

aPolyLineActor->SetUserTransform(trans2);


David Gobbi wrote:

>Hi Steffen,
>
>If you want to draw actors in the same scene as an image, it
>is crucial that you establish a coordinate system for the image.
>The image coordinate system is defined by the Origin and Spacing
>information that is attached to the image.
>
>When you use vtkImageChangeInformation to center the volume, you
>are modifying the 'Origin' of the image so that the origin of
>the coordinate system is at the center of the volume.  If,
>after centering the volume, you apply a transformation via
>vtkImageReslice, just set the inverse of the ResliceTransform
>as the UserTransform of the Actors.
>
> - David
>





More information about the vtkusers mailing list