]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/SkeletonToPolyDataFilter.hxx
...
[FrontAlgorithms.git] / lib / fpa / Image / SkeletonToPolyDataFilter.hxx
index 9468c4baf5debe3b728708c34965f3aab22aacb2..c9d1136e99f5d3aa8ad78321d2d5cb4a038d0ecf 100644 (file)
@@ -6,10 +6,14 @@
 #ifndef __fpa__Image__SkeletonToPolyDataFilter__hxx__
 #define __fpa__Image__SkeletonToPolyDataFilter__hxx__
 
-#include <vtkCellArray.h>
-#include <vtkInformation.h>
-#include <vtkInformationVector.h>
-#include <vtkSmartPointer.h>
+#ifdef USE_VTK
+#  include <vtkCellArray.h>
+#  include <vtkInformation.h>
+#  include <vtkInformationVector.h>
+#  include <vtkPointData.h>
+#  include <vtkUnsignedIntArray.h>
+#  include <vtkSmartPointer.h>
+#endif // USE_VTK
 
 // -------------------------------------------------------------------------
 template< class _TSkeleton >
@@ -38,7 +42,9 @@ SetInput( const TSkeleton* sk )
   if( this->m_Skeleton != sk )
   {
     this->m_Skeleton = sk;
+#ifdef USE_VTK
     this->Modified( );
+#endif // USE_VTK
 
   } // fi
 }
@@ -47,10 +53,14 @@ SetInput( const TSkeleton* sk )
 template< class _TSkeleton >
 fpa::Image::SkeletonToPolyDataFilter< _TSkeleton >::
 SkeletonToPolyDataFilter( )
+#ifdef USE_VTK
   : vtkPolyDataAlgorithm( ),
     m_Skeleton( NULL )
+#endif // USE_VTK
 {
+#ifdef USE_VTK
   this->SetNumberOfInputPorts( 0 );
+#endif // USE_VTK
 }
 
 // -------------------------------------------------------------------------
@@ -60,6 +70,7 @@ fpa::Image::SkeletonToPolyDataFilter< _TSkeleton >::
 {
 }
 
+#ifdef USE_VTK
 // -------------------------------------------------------------------------
 template< class _TSkeleton >
 int fpa::Image::SkeletonToPolyDataFilter< _TSkeleton >::
@@ -87,19 +98,24 @@ RequestData(
   out->SetLines( vtkSmartPointer< vtkCellArray >::New( ) );
   out->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) );
   out->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) );
+  vtkSmartPointer< vtkUnsignedIntArray > darray =
+    vtkSmartPointer< vtkUnsignedIntArray >::New( );
+  darray->SetNumberOfComponents( 1 );
+  out->GetPointData( )->SetScalars( darray );
   vtkPoints* points = out->GetPoints( );
   vtkCellArray* lines = out->GetLines( );
 
   // Assign all data
-  typename TMatrix::const_iterator  mIt = this->m_Skeleton->BeginEdgesRows( );
+  unsigned int dcount = 0;
+  typename TSkeleton::TMatrix::const_iterator  mIt = this->m_Skeleton->BeginEdgesRows( );
   for( ; mIt != this->m_Skeleton->EndEdgesRows( ); ++mIt )
   {
     // TODO: mIt->first; --> this is the row index. <--
-    typename TMatrixRow::const_iterator rIt = mIt->second.begin( );
+    typename TSkeleton::TMatrixRow::const_iterator rIt = mIt->second.begin( );
     for( ; rIt != mIt->second.end( ); ++rIt )
     {
       // TODO: rIt->first;  --> this is the column index.
-      typename TEdges::const_iterator eIt = rIt->second.begin( );
+      typename TSkeleton::TEdges::const_iterator eIt = rIt->second.begin( );
       for( ; eIt != rIt->second.end( ); ++eIt )
       {
         _TPath* path = *eIt;
@@ -112,6 +128,7 @@ RequestData(
             points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], 0 );
           else
             points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
+          darray->InsertNextTuple1( double( dcount ) );
           if( i > 0 )
           {
             lines->InsertNextCell( 2 );
@@ -121,6 +138,7 @@ RequestData(
           } // fi
 
         } // rof
+        dcount++;
 
       } // rof
 
@@ -141,6 +159,7 @@ RequestInformation(
 {
   return( 1 );
 }
+#endif // USE_VTK
 
 #endif // __fpa__Image__SkeletonToPolyDataFilterFilter__hxx__