// -------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
- if( argc < 8 )
+ if( argc < 5 )
{
std::cerr
<< "Usage: " << argv[ 0 ]
- << " input_image s_x s_y s_z thr_0 thr_1 n_samples" << std::endl;
+ << " input_image thr_0 thr_1 n_samples" << std::endl;
return( 1 );
} // fi
std::string input_image_fn = argv[ 1 ];
- TImage::PointType seed_pnt;
- seed_pnt[ 0 ] = std::atof( argv[ 2 ] );
- seed_pnt[ 1 ] = std::atof( argv[ 3 ] );
- seed_pnt[ 2 ] = std::atof( argv[ 4 ] );
- TPixel thr_0 = TPixel( std::atof( argv[ 5 ] ) );
- TPixel thr_1 = TPixel( std::atof( argv[ 6 ] ) );
- unsigned int n_samples = std::atoi( argv[ 7 ] );
+ TPixel thr_0 = TPixel( std::atof( argv[ 2 ] ) );
+ TPixel thr_1 = TPixel( std::atof( argv[ 3 ] ) );
+ unsigned int n_samples = std::atoi( argv[ 4 ] );
// Read image
TImageReader::Pointer input_image_reader = TImageReader::New( );
vtk_image->SetInput( input_image );
vtk_image->Update( );
- vtkSmartPointer< vtkSphereSource > seed =
- vtkSmartPointer< vtkSphereSource >::New( );
- seed->SetCenter( seed_pnt[ 0 ], seed_pnt[ 1 ], seed_pnt[ 2 ] );
- seed->SetRadius( min_spac * double( 5 ) );
- seed->Update( );
+ /* TODO
+ vtkSmartPointer< vtkSphereSource > seed =
+ vtkSmartPointer< vtkSphereSource >::New( );
+ seed->SetCenter( seed_pnt[ 0 ], seed_pnt[ 1 ], seed_pnt[ 2 ] );
+ seed->SetRadius( min_spac * double( 5 ) );
+ seed->Update( );
+ */
fpa::VTK::ImageMPR view;
view.SetBackground( 0.3, 0.2, 0.8 );
view.SetSize( 800, 800 );
view.SetImage( vtk_image->GetOutput( ) );
- view.AddPolyData( seed->GetOutput( ), 1, 0, 0 );
+ // TODO: view.AddPolyData( seed->GetOutput( ), 1, 0, 0 );
view.Start( );
// Configure observer
- TObserver::Pointer obs = TObserver::New( );
- obs->SetImage( input_image, view.GetWindow( ) );
-
- // Configure algorithm
- TFrontAlgorithm::Pointer algorithm = TFrontAlgorithm::New( );
- algorithm->AddThresholds( thr_0, thr_1, n_samples );
-
- TImage::IndexType seed_idx;
- input_image->TransformPhysicalPointToIndex( seed_pnt, seed_idx );
- algorithm->AddSeed( seed_idx, 0 );
-
- algorithm->AddObserver( itk::AnyEvent( ), obs );
- algorithm->ThrowEventsOn( );
- algorithm->SetInput( input_image );
- algorithm->SetNeighborhoodOrder( 1 );
- algorithm->SetDerivativeThreshold( double( 3 ) );
- algorithm->Update( );
-
- view.Start( );
-
+ /* TODO
+ TObserver::Pointer obs = TObserver::New( );
+ obs->SetImage( input_image, view.GetWindow( ) );
+
+ // Configure algorithm
+ TFrontAlgorithm::Pointer algorithm = TFrontAlgorithm::New( );
+ algorithm->AddThresholds( thr_0, thr_1, n_samples );
+
+ TImage::IndexType seed_idx;
+ input_image->TransformPhysicalPointToIndex( seed_pnt, seed_idx );
+ algorithm->AddSeed( seed_idx, 0 );
+
+ algorithm->AddObserver( itk::AnyEvent( ), obs );
+ algorithm->ThrowEventsOn( );
+ algorithm->SetInput( input_image );
+ algorithm->SetNeighborhoodOrder( 1 );
+ algorithm->SetDerivativeThreshold( double( 3 ) );
+ algorithm->Update( );
+
+ view.Start( );
+ */
return( 0 );
}
_TNode node = this->Superclass::_QueuePop( );
if( this->_IsQueueEmpty( ) )
{
- std::cerr << "ERROR!!!!" << std::endl;
+ // Replace queue
+ this->m_Queue = this->m_AuxiliaryQueue;
+
+ // Move to next function
+ this->m_ActualFunction++;
} // fi
return( node );
bool fpa::Base::RegionGrowWithMultipleCriteria< V, R, VV, VC, B >::
_CheckMembership( const _TNode& n ) const
{
- bool ret = ( *( this->m_ActualFunction ) )->Evaluate( n.Vertex );
- if( !ret )
- this->m_AuxiliaryQueue.push( n );
- return( ret );
+ if( this->m_ActualFunction != this->m_Functions.end( ) )
+ {
+ bool ret = ( *( this->m_ActualFunction ) )->Evaluate( n.Vertex );
+ if( !ret )
+ this->m_AuxiliaryQueue.push( n );
+ return( ret );
+ }
+ else
+ return( false );
}
#endif // __FPA__BASE__REGIONGROWWITHMULTIPLECRITERIA__HXX__
else
function->SetLowerThreshold( std::numeric_limits< TPixel >::min( ) );
std::cout
- << typeid( TPixel ).name( ) << " "
+ << typeid( TPixel ).name( ) << " <<<----->>> "
<< function->GetLowerThreshold( )
<< std::endl;
+ std::exit( 1 );
function->SetUpperThreshold( v );
this->AddMembershipFunction( function );
#include <fpa/VTK/ImageMPR.h>
+#include <vtkCommand.h>
#include <vtkInteractorStyleSwitch.h>
+#include <vtkPickingManager.h>
+
+class vtkUpdateCallback
+ : public vtkCommand
+{
+public:
+ static vtkUpdateCallback *New()
+ {
+ return new vtkUpdateCallback;
+ }
+ virtual void Execute(vtkObject *caller, unsigned long eventId, void*
+ arguments)
+ {
+ vtkRenderWindowInteractor* iren =
+ static_cast< vtkRenderWindowInteractor* >( caller );
+ if( caller == NULL )
+ return;
+
+ switch( iren->GetKeyCode( ) )
+ {
+ case 'x':
+ case 'X':
+ {
+ bool eSeed = ( this->SeedWidget->GetProcessEvents( ) == 1 );
+ if( eSeed )
+ {
+ this->SeedWidget->ProcessEventsOff( );
+ this->WidgetX->InteractionOn( );
+ this->WidgetY->InteractionOn( );
+ this->WidgetZ->InteractionOn( );
+ }
+ else
+ {
+ this->SeedWidget->ProcessEventsOn( );
+ this->WidgetX->InteractionOff( );
+ this->WidgetY->InteractionOff( );
+ this->WidgetZ->InteractionOff( );
+
+ } // fi
+ }
+ break;
+ default:
+ break;
+
+ } // hctiws
+ }
+
+public:
+ vtkImagePlaneWidget* WidgetX;
+ vtkImagePlaneWidget* WidgetY;
+ vtkImagePlaneWidget* WidgetZ;
+ vtkSeedWidget2* SeedWidget;
+};
// -------------------------------------------------------------------------
fpa::VTK::ImageMPR::
ImageMPR( )
{
- // vtkSmartPointer< vtkImageData > m_Image;
-
this->m_Outline = vtkSmartPointer< vtkOutlineSource >::New( );
this->m_OutlineMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
this->m_OutlineActor = vtkSmartPointer< vtkActor >::New( );
this->m_Renderer = vtkSmartPointer< vtkRenderer >::New( );
this->m_Window = vtkSmartPointer< vtkRenderWindow >::New( );
this->m_Interactor = vtkSmartPointer< vtkRenderWindowInteractor >::New( );
+
+
+
+
+
+
+ handlePointRep3D =
+ vtkSmartPointer<vtkPointHandleRepresentation3D>::New();
+ //handlePointRep3D->AllOn();
+ handlePointRep3D->GetProperty()->SetColor(1.,0.,1.);
+ seedRep =
+ vtkSmartPointer<vtkSeedRepresentation>::New();
+ seedRep->SetHandleRepresentation(handlePointRep3D);
+ seedWidget = vtkSmartPointer<vtkSeedWidget2>::New();
+
+ seedWidget->SetRepresentation(seedRep);
+
+ this->m_WidgetX->KeyPressActivationOff( );
+ this->m_WidgetY->KeyPressActivationOff( );
+ this->m_WidgetZ->KeyPressActivationOff( );
+ seedWidget->KeyPressActivationOff( );
+
+ // this->m_Interactor->GetPickingManager( )->AddPicker( this->m_Picker );
+
+
+ vtkUpdateCallback* onUpdate = vtkUpdateCallback::New();
+ onUpdate->WidgetX = this->m_WidgetX;
+ onUpdate->WidgetY = this->m_WidgetY;
+ onUpdate->WidgetZ = this->m_WidgetZ;
+ onUpdate->SeedWidget = this->seedWidget;
+
+ this->m_Interactor->AddObserver(vtkCommand::KeyPressEvent, onUpdate);
}
// -------------------------------------------------------------------------
this->m_WidgetX->SetInteractor( this->m_Interactor );
this->m_WidgetY->SetInteractor( this->m_Interactor );
this->m_WidgetZ->SetInteractor( this->m_Interactor );
+ seedWidget->SetInteractor(this->m_Interactor);
+
+ this->m_WidgetX->On( );
+ this->m_WidgetY->On( );
+ this->m_WidgetZ->On( );
+ seedWidget->On( );
+ seedWidget->ProcessEventsOff( );
+ this->m_Interactor->SetPicker( this->m_Picker );
+ this->m_Interactor->GetPickingManager( )->AddPicker( this->m_Picker );
+ this->m_Interactor->GetPickingManager( )->EnabledOn( );
}
// -------------------------------------------------------------------------
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
+#include <vtkSeedWidget.h>
+#include <vtkSeedRepresentation.h>
+#include <vtkHandleWidget.h>
+#include <vtkPointHandleRepresentation3D.h>
+
+class vtkSeedWidget2
+ : public vtkSeedWidget
+{
+public:
+ // Description:
+ // Instantiate this class.
+ static vtkSeedWidget2 *New()
+ {
+ return new vtkSeedWidget2;
+ }
+
+ // Description:
+ // Standard methods for a VTK class.
+ vtkTypeMacro(vtkSeedWidget2, vtkSeedWidget);
+
+ virtual vtkPickingManager* GetPickingManager( )
+ {
+ return( this->Superclass::GetPickingManager( ) );
+ }
+
+protected:
+ vtkSeedWidget2()
+ : Superclass( )
+ {
+ }
+ virtual ~vtkSeedWidget2()
+ {
+ }
+
+private:
+ vtkSeedWidget2(const vtkSeedWidget2&); //Not implemented
+ void operator=(const vtkSeedWidget2&); //Not implemented
+};
+
namespace fpa
{
namespace VTK
std::vector< vtkSmartPointer< vtkPolyData > > m_PolyDatas;
std::vector< vtkSmartPointer< vtkPolyDataMapper > > m_Mappers;
std::vector< vtkSmartPointer< vtkActor > > m_Actors;
+
+
+ // Create the widget and its representation
+ vtkSmartPointer<vtkPointHandleRepresentation3D> handlePointRep3D;
+ vtkSmartPointer<vtkSeedRepresentation> seedRep;
+ vtkSmartPointer<vtkSeedWidget2> seedWidget;
+
};
} // ecapseman