X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=plugins%2FITKImageGenericFilters_1%2FMinimumMaximumImageCalculator.cxx;fp=plugins%2FITKImageGenericFilters_1%2FMinimumMaximumImageCalculator.cxx;h=0000000000000000000000000000000000000000;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=c30cad3b3c2caccba4dc9d2c05960ba3ab6711ca;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.cxx b/plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.cxx deleted file mode 100644 index c30cad3..0000000 --- a/plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.cxx +++ /dev/null @@ -1,120 +0,0 @@ -#include -#include -#include - -#include -#include -#include - -// ------------------------------------------------------------------------- -cpPluginsITKImageGenericFilters_1::MinimumMaximumImageCalculator:: -MinimumMaximumImageCalculator( ) - : Superclass( ) -{ - typedef cpInstances::DataObjects::Image _TImage; - typedef cpInstances::DataObjects::Mesh _TMesh; - - this->_ConfigureInput< _TImage >( "Input", true, false ); - this->_ConfigureOutput< _TMesh >( "Maximum" ); - this->_ConfigureOutput< _TMesh >( "Minimum" ); -} - -// ------------------------------------------------------------------------- -cpPluginsITKImageGenericFilters_1::MinimumMaximumImageCalculator:: -~MinimumMaximumImageCalculator( ) -{ -} - -// ------------------------------------------------------------------------- -void cpPluginsITKImageGenericFilters_1::MinimumMaximumImageCalculator:: -_GenerateData( ) -{ - auto o = this->GetInputData( "Input" ); - cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) - this->_Error( "Invalid input image." ); -} - -// ------------------------------------------------------------------------- -template< class _TImage > -void cpPluginsITKImageGenericFilters_1::MinimumMaximumImageCalculator:: -_GD0( _TImage* input ) -{ - typedef itk::MinimumMaximumImageCalculator< _TImage > _TFilter; - typedef typename _TImage::IndexType _TIndex; - typedef typename _TImage::PointType _TPoint; - - auto filter = this->_CreateITK< _TFilter >( ); - filter->SetImage( input ); - filter->Compute( ); - - _TIndex min_idx = filter->GetIndexOfMinimum( ); - _TIndex max_idx = filter->GetIndexOfMaximum( ); - - _TPoint min_pnt, max_pnt; - input->TransformIndexToPhysicalPoint( min_idx, min_pnt ); - input->TransformIndexToPhysicalPoint( max_idx, max_pnt ); - - auto min_pd = this->GetOutputData< vtkPolyData >( "Minimum" ); - if( min_pd == NULL ) - { - auto points = vtkSmartPointer< vtkPoints >::New( ); - auto verts = vtkSmartPointer< vtkCellArray >::New( ); - auto lines = vtkSmartPointer< vtkCellArray >::New( ); - auto polys = vtkSmartPointer< vtkCellArray >::New( ); - auto strips = vtkSmartPointer< vtkCellArray >::New( ); - auto pd = vtkSmartPointer< vtkPolyData >::New( ); - pd->SetPoints( points ); - pd->SetVerts( verts ); - pd->SetLines( lines ); - pd->SetPolys( polys ); - pd->SetStrips( strips ); - - points->InsertNextPoint( 0, 0, 0 ); - verts->InsertNextCell( 1 ); - verts->InsertCellPoint( 0 ); - - this->GetOutput( "Minimum" )->SetVTK( pd ); - min_pd = this->GetOutputData< vtkPolyData >( "Minimum" ); - - } // fi - - if( _TImage::ImageDimension == 1 ) - min_pd->GetPoints( )->SetPoint( 0, min_pnt[ 0 ], 0, 0 ); - else if( _TImage::ImageDimension == 2 ) - min_pd->GetPoints( )->SetPoint( 0, min_pnt[ 0 ], min_pnt[ 1 ], 0 ); - else if( _TImage::ImageDimension > 2 ) - min_pd->GetPoints( )->SetPoint( 0, min_pnt[ 0 ], min_pnt[ 1 ], min_pnt[ 2 ] ); - - auto max_pd = this->GetOutputData< vtkPolyData >( "Maximum" ); - if( max_pd == NULL ) - { - auto points = vtkSmartPointer< vtkPoints >::New( ); - auto verts = vtkSmartPointer< vtkCellArray >::New( ); - auto lines = vtkSmartPointer< vtkCellArray >::New( ); - auto polys = vtkSmartPointer< vtkCellArray >::New( ); - auto strips = vtkSmartPointer< vtkCellArray >::New( ); - auto pd = vtkSmartPointer< vtkPolyData >::New( ); - pd->SetPoints( points ); - pd->SetVerts( verts ); - pd->SetLines( lines ); - pd->SetPolys( polys ); - pd->SetStrips( strips ); - - points->InsertNextPoint( 0, 0, 0 ); - verts->InsertNextCell( 1 ); - verts->InsertCellPoint( 0 ); - - this->GetOutput( "Maximum" )->SetVTK( pd ); - max_pd = this->GetOutputData< vtkPolyData >( "Maximum" ); - - } // fi - - if( _TImage::ImageDimension == 1 ) - max_pd->GetPoints( )->SetPoint( 0, max_pnt[ 0 ], 0, 0 ); - else if( _TImage::ImageDimension == 2 ) - max_pd->GetPoints( )->SetPoint( 0, max_pnt[ 0 ], max_pnt[ 1 ], 0 ); - else if( _TImage::ImageDimension > 2 ) - max_pd->GetPoints( )->SetPoint( 0, max_pnt[ 0 ], max_pnt[ 1 ], max_pnt[ 2 ] ); -} - -// eof - $RCSfile$