+++ /dev/null
-#include <cpExtensions/Visualization/ImageOutlineSource.h>
-#include <vtkInformation.h>
-#include <vtkInformationVector.h>
-
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::ImageOutlineSource::
-Self* cpExtensions::Visualization::ImageOutlineSource::
-New( )
-{
- return( new Self( ) );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageOutlineSource::
-SetBounds( int orientation, double step, double* bounds )
-{
- // Update geometry
- int o = orientation % 3;
- if( o == 0 )
- {
- this->m_Bounds[ 0 ][ 0 ] = step;
- this->m_Bounds[ 0 ][ 1 ] = bounds[ 2 ];
- this->m_Bounds[ 0 ][ 2 ] = bounds[ 4 ];
-
- this->m_Bounds[ 1 ][ 0 ] = step;
- this->m_Bounds[ 1 ][ 1 ] = bounds[ 2 ];
- this->m_Bounds[ 1 ][ 2 ] = bounds[ 5 ];
-
- this->m_Bounds[ 2 ][ 0 ] = step;
- this->m_Bounds[ 2 ][ 1 ] = bounds[ 3 ];
- this->m_Bounds[ 2 ][ 2 ] = bounds[ 5 ];
-
- this->m_Bounds[ 3 ][ 0 ] = step;
- this->m_Bounds[ 3 ][ 1 ] = bounds[ 3 ];
- this->m_Bounds[ 3 ][ 2 ] = bounds[ 4 ];
- }
- else if( o == 1 )
- {
- this->m_Bounds[ 0 ][ 0 ] = bounds[ 0 ];
- this->m_Bounds[ 0 ][ 1 ] = step;
- this->m_Bounds[ 0 ][ 2 ] = bounds[ 4 ];
-
- this->m_Bounds[ 1 ][ 0 ] = bounds[ 1 ];
- this->m_Bounds[ 1 ][ 1 ] = step;
- this->m_Bounds[ 1 ][ 2 ] = bounds[ 4 ];
-
- this->m_Bounds[ 2 ][ 0 ] = bounds[ 1 ];
- this->m_Bounds[ 2 ][ 1 ] = step;
- this->m_Bounds[ 2 ][ 2 ] = bounds[ 5 ];
-
- this->m_Bounds[ 3 ][ 0 ] = bounds[ 0 ];
- this->m_Bounds[ 3 ][ 1 ] = step;
- this->m_Bounds[ 3 ][ 2 ] = bounds[ 5 ];
- }
- else if( o == 2 )
- {
- this->m_Bounds[ 0 ][ 0 ] = bounds[ 0 ];
- this->m_Bounds[ 0 ][ 1 ] = bounds[ 2 ];
- this->m_Bounds[ 0 ][ 2 ] = step;
-
- this->m_Bounds[ 1 ][ 0 ] = bounds[ 1 ];
- this->m_Bounds[ 1 ][ 1 ] = bounds[ 2 ];
- this->m_Bounds[ 1 ][ 2 ] = step;
-
- this->m_Bounds[ 2 ][ 0 ] = bounds[ 1 ];
- this->m_Bounds[ 2 ][ 1 ] = bounds[ 3 ];
- this->m_Bounds[ 2 ][ 2 ] = step;
-
- this->m_Bounds[ 3 ][ 0 ] = bounds[ 0 ];
- this->m_Bounds[ 3 ][ 1 ] = bounds[ 3 ];
- this->m_Bounds[ 3 ][ 2 ] = step;
-
- } // fi
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::ImageOutlineSource::
-ImageOutlineSource( )
- : Superclass( )
-{
- this->SetNumberOfInputPorts( 0 );
- for( unsigned int j = 0; j < 4; ++j )
- for( unsigned int i = 0; i < 3; ++i )
- this->m_Bounds[ j ][ i ] = double( 0 );
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::ImageOutlineSource::
-~ImageOutlineSource( )
-{
-}
-
-// -------------------------------------------------------------------------
-int cpExtensions::Visualization::ImageOutlineSource::
-RequestData(
- vtkInformation* request,
- vtkInformationVector** inputVector,
- vtkInformationVector* outputVector
- )
-{
- // Get output object
- vtkInformation* outInfo = outputVector->GetInformationObject( 0 );
- vtkPolyData* output =
- vtkPolyData::SafeDownCast(
- outInfo->Get( vtkDataObject::DATA_OBJECT( ) )
- );
-
- // Create points
- vtkPoints* points = vtkPoints::New( );
- points->SetDataType( VTK_FLOAT );
- points->Allocate( 4 );
-
- // Create lines
- vtkCellArray* verts = vtkCellArray::New( );
- vtkCellArray* lines = vtkCellArray::New( );
- vtkCellArray* faces = vtkCellArray::New( );
- vtkCellArray* strips = vtkCellArray::New( );
- lines->Allocate( lines->EstimateSize( 4, 2 ) );
-
- // Assign points
- points->InsertPoint( 0, this->m_Bounds[ 0 ] );
- points->InsertPoint( 1, this->m_Bounds[ 1 ] );
- points->InsertPoint( 2, this->m_Bounds[ 2 ] );
- points->InsertPoint( 3, this->m_Bounds[ 3 ] );
-
- // Assign cells
- vtkIdType cell_pts[ 4 ][ 2 ] =
- {
- { 0, 1 },
- { 1, 2 },
- { 2, 3 },
- { 3, 0 }
- };
- lines->InsertNextCell( 2, cell_pts[ 0 ] );
- lines->InsertNextCell( 2, cell_pts[ 1 ] );
- lines->InsertNextCell( 2, cell_pts[ 2 ] );
- lines->InsertNextCell( 2, cell_pts[ 3 ] );
-
- // Assign to output
- output->SetPoints( points );
- output->SetVerts( verts );
- output->SetLines( lines );
- output->SetPolys( faces );
- output->SetStrips( strips );
-
- // Finish and return
- points->Delete( );
- verts->Delete( );
- lines->Delete( );
- faces->Delete( );
- strips->Delete( );
- return( 1 );
-}
-
-// eof - $RCSfile$