]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Filters/Image/DefaultTraits.h
...
[FrontAlgorithms.git] / lib / fpa / Filters / Image / DefaultTraits.h
diff --git a/lib/fpa/Filters/Image/DefaultTraits.h b/lib/fpa/Filters/Image/DefaultTraits.h
new file mode 100644 (file)
index 0000000..27aaa3a
--- /dev/null
@@ -0,0 +1,94 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __fpa__Filters__Image__DefaultTraits__h__
+#define __fpa__Filters__Image__DefaultTraits__h__
+
+#include <set>
+#include <vector>
+#include <itkImage.h>
+#include <itkImageToImageFilter.h>
+#include <fpa/Filters/CollisionMarksInterface.h>
+#include <fpa/Filters/MultipleSeedsInterface.h>
+
+namespace fpa
+{
+  namespace Filters
+  {
+    namespace Image
+    {
+      /**
+       */
+      template< class _TInputImage, class _TOutputImage, class _TMark >
+      class DefaultTraits
+      {
+      public:
+        typedef _TInputImage  TInputImage;
+        typedef _TOutputImage TOutputImage;
+
+        /**
+         */
+        class TInternalTraits
+        {
+        public:
+          typedef _TMark TMark;
+          typedef typename TInputImage::IndexType  TVertex;
+          typedef typename TInputImage::PixelType  TInputValue;
+          typedef typename TInputImage::PointType  TPoint;
+          typedef typename TOutputImage::PixelType TOutputValue;
+          typedef typename TVertex::LexicographicCompare TVertexCompare;
+          itkStaticConstMacro(
+            Dimension, unsigned int, TInputImage::ImageDimension
+            );
+
+          typedef std::vector< TVertex > TNeighborhood;
+          struct TNode
+          {
+            TVertex Vertex;
+            TVertex Parent;
+            TMark   FrontId;
+
+            // Hack to hide the fact that nodes need to be (re-)initialized
+            mutable TOutputValue Value;
+          };
+          struct TNodeCompare
+          {
+            bool operator()( const TNode& a, const TNode& b ) const
+              {
+                static TVertexCompare c;
+                return( c( a.Vertex, b.Vertex ) );
+              }
+          };
+          typedef std::set< TNode, TNodeCompare > TNodes;
+
+          struct TSeed
+          {
+            TVertex Vertex;
+            TPoint  Point;
+            bool    IsPoint;
+            TMark   FrontId;
+            TSeed( const TMark& fid = 0 )
+              : FrontId( fid )
+              { }
+          };
+          typedef std::vector< TSeed > TSeeds;
+        };
+        itkStaticConstMacro(
+          Dimension, unsigned int, TInternalTraits::Dimension
+          );
+
+        typedef itk::Image< _TMark, TInternalTraits::Dimension >         TMarksImage;
+        typedef itk::ImageToImageFilter< TInputImage, TOutputImage >     TFilterInterface;
+        typedef fpa::Filters::CollisionMarksInterface< TInternalTraits > TMarksInterface;
+        typedef fpa::Filters::MultipleSeedsInterface< TInternalTraits >  TSeedsInterface;
+      };
+
+    } // ecapseman
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __fpa__Filters__Image__DefaultTraits__h__
+// eof - $RCSfile$