1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkArrayRange.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 // .NAME vtkArrayRange - Stores a half-open range of array coordinates.
23 //
24 // .SECTION Description
25 // vtkArrayRange stores a half-open range of array coordinates along a
26 // single dimension of a vtkArraySlice object.
27 //
28 // .SECTION See Also
29 // vtkArray, vtkArrayRange
30 //
31 // .SECTION Thanks
32 // Developed by Timothy M. Shead (tshead@sandia.gov) at Sandia National
33 // Laboratories.
34 
35 #ifndef vtkArrayRange_h
36 #define vtkArrayRange_h
37 
38 #include "vtkCommonCoreModule.h" // For export macro
39 #include "vtkSystemIncludes.h"
40 #include "vtkArrayCoordinates.h"
41 
42 class VTKCOMMONCORE_EXPORT vtkArrayRange
43 {
44 public:
45   typedef vtkArrayCoordinates::CoordinateT CoordinateT;
46 
47   // Description:
48   // Creates an empty range.
49   vtkArrayRange();
50 
51   // Description:
52   // Creates a half-open range [begin, end).
53   // Note that begin must be <= end,
54   // if not, creates the empty range [begin, begin).
55   vtkArrayRange(CoordinateT begin, CoordinateT end);
56 
57   // Description:
58   // Returns the beginning of the range
59   CoordinateT GetBegin() const;
60 
61   // Description:
62   // Returns one-past-the-end of the range
63   CoordinateT GetEnd() const;
64 
65   // Description:
66   // Returns the size of the range (the distance End - Begin).
67   CoordinateT GetSize() const;
68 
69   // Description:
70   // Returns true iff the given range is a non-overlapping subset of this
71   // range.
72   bool Contains(const vtkArrayRange& range) const;
73 
74   // Description:
75   // Returns true iff the given coordinate falls within this range.
76   bool Contains(const CoordinateT coordinate) const;
77 
78   // Description:
79   // Equality comparisons.
80   VTKCOMMONCORE_EXPORT friend bool operator==(const vtkArrayRange& lhs, const vtkArrayRange& rhs);
81   VTKCOMMONCORE_EXPORT friend bool operator!=(const vtkArrayRange& lhs, const vtkArrayRange& rhs);
82 
83   // Description:
84   // Serialization.
85   VTKCOMMONCORE_EXPORT friend ostream& operator<<(ostream& stream, const vtkArrayRange& rhs);
86 
87 private:
88   // Description:
89   // Stores the beginning of the range.
90   CoordinateT Begin;
91 
92   // Description:
93   // Stores one-past-the-end of the range.
94   CoordinateT End;
95 };
96 
97 #endif
98 // VTK-HeaderTest-Exclude: vtkArrayRange.h
99