#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Core/Container/Buffer/SBfAcc3d.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2001, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVL_SBFACC3D_HEADER #define RAVL_SBFACC3D_HEADER 1 /////////////////////////////////////////////////////////// //! rcsid="$Id: SBfAcc3d.hh,v 1.5 2002/05/21 14:46:10 craftit Exp $" //! file="Ravl/Core/Container/Buffer/SBfAcc3d.hh" //! lib=RavlCore //! userlevel=Develop //! author="Charles Galambos" //! date="24/01/2001" //! docentry="Ravl.Core.Arrays.Buffer" #include "Ravl/SBfAcc.hh" #include "Ravl/SBfAcc2d.hh" #include "Ravl/Index3d.hh" #include "Ravl/BfAcc3Iter.hh" #include "Ravl/Types.hh" namespace RavlN { class BinOStreamC; class BinIStreamC; //! userlevel=Develop //: Access for 3D array. template class SizeBufferAccess3dC : public SizeBufferAccessC > > { public: SizeBufferAccess3dC() : size2(0), size3(0) {} //: Default constructor. SizeBufferAccess3dC(SizeT nsize2,SizeT nsize3) : size2(nsize2), size3(nsize3) {} //: Constructor. SizeBufferAccess3dC(const SizeBufferAccessC > > &ab,SizeT nsize2,SizeT nsize3) : SizeBufferAccessC > >(ab), size2(nsize2), size3(nsize3) {} //: Constructor. inline bool Contains(const Index3dC & i) const { return (((UIntT) i.K().V()) < size3) && (((UIntT) i.J().V()) < size2) && (((UIntT) i.I().V()) < Size1()); } //: Returns true if there is an item of the 3D array inline DataT & operator[](const Index3dC & i) { RavlAssertMsg((((UIntT) i.K().V()) < size3) && (((UIntT) i.J().V()) < size2),"Index out of range. "); return SizeBufferAccessC > >::operator[](i.I())[i.J()][i.K()]; } //: access to the item array[(i)] inline const DataT & operator[](const Index3dC & i) const { RavlAssertMsg((((UIntT) i.K().V()) < size3) && (((UIntT) i.J().V()) < size2),"Index out of range. "); return SizeBufferAccessC > >::operator[](i.I())[i.J()][i.K()]; } //: return the item array[(i)] inline SizeBufferAccess2dC operator[](IndexC i) { return SizeBufferAccess2dC(BufferAccessC > >::operator[](i), size2,size3); } //: access to the item array[(i)] inline const SizeBufferAccess2dC operator[](IndexC i) const { return SizeBufferAccess2dC(BufferAccessC > >::operator[](i), size2,size3); } //: return the item array[(i)] SizeT Size1() const { return SizeBufferAccessC > >::Size(); } //: Get size of dimension 1 SizeT Size2() const { return size2; } //: Get size of dimension 2 SizeT Size3() const { return size3; } //: Get size of dimension 3 UIntT Size() const { return Size1() * Size2() * Size3(); } //: Get the total number of elements in the array. void Fill(const DataT &d); //: Fill array with value. protected: SizeT size2; SizeT size3; }; template void SizeBufferAccess3dC::Fill(const DataT &d) { for(BufferAccess3dIterC it(*this,size2,size3);it;it++) *it = d; } } #endif