SourceMixed.h

Go to the documentation of this file.
00001 #ifndef __SOURCEMIXED_H__
00002 #define __SOURCEMIXED_H__
00003 
00004 // $Id$
00005 
00006 #include "Source.h"
00007 #include "Registry.h"
00008 #include "libRefCount.h"
00009 
00010 #undef DEBUG 
00011 #define DEBUG 0
00012 #include "libDebug.h"
00013 
00014 template<class DATA, int DIMENSIONALITY, class PRECISION, class SOURCE1,
00015     class SOURCE2>
00016 class SourceMixedOf: public SourceOf<DATA, DIMENSIONALITY, PRECISION>
00017 {
00018 protected:
00019   SOURCE1* m_psource1;
00020   SOURCE2* m_psource2;
00021   mutable PointOf<DIMENSIONALITY, PRECISION> m_ptSize;
00022 
00023 protected:
00024   SourceMixedOf() :
00025     SourceOf<DATA, DIMENSIONALITY, PRECISION> (), m_psource1(NULL), m_psource2(
00026         NULL)
00027 
00028   {
00029   }
00030 
00031   SourceMixedOf(SourceMixedOf<DATA, DIMENSIONALITY, PRECISION, SOURCE1, SOURCE2>&src) :
00032     SourceOf<DATA, DIMENSIONALITY, PRECISION> (src)
00033   {
00034     m_psource1 = src.m_psource1;
00035     ClaimPointer(m_psource1);
00036     m_psource2 = src.m_psource2;
00037     ClaimPointer(m_psource2);
00038   }
00039 
00040   virtual ~SourceMixedOf()
00041   {
00042     ReleasePointer(m_psource1);
00043     ReleasePointer(m_psource2);
00044   }
00045 
00046 public:
00047 
00048   SOURCE1* PSource1()
00049   {
00050     return m_psource1;
00051   }
00052 
00053   const SOURCE1* PSource1() const
00054   {
00055     return m_psource1;
00056   }
00057 
00058   SOURCE2* PSource2()
00059   {
00060     return m_psource2;
00061   }
00062 
00063   const SOURCE2* PSource2() const
00064   {
00065     return m_psource2;
00066   }
00067 
00068   void SetSources(SOURCE1* psource1, SOURCE2* psource2)
00069   {
00070     ChangePointer(m_psource1, psource1);
00071     ChangePointer(m_psource2, psource2);
00072   }
00073 
00074   void WipeSource()
00075   {
00076     m_psource1 = NULL;
00077     m_psource2 = NULL;
00078   }
00079 
00080   virtual String Describe() const
00081   {
00082     return (_LINE + "SourceMixedOf(" + DIMENSIONALITY + "D)" + LINE_
00083         + this->DescribeCommon());
00084   }
00085 
00086   virtual String DescribeCommon() const
00087   {
00088     return _INDENT + (_LINE + "size: " + this->Size().Describe() + LINE_
00089         + (_INDENT + "source 1:" + LINE_ + this->m_psource1->Describe()
00090             + this->m_psource2->Describe()));
00091   }
00092 
00093   virtual void RegisterParameters(RegistryOfParameters& reg)
00094   {
00095   }
00096 
00097   virtual void RegisterDataAsParameters(RegistryOfParameters& reg)
00098   {
00099   }
00100 
00101   const PointOf<DIMENSIONALITY, PRECISION>& Size() const
00102   {
00103     return m_ptSize;
00104   }
00105 
00106   virtual PointOf<DIMENSIONALITY, PRECISION> Bound(const PointOf<
00107       DIMENSIONALITY, PRECISION>& pt) const
00108   {
00109     return pt.Bound(PointOf<DIMENSIONALITY, PRECISION> (PRECISION(0)),
00110         this->Size());
00111   }
00112 
00113   virtual void PrepareForAccessAction() const
00114   {
00115     this->m_ptSize = this->PSource1()->Size();
00116   }
00117 
00118   virtual void PrepareForAccess() const
00119   {
00120     // tell sources to prepare first
00121     m_psource1->PrepareForAccess();
00122     m_psource2->PrepareForAccess();
00123 
00124     // the call the specific mixed's AccessPreparation function
00125     this->PrepareForAccessAction();
00126   }
00127 
00128 };
00129 
00130 template<class DATA, class PRECISION, class SOURCE1, class SOURCE2>
00131 inline void Get(const SourceMixedOf<DATA, 3, PRECISION, SOURCE1, SOURCE2>& src, DATA& dataOut, const PRECISION& nX, const PRECISION& nY)
00132 {
00133   src.VirtualGet(dataOut, nX, nY);
00134 }
00135 
00136 template<class DATA, class PRECISION, class SOURCE1, class SOURCE2>
00137 inline void Set(SourceMixedOf<DATA, 3, PRECISION, SOURCE1, SOURCE2>& src, const PRECISION& nX, const PRECISION& nY, const DATA& data)
00138 {
00139   src.VirtualSet(nX, nY, data);
00140 }
00141 
00142 template<class DATA, class PRECISION, class SOURCE1, class SOURCE2>
00143 inline void Get(const SourceMixedOf<DATA, 3, PRECISION, SOURCE1, SOURCE2>& src, DATA& dataOut, const PRECISION& nX, const PRECISION& nY, const PRECISION& nZ)
00144 {
00145   src.VirtualGet(dataOut, nX, nY, nZ);
00146 }
00147 
00148 template<class DATA, class PRECISION, class SOURCE1, class SOURCE2>
00149 inline void Set(SourceMixedOf<DATA, 3, PRECISION, SOURCE1, SOURCE2>& src, const PRECISION& nX, const PRECISION& nY, const PRECISION& nZ, const DATA& data)
00150 {
00151   src.VirtualSet(nX, nY, nZ, data);
00152 }
00153 
00154 #endif // __SOURCEMIXED_H__

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1