Home > Software engineering >  [VTK] why can't this program displays mha file
[VTK] why can't this program displays mha file

Time:09-15

VTK 7.1

If (arg c & lt; 2)
{
STD: : coutReturn EXIT_FAILURE;
}
VtkSmartPointer Reader=
VtkSmartPointer : : New ();
Reader - & gt; SetFileName (argv [1]);
Reader - & gt; The Update ();

Int among [6].
Double spacing [3].
A double origin [3].

Reader - & gt; GetOutput () - & gt; GetExtent (among);
Reader - & gt; GetOutput () - & gt; GetSpacing (spacing);
Reader - & gt; GetOutput () - & gt; GetOrigin (origin);

Double center [3].
Center [0]=origin [0] + spacing [0] * 0.5 * (among other among [0] + [1]).
Center [1]=origin spacing [1] + [1] * 0.5 * (among other + among [2] [3]).
Center [2]=origin [2] + spacing [2] * 0.5 * (among other among [4] + [5]);

The static double axialElements [16]={
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};

VtkSmartPointerVtkSmartPointerResliceAxes - & gt; DeepCopy (axialElements);
ResliceAxes - & gt; SetElement (0, 3, center [0]).
ResliceAxes - & gt; SetElement (1, 3, center [1]).
ResliceAxes - & gt; SetElement (2, 3, center [2]).

VtkSmartPointer Reslice=
VtkSmartPointer : : New ();
Reslice - & gt; SetInputConnection (reader - & gt; GetOutputPort ());
Reslice - & gt; SetOutputDimensionality (2);
Reslice - & gt; SetResliceAxes (resliceAxes);
Reslice - & gt; SetInterpolationModeToLinear ();

VtkSmartPointer ColorTable=
VtkSmartPointer : : New ();
ColorTable - & gt; SetRange (0, 1000);
ColorTable - & gt; SetValueRange (0.0, 1.0);
ColorTable - & gt; SetSaturationRange (0.0, 0.0);
ColorTable - & gt; SetRampToLinear ();
ColorTable - & gt; Build ();

VtkSmartPointer ColorMap=
VtkSmartPointer : : New ();
ColorMap - & gt; SetLookupTable (colorTable);
ColorMap - & gt; SetInputConnection (reslice - & gt; GetOutputPort ());

VtkSmartPointer ImgActor=
VtkSmartPointer : : New ();
ImgActor - & gt; SetInputData (colorMap - & gt; GetOutput ());

VtkSmartPointer The renderer=
VtkSmartPointer : : New ();
The renderer - & gt; AddActor (imgActor);
The renderer - & gt; SetBackground (1.0, 1.0, 1.0);

VtkSmartPointer RenderWindow=
VtkSmartPointer : : New ();
RenderWindow - & gt; AddRenderer (the renderer);
RenderWindow - & gt; Render ();
RenderWindow - & gt; SetSize (640, 480);
RenderWindow - & gt; ImageResliceExample SetWindowName (" ");

VtkSmartPointer RenderWindowInteractor=
VtkSmartPointer : : New ();
VtkSmartPointer Imagestyle=
VtkSmartPointer : : New ();

RenderWindowInteractor - & gt; SetInteractorStyle (imagestyle);
RenderWindowInteractor - & gt; SetRenderWindow (renderWindow);
RenderWindowInteractor - & gt; The Initialize ();
RenderWindowInteractor - & gt; Start ().

Return EXIT_SUCCESS;

Results no error, no display graphical

CodePudding user response:

To set breakpoints single-step debugging, look at the file open, etc. If there is something wrong?

CodePudding user response:

Plus the colorMap - & gt; The update ()
  • Related