#define __CPEXTENSIONS__ALGORITHMS__SPATIALOBJECTMASKIMAGEFILTER__H__
#include <itkConceptChecking.h>
-#include <itkInPlaceImageFilter.h>
+#include <itkImageToImageFilter.h>
#include <itkSpatialObject.h>
namespace cpExtensions
*/
template< class I, class O = I >
class SpatialObjectMaskImageFilter
- : public itk::InPlaceImageFilter< I, O >
+ : public itk::ImageToImageFilter< I, O >
{
public:
typedef SpatialObjectMaskImageFilter Self;
- typedef itk::InPlaceImageFilter< I, O > Superclass;
+ typedef itk::ImageToImageFilter< I, O > Superclass;
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
itkStaticConstMacro( OutputDimension, unsigned int, O::ImageDimension );
#ifdef ITK_USE_CONCEPT_CHECKING
- // Begin concept checking
itkConceptMacro(
SameDimensionCheck1,
( itk::Concept::SameDimension< InputDimension, OutputDimension > )
);
- // End concept checking
#endif
typedef typename I::RegionType TRegion;
public:
itkNewMacro( Self );
- itkTypeMacro( SpatialObjectMaskImageFilter, itk::InPlaceImageFilter );
+ itkTypeMacro( SpatialObjectMaskImageFilter, itk::ImageToImageFilter );
itkGetObjectMacro( SpatialObject, TSpatialObject );
itkGetConstObjectMacro( SpatialObject, TSpatialObject );
itkSetObjectMacro( SpatialObject, TSpatialObject );
itkSetMacro( OutsideValue, TOutPixel );
+ public:
+ O* GetPositiveOutput( );
+ const O* GetPositiveOutput( ) const;
+ O* GetNegativeOutput( );
+ const O* GetNegativeOutput( ) const;
+
protected:
SpatialObjectMaskImageFilter( );
virtual ~SpatialObjectMaskImageFilter( );
#include <itkImageScanlineIterator.h>
#include <itkProgressReporter.h>
+// -------------------------------------------------------------------------
+template< class I, class O >
+O* cpExtensions::Algorithms::SpatialObjectMaskImageFilter< I, O >::
+GetPositiveOutput( )
+{
+ return( this->GetOutput( 0 ) );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+const O* cpExtensions::Algorithms::SpatialObjectMaskImageFilter< I, O >::
+GetPositiveOutput( ) const
+{
+ return( this->GetOutput( 0 ) );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+O* cpExtensions::Algorithms::SpatialObjectMaskImageFilter< I, O >::
+GetNegativeOutput( )
+{
+ return( this->GetOutput( 1 ) );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+const O* cpExtensions::Algorithms::SpatialObjectMaskImageFilter< I, O >::
+GetNegativeOutput( ) const
+{
+ return( this->GetOutput( 1 ) );
+}
+
// -------------------------------------------------------------------------
template< class I, class O >
cpExtensions::Algorithms::SpatialObjectMaskImageFilter< I, O >::
: Superclass( )
{
this->SetNumberOfRequiredInputs( 1 );
- this->InPlaceOff( );
+ this->SetNumberOfRequiredOutputs( 2 );
+ this->SetNthOutput( 0, O::New( ) );
+ this->SetNthOutput( 1, O::New( ) );
}
// -------------------------------------------------------------------------
// Get inputs
const I* in =
dynamic_cast< const I* >( this->itk::ProcessObject::GetInput( 0 ) );
- O* out = this->GetOutput( 0 );
+ O* pos_out = this->GetPositiveOutput( );
+ O* neg_out = this->GetNegativeOutput( );
const auto size0 = region.GetSize( 0 );
if( size0 == 0 )
return;
// Create iterators
itk::ImageScanlineConstIterator< I > iIt( in, region );
- itk::ImageScanlineIterator< O > oIt( out, region );
+ itk::ImageScanlineIterator< O > pos_oIt( pos_out, region );
+ itk::ImageScanlineIterator< O > neg_oIt( neg_out, region );
itk::ProgressReporter progress( this, threadId, nLines );
// Main loop
auto idx = iIt.GetIndex( );
in->TransformIndexToPhysicalPoint( idx, pnt );
if( this->m_SpatialObject->IsInside( pnt ) )
- oIt.Set( TOutPixel( iIt.Get( ) ) );
+ {
+ pos_oIt.Set( TOutPixel( iIt.Get( ) ) );
+ neg_oIt.Set( this->m_OutsideValue );
+ }
else
- oIt.Set( this->m_OutsideValue );
+ {
+ neg_oIt.Set( TOutPixel( iIt.Get( ) ) );
+ pos_oIt.Set( this->m_OutsideValue );
+
+ } // fi
++iIt;
- ++oIt;
+ ++pos_oIt;
+ ++neg_oIt;
} // elihw
iIt.NextLine( );
- oIt.NextLine( );
+ pos_oIt.NextLine( );
+ neg_oIt.NextLine( );
progress.CompletedPixel( );
} // elihw
return( new Self( ) );
}
+// -------------------------------------------------------------------------
+unsigned int cpExtensions::Visualization::ImageBlender::
+GetNumberOfInputs( )
+{
+ unsigned int np = this->GetNumberOfInputPorts( );
+ unsigned int ni = 0;
+ for( unsigned int p = 0; p < np; ++p )
+ ni += this->GetNumberOfInputConnections( p );
+ return( ni );
+}
// -------------------------------------------------------------------------
cpExtensions::Visualization::ImageBlender::
public:
static Self* New( );
+ unsigned int GetNumberOfInputs( );
+
protected:
ImageBlender( );
virtual ~ImageBlender( );
}
else // if( axis == 2 )
{
- camera->SetPosition( double( 0 ), double( 0 ), double( 1 ) );
- camera->SetViewUp ( double( 0 ), double( -1 ), double( 0 ) );
+ camera->SetPosition( double( 0 ), double( 0 ), double( -1 ) );
+ camera->SetViewUp ( double( 0 ), double( -1 ), double( 0 ) );
} // fi
unsigned int cpExtensions::Visualization::ImageSliceActors::
GetNumberOfImages( ) const
{
- return( this->m_Blender->GetNumberOfInputPorts( ) );
+ return( this->m_Blender->GetNumberOfInputs( ) );
}
// -------------------------------------------------------------------------
// Update text
this->UpdateText( );
- // Update lines from associated slices
- /* TODO
- auto sIt = this->m_AssociatedSlices.begin( );
- for( ; sIt != this->m_AssociatedSlices.end( ); ++sIt )
- {
- Self* slice = *sIt;
- for( unsigned int id = 0; id < slice->m_AssociatedSlices.size( ); ++id )
- {
- std::cout << id << std::endl;
- if( slice->m_AssociatedSlices[ id ] != this )
- continue;
-
- std::cout << "id : " << id << std::endl;
-
- } // rof
-
- } // rof
- */
-
// Update camera position
if( this->m_Window == NULL )
return;
typedef void ( *TSlicesCommand )( double*, int, void* );
typedef void ( *TWindowLevelCommand )( double, double, void* );
typedef TVoidCommand TRenderCommand;
- typedef TSlicesCommand TCursorAxesCommand;
typedef cpExtensions::Visualization::ImageBlender TBlender;
cpExtensions_BaseInteractorStyle_Commands( Slices );
cpExtensions_BaseInteractorStyle_Commands( WindowLevel );
cpExtensions_BaseInteractorStyle_Commands( Render );
- cpExtensions_BaseInteractorStyle_Commands( CursorAxes );
public:
// Creation
} // fi
}
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+SetAxesCursor( const int& axis, double* pos )
+{
+ if( axis < 3 )
+ this->Slices[ 0 ][ axis ]->SetAxesCursor( pos );
+}
+
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
Render( const int& axis )
if( actors->Slices[ 0 ][ j ]->GetAxis( ) != axis )
{
actors->SetSlice( j, pos );
+ actors->SetAxesCursor( j, pos );
actors->Render( j );
} // fi
int GetSliceNumberMaxValue( const int& axis ) const;
void SetSliceNumber( const int& axis, const int& slice );
void SetSlice( const int& axis, double* pos );
+ void SetAxesCursor( const int& axis, double* pos );
// Rendering controls
void Render( const int& axis );
if( name == this->m_MainImage )
this->m_MPRObjects->SetInputImage( iIt->second.Image );
else
+ {
+ std::cout << this->m_MPRObjects->GetNumberOfImages( ) << std::endl;
+
+
this->m_MPRObjects->AddBinaryImage( iIt->second.Image, 1, 0, 0 );
+ }
this->m_MPRObjects->Show( );
}
else if( iIt->second.Tag == Data::MESH )
_FindItemInTree( const std::string& name ) const
{
QList< QTreeWidgetItem* > items =
- this->m_UI->LoadedData->findItems( name.c_str( ), Qt::MatchExactly );
+ this->m_UI->LoadedData->findItems(
+ name.c_str( ), Qt::MatchExactly | Qt::MatchRecursive
+ );
if( items.size( ) > 0 )
return( items[ 0 ] );
else
void _SyncTop( int a, int b );
protected:
+ static double cm_Colors[ 8 ][ 3 ];
+
Ui::BaseMPRWidget* m_UI;
vtkSmartPointer< TMPRObjects > m_MPRObjects;
QVTKWidget* m_VTK[ 4 ];
m_PlaneWidget( NULL )
{
this->_AddInput( "Input" );
- this->_MakeOutput< cpPlugins::Interface::DataObject >( "Output" );
+ this->_MakeOutput< cpPlugins::Interface::DataObject >( "PositiveOutput" );
+ this->_MakeOutput< cpPlugins::Interface::DataObject >( "NegativeOutput" );
itk::Point< double, 3 > center;
itk::Vector< double, 3 > normal;
InfinitePlaneSpatialObject< I::ImageDimension > _TPlane;
typedef
cpExtensions::Algorithms::
- SpatialObjectMaskImageFilter< I > _TFilter;
- typedef cpPlugins::Interface::DataObject _TDataObject;
+ SpatialObjectMaskImageFilter< I, I > _TFilter;
+ typedef cpPlugins::Interface::DataObject _TObj;
typedef cpPlugins::Interface::Image _TImage;
- typedef typename _TPlane::PointType _TPoint;
- typedef typename _TPlane::VectorType _TVector;
- typedef typename I::PixelType _TPixel;
+ typedef typename _TPlane::PointType _TPoint;
+ typedef typename _TPlane::VectorType _TVector;
+ typedef typename I::PixelType _TPixel;
I* image = dynamic_cast< I* >( dobj );
filter->SetOutsideValue( _TPixel( 0 ) );
filter->Update( );
- // Connect output (and correct its type)
- auto name = this->GetOutput< _TDataObject >( "Output" )->GetName( );
- this->_MakeOutput< _TImage >( "Output" );
- _TImage* out = this->GetOutput< _TImage >( "Output" );
- if( out != NULL )
+ // Get output names
+ auto pos_name = this->GetOutput< _TObj >( "PositiveOutput" )->GetName( );
+ auto neg_name = this->GetOutput< _TObj >( "NegativeOutput" )->GetName( );
+
+ // Connect outputs (and correct their types and names)
+ _TImage* pos_out = this->GetOutput< _TImage >( "PositiveOutput" );
+ if( pos_out == NULL )
+ {
+ this->_MakeOutput< _TImage >( "PositiveOutput" );
+ pos_out = this->GetOutput< _TImage >( "PositiveOutput" );
+ pos_out->SetName( pos_name );
+
+ } // fi
+ _TImage* neg_out = this->GetOutput< _TImage >( "NegativeOutput" );
+ if( neg_out == NULL )
{
- out->SetITK< I >( filter->GetOutput( ) );
- out->SetName( name );
- return( "" );
- }
- else
- return( "MacheteFilter: output image not correctly created." );
+ this->_MakeOutput< _TImage >( "NegativeOutput" );
+ neg_out = this->GetOutput< _TImage >( "NegativeOutput" );
+ neg_out->SetName( neg_name );
+
+ } // fi
+
+ // Assign outputs
+ pos_out->SetITK< I >( filter->GetPositiveOutput( ) );
+ neg_out->SetITK< I >( filter->GetNegativeOutput( ) );
+ return( "" );
}
// eof - $RCSfile$