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

itkFEMPArray.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkFEMPArray.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/07/21 22:18:08 $
00007   Version:   $Revision: 1.10 $
00008 
00009   Copyright (c) 2002 Insight 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 
00018 #ifndef __itkFEMPArray_h
00019 #define __itkFEMPArray_h
00020 
00021 #include "itkFEMP.h"
00022 #include "itkFEMException.h"
00023 #include <vector>
00024 
00025 namespace itk {
00026 namespace fem {
00027 
00028 
00029 
00030 
00039 template<class T>
00040 class FEMPArray : public std::vector<FEMP<T> >
00041 {
00042 public:
00046   typedef FEMPArray Self;
00047 
00051   typedef std::vector<FEMP<T> > Superclass;
00052 
00056   typedef Self* Pointer;
00057   typedef const Self* ConstPointer;
00058 
00062   typedef T ClassType;
00063   typedef typename ClassType::Pointer ClassTypePointer;
00064   typedef typename ClassType::ConstPointer ClassTypeConstPointer;
00065 
00069   ClassTypePointer Find(int gn);
00070   ClassTypeConstPointer Find(int gn) const;
00071 
00075   ClassTypePointer operator() (int i) 
00076   {
00077     return &(*operator[](i));
00078   }
00079 
00084   ClassTypeConstPointer operator() (int i) const 
00085   {  
00086     return &(*operator[](i));
00087   }
00088 
00089 
00095   int Renumber();
00096 
00097 };
00098 
00099 
00100 
00104 template<class T>
00105 typename FEMPArray<T>::ClassTypePointer FEMPArray<T>::Find(int gn)
00106 {
00107 
00108   typename Superclass::iterator i;
00109 
00114   if( gn<0 ||
00115       gn>=(int)size() ||
00116       ( *( i=static_cast<typename Superclass::iterator>(&this->operator[](gn)) ) )->GN!=gn )
00117   {
00121     for(i=begin(); i!=end() && (*i)->GN!=gn; i++);
00122 
00126     if(i==end())
00127     {
00128       throw FEMExceptionObjectNotFound(__FILE__,__LINE__,"FEMPArray::Find()",typeid(T).name(),gn);
00129     }
00130   }
00131 
00135   return &(*(*i));
00136 
00137 }
00138 
00139 
00140 
00141 
00145 template<class T>
00146 typename FEMPArray<T>::ClassTypeConstPointer FEMPArray<T>::Find(int gn) const
00147 {
00148 
00149   typename Superclass::const_iterator i;
00150 
00151   if( gn<0 ||
00152       gn>=(int)size() ||
00153       ( *( i=static_cast<typename Superclass::const_iterator>(&this->operator[](gn)) ) )->GN!=gn )
00154   {
00155     for(i=begin(); i!=end() && (*i)->GN!=gn; i++);
00156     if(i==end())
00157     {
00158       throw FEMExceptionObjectNotFound(__FILE__,__LINE__,"FEMPArray::Find() const",typeid(T).name(),gn);
00159     }
00160 
00161   }
00162 
00163   return &(*(*i));
00164 
00165 }
00166 
00167 
00168 
00169 
00170 template<class T>
00171 int FEMPArray<T>::Renumber() 
00172 {
00173 
00174   typename Superclass::iterator i;
00175   int j=0;
00176 
00177   for(i=begin(); i!=end(); i++)
00178   {
00179     (*i)->GN=j;
00180     j++;
00181   }
00182 
00183   return j;
00184 
00185 }
00186 
00187 
00188 
00189 
00190 }} // end namespace itk::fem
00191 
00192 #endif // #ifndef __itkFEMPArray_h

Generated at Wed Mar 12 01:12:56 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000