How to make addClippingPlane match vtkResliceCursorWidget ?

I can’t get the clip plane to match the reslice cursor widget planes.

const cut3DPlane = vtkPlane.newInstance();
cut3DPlane.setNormal(...resliceWidgetState.getPlanes()[xyzToViewType[1]].normal); //this is working
cutPlane.setOrigin(...resliceWidgetState.getCenter()); //this does not work

How can I make the cut match ?

I do not see what you are doing wrong (except the typo cutPlane vs cut3DPlane)

The error of cutPlane has been when writing the code here in my code is fine, that is not the problem.
The problem is that the range of values obtained from resliceWidgetState.getCenter()[1] goes from 0 to 181.
These values are much higher than what cut3DPlane needs.
For example if I set cut3DPlane.setOrigin(0, resliceWidgetState.getCenter()[1], 0) the cube disappears when moving resliceCursorWidget.
the values that cut3DPlane.setOrigin needs are much smaller, for example cut3DPlane.setOrigin(0,-0.2,0) this will for example cut the cube approximately in half as seen in the picture above.

Here you can see the problem.
On the lines:
line 120 function updateCutPlanes
line 216 call to updateCutPlanes
line 372 - 383 add the cube and the clip plane

Any solution ?

By playing with your code and example, it seems that the problem comes from the clipping plane equation being sent to the shader (in getClippingPlaneInDataCoords() or in vtkPolyDataMapper.setMapperShaderParameters).

It is as if the cube while being 100x100x100 gets cut with a plane origin between 0.5 and -0.5.

FYI @thewtex

With what function can I get that range -0.5, 0.5 ?

I simply played with setOrigin() of vtkPlane and realized the range.

Any solution for this why is it happening?

No solution, just an idea. Your problem seems closely related to this issue and fix:

I would suggest:

  • to try by reverting this change and see if that fixes it
  • to understand this change and see if there is a problem with the logic
  • further debug that code that uses getClippingPlaneInDataCoords

Shall you have funding, we could investigate it for you…


Actually, what I suggested is correct, the bug you are experiencing is related to issue !2225 .
That issue has been fixed, so if you update your code to master (v26), you won’t have the problem anymore.