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: 2004/12/04 13:17:09 $
00007   Version:   $Revision: 1.15 $
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 
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:
00043 
00047   typedef FEMPArray Self;
00048 
00052   typedef std::vector<FEMP<T> > Superclass;
00053 
00057   typedef Self* Pointer;
00058   typedef const Self* ConstPointer;
00059 
00063   typedef T ClassType;
00064   typedef typename ClassType::Pointer ClassTypePointer;
00065   typedef typename ClassType::ConstPointer ClassTypeConstPointer;
00066 
00070   ClassTypePointer Find(int gn);
00071   ClassTypeConstPointer Find(int gn) const;
00073 
00077   ClassTypePointer operator() (int i) 
00078   {
00079     return &(*this->operator[](i));
00080   }
00081 
00086   ClassTypeConstPointer operator() (int i) const 
00087   {  
00088     return &(*this->operator[](i));
00089   }
00090 
00091 
00097   int Renumber();
00098 
00099 };
00100 
00101 
00102 
00106 template<class T>
00107 typename FEMPArray<T>::ClassTypePointer 
00108 FEMPArray<T>::Find(int gn)
00109 {
00110 
00111   typedef typename Superclass::iterator Iterator;
00112 
00113   Iterator it   = this->begin(); 
00114   Iterator iend = this->end();
00115   while( it != iend )
00116     {
00117     if( (*it)->GN == gn )
00118       {
00119       break;
00120       }
00121     it++;
00122     }  
00123 
00124   if( it == this->end() )
00125     {
00129     throw FEMExceptionObjectNotFound(__FILE__,__LINE__,"FEMPArray::Find() const",typeid(T).name(),gn);
00130     }
00131 
00135   return &(*(*it));
00136 
00137 }
00138 
00139 
00140 
00141 
00145 template<class T>
00146 typename FEMPArray<T>::ClassTypeConstPointer 
00147 FEMPArray<T>::Find( int gn ) const
00148 {
00149 
00150   typedef typename Superclass::const_iterator ConstIterator;
00151 
00152   ConstIterator it   = this->begin(); 
00153   ConstIterator iend = this->end();
00154   while( it != iend )
00155     {
00156     if( (*it)->GN == gn )
00157       {
00158       break;
00159       }
00160     it++;
00161     }  
00162 
00163   if( it == this->end() )
00164     {
00168     throw FEMExceptionObjectNotFound(__FILE__,__LINE__,"FEMPArray::Find() const",typeid(T).name(),gn);
00169     }
00170 
00174   return &(*(*it));
00175 
00176 }
00177 
00178 
00179 
00180 
00181 template<class T>
00182 int FEMPArray<T>::Renumber() 
00183 {
00184 
00185   typename Superclass::iterator i;
00186   int j=0;
00187 
00188   for(i=this->begin(); i!=this->end(); i++)
00189   {
00190     (*i)->GN=j;
00191     j++;
00192   }
00193 
00194   return j;
00195 
00196 }
00197 
00198 
00199 
00200 
00201 }} // end namespace itk::fem
00202 
00203 #endif // #ifndef __itkFEMPArray_h
00204 

Generated at Mon Mar 12 00:17:38 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000