]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Tue, 24 Oct 2017 21:31:13 +0000 (16:31 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Tue, 24 Oct 2017 21:31:13 +0000 (16:31 -0500)
appli/CTArteries/CTArteries.cxx

index 282f66f604521007519297d82e640ace3a739a00..d7cc1cb450343c636329decf96e77bba3c998240 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <ivq/ITK/CPRImageFilter.h>
 #include <ivq/VTK/ImageActor.h>
+#include <ivq/VTK/ImageToFourierSeriesFilter.h>
 #include <ivq/VTK/ImageViewer.h>
 #include <ivq/VTK/MPRViewers.h>
 #include <ivq/VTK/PolyDataActor.h>
@@ -313,19 +314,6 @@ _prepareQuantification( )
     roi->SetInput( this->m_CPRSegmentation );
     roi->SetRegionOfInterest( slc_region );
 
-    /* TODO
-       slc_idx[ 2 ] = 1;
-       slc_size[ 2 ] = 0;
-       slc_region.SetIndex( slc_idx );
-       slc_region.SetSize( slc_size );
-       typedef itk::Image< TBinPixel, 2 > _TBinSlice;
-       typedef itk::ExtractImageFilter< TBinImage, _TBinSlice > _TCollapse;
-       _TCollapse::Pointer collapse = _TCollapse::New( );
-       collapse->SetInput( roi->GetOutput( ) );
-       collapse->SetDirectionCollapseToIdentity( );
-       collapse->SetExtractionRegion( slc_region );
-       collapse->UpdateLargestPossibleRegion( );
-    */
     typedef TScalarImage _TScalarSlice;
 
     typedef itk::ImageToVTKImageFilter< _TScalarSlice > _TVTKScalarSlice;
@@ -333,75 +321,26 @@ _prepareQuantification( )
     vtk_slice->SetInput( roi->GetOutput( ) );
     vtk_slice->Update( );
 
-    double r[ 2 ];
-    vtk_slice->GetOutput( )->GetScalarRange( r );
-
-    vtkSmartPointer< vtkMarchingSquares > ms =
-      vtkSmartPointer< vtkMarchingSquares >::New( );
-    ms->SetInputData( vtk_slice->GetOutput( ) );
-    ms->SetValue( 0, 0 );
-
-    vtkSmartPointer< vtkPolyDataConnectivityFilter > conn =
-      vtkSmartPointer< vtkPolyDataConnectivityFilter >::New( );
-    conn->SetInputConnection( ms->GetOutputPort( ) );
-    conn->SetExtractionModeToClosestPointRegion( );
-    conn->SetClosestPoint( 0, 0, 0 );
-    conn->Update( );
-
-    vtkSmartPointer< vtkPolyData > cnt = vtkSmartPointer< vtkPolyData >::New( );
-    cnt->DeepCopy( conn->GetOutput( ) );
-    this->m_Contours.push_back( cnt );
-
-    typedef itk::QuadEdgeMesh< double, 2 > _TQEMesh;
-    typedef _TQEMesh::PointType _T2DPoint;
-    typedef std::vector< _T2DPoint > _T2DPoints;
-    _T2DPoints points;
-    _TQEMesh::Pointer mesh = _TQEMesh::New( );
-    for( unsigned int i = 0; i < cnt->GetNumberOfPoints( ); ++i )
-    {
-      _T2DPoint pnt;
-      double p[ 3 ];
-      cnt->GetPoint( i, p );
-      pnt[ 0 ] = p[ 0 ];
-      pnt[ 1 ] = p[ 1 ];
-      mesh->AddPoint( pnt );
+    typedef ivq::VTK::ImageToFourierSeriesFilter< TFourier > _TFourierFilter;
+    vtkSmartPointer< _TFourierFilter > fFilter =
+      vtkSmartPointer< _TFourierFilter >::New( );
+    fFilter->SetInputData( vtk_slice->GetOutput( ) );
+    fFilter->SetContourValue( 0 );
+    fFilter->SetNumberOfHarmonics( 6 );
+    fFilter->Update( );
 
-    } // rof
-    vtkCellArray* lines = cnt->GetLines( );
-    lines->InitTraversal( );
-    vtkIdType* ids = new vtkIdType[ 2 ];
-    vtkIdType npts;
-    while( lines->GetNextCell( npts, ids ) != 0 )
-      mesh->AddEdge( ids[ 0 ], ids[ 1 ] );
-    delete ids;
-    _TQEMesh::QEPrimal* edge = mesh->GetEdge( );
-    if( edge != NULL )
-    {
-      mesh->AddFace( edge );
-      edge = mesh->GetEdge( );
-      for( auto eIt = edge->BeginGeomLnext( ); eIt != edge->EndGeomLnext( ); ++eIt )
-        points.push_back( mesh->GetPoint( *eIt ) );
-
-      TFourier f( points.begin( ), points.end( ), 6 );
-      f.SetOrderingToCounterClockWise( );
-      this->m_Fourier.push_back( f );
-    }
-    else
-    {
-      TFourier f( 6 );
-      f[ 1 ] = 0.1;
-      this->m_Fourier.push_back( f );
-
-    } // fi
+    this->m_Fourier.push_back( fFilter->GetOutput( ) );
 
-    vtkSmartPointer< ivq::VTK::PolyDataActor > actor =
-      vtkSmartPointer< ivq::VTK::PolyDataActor >::New( );
-    actor->SetInputData( cnt );
-    actor->GetMapper( )->ScalarVisibilityOff( );
-    actor->Update( );
-    actor->GetProperty( )->SetColor( 1, 0, 0 );
-    actor->GetProperty( )->SetLineWidth( 2 );
-    this->m_ContoursActors.push_back( actor );
+    /* TODO
+       vtkSmartPointer< ivq::VTK::PolyDataActor > actor =
+       vtkSmartPointer< ivq::VTK::PolyDataActor >::New( );
+       actor->SetInputData( cnt );
+       actor->GetMapper( )->ScalarVisibilityOff( );
+       actor->Update( );
+       actor->GetProperty( )->SetColor( 1, 0, 0 );
+       actor->GetProperty( )->SetLineWidth( 2 );
+       this->m_ContoursActors.push_back( actor );
+    */
 
   } // rof
 
