]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Filters/SingleSeedInterface.hxx
...
[FrontAlgorithms.git] / lib / fpa / Filters / SingleSeedInterface.hxx
diff --git a/lib/fpa/Filters/SingleSeedInterface.hxx b/lib/fpa/Filters/SingleSeedInterface.hxx
new file mode 100644 (file)
index 0000000..25acc2b
--- /dev/null
@@ -0,0 +1,73 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __fpa__Filters__SingleSeedInterface__hxx__
+#define __fpa__Filters__SingleSeedInterface__hxx__
+
+#include <itkImageBase.h>
+
+// -------------------------------------------------------------------------
+template< class _TTraits >
+void fpa::Filters::SingleSeedInterface< _TTraits >::
+SetSeed( const TPoint& s )
+{
+  this->m_InputSeed.Point = s;
+  this->m_InputSeed.IsPoint = true;
+  if( this->m_Filter.IsNotNull( ) )
+    this->m_Filter->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TTraits >
+void fpa::Filters::SingleSeedInterface< _TTraits >::
+SetSeed( const TVertex& s )
+{
+  this->m_InputSeed.Vertex = s;
+  this->m_InputSeed.IsPoint = false;
+  if( this->m_Filter.IsNotNull( ) )
+    this->m_Filter->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TTraits >
+fpa::Filters::SingleSeedInterface< _TTraits >::
+SingleSeedInterface( itk::ProcessObject* f )
+  : Superclass( f )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TTraits >
+fpa::Filters::SingleSeedInterface< _TTraits >::
+~SingleSeedInterface( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TTraits >
+void fpa::Filters::SingleSeedInterface< _TTraits >::
+_PrepareSeeds( const itk::DataObject* reference )
+{
+  // Input object is an image?
+  typedef itk::ImageBase< TTraits::Dimension > _TImageBase;
+  const _TImageBase* image =
+    dynamic_cast< const _TImageBase* >( reference );
+  if( image != NULL )
+  {
+    this->m_UnifiedSeeds.clear( );
+    if( this->m_InputSeed.IsPoint )
+      image->TransformPhysicalPointToIndex(
+        this->m_InputSeed.Point, this->m_InputSeed.Vertex
+        );
+    TNode node;
+    node.Vertex = this->m_InputSeed.Vertex;
+    node.Parent = this->m_InputSeed.Vertex;
+    node.FrontId = this->m_InputSeed.FrontId;
+    this->m_UnifiedSeeds.insert( node );
+
+  } // fi
+}
+
+#endif // __fpa__Filters__SingleSeedInterface__hxx__
+// eof - $RCSfile$