[vtkusers] vtkImageSlice using UserTransform

Miro Drahos mdrahos at robodoc.com
Tue Nov 26 17:23:33 EST 2013


Hi David,
thanks for the response.
I do not call SetUserMatrix(m) on vtkImageSlice, that's why I am quite 
surprised to see it changing.
I am only manipulating the UserMatrix of vtkActor (of the surface model).
I was using actor->PokeMatrix(m) on each mouse move, let me illustrate 
with some code:
//---------------------------------------------------
// triggered by means of vtkCommand::MouseMoveEvent
void PickImplantCallback::Pan()
{
     VTK_CREATE(vtkTransform, t);
     // ... build a transform based on interaction event positions

this->InteractionProp->PokeMatrix(t->GetMatrix());

     this->Render();
}

//---------------------------------------------------
// triggered by means of vtkCommand::MouseButtonReleaseEvent
void PickImplantCallback::OnButtonUp()
{
     // transform the actual polydata
     VTK_CREATE(vtkTransform, t);
t->SetMatrix(this->InteractionProp->GetMatrix());

     //... use vtkTransformPolyDataFilter to transform the vtkPolyData 
object

     // reset the actor's matrix:
     VTK_CREATE(vtkMatrix4x4, identity);
     this->InteractionProp->PokeMatrix(identity);

     // update the state vars, other cleanup

     this->Render();
}

This callback class doesn't even know about the vtkImageSlice, yet the 
vtkImageSlice objects update their textures as the InteractionProp's 
matrix is being updated, and then on button up reset the view that was 
before interaction (as the InteractionProp's matrix is reset to identity).

I have been using actor->PokeMatrix(m), which internally sets the 
UserMatrix; I tried to change all actor->PokeMatrix(m) calls to 
actor->SetUserMatrix(m) but that doesn't change anything.

Best,
Miro


On 11/26/2013 01:25 PM, David Gobbi wrote:
> Hi Miro,
>
> Let me see if I understand... you have a vtkImageSlice, and you have a
> vtkActor, and you have a matrix.  You call SetUserMatrix(matrix) on
> the vtkImageSlice, and you call SetUserMatrix(matrix) on the vtkActor.
>   Finally, you use the vtkRenderWindowInteractor to interact with the
> vtkActor.
>
> Why not call a DeepCopy on the original matrix, so that the
> vtkImageSlice and the vtkActor each has its own matrix?
>
> matrix2 = vtkMatrix4x4::New();
> matrix2->DeepCopy(matrix);
> imageSlice->SetUserMatrix(matrix2);
> actor->SetUserMatrix(matrix);
>
>    David
>
>
>
> On Mon, Nov 25, 2013 at 6:31 PM, Miro Drahos <mdrahos at robodoc.com> wrote:
>> Hi David,
>> I was hoping you could advise on an issue I am experiencing with
>> vtkImageSlice.
>> Together with the sliced image I am rendering a surface model in the scene,
>> that the user needs to be able to pick and interact with. When the surface
>> (~ 20000 vertices) is picked, I call SetUserMatrix() on its actor to render
>> the translation or rotation that user is performing in real-time.
>> This, however has a side-effect that vtkImageSlice uses the matrix and so
>> the displayed slice is modified during the interaction.
>> Is there a way to tell vtkImageSlice not to use the UserMatrix? Or perhaps
>> is there a better way to set the transformation matrix on the surface/its
>> actor to render the interaction?
>> I turned SliceAtFocalPointOff() and SliceFacesCameraOff() but that doesn't
>> change this behavior.
>> Thank you!
>> Miro
>>



More information about the vtkusers mailing list