18 #include "vtkPolyDataMapper.h"
19 #include "vtkProperty.h"
20 #include "vtkRenderWindow.h"
21 #include "vtkRenderWindowInteractor.h"
22 #include "vtkRenderer.h"
23 #include "vtkSphereSource.h"
24 #include "vtkUnsignedCharArray.h"
27 #include <mitkPicFileReader.h>
37 #include <itksys/SystemTools.hxx>
46 if (itksys::SystemTools::LowerCase(itksys::SystemTools::GetFilenameExtension(argv[1])).find(
".pic") !=
50 if (picheader == NULL)
52 std::cout <<
"file not found/not a pic-file - test not applied [PASSED]" << std::endl;
53 std::cout <<
"[TEST DONE]" << std::endl;
57 static long int sum_orig_Pic3D_pic_gz = 14685408;
62 std::cout <<
"Reading image: ";
64 reader->SetFileName(argv[1]);
66 std::cout <<
"[PASSED]" << std::endl;
70 std::cout <<
"Creating node: ";
73 std::cout <<
"[PASSED]" << std::endl;
75 std::cout <<
"Creating DataStorage: ";
77 std::cout <<
"[PASSED]" << std::endl;
79 std::cout <<
"Adding node via DataStorage: ";
81 std::cout <<
"[PASSED]" << std::endl;
83 std::cout <<
"Adding level-window property: ";
87 levWinProp->SetLevelWindow(levelwindow);
88 node->GetPropertyList()->SetProperty(
"levelwindow", levWinProp);
89 std::cout <<
"[PASSED]" << std::endl;
91 std::cout <<
"Creating a vtk sphere: ";
93 sphere->SetRadius(1.0);
94 sphere->SetThetaResolution(18);
95 sphere->SetPhiResolution(18);
98 map->SetInput(sphere->GetOutput());
102 aSphere->SetMapper(map);
104 aSphere->GetProperty()->SetColor(0, 0, 1);
105 std::cout <<
"[PASSED]" << std::endl;
107 std::cout <<
"Creating a renderer for the sphere: ";
109 sphereRenderer->AddActor(aSphere);
112 std::cout <<
"[PASSED]" << std::endl;
114 std::cout <<
"Creating vtkRenderWindow and VtkPropRenderer: ";
118 std::cout <<
"[PASSED]" << std::endl;
123 std::cout <<
"BaseRenderer::SetData(iterator): ";
124 propRenderer->SetDataStorage(ds);
125 std::cout <<
"[PASSED]" << std::endl;
127 std::cout <<
"Creating vtkMitkRenderProp and connecting it to the VtkPropRenderer: ";
130 propRenderer->GetVtkRenderer()->AddViewProp(renderProp);
131 std::cout <<
"[PASSED]" << std::endl;
133 std::cout <<
"Inserting the sphere into the foreground of the VtkLayerController: ";
135 std::cout <<
"[PASSED]" << std::endl;
141 std::cout <<
"Setting and getting size of renderWindow: ";
142 renderWindow->SetSize(400, 400);
143 int *size = renderWindow->GetSize();
144 std::cout <<
"[PASSED]" << std::endl;
146 std::cout <<
"Do the rendering: ";
147 renderWindow->Render();
148 std::cout <<
"[PASSED]" << std::endl;
152 std::cout <<
"Testing to pick a world position: ";
157 propRenderer->PickWorldPoint(p, p_mm);
158 std::cout <<
"returned world position: " << p_mm <<
"\n";
160 std::cout <<
"Creating vtkUnsignedCharArray: ";
162 std::cout <<
"[PASSED]" << std::endl;
164 cout <<
"Reading image from renderWindow" << std::endl;
165 renderWindow->GetRGBACharPixelData(0, 0, size[0] - 1, size[1] - 1, 0, vtkImage);
166 cout <<
"Read " << size[0] * size[1] <<
" data points\n";
168 cout <<
"Computing sum of all RGBA values..\n";
169 long int sum_now = 0;
170 for (
int i = 0; i < size[0] * size[1]; i++)
171 sum_now += vtkImage->GetValue(i);
172 std::cout <<
"Sum of all RGBA values: " << sum_now <<
"\n";
173 std::cout <<
"Sum should be: " << sum_orig_Pic3D_pic_gz <<
"\n";
197 propRenderer->GetVtkRenderer()->RemoveViewProp(renderProp);
198 renderProp->Delete();
200 sphereRenderer->Delete();
202 renderWindow->Delete();
207 std::cout <<
"[TEST DONE]" << std::endl;
void SetPropRenderer(mitk::VtkPropRenderer::Pointer propRenderer)
itk::SmartPointer< Self > Pointer
mitkIpPicDescriptor * mitkIpPicGetHeader(const char *picfile_name, mitkIpPicDescriptor *pic)
void InsertForegroundRenderer(vtkSmartPointer< vtkRenderer > renderer, bool forceAbsoluteForeground)
mitkIpPicDescriptor * mitkIpPicGetTags(const char *picfile_name, mitkIpPicDescriptor *pic)
The LevelWindow class Class to store level/window values.
static VtkLayerController * GetInstance(vtkSmartPointer< vtkRenderWindow > renWin)
void SetAuto(const Image *image, bool tryPicTags=true, bool guessByCentralSlice=true, unsigned selectedComponent=0)
sets level/window to optimize the contrast of the given Image
int mitkVtkPropRendererTest(int argc, char *argv[])
static vtkMitkRenderProp * New()
static Pointer New(const char *_arga, vtkRenderWindow *_argb, mitk::RenderingManager *_argc)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.