]> Creatis software - cpPlugins.git/commitdiff
Widget integration (step 4/6)... Testing on windows.
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 5 Oct 2015 02:04:39 +0000 (21:04 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 5 Oct 2015 02:04:39 +0000 (21:04 -0500)
lib/cpExtensions/Visualization/ImageSliceActors.cxx
lib/cpExtensions/Visualization/ImageSliceActors.h
lib/cpPlugins/Interface/Image.hxx
lib/cpPlugins/Interface/Mesh.cxx
lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx
lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx [new file with mode: 0644]
lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.h [new file with mode: 0644]
lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx
lib/cpPlugins/Plugins/IO/ImageWriter.cxx

index f945bd397eb6c6b885f61f5e234c2bdb44182c7e..469f270f6b7df5886232ed7601f339c857579110 100644 (file)
@@ -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( );
 }
index 8889b2f08d5986decaea77dbeef024e03c3cdc8b..d51d656ba48a883fb63756e7daafa0455441fae5 100644 (file)
@@ -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
index 2f5f1d59a5071adee381adc82ef18361ad95d9fd..dfabc0ab6ecdb1503981e4ac729d1dd619b6f23b 100644 (file)
@@ -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 );
index e179c8ed61e4b0e34b7fcd391b6c92d2cf73309c..0dc2f9aab5ab3872b59cdbf5247d5b614a6c18eb 100644 (file)
@@ -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( );
 
index 32a7c5a3b1e3ad1af7c1a1cdb69d52df5ba279ca..c6ac99f17294d97d590d1cb96054a25b0576e8c2 100644 (file)
@@ -5,6 +5,9 @@
 #include <vtkCutter.h>
 #include <vtkProperty.h>
 
+
+#include <vtkPlane.h>
+
 // -------------------------------------------------------------------------
 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 (file)
index 0000000..ff14aa4
--- /dev/null
@@ -0,0 +1,102 @@
+#include "ExtractSliceImageFilter.h"
+#include <cpPlugins/Interface/Image.h>
+
+#include <itkExtractImageFilter.h>
+
+// -------------------------------------------------------------------------
+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 (file)
index 0000000..a18e992
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef __CPPLUGINS__PLUGINS__EXTRACTSLICEIMAGEFILTER__H__
+#define __CPPLUGINS__PLUGINS__EXTRACTSLICEIMAGEFILTER__H__
+
+#include <cpPlugins/BasicFilters/cpPluginsBasicFilters_Export.h>
+#include <cpPlugins/Interface/BaseProcessObjects.h>
+
+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$
index e3b582dfbf7bfcb788f5735e448b72bfc61fa41a..61a330e1c218598331578ed6c28d85fd7281b6ae 100644 (file)
@@ -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" );
index 3330e681bc0b679fb4844411bcba95dd507e64d4..9de1fe60f2613bccf9733e2381c1013162e47d41 100644 (file)
@@ -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 );