Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkValarrayImageContainer.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkValarrayImageContainer.h,v $
00005   Language:  C++
00006   Date:      $Date: 2004/07/22 01:35:48 $
00007   Version:   $Revision: 1.13 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkValarrayImageContainer_h
00018 #define __itkValarrayImageContainer_h
00019 
00020 #include "itkObject.h"
00021 #include "itkObjectFactory.h"
00022 
00023 #include <utility>
00024 #include <valarray>
00025 
00026 namespace itk
00027 {
00028 
00046 template <
00047   typename TElementIdentifier,
00048   typename TElement
00049   >
00050 class ValarrayImageContainer: 
00051   public Object,
00052   private std::valarray<TElement>
00053 {
00054 public:
00056   typedef ValarrayImageContainer     Self;
00057   typedef Object  Superclass;
00058   typedef SmartPointer<Self>  Pointer;
00059   typedef SmartPointer<const Self>  ConstPointer;
00060 
00062   typedef TElementIdentifier  ElementIdentifier;
00063   typedef TElement            Element;
00064 
00065 private:
00067   typedef std::valarray<Element>  ValarrayType;
00068 
00069 protected:
00074   ValarrayImageContainer():
00075     ValarrayType() {}
00076   ValarrayImageContainer(unsigned long n):
00077     ValarrayType(n) {}
00078   ValarrayImageContainer(unsigned long n, const Element& x):
00079     ValarrayType(n, x) {}
00080   ValarrayImageContainer(const Self& r):
00081     ValarrayType(r) {}
00083 
00084 public:
00086   itkNewMacro(Self);
00087 
00089   itkTypeMacro(ValarrayImageContainer, Object);
00090 
00092   TElement & operator[](const ElementIdentifier id)
00093     { return this->ValarrayType::operator[](id); };
00094 
00096   const TElement & operator[](const ElementIdentifier id) const
00097     { return this->ValarrayType::operator[](id); };
00098 
00101   TElement *GetBufferPointer()
00102     { return &(this->ValarrayType::operator[](0)); };
00103 
00105   unsigned long Size(void) const
00106     { return static_cast<unsigned long>(this->ValarrayType::size()); };
00107 
00112   void Reserve(ElementIdentifier num)
00113     { this->ValarrayType::resize(num); };
00114 
00118   void Squeeze(void)
00119     { this->ValarrayType::resize( this->ValarrayType::size() ); };
00120 
00122   void Initialize(void)
00123     { this->ValarrayType::resize( 0 ); };
00124 
00126   void Fill(const TElement & value)
00127     { this->ValarrayType::operator=( value ); };
00128 
00129 public:
00133   virtual void PrintSelf(std::ostream& os, Indent indent) const
00134   {
00135     Object::PrintSelf(os, indent);
00136     // Print out the pointer to bulk data memory. We use const_cast<> to
00137     // cast away the constness so we can call GetBufferPointer()
00138     os << indent << "Pointer: "
00139        << const_cast<ValarrayImageContainer*>(this)->GetBufferPointer()
00140        << std::endl;
00142 
00143     os << indent << "Size: " << this->Size() << std::endl;
00144   };
00145   
00146 };
00147 
00148 } // end namespace itk
00149   
00150 #endif
00151 

Generated at Mon Mar 12 03:15:46 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000