]> Creatis software - FrontAlgorithms.git/blobdiff - appli/CTBronchi/Skeleton.hxx
...
[FrontAlgorithms.git] / appli / CTBronchi / Skeleton.hxx
diff --git a/appli/CTBronchi/Skeleton.hxx b/appli/CTBronchi/Skeleton.hxx
new file mode 100644 (file)
index 0000000..2b293e5
--- /dev/null
@@ -0,0 +1,130 @@
+// =========================================================================
+// @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
+// =========================================================================
+#ifndef __CTBronchi__Skeleton__hxx__
+#define __CTBronchi__Skeleton__hxx__
+
+#include "Filter.h"
+#include <ivq/ITK/ImageSkeletonReader.h>
+#include <ivq/ITK/ImageSkeletonWriter.h>
+
+// -------------------------------------------------------------------------
+template< unsigned int _VDim >
+CTBronchi::Skeleton< _VDim >::
+Skeleton( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int _VDim >
+CTBronchi::Skeleton< _VDim >::
+~Skeleton( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int _VDim >
+bool CTBronchi::Skeleton< _VDim >::
+IsNotNull( ) const
+{
+  return( this->m_Skeleton.IsNotNull( ) );
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int _VDim >
+bool CTBronchi::Skeleton< _VDim >::
+IsNull( ) const
+{
+  return( this->m_Skeleton.IsNull( ) );
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int _VDim >
+typename CTBronchi::Skeleton< _VDim >::
+TSkeleton* CTBronchi::Skeleton< _VDim >::
+Get( )
+{
+  return( this->m_Skeleton.GetPointer( ) );
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int _VDim >
+const typename CTBronchi::Skeleton< _VDim >::
+TSkeleton* CTBronchi::Skeleton< _VDim >::
+Get( ) const
+{
+  return( this->m_Skeleton.GetPointer( ) );
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int _VDim >
+void CTBronchi::Skeleton< _VDim >::
+Set( TSkeleton* sk )
+{
+  this->m_Skeleton = sk;
+  /* TODO
+     if( this->m_Skeleton.IsNotNull( ) )
+     this->m_Skeleton->DisconnectPipeline( );
+  */
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int _VDim >
+void CTBronchi::Skeleton< _VDim >::
+Set( const typename TSkeleton::Pointer& sk )
+{
+  this->m_Skeleton = sk.GetPointer( );
+  /* TODO
+     if( this->m_Skeleton.IsNotNull( ) )
+     this->m_Skeleton->DisconnectPipeline( );
+  */
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int _VDim >
+double CTBronchi::Skeleton< _VDim >::
+Load( const std::string& fname )
+{
+  typedef CTBronchi::Filter< ivq::ITK::ImageSkeletonReader< TSkeleton > > _TReader;
+  _TReader r;
+  r.Get( )->SetFileName( fname );
+  try
+  {
+    double t = r.Update( );
+    this->Set( r.Get( )->GetOutput( ) );
+    return( t );
+  }
+  catch( ... )
+  {
+    this->Set( NULL );
+    return( -1 );
+
+  } // yrt
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int _VDim >
+double CTBronchi::Skeleton< _VDim >::
+Save( const std::string& fname )
+{
+  typedef CTBronchi::Filter< ivq::ITK::ImageSkeletonWriter< TSkeleton > > _TWriter;
+
+  double t = -1;
+  if( this->IsNotNull( ) )
+  {
+    _TWriter w;
+    w.Get( )->SetFileName( fname );
+    w.Get( )->SetInput( this->m_Skeleton );
+    try
+    {
+      t = w.Update( );
+    }
+    catch( ... ) { }
+
+  } // fi
+  return( t );
+}
+
+#endif // __CTBronchi__Skeleton__hxx__
+
+// eof - $RCSfile$