Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

TalkNgbP1Cnum.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Array_Trait_TalkNgbP1Cnum_h
00002 #define Impala_Core_Array_Trait_TalkNgbP1Cnum_h
00003 
00004 #include "Core/Array/Pattern/Categories.h"
00005 #include "Core/Array/Pattern/Cnum.h"
00006 #include "Core/Array/Element/E1Cast.h"
00007 
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Array
00013 {
00014 namespace Trait
00015 {
00016 
00017 
00020 template<class DstArrayT, class SrcArrayT>
00021 class TalkNgbP1Cnum
00022 {
00023 public:
00024 
00026     typedef Pattern::TagCnum IteratorCategory;
00027 
00029     typedef Pattern::Tag1Phase PhaseCategory;
00030 
00032     typedef Pattern::Cnum CnumType;
00033 
00034     typedef typename DstArrayT::StorType DstStorType;
00035     typedef typename DstArrayT::ArithType DstArithType;
00036     typedef typename SrcArrayT::StorType SrcStorType;
00037     typedef typename SrcArrayT::ArithType SrcArithType;
00038 
00040     TalkNgbP1Cnum(bool verbose)
00041     {
00042         mVerbose = verbose;
00043     }
00044 
00046     int
00047     Width()
00048     {
00049         return 3;
00050     }
00051 
00053     int
00054     Height()
00055     {
00056         return 3;
00057     }
00058 
00060     CnumType
00061     Begin()
00062     {
00063         return mBegin;
00064     }
00065 
00067     CnumType&
00068     End()
00069     {
00070         return mEnd;
00071     }
00072 
00074     void
00075     Init(int x, int y, const SrcArithType& value)
00076     {
00077         if (mVerbose)
00078             std::cout << "  TalkNgbP1Cnum::init(" << x << "," << y << ","
00079                       << value << ") " << std::endl;
00080         mBegin = CnumType(&mCoordPairs[0]);
00081         mEnd = CnumType(&mCoordPairs[8]);
00082         mResult = Element::E1Cast(0, DstArithType());
00083     }
00084 
00086     void
00087     NextEl(int x, int y, const SrcArithType& value)
00088     {
00089         if (mVerbose)
00090             std::cout << "      TalkNgbP1Cnum::next(" << x << "," << y << ","
00091                       << value << ") " << std::endl;
00092         mResult += value;
00093     }
00094 
00096     DstArithType
00097     Result() const
00098     {
00099         return mResult;
00100     }
00101 
00102 private:
00103     SrcArithType   mResult;
00104     bool           mVerbose;
00105     CnumType       mBegin;
00106     CnumType       mEnd;
00107     static Pattern::Coord mCoordPairs[8];
00108 };
00109 
00110 
00111 template<class DstArrayT, class SrcArrayT>
00112 Pattern::Coord TalkNgbP1Cnum<DstArrayT,SrcArrayT>::mCoordPairs[8] = 
00113 {
00114     { -1, -1 },
00115     {  0, -1 },
00116     {  1, -1 },
00117     {  1,  0 },
00118     {  1,  1 },
00119     {  0,  1 },
00120     { -1,  1 },
00121     {  0, -1 }
00122 };
00123 
00124 } // namespace Trait
00125 } // namespace Array
00126 } // namespace Core
00127 } // namespace Impala
00128 
00129 #endif

Generated on Fri Mar 19 09:31:01 2010 for ImpalaSrc by  doxygen 1.5.1