Preservation of cut plane(vtkImplicitPlaneWidget2)

Hi,
I am improving tkImplicitPlaneWidget2.

For example, I want to be able to save to my file by pressing a specific key after selecting the cutting plane.
Is it technically possible to save the cutting plane as a 2D image(.raw) in my file?

If you know, could you tell me something to help?

@dgobbi

I had the same problem.

Yes, it is possible to extract a 2D slice with vtkImageReslice. But vtkImageReslice needs you to set the ResliceAxes that correspond to the cutting plane. This requires some mathematics.

So the question is this: what is the 4x4 matrix that corresponds to the cutting plane?

For the rest of this explanation, you must have a good understanding of how a 4x4 matrix is used in computer graphics. So if you are not sure, then read about it in a good computer graphics textbook.

Here is what we know about the 4x4 matrix that we need:

  1. This 4x4 matrix defines a rotation an a translation. The rotation gives the angulation of the plane, the translation gives the position of the plane.

  2. The 3rd column of the matrix (the column that corresponds to ‘z’) is equal to the normal of the cutting plane.

  3. The 1st, 2nd, and 3rd columns of the matrix are perpendicular to each other (because they define a rotation).

  4. The 4th column of the matrix (the translation) must be such that it translates the origin (0,0,0) to a point on the plane. In other words, the x,y,z parts of the 4th column must be equal to the x,y,z of a point on the plane.

That’s all that I have to say for now, because I’m heading to bed. But it should be enough for you to start thinking about possible solutions. There is no class in VTK that will compute the 4x4 matrix that is needed, so don’t try looking for one.

Thank you for your help. :grinning:

Thank you for your reply.

Does this mean that the plane in vtkImplicitPlaneWidget2 can not extract a two-dimensional image?

I do not understand about the 4x4 matrix, so I will study a little more.

Does that mean it is necessary to understand the 4x4 matrix and then create a program to calculate it yourself?

@dgobbi

Yes. If you are curious, here is the code in vtkImageResliceMapper that is used to do something similar:

https://gitlab.kitware.com/vtk/vtk/blob/master/Rendering/Image/vtkImageResliceMapper.cxx#L600

Thank you for your reply.

OK.
I think once.

@dgobbi