]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 22 Sep 2015 17:39:15 +0000 (19:39 +0200)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 22 Sep 2015 17:39:15 +0000 (19:39 +0200)
14 files changed:
appli/ImageMPR/ImageMPR.cxx
appli/ImageMPR/ImageMPR.h
appli/examples/CMakeLists.txt
appli/examples/example_MPR.cxx
appli/examples/example_ReadWriteImage.cxx
lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.cxx [new file with mode: 0644]
lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.h [new file with mode: 0644]
lib/cpExtensions/Visualization/MPRActors.cxx
lib/cpPlugins/Interface/Instances_itkImage.cxx
lib/cpPlugins/Plugins/CMakeLists.txt
lib/cpPlugins/Plugins/Host.cxx
lib/cpPlugins/Plugins/ImageReader.cxx
lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.cxx [new file with mode: 0644]
lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.h [new file with mode: 0644]

index def9fc4dd3d94a94dfab50d58ea094210acbafcc..337aac1b17d37a6b4d8888db828b0947700f2073 100644 (file)
@@ -30,12 +30,18 @@ ImageMPR::ImageMPR( QWidget* parent )
   this->m_UI->setupUi( this );
 
   // Create and associate renderers
-  this->m_MPR = new TMPR(
-    this->m_UI->m_XPlaneVTK->GetRenderWindow( ),
-    this->m_UI->m_YPlaneVTK->GetRenderWindow( ),
-    this->m_UI->m_ZPlaneVTK->GetRenderWindow( ),
-    this->m_UI->m_3DVTK->GetRenderWindow( )
-    );
+  this->m_MPRActors = vtkSmartPointer< TMPRActors >::New( );
+
+  for( unsigned int i = 0; i < 4; ++i )
+  {
+    this->m_Renderers[ i ] = vtkSmartPointer< vtkRenderer >::New( );
+    this->m_Renderers[ i ]->SetBackground( 0.1, 0.3, 0.8 );
+
+  } // rof
+  this->m_UI->m_XPlaneVTK->GetRenderWindow( )->AddRenderer( this->m_Renderers[ 0 ] );
+  this->m_UI->m_YPlaneVTK->GetRenderWindow( )->AddRenderer( this->m_Renderers[ 1 ] );
+  this->m_UI->m_ZPlaneVTK->GetRenderWindow( )->AddRenderer( this->m_Renderers[ 2 ] );
+  this->m_UI->m_3DVTK->GetRenderWindow( )->AddRenderer( this->m_Renderers[ 3 ] );
 
   // signals <-> slots
   QObject::connect(
@@ -68,7 +74,6 @@ ImageMPR::
 
   // Delete objects
   delete this->m_UI;
-  delete this->m_MPR;
 }
 
 // -------------------------------------------------------------------------
@@ -193,7 +198,31 @@ _triggered_actionOpenInputImage( )
       dynamic_cast< TPluginImage* >( reader->GetOutput( 0 ) );
     reader->DisconnectOutputs( );
     if( this->m_InputImage.IsNotNull( ) )
