GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
VisualizePolydataHelper.h
Go to the documentation of this file.
1 /*=========================================================================
2  Authors: The GoFigure Dev. Team.
3  at Megason Lab, Systems biology, Harvard Medical school, 2009-11
4 
5  Copyright (c) 2009-11, President and Fellows of Harvard College.
6  All rights reserved.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  Redistributions of source code must retain the above copyright notice,
12  this list of conditions and the following disclaimer.
13  Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16  Neither the name of the President and Fellows of Harvard College
17  nor the names of its contributors may be used to endorse or promote
18  products derived from this software without specific prior written
19  permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 =========================================================================*/
34 #ifndef __VisualizePolydataHelper_h
35 #define __VisualizePolydataHelper_h
36 
37 #include "vtkSmartPointer.h"
38 
39 #include "vtkPolyDataMapper.h"
40 #include "vtkActor.h"
41 #include "vtkRenderer.h"
42 #include "vtkRenderWindow.h"
43 #include "vtkRenderWindowInteractor.h"
44 
45 #include "vtkImageViewer2.h"
46 
47 #include "vtkExtractVOI.h"
48 
49 void ShowPolyData(vtkPolyData *iPolyData)
50 {
51  vtkSmartPointer< vtkPolyDataMapper > mapper =
52  vtkSmartPointer< vtkPolyDataMapper >::New();
53  mapper->SetInput(iPolyData);
54 
55  vtkSmartPointer< vtkActor > actor =
56  vtkSmartPointer< vtkActor >::New();
57  actor->SetMapper(mapper);
58 
59  vtkSmartPointer< vtkRenderer > renderer =
60  vtkSmartPointer< vtkRenderer >::New();
61  renderer->AddActor(actor);
62 
63  vtkSmartPointer< vtkRenderWindow > renderWindow =
64  vtkSmartPointer< vtkRenderWindow >::New();
65  renderWindow->AddRenderer(renderer);
66 
67  vtkSmartPointer< vtkRenderWindowInteractor > renderWindowInteractor =
68  vtkSmartPointer< vtkRenderWindowInteractor >::New();
69  renderWindowInteractor->SetRenderWindow(renderWindow);
70 
71  renderWindowInteractor->Initialize();
72  renderWindow->Render();
73  renderWindowInteractor->Start();
74 }
75 
76 void ShowImage(vtkImageData *iData)
77 {
78  // Create the rendering window
79  vtkSmartPointer< vtkRenderer > ren1 = vtkSmartPointer< vtkRenderer >::New();
80  vtkSmartPointer< vtkRenderWindow > renWin = vtkSmartPointer< vtkRenderWindow >::New();
81  vtkSmartPointer< vtkRenderWindowInteractor > iren = vtkSmartPointer< vtkRenderWindowInteractor >::New();
82 
83  // Create the rendering window
84  renWin->AddRenderer(ren1);
85  iren->SetRenderWindow(renWin);
86 
87  vtkSmartPointer< vtkImageViewer2 > viewer = vtkSmartPointer< vtkImageViewer2 >::New();
88 
89  /*vtkSmartPointer<vtkExtractVOI> voi = vtkSmartPointer<vtkExtractVOI>::New();
90  voi->SetInput(iData);
91  voi->SetVOI(25, 75, 25, 75, 25, 75);
92  voi->Update();*/
93 
94 
95  viewer->SetInput(iData);
96  viewer->SetRenderWindow(renWin);
97  viewer->SetRenderer(ren1);
98 
99  iren->Initialize();
100  viewer->Render();
101  iren->Start();
102 }
103 
104 void ShowActor(vtkActor *iActor)
105 {
106  vtkSmartPointer< vtkRenderer > renderer =
107  vtkSmartPointer< vtkRenderer >::New();
108  renderer->AddActor(iActor);
109 
110  vtkSmartPointer< vtkRenderWindow > renderWindow =
111  vtkSmartPointer< vtkRenderWindow >::New();
112  renderWindow->AddRenderer(renderer);
113 
114  vtkSmartPointer< vtkRenderWindowInteractor > renderWindowInteractor =
115  vtkSmartPointer< vtkRenderWindowInteractor >::New();
116  renderWindowInteractor->SetRenderWindow(renderWindow);
117 
118  renderWindowInteractor->Initialize();
119  renderWindow->Render();
120  renderWindowInteractor->Start();
121 }
122 
123 #endif
void ShowPolyData(vtkPolyData *iPolyData)
void ShowImage(vtkImageData *iData)
void ShowActor(vtkActor *iActor)