1 #include <cpExtensions/Visualization/MPRObjects.h>
4 #include <vtkImageData.h>
5 #include <vtkLookupTable.h>
7 // -------------------------------------------------------------------------
8 cpExtensions::Visualization::MPRObjects*
9 cpExtensions::Visualization::MPRObjects::
12 return( new Self( ) );
15 // -------------------------------------------------------------------------
16 void cpExtensions::Visualization::MPRObjects::
18 vtkRenderWindow* x, vtkRenderWindow* y,
19 vtkRenderWindow* z, vtkRenderWindow* w
22 this->m_Windows[ 0 ] = x;
23 this->m_Windows[ 1 ] = y;
24 this->m_Windows[ 2 ] = z;
25 this->m_Windows[ 3 ] = w;
27 // Prepare 2D renderers
28 for( int i = 0; i < 4; ++i )
30 // Create renderer, if render window exists
31 if( this->m_Windows[ i ] != NULL )
33 this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( );
34 this->m_Renderers[ i ]->SetBackground( 0.3, 0.3, 0.3 );
35 this->m_Windows[ i ]->AddRenderer( this->m_Renderers[ i ] );
38 this->m_Renderers[ i ] = NULL;
43 // -------------------------------------------------------------------------
44 void cpExtensions::Visualization::MPRObjects::
45 SetInputConnection( vtkAlgorithmOutput* aout )
47 this->m_MPRActors->SetInputConnection( aout );
50 // -------------------------------------------------------------------------
51 void cpExtensions::Visualization::MPRObjects::
52 SetInputImage( vtkImageData* data )
54 this->m_MPRActors->SetInputImage( data );
57 // -------------------------------------------------------------------------
58 int cpExtensions::Visualization::MPRObjects::
60 vtkAlgorithmOutput* aout,
61 const double& r, const double& g, const double& b
64 return( this->m_MPRActors->AddBinaryConnection( aout, r, g, b ) );
67 // -------------------------------------------------------------------------
68 int cpExtensions::Visualization::MPRObjects::
71 const double& r, const double& g, const double& b
74 return( this->m_MPRActors->AddBinaryImage( data, r, g, b ) );
77 // -------------------------------------------------------------------------
78 void cpExtensions::Visualization::MPRObjects::
81 this->m_MPRActors->PushActorsInto(
89 // -------------------------------------------------------------------------
90 void cpExtensions::Visualization::MPRObjects::
95 // -------------------------------------------------------------------------
96 void cpExtensions::Visualization::MPRObjects::
99 this->m_MPRActors->Clear( );
102 // -------------------------------------------------------------------------
103 vtkImageData* cpExtensions::Visualization::MPRObjects::
106 return( this->m_MPRActors->GetInputImage( ) );
109 // -------------------------------------------------------------------------
110 const vtkImageData* cpExtensions::Visualization::MPRObjects::
111 GetInputImage( ) const
113 return( this->m_MPRActors->GetInputImage( ) );
116 // -------------------------------------------------------------------------
117 unsigned int cpExtensions::Visualization::MPRObjects::
118 GetNumberOfImages( ) const
120 return( this->m_MPRActors->GetNumberOfImages( ) );
123 // -------------------------------------------------------------------------
124 void cpExtensions::Visualization::MPRObjects::
125 SetInterpolate( bool v )
127 this->m_MPRActors->SetInterpolate( v );
130 // -------------------------------------------------------------------------
131 void cpExtensions::Visualization::MPRObjects::
134 this->m_MPRActors->InterpolateOn( );
137 // -------------------------------------------------------------------------
138 void cpExtensions::Visualization::MPRObjects::
141 this->m_MPRActors->InterpolateOff( );
144 // -------------------------------------------------------------------------
145 double cpExtensions::Visualization::MPRObjects::
146 GetMinWindow( ) const
148 return( this->m_MPRActors->GetMinWindow( ) );
151 // -------------------------------------------------------------------------
152 double cpExtensions::Visualization::MPRObjects::
153 GetMaxWindow( ) const
155 return( this->m_MPRActors->GetMaxWindow( ) );
158 // -------------------------------------------------------------------------
159 double cpExtensions::Visualization::MPRObjects::
162 return( this->m_MPRActors->GetMinLevel( ) );
165 // -------------------------------------------------------------------------
166 double cpExtensions::Visualization::MPRObjects::
169 return( this->m_MPRActors->GetMaxLevel( ) );
172 // -------------------------------------------------------------------------
173 double cpExtensions::Visualization::MPRObjects::
176 return( this->m_MPRActors->GetWindow( ) );
179 // -------------------------------------------------------------------------
180 double cpExtensions::Visualization::MPRObjects::
183 return( this->m_MPRActors->GetLevel( ) );
186 // -------------------------------------------------------------------------
187 void cpExtensions::Visualization::MPRObjects::
188 SetWindow( double w )
190 this->m_MPRActors->SetWindow( w );
193 // -------------------------------------------------------------------------
194 void cpExtensions::Visualization::MPRObjects::
197 this->m_MPRActors->SetLevel( l );
200 // -------------------------------------------------------------------------
201 void cpExtensions::Visualization::MPRObjects::
202 SetWindowLevel( double w, double l )
204 this->m_MPRActors->SetWindowLevel( w, l );
207 // -------------------------------------------------------------------------
208 void cpExtensions::Visualization::MPRObjects::
211 this->m_MPRActors->ResetWindowLevel( );
214 // -------------------------------------------------------------------------
215 int cpExtensions::Visualization::MPRObjects::
216 GetSliceNumber( const int& axis ) const
218 return( this->m_MPRActors->GetSliceNumber( axis ) );
221 // -------------------------------------------------------------------------
222 int cpExtensions::Visualization::MPRObjects::
223 GetSliceNumberMinValue( const int& axis ) const
225 return( this->m_MPRActors->GetSliceNumberMinValue( axis ) );
228 // -------------------------------------------------------------------------
229 int cpExtensions::Visualization::MPRObjects::
230 GetSliceNumberMaxValue( const int& axis ) const
232 return( this->m_MPRActors->GetSliceNumberMaxValue( axis ) );
235 // -------------------------------------------------------------------------
236 void cpExtensions::Visualization::MPRObjects::
237 SetSliceNumber( const int& axis, const int& slice )
239 this->m_MPRActors->SetSliceNumber( axis, slice );
242 // -------------------------------------------------------------------------
243 void cpExtensions::Visualization::MPRObjects::
244 SetSlice( const int& axis, double* pos )
246 this->m_MPRActors->SetSlice( axis, pos );
249 // -------------------------------------------------------------------------
250 void cpExtensions::Visualization::MPRObjects::
251 Render( const double& t )
253 this->Render( 0, t );
254 this->Render( 1, t );
255 this->Render( 2, t );
256 this->Render( 3, t );
259 // -------------------------------------------------------------------------
260 void cpExtensions::Visualization::MPRObjects::
261 Render( const int& axis, const double& t )
265 if( this->m_Windows[ axis ].GetPointer( ) != NULL )
267 if( this->m_Renderers[ axis ].GetPointer( ) != NULL )
268 this->m_Renderers[ axis ]->SetAllocatedRenderTime( t );
269 this->m_Windows[ axis ]->Render( );
276 // -------------------------------------------------------------------------
277 void cpExtensions::Visualization::MPRObjects::
278 ResetCamera( const int& axis )
281 if( this->m_Renderers[ axis ].GetPointer( ) != NULL )
282 this->m_Renderers[ axis ]->ResetCamera( );
285 // -------------------------------------------------------------------------
286 void cpExtensions::Visualization::MPRObjects::
289 this->ResetCamera( 0 );
290 this->ResetCamera( 1 );
291 this->ResetCamera( 2 );
292 this->ResetCamera( 3 );
295 // -------------------------------------------------------------------------
296 cpExtensions::Visualization::MPRObjects::
300 this->m_MPRActors = vtkSmartPointer< MPRActors >::New( );
303 // -------------------------------------------------------------------------
304 cpExtensions::Visualization::MPRObjects::
313 // -------------------------------------------------------------------------
314 void cpExtensions::Visualization::MPRObjects::
316 vtkRenderWindow* wx, vtkRenderWindow* wy,
317 vtkRenderWindow* wz, vtkRenderWindow* w3D
322 // -------------------------------------------------------------------------
323 void cpExtensions::Visualization::MPRObjects::
324 AddImage( vtkImageData* image )
326 this->m_MPRActors->AddInputData( image );
327 this->m_MPRActors->PushActorsInto(
328 this->m_Windows[ 0 ],
329 this->m_Windows[ 1 ],
330 this->m_Windows[ 2 ],
335 if( this->m_MPRActors->GetNumberOfImages( ) == 1 )
337 this->m_MPRActors->ResetSlices( );
338 this->ResetCameras( );
341 this->RenderAll( 1e-3 );
344 // -------------------------------------------------------------------------
345 unsigned int cpExtensions::Visualization::MPRObjects::
346 GetNumberOfImages( ) const
348 return( this->m_MPRActors->GetNumberOfImages( ) );
351 // -------------------------------------------------------------------------
352 void cpExtensions::Visualization::MPRObjects::
355 this->m_MPRActors->PopActorsFrom(
356 this->m_Windows[ 0 ],
357 this->m_Windows[ 1 ],
358 this->m_Windows[ 2 ],
361 this->ResetCameras( );
362 this->RenderAll( 1e-3 );
365 // -------------------------------------------------------------------------
366 void cpExtensions::Visualization::MPRObjects::
367 ResetCamera( const int& id )
370 if( this->m_Windows[ id ] != NULL )
371 this->m_Renderers[ id ]->ResetCamera( );
374 // -------------------------------------------------------------------------
375 void cpExtensions::Visualization::MPRObjects::
378 for( int i = 0; i < 4; ++i )
379 if( this->m_Windows[ i ] != NULL )
380 this->m_Renderers[ i ]->ResetCamera( );
383 // -------------------------------------------------------------------------
384 void cpExtensions::Visualization::MPRObjects::
385 Render( const int& id, const double& t )
389 if( this->m_Windows[ id ] != NULL )
391 if( this->m_Renderers[ id ] != NULL )
392 this->m_Renderers[ id ]->SetAllocatedRenderTime( t );
393 this->m_Windows[ id ]->Render( );
400 // -------------------------------------------------------------------------
401 void cpExtensions::Visualization::MPRObjects::
402 RenderAll( const double& t )
404 for( int i = 0; i < 4; ++i )
406 if( this->m_Windows[ i ] != NULL )
408 if( this->m_Renderers[ i ] != NULL )
409 this->m_Renderers[ i ]->SetAllocatedRenderTime( t );
410 this->m_Windows[ i ]->Render( );
417 // -------------------------------------------------------------------------
418 vtkRenderer* cpExtensions::Visualization::MPRObjects::
421 return( this->m_Renderers[ 0 ] );
424 // -------------------------------------------------------------------------
425 vtkRenderer* cpExtensions::Visualization::MPRObjects::
428 return( this->m_Renderers[ 1 ] );
431 // -------------------------------------------------------------------------
432 vtkRenderer* cpExtensions::Visualization::MPRObjects::
435 return( this->m_Renderers[ 2 ] );
438 // -------------------------------------------------------------------------
439 vtkRenderer* cpExtensions::Visualization::MPRObjects::
442 return( this->m_Renderers[ 3 ] );
445 // -------------------------------------------------------------------------
446 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
447 GetXRenderer( ) const
449 return( this->m_Renderers[ 0 ] );
452 // -------------------------------------------------------------------------
453 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
454 GetYRenderer( ) const
456 return( this->m_Renderers[ 1 ] );
459 // -------------------------------------------------------------------------
460 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
461 GetZRenderer( ) const
463 return( this->m_Renderers[ 2 ] );
466 // -------------------------------------------------------------------------
467 const vtkRenderer* cpExtensions::Visualization::MPRObjects::
468 Get3DRenderer( ) const
470 return( this->m_Renderers[ 3 ] );
473 // -------------------------------------------------------------------------
474 cpExtensions::Visualization::
475 MPRActors* cpExtensions::Visualization::MPRObjects::
478 return( this->m_MPRActors );
481 // -------------------------------------------------------------------------
482 const cpExtensions::Visualization::
483 MPRActors* cpExtensions::Visualization::MPRObjects::
484 GetMPRActors( ) const
486 return( this->m_MPRActors );
489 // -------------------------------------------------------------------------
490 double cpExtensions::Visualization::MPRObjects::
493 return( this->m_MPRActors->GetWindow( ) );
496 // -------------------------------------------------------------------------
497 double cpExtensions::Visualization::MPRObjects::
500 return( this->m_MPRActors->GetLevel( ) );
503 // -------------------------------------------------------------------------
504 cpExtensions::Visualization::MPRObjects::
509 this->m_MPRActors = vtkSmartPointer< MPRActors >::New( );
512 // -------------------------------------------------------------------------
513 cpExtensions::Visualization::MPRObjects::