Hai everyone,
I’ve incorporated a DICOM series into vtkMarchingCubes and subsequently added it to the renderer as an actor. This renderer was then placed into the vtkGenericOpenGLRenderWindow. Following that, I added a vtkImagePlaneWidget to the same renderer. I’m attempting to move this PlaneWidget and obtain the current vtkImageReslice, displaying that slice in another renderer.This second renderer was then placed into the vtkGenericOpenGLRenderWindow. Unfortunately, when I add an interactor to the render window, the application crashes. I need to move the PlaneWidget, but without adding the interactor, the widget remains immobile. How can I resolve this issue? Code given below
m_qobjVTKOpenGLWidget = new QVTKOpenGLWidget();
m_qobjVTKOpenGLWidget->SetRenderWindow(m_objvtkGenericOpenGLRenderWindow);
QString folderPath = QDir::currentPath() + "/TwinFetuses_dicom";
vtkSmartPointer<vtkNamedColors> colors = vtkSmartPointer<vtkNamedColors>::New();
vtkSmartPointer<vtkImageData> volume = vtkSmartPointer<vtkImageData>::New();
double isoValue;
vtkSmartPointer<vtkDICOMImageReader> reader = vtkSmartPointer<vtkDICOMImageReader>::New();
reader->SetDirectoryName(folderPath.toUtf8().constData());
reader->Update();
volume->DeepCopy(reader->GetOutput());
vtkSmartPointer<vtkMarchingCubes> surface = vtkSmartPointer<vtkMarchingCubes>::New();
surface->SetInputData(volume);
surface->ComputeNormalsOn();
surface->SetValue(0, 75);
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(surface->GetOutputPort());
mapper->ScalarVisibilityOff();
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetColor(colors->GetColor3d("MistyRose").GetData());
renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->SetBackground(colors->GetColor3d("DarkSlateGray").GetData());
renderer->AddActor(actor);
renderer->SetViewport(0,0,0.5,1 );
m_qobjVTKOpenGLWidget->GetRenderWindow()->AddRenderer(renderer);
vtkSmartPointer<vtkImagePlaneWidget> m_objvtkImagePlaneWidget = vtkSmartPointer<vtkImagePlaneWidget>::New();
m_objvtkImagePlaneWidget->SetInputConnection(reader->GetOutputPort());
m_objvtkImagePlaneWidget->SetPlaneOrientationToXAxes();
m_objvtkImagePlaneWidget->SetSliceIndex(100);
m_objvtkImagePlaneWidget->DisplayTextOn();
m_objvtkImagePlaneWidget->SetInteractor(m_objvtkGenericOpenGLRenderWindow->GetInteractor());
m_objvtkImagePlaneWidget->SetDefaultRenderer(renderer);
m_objvtkImagePlaneWidget->RestrictPlaneToVolumeOn();
m_objvtkImagePlaneWidget->GetPlaneProperty()->SetColor(1,0,0);
m_objvtkImagePlaneWidget->TextureInterpolateOff();
m_objvtkImagePlaneWidget->SetResliceInterpolateToLinear();
m_objvtkImagePlaneWidget->GetPlaneProperty()->SetLineWidth(2.5);
m_objvtkImagePlaneWidget->GetTexturePlaneProperty()->SetOpacity(0.01);
m_objvtkImagePlaneWidget->UpdatePlacement();
m_objvtkImagePlaneWidget->On();
m_objvtkImagePlaneWidget->AddObserver(vtkCommand::InteractionEvent,this, &showScannedOut::FovPlaneCallbackPoint);
vtkSmartPointer<vtkImageReslice> reslice = vtkSmartPointer<vtkImageReslice>::New();
reslice->SetInputData(m_objvtkImagePlaneWidget->GetInput());
reslice->Update();
vtkSmartPointer<vtkImageSliceMapper> map = vtkSmartPointer<vtkImageSliceMapper>::New();
map->SetInputConnection(reslice->GetOutputPort());
map->SetOrientation(2);
map->Update();
vtkSmartPointer<vtkImageSlice> imageActor = vtkSmartPointer<vtkImageSlice>::New();
imageActor->SetMapper(map);
renderertwoD = vtkSmartPointer<vtkRenderer>::New();
renderertwoD->SetBackground(colors->GetColor3d("AliceBlue").GetData());
renderertwoD->SetViewport(0.5,0,1,1 );
renderertwoD->AddViewProp(imageActor);
renderer->ResetCamera();
renderer->SetBackground(colors->GetColor3d("NavajoWhite").GetData());
m_objvtkGenericOpenGLRenderWindow->AddRenderer(renderertwoD);
QHBoxLayout *lay= new QHBoxLayout;
lay->addWidget(m_qobjVTKOpenGLWidget);
this->setLayout(lay);
m_objvtkGenericOpenGLRenderWindow->Render();
Kindly help me to sort out this probem. Thank in advance.
Deepak