VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkArrayExtents.h 00005 00006 ------------------------------------------------------------------------- 00007 Copyright 2008 Sandia Corporation. 00008 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00009 the U.S. Government retains certain rights in this software. 00010 ------------------------------------------------------------------------- 00011 00012 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00013 All rights reserved. 00014 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00015 00016 This software is distributed WITHOUT ANY WARRANTY; without even 00017 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00018 PURPOSE. See the above copyright notice for more information. 00019 00020 =========================================================================*/ 00021 00064 #ifndef __vtkArrayExtents_h 00065 #define __vtkArrayExtents_h 00066 00067 #include "vtkSystemIncludes.h" 00068 #include "vtkArrayRange.h" 00069 #include <vtksys/stl/vector> // STL Header 00070 00071 class vtkArrayCoordinates; 00072 00073 class VTK_COMMON_EXPORT vtkArrayExtents 00074 { 00075 public: 00077 vtkArrayExtents(); 00078 00080 00082 explicit vtkArrayExtents(const vtkIdType i); 00083 // Description: 00084 // Create one-dimensional extents. 00085 explicit vtkArrayExtents(const vtkArrayRange& i); 00087 00089 00091 vtkArrayExtents(const vtkIdType i, const vtkIdType j); 00092 // Description: 00093 // Create two-dimensional extents. 00094 vtkArrayExtents(const vtkArrayRange& i, const vtkArrayRange& j); 00096 00098 00101 vtkArrayExtents(const vtkIdType i, const vtkIdType j, const vtkIdType k); 00102 // Description: 00103 // Create two-dimensional extents. 00104 vtkArrayExtents(const vtkArrayRange& i, const vtkArrayRange& j, const vtkArrayRange& k); 00106 00109 static const vtkArrayExtents Uniform(vtkIdType n, vtkIdType m); 00110 00113 void Append(const vtkArrayRange& extent); 00114 00116 vtkIdType GetDimensions() const; 00117 00121 vtkIdType GetSize() const; 00122 00127 void SetDimensions(vtkIdType dimensions); 00128 00130 vtkArrayRange& operator[](vtkIdType i); 00131 00133 const vtkArrayRange& operator[](vtkIdType i) const; 00134 00136 bool operator==(const vtkArrayExtents& rhs) const; 00137 00139 bool operator!=(const vtkArrayExtents& rhs) const; 00140 00147 bool ZeroBased() const; 00148 00152 bool SameShape(const vtkArrayExtents& rhs) const; 00153 00155 00161 void GetLeftToRightCoordinatesN(vtkIdType n, vtkArrayCoordinates& coordinates) const; 00162 // Description: 00163 // Returns coordinates that reference the n-th value in the extents, where 00164 // n is in the range [0, GetSize()). The returned coordinates will be ordered 00165 // so that the right-most indices vary fastest. The is equivalent to row-major 00166 // ordering for matrices, and corresponds to the order in which consecutive array 00167 // values would be stored in languages including C and C++. 00168 void GetRightToLeftCoordinatesN(vtkIdType n, vtkArrayCoordinates& coordinates) const; 00170 00175 bool Contains(const vtkArrayExtents& extents) const; 00176 00182 bool Contains(const vtkArrayCoordinates& coordinates) const; 00183 00184 VTK_COMMON_EXPORT friend ostream& operator<<( 00185 ostream& stream, const vtkArrayExtents& rhs); 00186 00187 private: 00188 vtksys_stl::vector<vtkArrayRange> Storage; 00189 }; 00190 00191 #endif 00192