-      this->m_MPR->SetImage( this->m_InputImage->GetVTKImageData( ) );
+    {
+      this->m_MPRActors->SetInputData( this->m_InputImage->GetVTKImageData( ) );
+      this->m_MPRActors->PushDataInto(
+        this->m_Renderers[ 0 ],
+        this->m_Renderers[ 1 ],
+        this->m_Renderers[ 2 ],
+        this->m_Renderers[ 3 ]
+        );
+
+      /*
+        this->m_MPR.AssociatePlaneInteractor( 0, this->m_UI->m_XPlaneVTK->GetRenderWindow( )->GetInteractor( ) );
+        this->m_MPR.AssociatePlaneInteractor( 1, this->m_UI->m_YPlaneVTK->GetRenderWindow( )->GetInteractor( ) );
+        this->m_MPR.AssociatePlaneInteractor( 2, this->m_UI->m_ZPlaneVTK->GetRenderWindow( )->GetInteractor( ) );
+      */
+
+    } // fi
+    this->m_Renderers[ 0 ]->ResetCamera( );
+    this->m_Renderers[ 1 ]->ResetCamera( );
+    this->m_Renderers[ 2 ]->ResetCamera( );
+    this->m_Renderers[ 3 ]->ResetCamera( );
+
+    this->m_UI->m_XPlaneVTK->GetRenderWindow( )->Render( );
+    this->m_UI->m_YPlaneVTK->GetRenderWindow( )->Render( );
+    this->m_UI->m_ZPlaneVTK->GetRenderWindow( )->Render( );
+    this->m_UI->m_3DVTK->GetRenderWindow( )->Render( );
   }
   else
     QMessageBox::critical(
@@ -264,6 +293,7 @@ _triggered_actionOpenInputPolyData( )
 void ImageMPR::
 _triggered_actionImageToImage( )
 {
+  /* TODO
   if( this->m_InputImage.IsNull( ) )
     return;
 
@@ -305,6 +335,7 @@ _triggered_actionImageToImage( )
       tr( "Error executing filter" ),
       tr( err.c_str( ) )
       );
+  */
 }
 
 // -------------------------------------------------------------------------
index 1418bf6eae97263e969e78e740e0394030ccb272..808c0ab012407e6b11a681e46b2cd0c9428de39c 100644 (file)
@@ -9,14 +9,15 @@
 #include <QMainWindow>
 
 // vtk stuff
+#include <vtkRenderer.h>
 #include <vtkSmartPointer.h>
+#include <cpExtensions/Visualization/MPRActors.h>
 
 // Plugins interface
 #include <cpPlugins/Interface/Interface.h>
 #include <cpPlugins/Interface/ProcessObject.h>
 #include <cpPlugins/Interface/Image.h>
 #include <cpPlugins/Interface/Mesh.h>
-#include <cpExtensions/Visualization/MPRWithDifferentWindows.h>
 
 // -------------------------------------------------------------------------
 namespace Ui
@@ -43,7 +44,7 @@ public:
   typedef cpPlugins::Interface::Parameters    TParameters;
 
   typedef std::set< std::string > TStringContainer;
-  typedef cpExtensions::Visualization::MPRWithDifferentWindows TMPR;
+  typedef cpExtensions::Visualization::MPRActors TMPRActors;
 
 public:
   explicit ImageMPR( QWidget* parent = 0 );
@@ -78,7 +79,8 @@ private:
   TPluginMesh::Pointer  m_InputMesh;
 
   // Visualization stuff
-  TMPR* m_MPR;
+  vtkSmartPointer< TMPRActors >        m_MPRActors;
+  vtkSmartPointer< vtkRenderer >       m_Renderers[ 4 ];
   vtkSmartPointer< vtkPolyDataMapper > m_InputMeshMapper;
   vtkSmartPointer< vtkActor >          m_InputMeshActor;
 
index 7d1265397f5913b8c001c09b3e71847f761de6f8..f233136b0c8d72eab44ea6f0f642230e56c588ac 100644 (file)
@@ -15,7 +15,7 @@ SET(
   ## example_ReadImageSeriesWriteImage
   ## example_ReadQuadEdgeMesh
   ## example_RenderQuadEdgeMesh
-  ## example_MPR
+  example_MPR
   )
 
 FOREACH(prog ${EXAMPLES_PROGRAMS}) 
index f3dbffb7599e0581c058cf7d152086cb08b58510..1691e089a0ab571acf47238508146bc5a6327176 100644 (file)
@@ -5,31 +5,24 @@
 #include <cpPlugins/Interface/Interface.h>
 #include <cpPlugins/Interface/ProcessObject.h>
 #include <cpPlugins/Interface/Image.h>
-#include <cpPlugins/Extensions/Visualization/MPRActors.h>
+#include <cpExtensions/Visualization/MPRObjects.h>
 
-#include <vtkActor.h>
-#include <vtkCallbackCommand.h>
-#include <vtkProperty.h>
 #include <vtkRenderer.h>
 #include <vtkRenderWindow.h>
 #include <vtkRenderWindowInteractor.h>
-#include <vtkSmartPointer.h>
 
 int main( int argc, char* argv[] )
 {
-  if( argc < 4 )
+  if( argc < 3 )
   {
     std::cerr
       << "Usage: " << argv[ 0 ]
-      << " plugins_file"
-      << " input_image"
-      << " pixel_type" << std::endl;
+      << " plugins_file input_image(s)"
+      << std::endl;
     return( 1 );
 
   } // fi
   std::string plugins_file = argv[ 1 ];
-  std::string input_image_file = argv[ 2 ];
-  std::string pixel_type = argv[ 3 ];
 
   // Create interface
   typedef cpPlugins::Interface::Interface TInterface;
@@ -42,8 +35,7 @@ int main( int argc, char* argv[] )
   typedef cpPlugins::Interface::ProcessObject TProcessObject;
   typedef cpPlugins::Interface::Parameters    TParameters;
   cpPlugins::Interface::ProcessObject::Pointer reader;
-
-  reader = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageReader" );
+  reader = plugins.CreateProcessObject( "cpPlugins::ImageReader" );
   if( reader.IsNull( ) )
   {
     std::cerr << "No suitable reader found in plugins." << std::endl;
@@ -53,67 +45,56 @@ int main( int argc, char* argv[] )
 
   // Configure reader
   TParameters reader_params = reader->GetDefaultParameters( );
-  reader_params.AddValueToStringList( "FileNames", input_image_file );
-  reader_params.SetValueAsString( "PixelType", pixel_type );
-  reader_params.SetValueAsUint( "ImageDimension", 3 );
-  reader_params.SetValueAsUint( "IsColorImage", 0 );
+  for( int i = 2; i < argc; ++i )
+    reader_params.AddValueToStringList( "FileNames", argv[ i ] );
   reader->SetParameters( reader_params );
 
   // Execute reader
   std::string msg = reader->Update( );
-
   if( msg != "" )
+  {
     std::cerr << "ERROR: " << msg << std::endl;
+    return( 1 );
+
+  } // fi
+  cpPlugins::Interface::Image* image =
+    dynamic_cast< cpPlugins::Interface::Image* >( reader->GetOutput( 0 ) );
+  vtkImageData* vtk_image = image->GetVTKImageData( );
+  if( vtk_image == NULL )
+  {
+    std::cerr
+      << "ERROR: read image does not have a valid VTK conversion."
+      << std::endl;
+    return( 1 );
+
+  } // fi
 
   // Visualization stuff
-  vtkSmartPointer< vtkRenderWindow > window = 
+  vtkSmartPointer< vtkRenderWindow > window =
     vtkSmartPointer< vtkRenderWindow >::New( );
+  window->SetSize( 700, 700 );
 
-  vtkSmartPointer< vtkRenderWindowInteractor > interactor = 
+  // Renderers
+  vtkSmartPointer< vtkRenderer > renderer =
+    vtkSmartPointer< vtkRenderer >::New( );
+  window->AddRenderer( renderer );
+
+  // Interactor
+  vtkSmartPointer< vtkRenderWindowInteractor > interactor =
     vtkSmartPointer< vtkRenderWindowInteractor >::New( );
   interactor->SetRenderWindow( window );
 
-  // Renderers
-  vtkSmartPointer< vtkRenderer > xrenderer =
-    vtkSmartPointer< vtkRenderer >::New( );
-  vtkSmartPointer< vtkRenderer > yrenderer =
-    vtkSmartPointer< vtkRenderer >::New( );
-  vtkSmartPointer< vtkRenderer > zrenderer =
-    vtkSmartPointer< vtkRenderer >::New( );
-  vtkSmartPointer< vtkRenderer > wrenderer =
-    vtkSmartPointer< vtkRenderer >::New( );
-  xrenderer->SetBackground( 0.7, 0.5, 0.5 );
-  yrenderer->SetBackground( 0.5, 0.7, 0.5 );
-  zrenderer->SetBackground( 0.5, 0.5, 0.7 );
-  wrenderer->SetBackground( 0.5, 0.5, 0.5 );
-
-  xrenderer->SetViewport( 0, 0, 0.5, 0.5 );
-  yrenderer->SetViewport( 0, 0.5, 0.5, 1 );
-  zrenderer->SetViewport( 0.5, 0, 1, 0.5 );
-  wrenderer->SetViewport( 0.5, 0.5, 1, 1 );
-
-  window->AddRenderer( xrenderer );
-  window->AddRenderer( yrenderer );
-  window->AddRenderer( zrenderer );
-  window->AddRenderer( wrenderer );
-
-  // Create actors
-  typedef cpPlugins::Extensions::Visualization::MPRActors TMPRActors;
-  vtkSmartPointer< TMPRActors > mprActors =
-    vtkSmartPointer< TMPRActors >::New( );
-  mprActors->SetInputData(
-    dynamic_cast< cpPlugins::Interface::Image* >( reader->GetOutput( 0 ) )->
-    GetVTKImageData( )
-    );
-  mprActors->PushDataInto( xrenderer, yrenderer, zrenderer, wrenderer );
+  // Actors
+  cpExtensions::Visualization::MPRObjects mpr;
+  mpr.SetImage( vtk_image );
+  /*
+    mpr.AssociatePlaneInteractor( 0, interactor );
+    mpr.AssociatePlaneInteractor( 1, interactor );
+    mpr.AssociatePlaneInteractor( 2, interactor );
+  */
 
   // Begin interaction
-  xrenderer->ResetCamera( );
-  yrenderer->ResetCamera( );
-  zrenderer->ResetCamera( );
-  wrenderer->ResetCamera( );
+  renderer->ResetCamera( );
   window->Render( );
   interactor->Start( );
 
index 8c562a96dcb0ea9aebcc94faea5b9c11a6d6c9c8..0098973bd520c79049c6a60112d1327664adce30 100644 (file)
@@ -5,6 +5,8 @@
 #include <cpPlugins/Interface/Interface.h>
 #include <cpPlugins/Interface/ProcessObject.h>
 
+#include <cpPlugins/Interface/Image.h>
+
 int main( int argc, char* argv[] )
 {
   if( argc < 4 )
@@ -69,6 +71,9 @@ int main( int argc, char* argv[] )
     return( 1 );
 
   } // fi
+
+  dynamic_cast< cpPlugins::Interface::Image* >( reader->GetOutput( 0 ) )->GetVTKImageData( )->Print( std::cout );
+
   return( 0 );
 }
 
diff --git a/lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.cxx b/lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.cxx
new file mode 100644 (file)
index 0000000..0645898
--- /dev/null
@@ -0,0 +1,181 @@
+// -------------------------------------------------------------------------
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// -------------------------------------------------------------------------
+
+#include <cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.h>
+#include <itkImage.h>
+#include <itkSymmetricSecondRankTensor.h>
+#include <itkImageRegionConstIteratorWithIndex.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+#include <vtkPoints.h>
+#include <vtkPointData.h>
+#include <vtkSmartPointer.h>
+#include <vtkDoubleArray.h>
+
+// -------------------------------------------------------------------------
+template< class I >
+typename cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >::
+Self* cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >::
+New( )
+{
+  return( new Self );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+void cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >::
+SetInputData( const I* image )
+{
+  this->m_ITKImage = image;
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >::
+SecondRankDiffusionTensorToPolyData( )
+  : vtkPolyDataAlgorithm( )
+{
+  this->SetNumberOfInputPorts( 0 );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >::
+~SecondRankDiffusionTensorToPolyData( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+int cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I >::
+RequestData(
+  vtkInformation* request,
+  vtkInformationVector** inputVector,
+  vtkInformationVector* outputVector
+  )
+{
+  if( this->m_ITKImage.IsNull( ) )
+    return( 0 );
+  
+  // get the info objects
+  vtkInformation* outInfo = outputVector->GetInformationObject( 0 );
+  vtkPolyData* polyData = vtkPolyData::SafeDownCast(
+    outInfo->Get(vtkDataObject::DATA_OBJECT())
+    );
+
+  itk::ImageRegionConstIteratorWithIndex< I > tensorIt( this->m_ITKImage, this->m_ITKImage->GetRequestedRegion() );
+
+  vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
+  vtkSmartPointer<vtkDoubleArray> vtkTensors = vtkSmartPointer<vtkDoubleArray>::New();
+  vtkTensors->SetNumberOfComponents(9);
+  for ( tensorIt.GoToBegin(); !tensorIt.IsAtEnd(); ++tensorIt )
+  {
+    typename I::IndexType tensorIndex = tensorIt.GetIndex();
+    typename I::PixelType tensor = tensorIt.Get();
+    typename I::PointType ptensor;
+
+    // TODO: std::cout << "\n Index [" << tensorIndex[0] << ", " << tensorIndex[1] << ", " << tensorIndex[2] << "]" << std::endl;
+    this->m_ITKImage->TransformIndexToPhysicalPoint( tensorIndex, ptensor );
+    vtkIdType vtkPointID = points->InsertNextPoint(ptensor[0], ptensor[1], ptensor[2]);
+
+    /**
+     * Definition included in cdifTypes.
+     * typedef itk::SymmetricSecondRankTensor< double > Diffusion2ndRankTensor;
+     */
+    //Diffusion2ndRankTensor Diffusion2ndRankTensor;
+        
+        
+    /**
+     * SYMMETRIC SECOND RANK TENSOR
+     *
+     * The upper-right triangle of the matrix:
+     *
+     *       | 0  1  2  |
+     *       | X  3  4  |
+     *       | X  X  5  |
+     *
+     *       | xx  xy  xz  |
+     *       | X   yy  yz  |
+     *       | X   X   zz  |
+     */
+    /*
+      Diffusion2ndRankTensor = tensor[0];
+      Diffusion2ndRankTensor = tensor[1];
+      Diffusion2ndRankTensor = tensor[2];
+      Diffusion2ndRankTensor = tensor[3];
+      Diffusion2ndRankTensor = tensor[4];
+      Diffusion2ndRankTensor = tensor[5];
+    */
+    typename I::PixelType::EigenValuesArrayType    evalues;
+    typename I::PixelType::EigenVectorsMatrixType  evectors;
+        
+    /**
+     * Return an array containing EigenValues,
+     * and a matrix containing Eigenvectors.
+     */
+    tensor.ComputeEigenAnalysis(evalues, evectors);
+        
+    /*
+      std::cout << "[C-DIFFUSION - NRRD Tensors Example] Eigen values: " << evalues[0] << ", " << evalues[1] << ", " << evalues[2] << std::endl;
+      
+      std::cout << "[C-DIFFUSION - NRRD Tensors Example] Eigen vectors: "
+      
+      << "(" << evectors(0,0) << ", " << evectors(0,1) << ", " << evectors(0,2) << "), "
+      << "(" << evectors(1,0) << ", " << evectors(1,1) << ", " << evectors(1,2) << "), "
+      << "(" << evectors(2,0) << ", " << evectors(2,1) << ", " << evectors(2,2) << ")" << std::endl;
+    */
+    evectors.GetVnlMatrix().scale_row(0, evalues[0]);
+    evectors.GetVnlMatrix().scale_row(1, evalues[1]);
+    evectors.GetVnlMatrix().scale_row(2, evalues[2]);
+    
+    /*
+      std::cout << "[C-DIFFUSION - NRRD Tensors Example] Eigen values x Eigen vectors : "
+      
+      << "(" << evectors(0,0) << ", " << evectors(0,1) << ", " << evectors(0,2) << "), "
+      << "(" << evectors(1,0) << ", " << evectors(1,1) << ", " << evectors(1,2) << "), "
+      << "(" << evectors(2,0) << ", " << evectors(2,1) << ", " << evectors(2,2) << ")" << std::endl;
+    */
+    vtkTensors->InsertTuple9(
+      vtkPointID,
+      evectors(0,0), evectors(0,1), evectors(0,2),
+      evectors(1,0), evectors(1,1), evectors(1,2),
+      evectors(2,0), evectors(2,1), evectors(2,2)
+      );
+  } // rof
+    
+  polyData->SetPoints( points );
+  vtkSmartPointer<vtkPointData> pointData = polyData->GetPointData();
+  pointData->SetTensors( vtkTensors );
+  return( 1 );
+
+  /**
+   * VISUALISATION CODE BELOW
+   */
+  
+//    vtkSmartPointer<vtkCubeSource> cubeSource = vtkSmartPointer<vtkCubeSource>::New();
+//    cubeSource->Update();
+//
+//    vtkSmartPointer<vtkTensorGlyph> tensorGlyph = vtkSmartPointer<vtkTensorGlyph>::New();
+//#if VTK_MAJOR_VERSION <= 5
+//    tensorGlyph->SetInput(polyData);
+//#else
+//    tensorGlyph->SetInputData(polyData);
+//#endif
+//    tensorGlyph->SetSourceConnection(cubeSource->GetOutputPort());
+//    tensorGlyph->ColorGlyphsOff();
+//    tensorGlyph->ThreeGlyphsOff();
+//    tensorGlyph->ExtractEigenvaluesOff();
+//    tensorGlyph->Update();
+//    .
+//    .
+//    .
+
+}
+
+// -------------------------------------------------------------------------
+template class cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< itk::Image< itk::SymmetricSecondRankTensor< float, 3 >, 3 > >;
+template class cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< itk::Image< itk::SymmetricSecondRankTensor< double, 3 >, 3 > >;
+
+// eof - $RCSfile$
diff --git a/lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.h b/lib/cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.h
new file mode 100644 (file)
index 0000000..1861263
--- /dev/null
@@ -0,0 +1,53 @@
+// -------------------------------------------------------------------------
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// -------------------------------------------------------------------------
+
+#ifndef __CPEXTENSIONS__ALGORITHMS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__
+#define __CPEXTENSIONS__ALGORITHMS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__
+
+#include <cpExtensions/cpExtensions_Export.h>
+
+#include <vtkPolyDataAlgorithm.h>
+
+namespace cpExtensions
+{
+  namespace Algorithms
+  {
+    /**
+     */
+    template< class I >
+    class cpExtensions_EXPORT SecondRankDiffusionTensorToPolyData
+      : public vtkPolyDataAlgorithm
+    {
+    public:
+      typedef SecondRankDiffusionTensorToPolyData Self;
+
+    public:
+      static Self* New( );
+      vtkTypeMacro( SecondRankDiffusionTensorToPolyData, vtkPolyDataAlgorithm );
+
+      void SetInputData( const I* image );
+
+    protected:
+      SecondRankDiffusionTensorToPolyData( );
+      virtual ~SecondRankDiffusionTensorToPolyData( );
+
+      virtual int RequestData(
+        vtkInformation* , vtkInformationVector**, vtkInformationVector*
+        );
+
+    private:
+      SecondRankDiffusionTensorToPolyData( const Self& other );
+      Self& operator=( const Self& other );
+
+    protected:
+      typename I::ConstPointer m_ITKImage;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPEXTENSIONS__ALGORITHMS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__
+
+// eof - $RCSfile$
index b7ebc2455ed796e0a74f56b6da10945ca12d066d..43600a36652f70118740881889814558f19e27ae 100644 (file)
@@ -70,10 +70,7 @@ PushDataInto( vtkRenderer* x, vtkRenderer* y, vtkRenderer* z, vtkRenderer* w )
   } // rof
 
   if( w != NULL )
-  {
     w->AddActor( this->ImageOutlineActor );
-
-  } // fi
 }
 
 // -------------------------------------------------------------------------
index ab8d38a7f19688a324da95d9599c94d5667cca63..8fadae00bd0e3ff5c5d78e618ff933da14e09430 100644 (file)
@@ -124,6 +124,8 @@ cpPlugins_ImageArray_Export_AllDimensions(
 
 cpPlugins_Image_Export( itk::DiffusionTensor3D< float >, 3 );
 cpPlugins_Image_Export( itk::DiffusionTensor3D< double >, 3 );
+cpPlugins_Image_Export( itk::DiffusionTensor3D< float >, 4 );
+cpPlugins_Image_Export( itk::DiffusionTensor3D< double >, 4 );
 cpPlugins_Image_Export( itk::Offset< 2 >, 2 );
 cpPlugins_Image_Export( itk::Offset< 3 >, 3 );
 cpPlugins_Image_Export( itk::Offset< 4 >, 4 );
index 6f972d20a13b05543130671d004d1828eda59b09..d908e42381522f7b20c88317362cf6aaf677b418 100644 (file)
@@ -31,6 +31,7 @@ GENERATE_EXPORT_HEADER(
   )
 TARGET_LINK_LIBRARIES(
   ${LIBRARY_NAME}
+  cpExtensions
   cpPlugins_Interface
   )
 
index 81488ebbce8776de62b8e31004de6d291e6a1ee6..e07b5b0702a2ce5b0a029517830ee098a32a4cf1 100644 (file)
@@ -6,6 +6,7 @@
 #include <cpPlugins/Plugins/MarchingCubes.h>
 #include <cpPlugins/Plugins/OtsuThresholdImageFilter.h>
 #include <cpPlugins/Plugins/RGBImageToOtherChannelsFilter.h>
+#include <cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.h>
 
 /// TODO: doc
 PLUMA_CONNECTOR
@@ -20,6 +21,7 @@ bool connect( pluma::Host& host )
   host.add( new MarchingCubesProvider( ) );
   host.add( new OtsuThresholdImageFilterProvider( ) );
   host.add( new RGBImageToOtherChannelsFilterProvider( ) );
+  host.add( new SecondRankDiffusionTensorToPolyDataProvider( ) );
   return( true );
 }
 
index 25bdc7ae43280419528a881e3e252ccc0b75b13c..fc752efaafe5d8227b2be6f91e70bebd6ae2c452 100644 (file)
@@ -366,6 +366,21 @@ _GD0( itk::ImageIOBase* io, const TStringList& names )
         break;
       } // hctiws
     }
+    else if( D == 4 )
+    {
+      switch( ct )
+      {
+      case itk::ImageIOBase::FLOAT:
+        r = this->_RealGD< itk::DiffusionTensor3D< float >, 4 >( names );
+        break;
+      case itk::ImageIOBase::DOUBLE:
+        r = this->_RealGD< itk::DiffusionTensor3D< double >, 4 >( names );
+        break;
+      default:
+        r = "ImageReader: Diffusion tensor type not supported.";
+        break;
+      } // hctiws
+    }
     else
       r = "ImageReader: Diffusion tensor dimension not supported.";
   }
diff --git a/lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.cxx b/lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.cxx
new file mode 100644 (file)
index 0000000..47261cc
--- /dev/null
@@ -0,0 +1,82 @@
+#include <cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.h>
+#include <cpPlugins/Interface/Image.h>
+#include <cpPlugins/Interface/Mesh.h>
+
+#include <cpExtensions/Algorithms/SecondRankDiffusionTensorToPolyData.h>
+#include <itkSymmetricSecondRankTensor.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::Plugins::SecondRankDiffusionTensorToPolyData::
+SecondRankDiffusionTensorToPolyData( )
+  : Superclass( ),
+    m_Algorithm( NULL )
+{
+  this->m_ClassName = "cpPlugins::SecondRankDiffusionTensorToPolyData";
+  this->m_ClassCategory = "ImageToMeshFilter";
+
+  this->SetNumberOfInputs( 1 );
+  this->SetNumberOfOutputs( 1 );
+  this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
+
+  using namespace cpPlugins::Interface;
+  this->m_Parameters = this->m_DefaultParameters;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Plugins::SecondRankDiffusionTensorToPolyData::
+~SecondRankDiffusionTensorToPolyData( )
+{
+  if( this->m_Algorithm != NULL )
+    this->m_Algorithm->Delete( );
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Plugins::SecondRankDiffusionTensorToPolyData::
+_GenerateData( )
+{
+  // Get input
+  cpPlugins::Interface::Image* image =
+    this->_Input< cpPlugins::Interface::Image >( 0 );
+  if( image == NULL )
+    return( "SecondRankDiffusionTensorToPolyData: Input data is not a valid image." );
+
+  itk::DataObject* itk_image = NULL;
+  std::string r = "";
+  cpPlugins_ImageArray_Input_Demangle( itk::SymmetricSecondRankTensor, float, 3, 3, image, itk_image, r, _RealGD );
+  else cpPlugins_ImageArray_Input_Demangle( itk::SymmetricSecondRankTensor, double, 3, 3, image, itk_image, r, _RealGD );
+  else
+    r = "SecondRankDiffusionTensorToPolyData: Input does not have a DiffusionTensor3D.";
+  return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+std::string cpPlugins::Plugins::SecondRankDiffusionTensorToPolyData::
+_RealGD( itk::DataObject* image )
+{
+  typedef cpExtensions::Algorithms::SecondRankDiffusionTensorToPolyData< I > _F;
+
+  // Configure filter
+  _F* f = NULL;
+  if( this->m_Algorithm == NULL )
+  {
+    f = _F::New( );
+    this->m_Algorithm = f;
+
+  } // fi
+  f->SetInputData( dynamic_cast< I* >( image ) );
+  this->m_Algorithm->Update( );
+
+  // Connect output
+  cpPlugins::Interface::Mesh* out =
+    this->_Output< cpPlugins::Interface::Mesh >( 0 );
+  if( out != NULL )
+  {
+    out->SetVTKMesh( this->m_Algorithm->GetOutput( ) );
+    return( "" );
+  }
+  else
+    return( "OtsuThresholdImageFilter: output not correctly created." );
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.h b/lib/cpPlugins/Plugins/SecondRankDiffusionTensorToPolyData.h
new file mode 100644 (file)
index 0000000..ff03716
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef __CPPLUGINS__PLUGINS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__
+#define __CPPLUGINS__PLUGINS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__
+
+#include <cpPlugins/Plugins/cpPlugins_Export.h>
+#include <cpPlugins/Interface/BaseProcessObjects.h>
+
+class vtkPolyDataAlgorithm;
+
+namespace cpPlugins
+{
+  namespace Plugins
+  {
+    /**
+     */
+    class cpPlugins_EXPORT SecondRankDiffusionTensorToPolyData
+      : public cpPlugins::Interface::ImageToMeshFilter
+    {
+    public:
+      typedef SecondRankDiffusionTensorToPolyData     Self;
+      typedef cpPlugins::Interface::ImageToMeshFilter Superclass;
+      typedef itk::SmartPointer< Self >               Pointer;
+      typedef itk::SmartPointer< const Self >         ConstPointer;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( SecondRankDiffusionTensorToPolyData, cpPluginsInterfaceImageToMeshFilter );
+
+    protected:
+      SecondRankDiffusionTensorToPolyData( );
+      virtual ~SecondRankDiffusionTensorToPolyData( );
+
+      virtual std::string _GenerateData( );
+
+      template< class I >
+        inline std::string _RealGD( itk::DataObject* image );
+
+    private:
+      // Purposely not implemented
+      SecondRankDiffusionTensorToPolyData( const Self& );
+      Self& operator=( const Self& );
+
+    protected:
+      vtkPolyDataAlgorithm* m_Algorithm;
+    };
+
+    // ---------------------------------------------------------------------
+    CPPLUGINS_INHERIT_PROVIDER( SecondRankDiffusionTensorToPolyData );
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__PLUGINS__SECONDRANKDIFFUSIONTENSORTOPOLYDATA__H__
+
+// eof - $RCSfile$