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: 2009-01-30 21:53:03 $
00007   Version:   $Revision: 1.16 $
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 
00036 template<class T>
00037 class FEMPArray : public std::vector<FEMP<T> >
00038 {
00039 public:
00040 
00044   typedef FEMPArray Self;
00045 
00049   typedef std::vector<FEMP<T> > Superclass;
00050 
00054   typedef Self*       Pointer;
00055   typedef const Self* ConstPointer;
00056 
00060   typedef T                                ClassType;
00061   typedef typename ClassType::Pointer      ClassTypePointer;
00062   typedef typename ClassType::ConstPointer ClassTypeConstPointer;
00063 
00067   ClassTypePointer Find(int gn);
00068   ClassTypeConstPointer Find(int gn) const;
00070 
00074   ClassTypePointer operator() (int i) 
00075     {
00076     return &(*this->operator[](i));
00077     }
00078 
00083   ClassTypeConstPointer operator() (int i) const 
00084     {  
00085     return &(*this->operator[](i));
00086     }
00087 
00088 
00094   int Renumber();
00095 
00096 };
00097 
00101 template<class T>
00102 typename FEMPArray<T>::ClassTypePointer 
00103 FEMPArray<T>::Find(int gn)
00104 {
00105 
00106   typedef typename Superclass::iterator Iterator;
00107 
00108   Iterator it   = this->begin(); 
00109   Iterator iend = this->end();
00110   while( it != iend )
00111     {
00112     if( (*it)->GN == gn )
00113       {
00114       break;
00115       }
00116     it++;
00117     }  
00118 
00119   if( it == this->end() )
00120     {
00124     throw FEMExceptionObjectNotFound(__FILE__,__LINE__,"FEMPArray::Find() const",typeid(T).name(),gn);
00125     }
00126 
00130   return &(*(*it));
00131 
00132 } 
00133 
00134 
00138 template<class T>
00139 typename FEMPArray<T>::ClassTypeConstPointer 
00140 FEMPArray<T>::Find( int gn ) const
00141 {
00142 
00143   typedef typename Superclass::const_iterator ConstIterator;
00144 
00145   ConstIterator it   = this->begin(); 
00146   ConstIterator iend = this->end();
00147   while( it != iend )
00148     {
00149     if( (*it)->GN == gn )
00150       {
00151       break;
00152       }
00153     it++;
00154     }  
00155 
00156   if( it == this->end() )
00157     {
00161     throw FEMExceptionObjectNotFound(__FILE__,__LINE__,"FEMPArray::Find() const",typeid(T).name(),gn);
00162     }
00163 
00167   return &(*(*it));
00168 
00169 }
00170 
00171 template<class T>
00172 int FEMPArray<T>::Renumber() 
00173 {
00174 
00175   typename Superclass::iterator i;
00176   int j=0;
00177 
00178   for(i = this->begin(); i != this->end(); i++)
00179     {
00180     (*i)->GN=j;
00181     j++;
00182     }
00183 
00184   return j;
00185 
00186 }
00187 
00188 }} // end namespace itk::fem
00189 
00190 #endif // #ifndef __itkFEMPArray_h
00191 

Generated at Sat Feb 28 12:24:49 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000