]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/SingleSeedInterface.h
...
[FrontAlgorithms.git] / lib / fpa / Base / SingleSeedInterface.h
diff --git a/lib/fpa/Base/SingleSeedInterface.h b/lib/fpa/Base/SingleSeedInterface.h
new file mode 100644 (file)
index 0000000..dc45fe9
--- /dev/null
@@ -0,0 +1,101 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+
+#ifndef __fpa__Base__SingleSeedInterface__h__
+#define __fpa__Base__SingleSeedInterface__h__
+
+#include <functional>
+#include <set>
+#include <vector>
+
+#include <itkConceptChecking.h>
+#include <itkProcessObject.h>
+
+namespace fpa
+{
+  namespace Base
+  {
+    /**
+     */
+    template< class _TVertex, class _TPoint, class _TInputValue, class _TOutputValue, class _TFrontId, class _TCompare = std::greater< _TVertex > >
+    class SingleSeedInterface
+    {
+    public:
+      itkConceptMacro(
+        Check_TFrontId,
+        ( itk::Concept::IsUnsignedInteger< _TFrontId > )
+        );
+
+    public:
+      typedef _TVertex       TVertex;
+      typedef _TPoint        TPoint;
+      typedef _TInputValue   TInputValue;
+      typedef _TOutputValue  TOutputValue;
+      typedef _TFrontId      TFrontId;
+      typedef _TCompare      TCompare;
+      typedef SingleSeedInterface Self;
+
+      struct TSeed
+      {
+        TVertex  Vertex;
+        TPoint   Point;
+        bool     IsPoint;
+        bool     IsUnified;
+        TFrontId FrontId;
+        TSeed( )
+          : IsUnified( false ),
+            FrontId( TFrontId( 0 ) )
+          { }
+      };
+      typedef std::vector< TSeed > TSeeds;
+
+      struct TNode
+      {
+        TVertex  Vertex;
+        TVertex  Parent;
+        TFrontId FrontId;
+
+        // Hack to hide the fact that seed values need to be initialized
+        mutable TOutputValue Value;
+      };
+      struct TNodeCompare
+      {
+        bool operator()( const TNode& a, const TNode& b ) const
+          {
+            TCompare cmp;
+            return( cmp( a.Vertex, b.Vertex ) );
+          }
+      };
+      typedef std::set< TNode, TNodeCompare > TNodes;
+
+    public:
+      const TSeeds& GetSeeds( ) const;
+
+      virtual void SetSeed( const TVertex& seed );
+      virtual void SetSeed( const TPoint& seed );
+
+    protected:
+      SingleSeedInterface( itk::ProcessObject* filter );
+      virtual ~SingleSeedInterface( );
+
+      virtual TNodes _UnifySeeds( ) = 0;
+      virtual void _PrepareSeeds( TNodes& nodes ) = 0;
+
+    protected:
+      TSeeds m_Seeds;
+      itk::ProcessObject* m_Filter;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Base/SingleSeedInterface.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __fpa__Base__SingleSeedInterface__h__
+
+// eof - $RCSfile$