Issues Encountered While Picking Coordinates Using vtkCellPicker in MPR Program

When using this picker, I found that its picking range only covers half of the entire space. If my world coordinate range is 0-100, it can only pick up values from 50-100, and within the range of 0-50, the picked value consistently remains at 50

“I have observed that when the mouse wheel is scrolled forward, the data changes normally, but it does not when scrolled backward, even after I have updated the camera.”
image

#include "vtkAutoInit.h"
VTK_MODULE_INIT(vtkRenderingFreeType)
VTK_MODULE_INIT(vtkRenderingOpenGL2);

VTK_MODULE_INIT(vtkInteractionStyle);

#include <vtkDICOMImageReader.h>
#include <vtkResliceImageViewer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkVector.h>
#include<vtkContourWidget.h>

#include<vtkImageData.h>
#include<vtkRenderer.h>
#include<vtkResliceCursorLineRepresentation.h>
#include<vtkResliceCursorWidget.h>
#include<vtkResliceCursorActor.h>
#include<vtkProperty.h>
#include<vtkResliceCursor.h>
#include<vtkResliceCursorPolyDataAlgorithm.h>
#include<vtkBezierWedge.h>
#include<vtkOrientedGlyphContourRepresentation.h>
#include<vtkTransform.h>
#include<vtkSplineFilter.h>
#include<vtkImagePermute.h>
#include<vtkImageFlip.h>
#include<vtkImageAppend.h>
#include<vtkMetaImageWriter.h>
#include<vtkImageMapToWindowLevelColors.h>
#include<vtkInteractorStyleImage.h>
#include<vtkProbeFilter.h>
#include <vtkParametricSpline.h>
#include<vtkCardinalSpline.h>
#include<vtkMetaImageWriter.h>

#include <chrono>
#include<vtkImageViewer2.h>
#include <vtkSmartPointer.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSphereSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkSphereWidget.h>
#include <vtkCommand.h>
#include <vtkCellPicker.h>
#include <vtkRendererCollection.h>
// 自定义回调类来处理 vtkSphereWidget 的事件
class Callback : public vtkCommand
{
public:
	static Callback* New()
	{	
		return new Callback;
	}
	void init() {
		CellPicker = vtkCellPicker::New();
	}
	virtual void Execute(vtkObject* caller, unsigned long eid, void*)
	{
		vtkRenderWindowInteractor* interactor = vtkRenderWindowInteractor::SafeDownCast(caller);
	
		vtkRenderer* renderer = interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer();

		// Pick at the mouse location provided by the interactor
		int x = interactor->GetEventPosition()[0];
		int y = interactor->GetEventPosition()[1];

		//虽然什么都没拾取到但是也是必须的
		this->CellPicker->Pick(x, y, 0.0, renderer);
		double world_coordinate[3];
		// Get the world coordinates of the pick
		this->CellPicker->GetPickPosition(world_coordinate);

		cout << "world_coordinate[0]  " << world_coordinate[0] << endl;
		cout << "world_coordinate[1]  " << world_coordinate[1] << endl;
		cout << "world_coordinate[2]  " << world_coordinate[2] << endl;
	}
	vtkCellPicker* CellPicker;
};

int main()
{

	// 读取DICOM数据
	vtkSmartPointer<vtkDICOMImageReader> reader =
		vtkSmartPointer<vtkDICOMImageReader>::New();
	reader->SetDirectoryName("D:\\rt_ct");
	reader->Update();

	// 创建vtkResliceImageViewer对象
	vtkVector<vtkSmartPointer<vtkResliceImageViewer>, 3> viewer;
	vtkVector<vtkSmartPointer<vtkRenderWindowInteractor>, 3> interactor;
	auto cursor = vtkSmartPointer<vtkResliceCursor>::New();
	cursor->SetThickMode(0);
	for (int i = 0; i < 3; i++)
	{

		viewer[i] = vtkSmartPointer<vtkResliceImageViewer>::New();
		viewer[i]->SetResliceCursor(cursor);
		viewer[i]->SetInputData(reader->GetOutput());
		viewer[i]->SetSliceOrientation(0);
		viewer[i]->SetSliceOrientation(i);
		viewer[i]->SetSlice(reader->GetOutput()->GetDimensions()[i] / 2);

		auto rep = viewer[i]->GetResliceCursorWidget()->GetRepresentation();

		auto reps = vtkResliceCursorLineRepresentation::SafeDownCast(rep);
		reps->SetWindowLevel(4095, 1024);
		auto res = reps->GetReslice();

		auto reslice = vtkImageReslice::SafeDownCast(res);
		reslice->SetInterpolationModeToCubic();
		auto  ResliceCursorActor = reps->GetResliceCursorActor();
		ResliceCursorActor->GetCursorAlgorithm()->SetReslicePlaneNormal(i);
		ResliceCursorActor->GetCenterlineProperty(0)->SetRepresentationToWireframe();//代表12窗口竖线
		ResliceCursorActor->GetCenterlineProperty(1)->SetRepresentationToWireframe();//0竖线,2横线
		ResliceCursorActor->GetCenterlineProperty(2)->SetRepresentationToWireframe();//01横线
		ResliceCursorActor->GetCenterlineProperty(0)->RenderLinesAsTubesOn();
		ResliceCursorActor->GetCenterlineProperty(1)->RenderLinesAsTubesOn();
		ResliceCursorActor->GetCenterlineProperty(2)->RenderLinesAsTubesOn();
		ResliceCursorActor->GetCenterlineProperty(0)->SetLineWidth(2);
		ResliceCursorActor->GetCenterlineProperty(1)->SetLineWidth(2);
		ResliceCursorActor->GetCenterlineProperty(2)->SetLineWidth(2);

		viewer[i]->GetResliceCursorWidget()->SetRepresentation(reps);
		interactor[i] = vtkSmartPointer<vtkRenderWindowInteractor>::New();
		//interactor[i]->SetRenderWindow(viewer[i]->GetRenderWindow());
		viewer[i]->SetupInteractor(interactor[i]);
		// 显示vtkResliceImageViewer对象
		viewer[i]->GetRenderWindow()->SetPosition(400 * i, 400 * i);
		viewer[i]->GetRenderWindow()->SetSize(400, 400);

		viewer[i]->SetResliceMode(1);

		viewer[i]->Render();
		viewer[i]->GetRenderer()->ResetCamera();
		viewer[i]->GetRenderWindow()->Render();
	}



	auto ckb = Callback::New();
	ckb->init();
	interactor[0]->AddObserver(vtkCommand::MouseMoveEvent, ckb, 1.0);
	interactor[1]->AddObserver(vtkCommand::MouseMoveEvent, ckb, 1.0);
	interactor[2]->AddObserver(vtkCommand::MouseMoveEvent, ckb, 1.0);

	interactor[0]->Start();


	return 0;
}
```This program can reproduce the issue I mentioned. When you scroll the mouse forward in the third window, you can see that the Z value of the world coordinates changes normally, but when you scroll in the opposite direction, the Z axis no longer changes.

i guess it is a bug ,help me

Hello,

Please, share the code involved in the picking process.

best,

PC

There is demo code available above that can reproduce this issue.

Sorry, the scroll bar is almost invisible here. I didn’t notice there were more code than the #includes.