Hi,
Currently, we are creating a program that displays the display in vtkImplicitPlaneWidget2 and the plane in vtkImplicitPlaneWidget2 in two dimensions.
The display was successful in the two windows.
However, when a plane in vtkImplicitPlaneWidget2 is selected, the 2D image cannot be updated automatically.
I want to automatically display 2D at the same time as selecting a plane.
Can you tell me where to improve?
A portion of my code is shown below.
class vtkIPWCallback : public vtkCommand
{
public:
static vtkIPWCallback *New()
{ return new vtkIPWCallback; }
virtual void Execute(vtkObject *caller, unsigned long, void*)
{
vtkImplicitPlaneWidget2 *planeWidget =
reinterpret_cast<vtkImplicitPlaneWidget2*>(caller);
vtkImplicitPlaneRepresentation *rep =
reinterpret_cast<vtkImplicitPlaneRepresentation*>(planeWidget->GetRepresentation());
rep->GetPlane(this->Plane);
double normal[3];
Plane->GetNormal(normal);
double Origin[3];
Plane->GetOrigin(Origin);
// Set the slice orientation
vtkSmartPointer<vtkMatrix4x4> resliceMatrix =
vtkSmartPointer<vtkMatrix4x4>::New();
(Compute of the 4x4 matrix)
vtkImageReslice *reslice = this->Reslice;
reslice->SetResliceAxes(resliceMatrix);
reslice->Update();
}
vtkIPWCallback():Plane(0) {}
vtkPlane *Plane;
vtkImageReslice *Reslice;
};
Reslice part code
// Set the slice orientation
vtkSmartPointer<vtkMatrix4x4> resliceMatrix =
vtkSmartPointer<vtkMatrix4x4>::New();
//Compute the center of the slice plane
int n = 512; // size in pixels
double s = 1.0; // size of each pixel
// Extract a slice in the desired orientation
vtkSmartPointer<vtkImageReslice> reslice =
vtkSmartPointer<vtkImageReslice>::New();
reslice->SetInputConnection(reader->GetOutputPort());
reslice->SetOutputDimensionality(2);
reslice->SetResliceAxes(resliceMatrix);
reslice->SetInterpolationModeToLinear();
reslice->SetOutputOrigin(0.0, 0.0, 0.0);
reslice->SetOutputExtent(0, n-1, 0, n-1, 0, 0);
reslice->SetOutputSpacing(s, s, s);
reslice->UpdateWholeExtent();
reslice->Update();