ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkNthElementPixelAccessor_h 00019 #define __itkNthElementPixelAccessor_h 00020 00021 #include "itkMacro.h" 00022 00023 namespace itk 00024 { 00048 template< class T, class TContainer > 00049 class ITK_EXPORT NthElementPixelAccessor 00050 { 00051 public: 00053 typedef NthElementPixelAccessor Self; 00054 00056 typedef T ExternalType; 00057 00060 typedef TContainer InternalType; 00061 00063 inline void Set(InternalType & output, const ExternalType & input) const 00064 { output[m_ElementNumber] = input; } 00065 00067 inline ExternalType Get(const InternalType & input) const 00068 { return static_cast< ExternalType >( input[m_ElementNumber] ); } 00069 00071 unsigned int GetElementNumber(void) const 00072 { return m_ElementNumber; } 00073 00075 void SetElementNumber(unsigned int nth) 00076 { m_ElementNumber = nth; } 00077 00080 bool operator!=(const Self & accessor) const 00081 { 00082 return ( m_ElementNumber != accessor.m_ElementNumber ); 00083 } 00084 00086 NthElementPixelAccessor & operator=(const NthElementPixelAccessor & accessor) 00087 { 00088 m_ElementNumber = accessor.m_ElementNumber; 00089 return *this; 00090 } 00091 00093 NthElementPixelAccessor() 00094 { 00095 m_ElementNumber = 0; 00096 } 00097 00098 private: 00099 // Identifier of the N-th element to be accessed 00100 unsigned int m_ElementNumber; 00101 }; 00102 } // end namespace itk 00103 00104 #endif 00105