@@ -442,9 +381,9 @@ _prepareQuantification( )
   double data[ 3 ];
   for( unsigned int i = 0; i < this->m_Fourier.size( ); ++i )
   {
-    double a, b, t, p;
+    TScalar a, b, t, p;
     this->m_Fourier[ i ].GetEllipse( 1, a, b, t, p );
-    double area = this->m_Fourier[ i ].GetArea( );
+    TScalar area = this->m_Fourier[ i ].GetArea( );
 
     xdata.push_back( double( i ) );
     dmindata.push_back( b );
@@ -584,12 +523,12 @@ _showStenosis( )
   if( this->m_StenosisSlice < 0 || this->m_ReferenceSlice < 0 )
     return;
 
-  double sa, sb, st, sp;
+  TScalar sa, sb, st, sp;
   this->m_Fourier[ this->m_StenosisSlice ].GetEllipse( 1, sa, sb, st, sp );
-  double sarea = this->m_Fourier[ this->m_StenosisSlice ].GetArea( );
-  double ra, rb, rt, rp;
+  TScalar sarea = this->m_Fourier[ this->m_StenosisSlice ].GetArea( );
+  TScalar ra, rb, rt, rp;
   this->m_Fourier[ this->m_ReferenceSlice ].GetEllipse( 1, ra, rb, rt, rp );
-  double rarea = this->m_Fourier[ this->m_ReferenceSlice ].GetArea( );
+  TScalar rarea = this->m_Fourier[ this->m_ReferenceSlice ].GetArea( );
   double qmin = 100.0 * ( 1.0 - ( sb / rb ) );
   double qmax = 100.0 * ( 1.0 - ( sa / ra ) );
   double qarea = 100.0 * ( 1.0 - ( sarea / rarea ) );
@@ -739,9 +678,9 @@ _sSaveResults( )
   out << "slice;min_diameter;max_diameter;area" << std::endl;
   for( unsigned int i = 0; i < this->m_Fourier.size( ); ++i )
   {
-    double a, b, t, p;
+    TScalar a, b, t, p;
     this->m_Fourier[ i ].GetEllipse( 1, a, b, t, p );
-    double area = this->m_Fourier[ i ].GetArea( );
+    TScalar area = this->m_Fourier[ i ].GetArea( );
     out << i << ";" << b << ";" << a << ";" << area << std::endl;
 
   } // rof