1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkArrayCoordinates.h 5 6 ------------------------------------------------------------------------- 7 Copyright 2008 Sandia Corporation. 8 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 9 the U.S. Government retains certain rights in this software. 10 ------------------------------------------------------------------------- 11 12 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 13 All rights reserved. 14 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 15 16 This software is distributed WITHOUT ANY WARRANTY; without even 17 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 18 PURPOSE. See the above copyright notice for more information. 19 20 =========================================================================*/ 21 22 /** 23 * @class vtkArrayCoordinates 24 * @brief Stores coordinate into an N-way array. 25 * 26 * 27 * vtkArrayCoordinates stores a collection of coordinates that can be 28 * used to access values in a vtkArray containing an arbitrary number of 29 * dimensions. 30 * 31 * Convenience constructors are provided for working with one, two, and 32 * three dimensions. For higher dimensions, use the default constructor, 33 * SetDimensions() and operator[] to assign a coordinate value along each 34 * dimension. 35 * 36 * @sa 37 * vtkArray, vtkArrayExtents 38 * 39 * @par Thanks: 40 * Developed by Timothy M. Shead (tshead@sandia.gov) at Sandia National 41 * Laboratories. 42 */ 43 44 #ifndef vtkArrayCoordinates_h 45 #define vtkArrayCoordinates_h 46 47 #include "vtkCommonCoreModule.h" // For export macro 48 #include "vtkSystemIncludes.h" 49 #include <vector> 50 51 class VTKCOMMONCORE_EXPORT vtkArrayCoordinates 52 { 53 public: 54 typedef vtkIdType CoordinateT; 55 typedef vtkIdType DimensionT; 56 57 /** 58 * Create an empty set of coordinates. Use SetDimensions() and 59 * operator[] to populate the coordinates. 60 */ 61 vtkArrayCoordinates(); 62 63 /** 64 * Create coordinates for a one-dimensional array. 65 */ 66 explicit vtkArrayCoordinates(CoordinateT i); 67 68 /** 69 * Create coordinates for a two-dimensional array. 70 */ 71 vtkArrayCoordinates(CoordinateT i, CoordinateT j); 72 73 /** 74 * Create coordinates for a three-dimensional array. 75 */ 76 vtkArrayCoordinates(CoordinateT i, CoordinateT j, CoordinateT k); 77 78 /** 79 * Return the number of dimensions contained in the coordinates. 80 */ 81 DimensionT GetDimensions() const; 82 83 /** 84 * Set the number of dimensions. Note that this method resets the 85 * coordinate along each dimension to zero, so you must set every 86 * coordinate explicitly using operator[] after calling SetDimensions(). 87 */ 88 void SetDimensions(DimensionT dimensions); 89 90 /** 91 * Returns the coordinate of the i-th dimension. 92 */ 93 CoordinateT& operator[](DimensionT i); 94 95 /** 96 * Returns the coordinate of the i-th dimension. 97 */ 98 const CoordinateT& operator[](DimensionT i) const; 99 100 /** 101 * Returns the coordinate of the i-th dimension. 102 */ 103 CoordinateT GetCoordinate(DimensionT i) const; 104 105 /** 106 * Sets the coordinate of the i-th dimension. 107 */ 108 void SetCoordinate(DimensionT i, const CoordinateT&); 109 110 /** 111 * Equality comparison 112 */ 113 bool operator==(const vtkArrayCoordinates& rhs) const; 114 115 ///@{ 116 /** 117 * Inequality comparison 118 */ 119 bool operator!=(const vtkArrayCoordinates& rhs) const; 120 VTKCOMMONCORE_EXPORT friend ostream& operator<<(ostream& stream, const vtkArrayCoordinates& rhs); 121 ///@} 122 123 private: 124 std::vector<CoordinateT> Storage; 125 }; 126 127 #endif 128 129 // VTK-HeaderTest-Exclude: vtkArrayCoordinates.h 130