From: Leonardo Florez-Valencia Date: Mon, 5 Oct 2015 02:04:39 +0000 (-0500) Subject: Widget integration (step 4/6)... Testing on windows. X-Git-Tag: v0.1~349 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=2da3b422ceb0b6abfd336200a4ede6efe982ebe2;p=cpPlugins.git Widget integration (step 4/6)... Testing on windows. --- diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.cxx b/lib/cpExtensions/Visualization/ImageSliceActors.cxx index f945bd3..469f270 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.cxx +++ b/lib/cpExtensions/Visualization/ImageSliceActors.cxx @@ -399,6 +399,9 @@ SetSliceNumber( const int& slice ) } // rof + if( this->m_UpdateCommand != NULL ) + this->m_UpdateCommand( this->m_UpdateData ); + // Update text this->UpdateText( ); } @@ -455,7 +458,9 @@ UpdateText( const double& w, const double& l ) cpExtensions::Visualization::ImageSliceActors:: ImageSliceActors( ) : Superclass( ), - Interpolate( false ) + Interpolate( false ), + m_UpdateCommand( NULL ), + m_UpdateData( NULL ) { this->Clear( ); } diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.h b/lib/cpExtensions/Visualization/ImageSliceActors.h index 8889b2f..d51d656 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.h +++ b/lib/cpExtensions/Visualization/ImageSliceActors.h @@ -33,6 +33,8 @@ namespace cpExtensions public: typedef ImageSliceActors Self; + typedef void ( *TUpdateCommand )( void* ); + public: vtkTypeMacro( ImageSliceActors, vtkPropCollection ); @@ -72,6 +74,12 @@ namespace cpExtensions void UpdateText( ); void UpdateText( const double& w, const double& l ); + TUpdateCommand SetUpdateCommand( TUpdateCommand cmd, void* data ) + { + this->m_UpdateCommand = cmd; + this->m_UpdateData = data; + } + protected: ImageSliceActors( ); virtual ~ImageSliceActors( ); @@ -101,6 +109,10 @@ namespace cpExtensions char TextBuffer[ 1024 ]; vtkSmartPointer< vtkTextActor > TextActor; vtkSmartPointer< vtkActor > PlaneActor; + + + TUpdateCommand m_UpdateCommand; + void* m_UpdateData; }; } // ecapseman diff --git a/lib/cpPlugins/Interface/Image.hxx b/lib/cpPlugins/Interface/Image.hxx index 2f5f1d5..dfabc0a 100644 --- a/lib/cpPlugins/Interface/Image.hxx +++ b/lib/cpPlugins/Interface/Image.hxx @@ -53,6 +53,12 @@ SetITK( itk::Object* object ) } // fi + // --------- TODO --------------- + typename I::DirectionType norm_dir; + norm_dir.SetIdentity( ); + image->SetDirection( norm_dir ); + // --------- TODO --------------- + // Connect it to VTK cpPlugins_VTKImage_Demangle_AllDims( I, char, image ); else cpPlugins_VTKImage_Demangle_AllDims( I, short, image ); diff --git a/lib/cpPlugins/Interface/Mesh.cxx b/lib/cpPlugins/Interface/Mesh.cxx index e179c8e..0dc2f9a 100644 --- a/lib/cpPlugins/Interface/Mesh.cxx +++ b/lib/cpPlugins/Interface/Mesh.cxx @@ -28,9 +28,16 @@ CreateVTKActor( ) ) ) { + double range[ 2 ]; + pd->GetScalarRange( range ); + this->m_Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); this->m_Actor = vtkSmartPointer< vtkActor >::New( ); this->m_Mapper->SetInputData( pd ); + this->m_Mapper->UseLookupTableScalarRangeOff( ); + this->m_Mapper->SetScalarRange( + range[ 0 ], ( ( range[ 1 ] - range[ 0 ] ) * 0.75 ) + range[ 0 ] + ); this->m_Actor->SetMapper( this->m_Mapper ); this->Modified( ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx b/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx index 32a7c5a..c6ac99f 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx @@ -5,6 +5,9 @@ #include #include + +#include + // ------------------------------------------------------------------------- cpPlugins::BasicFilters::Cutter:: Cutter( ) @@ -39,8 +42,10 @@ _GenerateData( ) return( "Cutter: Input data 1 is not a valid implicit function." ); vtkCutter* cutter = this->_CreateVTK< vtkCutter >( ); + cutter->DebugOn( ); cutter->SetInputData( mesh->GetVTK< vtkPolyData >( ) ); cutter->SetCutFunction( function->GetVTK< vtkImplicitFunction >( ) ); + cutter->SetValue( 0, 1 ); cutter->GenerateTrianglesOff( ); cutter->Update( ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx new file mode 100644 index 0000000..ff14aa4 --- /dev/null +++ b/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx @@ -0,0 +1,102 @@ +#include "ExtractSliceImageFilter.h" +#include + +#include + +// ------------------------------------------------------------------------- +cpPlugins::BasicFilters::ExtractSliceImageFilter:: +ExtractSliceImageFilter( ) + : Superclass( ) +{ + this->m_ClassName = "cpPlugins::BasicFilters::ExtractSliceImageFilter"; + this->m_ClassCategory = "ImageToImageFilter"; + this->SetNumberOfInputs( 1 ); + this->SetNumberOfOutputs( 1 ); + this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); + + using namespace cpPlugins::Interface; + this->m_DefaultParameters.Configure( Parameters::Int, "Axis" ); + this->m_DefaultParameters.Configure( Parameters::Int, "Slice" ); + this->m_DefaultParameters.SetValueAsInt( "Axis", 0 ); + this->m_DefaultParameters.SetValueAsInt( "Slice", 0 ); + this->m_Parameters = this->m_DefaultParameters; +} + +// ------------------------------------------------------------------------- +cpPlugins::BasicFilters::ExtractSliceImageFilter:: +~ExtractSliceImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPlugins::BasicFilters::ExtractSliceImageFilter:: +_GenerateData( ) +{ + cpPlugins::Interface::Image* image = + this->GetInput< cpPlugins::Interface::Image >( 0 ); + if( image == NULL ) + return( "ExtractSliceImageFilter: No input image." ); + + itk::DataObject* itk_image = NULL; + std::string r = ""; + cpPlugins_Image_Demangle_AllTypes( 3, image, itk_image, r, _GD0 ); + else cpPlugins_VectorImage_Demangle_AllTypes( 3, image, itk_image, r, _GD0 ); + else r = "ExtractSliceImageFilter: Input image type not supported."; + return( r ); +} + +// ------------------------------------------------------------------------- +template< class I > +std::string cpPlugins::BasicFilters::ExtractSliceImageFilter:: +_GD0( itk::DataObject* image ) +{ + return( this->_RealGD< I, I >( image ) ); +} + +// ------------------------------------------------------------------------- +template< class I, class O > +inline std::string cpPlugins::BasicFilters::ExtractSliceImageFilter:: +_RealGD( itk::DataObject* image ) +{ + typedef itk::ExtractImageFilter< I, O > _F; + typedef typename O::PixelType _OP; + + // Get parameters + int axis = this->m_Parameters.GetValueAsInt( "Axis" ); + int slice = this->m_Parameters.GetValueAsInt( "Slice" ); + + std::cout << "HOLA: " << slice << std::endl; + + + // Compute region + I* img = dynamic_cast< I* >( image ); + typename I::RegionType region = img->GetRequestedRegion( ); + typename I::SizeType size = region.GetSize( ); + typename I::IndexType index = region.GetIndex( ); + size[ axis ] = 1; + index[ axis ] = slice; + region.SetSize( size ); + region.SetIndex( index ); + + std::cout << "HOLA-: " << region << std::endl; + + // Configure filter + _F* filter = this->_CreateITK< _F >( ); + filter->SetInput( img ); + filter->SetExtractionRegion( region ); + filter->SetDirectionCollapseToIdentity( ); + filter->Update( ); + + // Connect output + cpPlugins::Interface::Image* out = + this->GetOutput< cpPlugins::Interface::Image >( 0 ); + if( out != NULL ) + { + out->SetITK< O >( filter->GetOutput( ) ); + return( "" ); + } + else + return( "ExtractSliceImageFilter: output not correctly created." ); +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.h new file mode 100644 index 0000000..a18e992 --- /dev/null +++ b/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.h @@ -0,0 +1,55 @@ +#ifndef __CPPLUGINS__PLUGINS__EXTRACTSLICEIMAGEFILTER__H__ +#define __CPPLUGINS__PLUGINS__EXTRACTSLICEIMAGEFILTER__H__ + +#include +#include + +namespace cpPlugins +{ + namespace BasicFilters + { + /** + */ + class cpPluginsBasicFilters_EXPORT ExtractSliceImageFilter + : public cpPlugins::Interface::ImageToImageFilter + { + public: + typedef ExtractSliceImageFilter Self; + typedef cpPlugins::Interface::ImageToImageFilter Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( + ExtractSliceImageFilter, cpPluginsInterfaceImageToImageFilter + ); + + protected: + ExtractSliceImageFilter( ); + virtual ~ExtractSliceImageFilter( ); + + virtual std::string _GenerateData( ); + + template< class I > + inline std::string _GD0( itk::DataObject* image ); + + template< class I, class O > + inline std::string _RealGD( itk::DataObject* image ); + + private: + // Purposely not implemented + ExtractSliceImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + + // --------------------------------------------------------------------- + CPPLUGINS_INHERIT_PROVIDER( ExtractSliceImageFilter ); + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__PLUGINS__EXTRACTSLICEIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx b/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx index e3b582d..61a330e 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx @@ -41,6 +41,7 @@ _GenerateData( ) { itk::Point< double, 3 > center = this->m_Parameters.GetValueAsPoint< itk::Point< double, 3 > >( "Center" ); + center.Fill( double( 0 ) ); // TODO double radius = this->m_Parameters.GetValueAsReal( "Radius" ); unsigned int phi = this->m_Parameters.GetValueAsUint( "PhiResolution" ); unsigned int theta = this->m_Parameters.GetValueAsUint( "ThetaResolution" ); diff --git a/lib/cpPlugins/Plugins/IO/ImageWriter.cxx b/lib/cpPlugins/Plugins/IO/ImageWriter.cxx index 3330e68..9de1fe6 100644 --- a/lib/cpPlugins/Plugins/IO/ImageWriter.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageWriter.cxx @@ -34,7 +34,6 @@ _GenerateData( ) itk::DataObject* itk_image = NULL; std::string r = ""; - cpPlugins_Image_Demangle_AllTypes( 2, image, itk_image, r, _RealGD ); else cpPlugins_Image_Demangle_AllTypes( 3, image, itk_image, r, _RealGD ); else cpPlugins_Image_Demangle_AllTypes( 4, image, itk_image, r, _RealGD );