1 #ifndef __CPEXTENSIONS__VISUALIZATION__IMAGEINDEXESCONTAINERTOPOLYDATA__HXX__
2 #define __CPEXTENSIONS__VISUALIZATION__IMAGEINDEXESCONTAINERTOPOLYDATA__HXX__
4 #include <vtkInformation.h>
5 #include <vtkInformationVector.h>
7 // -------------------------------------------------------------------------
8 template< class _TIndexes >
9 typename cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
10 Self* cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
13 return( new Self( ) );
16 // -------------------------------------------------------------------------
17 template< class _TIndexes >
18 const typename cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
19 TIndexes* cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
22 return( this->m_Indexes );
25 // -------------------------------------------------------------------------
26 template< class _TIndexes >
27 const typename cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
28 TImage* cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
29 GetReferenceImage( ) const
31 return( this->m_ReferenceImage );
34 // -------------------------------------------------------------------------
35 template< class _TIndexes >
36 void cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
37 SetInput( const TIndexes* imageindexescontainer )
39 if( this->m_Indexes != imageindexescontainer )
41 this->m_Indexes = imageindexescontainer;
47 // -------------------------------------------------------------------------
48 template< class _TIndexes >
49 void cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
50 SetReferenceImage( const TImage* i )
52 if( this->m_ReferenceImage != i )
54 this->m_ReferenceImage = i;
60 // -------------------------------------------------------------------------
61 template< class _TIndexes >
62 cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
63 ImageIndexesContainerToPolyData( )
64 : vtkPolyDataAlgorithm( ),
66 m_ReferenceImage( NULL )
68 this->SetNumberOfInputPorts( 0 );
71 // -------------------------------------------------------------------------
72 template< class _TIndexes >
73 cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
74 ~ImageIndexesContainerToPolyData( )
78 // -------------------------------------------------------------------------
79 template< class _TIndexes >
80 int cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
82 vtkInformation* information,
83 vtkInformationVector** input,
84 vtkInformationVector* output
87 static const unsigned int dim = TIndex::Dimension;
89 if( this->m_Indexes == NULL )
93 vtkInformation* info = output->GetInformationObject( 0 );
94 vtkPolyData* out = vtkPolyData::SafeDownCast(
95 info->Get( vtkDataObject::DATA_OBJECT( ) )
99 auto& lst = this->m_Indexes->Get( );
102 vtkPoints* points = out->GetPoints( );
105 points = vtkPoints::New( );
106 out->SetPoints( points );
110 points->SetNumberOfPoints( lst.size( ) );
113 vtkSmartPointer< vtkCellArray > verts =
114 vtkSmartPointer< vtkCellArray >::New( );
116 for( unsigned int i = 0; i < lst.size( ); ++i )
119 if( this->m_ReferenceImage != NULL )
121 typename TImage::PointType pnt;
122 this->m_ReferenceImage->TransformIndexToPhysicalPoint( idx, pnt );
124 points->SetPoint( i, pnt[ 0 ], 0, 0 );
126 points->SetPoint( i, pnt[ 0 ], pnt[ 1 ], 0 );
128 points->SetPoint( i, pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
133 points->SetPoint( i, idx[ 0 ], 0, 0 );
135 points->SetPoint( i, idx[ 0 ], idx[ 1 ], 0 );
137 points->SetPoint( i, idx[ 0 ], idx[ 1 ], idx[ 2 ] );
140 verts->InsertNextCell( 1 );
141 verts->InsertCellPoint( i );
144 out->SetPoints( points );
145 out->SetVerts( verts );
149 // -------------------------------------------------------------------------
150 template< class _TIndexes >
152 cpExtensions::Visualization::ImageIndexesContainerToPolyData< _TIndexes >::
154 vtkInformation* information,
155 vtkInformationVector** input,
156 vtkInformationVector* output
159 vtkInformation* info = output->GetInformationObject( 0 );
162 vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES( ), -1
166 if( this->m_Indexes != NULL && this->m_ReferenceImage != NULL )
169 typename C::TScalar len = this->m_RGC->GetTotalLength( );
170 typename C::TScalar s0 = this->m_RGC->Gets0( );
171 typename C::TPoint p0 = this->m_RGC->Axis( s0 );
172 typename C::TPoint p1 = this->m_RGC->Axis( s0 + len );
175 vtkStreamingDemandDrivenPipeline::WHOLE_BOUNDING_BOX( ),
176 double( p0[ 0 ] ), double( p1[ 0 ] ),
177 double( p0[ 1 ] ), double( p1[ 1 ] ),
178 double( p0[ 2 ] ), double( p1[ 2 ] )
186 #endif // __CPEXTENSIONS__VISUALIZATION__IMAGEINDEXESCONTAINERTOPOLYDATA__HXX__