1 #include <cpExtensions/Visualization/ImageOutlineSource.h>
2 #include <vtkInformation.h>
3 #include <vtkInformationVector.h>
5 // -------------------------------------------------------------------------
6 cpExtensions::Visualization::ImageOutlineSource::
7 Self* cpExtensions::Visualization::ImageOutlineSource::
10 return( new Self( ) );
13 // -------------------------------------------------------------------------
14 void cpExtensions::Visualization::ImageOutlineSource::
15 SetBounds( int orientation, double step, double* bounds )
18 int o = orientation % 3;
21 this->m_Bounds[ 0 ][ 0 ] = step;
22 this->m_Bounds[ 0 ][ 1 ] = bounds[ 2 ];
23 this->m_Bounds[ 0 ][ 2 ] = bounds[ 4 ];
25 this->m_Bounds[ 1 ][ 0 ] = step;
26 this->m_Bounds[ 1 ][ 1 ] = bounds[ 2 ];
27 this->m_Bounds[ 1 ][ 2 ] = bounds[ 5 ];
29 this->m_Bounds[ 2 ][ 0 ] = step;
30 this->m_Bounds[ 2 ][ 1 ] = bounds[ 3 ];
31 this->m_Bounds[ 2 ][ 2 ] = bounds[ 5 ];
33 this->m_Bounds[ 3 ][ 0 ] = step;
34 this->m_Bounds[ 3 ][ 1 ] = bounds[ 3 ];
35 this->m_Bounds[ 3 ][ 2 ] = bounds[ 4 ];
39 this->m_Bounds[ 0 ][ 0 ] = bounds[ 0 ];
40 this->m_Bounds[ 0 ][ 1 ] = step;
41 this->m_Bounds[ 0 ][ 2 ] = bounds[ 4 ];
43 this->m_Bounds[ 1 ][ 0 ] = bounds[ 1 ];
44 this->m_Bounds[ 1 ][ 1 ] = step;
45 this->m_Bounds[ 1 ][ 2 ] = bounds[ 4 ];
47 this->m_Bounds[ 2 ][ 0 ] = bounds[ 1 ];
48 this->m_Bounds[ 2 ][ 1 ] = step;
49 this->m_Bounds[ 2 ][ 2 ] = bounds[ 5 ];
51 this->m_Bounds[ 3 ][ 0 ] = bounds[ 0 ];
52 this->m_Bounds[ 3 ][ 1 ] = step;
53 this->m_Bounds[ 3 ][ 2 ] = bounds[ 5 ];
57 this->m_Bounds[ 0 ][ 0 ] = bounds[ 0 ];
58 this->m_Bounds[ 0 ][ 1 ] = bounds[ 2 ];
59 this->m_Bounds[ 0 ][ 2 ] = step;
61 this->m_Bounds[ 1 ][ 0 ] = bounds[ 1 ];
62 this->m_Bounds[ 1 ][ 1 ] = bounds[ 2 ];
63 this->m_Bounds[ 1 ][ 2 ] = step;
65 this->m_Bounds[ 2 ][ 0 ] = bounds[ 1 ];
66 this->m_Bounds[ 2 ][ 1 ] = bounds[ 3 ];
67 this->m_Bounds[ 2 ][ 2 ] = step;
69 this->m_Bounds[ 3 ][ 0 ] = bounds[ 0 ];
70 this->m_Bounds[ 3 ][ 1 ] = bounds[ 3 ];
71 this->m_Bounds[ 3 ][ 2 ] = step;
77 // -------------------------------------------------------------------------
78 cpExtensions::Visualization::ImageOutlineSource::
82 this->SetNumberOfInputPorts( 0 );
83 for( unsigned int j = 0; j < 4; ++j )
84 for( unsigned int i = 0; i < 3; ++i )
85 this->m_Bounds[ j ][ i ] = double( 0 );
88 // -------------------------------------------------------------------------
89 cpExtensions::Visualization::ImageOutlineSource::
90 ~ImageOutlineSource( )
94 // -------------------------------------------------------------------------
95 int cpExtensions::Visualization::ImageOutlineSource::
97 vtkInformation* request,
98 vtkInformationVector** inputVector,
99 vtkInformationVector* outputVector
103 vtkInformation* outInfo = outputVector->GetInformationObject( 0 );
104 vtkPolyData* output =
105 vtkPolyData::SafeDownCast(
106 outInfo->Get( vtkDataObject::DATA_OBJECT( ) )
110 vtkPoints* points = vtkPoints::New( );
111 points->SetDataType( VTK_FLOAT );
112 points->Allocate( 4 );
115 vtkCellArray* verts = vtkCellArray::New( );
116 vtkCellArray* lines = vtkCellArray::New( );
117 vtkCellArray* faces = vtkCellArray::New( );
118 vtkCellArray* strips = vtkCellArray::New( );
119 lines->Allocate( lines->EstimateSize( 4, 2 ) );
122 points->InsertPoint( 0, this->m_Bounds[ 0 ] );
123 points->InsertPoint( 1, this->m_Bounds[ 1 ] );
124 points->InsertPoint( 2, this->m_Bounds[ 2 ] );
125 points->InsertPoint( 3, this->m_Bounds[ 3 ] );
128 vtkIdType cell_pts[ 4 ][ 2 ] =
135 lines->InsertNextCell( 2, cell_pts[ 0 ] );
136 lines->InsertNextCell( 2, cell_pts[ 1 ] );
137 lines->InsertNextCell( 2, cell_pts[ 2 ] );
138 lines->InsertNextCell( 2, cell_pts[ 3 ] );
141 output->SetPoints( points );
142 output->SetVerts( verts );
143 output->SetLines( lines );
144 output->SetPolys( faces );
145 output->SetStrips( strips );