VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkSMPToolsInternal.h.in 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 =========================================================================*/ 00015 namespace vtk 00016 { 00017 namespace detail 00018 { 00019 namespace smp 00020 { 00021 template <typename FunctorInternal> 00022 static void vtkSMPTools_Impl_For( 00023 vtkIdType first, vtkIdType last, vtkIdType grain, 00024 FunctorInternal& fi) 00025 { 00026 vtkIdType n = last - first; 00027 if (!n) 00028 { 00029 return; 00030 } 00031 00032 if (grain == 0 || grain >= n) 00033 { 00034 fi.Execute(first, last); 00035 } 00036 else 00037 { 00038 vtkIdType b = first; 00039 while (b < last) 00040 { 00041 vtkIdType e = b + grain; 00042 if (e > last) 00043 { 00044 e = last; 00045 } 00046 fi.Execute(b, e); 00047 b = e; 00048 } 00049 } 00050 } 00051 } 00052 } 00053 }