VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkDataArrayIteratorMacro.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00078 #ifndef __vtkDataArrayIteratorMacro_h 00079 #define __vtkDataArrayIteratorMacro_h 00080 00081 #include "vtkDataArrayTemplate.h" // For all classes referred to in the macro 00082 #include "vtkSetGet.h" // For vtkTemplateMacro 00083 00084 // Silence 'unused typedef' warnings on newer GCC. 00085 // use of the typedef in question depends on the macro 00086 // argument _call and thus should not be removed. 00087 #if defined(__GNUC__) 00088 #define _vtkDAIMUnused __attribute__ ((unused)) 00089 #else 00090 #define _vtkDAIMUnused 00091 #endif 00092 00093 #define vtkDataArrayIteratorMacro(_array, _call) \ 00094 vtkTemplateMacro( \ 00095 vtkAbstractArray *_aa(_array); \ 00096 if (vtkDataArrayTemplate<VTK_TT> *_dat = \ 00097 vtkDataArrayTemplate<VTK_TT>::FastDownCast(_aa)) \ 00098 { \ 00099 typedef VTK_TT vtkDAValueType; \ 00100 typedef vtkDataArrayTemplate<vtkDAValueType> vtkDAContainerType; \ 00101 typedef vtkDAContainerType::Iterator vtkDAIteratorType; \ 00102 vtkDAIteratorType vtkDABegin(_dat->Begin()); \ 00103 vtkDAIteratorType vtkDAEnd(_dat->End()); \ 00104 (void)vtkDABegin; /* Prevent warnings when unused */ \ 00105 (void)vtkDAEnd; \ 00106 _call; \ 00107 } \ 00108 else if (vtkTypedDataArray<VTK_TT> *_tda = \ 00109 vtkTypedDataArray<VTK_TT>::FastDownCast(_aa)) \ 00110 { \ 00111 typedef VTK_TT vtkDAValueType; \ 00112 typedef vtkTypedDataArray<vtkDAValueType> vtkDAContainerType; \ 00113 typedef vtkDAContainerType::Iterator vtkDAIteratorType; \ 00114 vtkDAIteratorType vtkDABegin(_tda->Begin()); \ 00115 vtkDAIteratorType vtkDAEnd(_tda->End()); \ 00116 (void)vtkDABegin; \ 00117 (void)vtkDAEnd; \ 00118 _call; \ 00119 } \ 00120 else \ 00121 { \ 00122 /* This is not ideal, as no explicit iterator has been declared. \ 00123 * Cast the void pointer and hope for the best! */ \ 00124 typedef VTK_TT vtkDAValueType; \ 00125 typedef vtkAbstractArray vtkDAContainerType _vtkDAIMUnused; \ 00126 typedef vtkDAValueType* vtkDAIteratorType; \ 00127 vtkDAIteratorType vtkDABegin = \ 00128 static_cast<vtkDAIteratorType>(_aa->GetVoidPointer(0)); \ 00129 vtkDAIteratorType vtkDAEnd = vtkDABegin + _aa->GetMaxId() + 1; \ 00130 (void)vtkDABegin; \ 00131 (void)vtkDAEnd; \ 00132 _call; \ 00133 } \ 00134 ) 00135 00136 #endif //__vtkDataArrayIteratorMacro_h 00137 00138 // VTK-HeaderTest-Exclude: vtkDataArrayIteratorMacro.h