VTK
vtkStructuredExtent.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkStructuredExtent.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
29 #ifndef vtkStructuredExtent_h
30 #define vtkStructuredExtent_h
31 
32 #include "vtkCommonDataModelModule.h" // For export macro
33 #include "vtkObject.h"
34 
35 class VTKCOMMONDATAMODEL_EXPORT vtkStructuredExtent : public vtkObject
36 {
37 public:
38  static vtkStructuredExtent* New();
40  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
41 
45  static void Clamp(int ext[6], const int wholeExt[]);
46 
51  static bool StrictlySmaller(const int ext[6], const int wholeExt[6]);
52 
57  static bool Smaller(const int ext[6], const int wholeExt[6]);
58 
62  static void Grow(int ext[6], int count);
63 
67  static void Transform(int ext[6], int wholeExt[6]);
68 
72  static void GetDimensions(const int ext[6], int dims[3]);
73 
74 protected:
76  ~vtkStructuredExtent() VTK_OVERRIDE;
77 
78 private:
79  vtkStructuredExtent(const vtkStructuredExtent&) VTK_DELETE_FUNCTION;
80  void operator=(const vtkStructuredExtent&) VTK_DELETE_FUNCTION;
81 
82 };
83 
84 //----------------------------------------------------------------------------
85 inline void vtkStructuredExtent::Clamp(int ext[6], const int wholeExt[6])
86 {
87  ext[0] = (ext[0] < wholeExt[0])? wholeExt[0] : ext[0];
88  ext[1] = (ext[1] > wholeExt[1])? wholeExt[1] : ext[1];
89 
90  ext[2] = (ext[2] < wholeExt[2])? wholeExt[2] : ext[2];
91  ext[3] = (ext[3] > wholeExt[3])? wholeExt[3] : ext[3];
92 
93  ext[4] = (ext[4] < wholeExt[4])? wholeExt[4] : ext[4];
94  ext[5] = (ext[5] > wholeExt[5])? wholeExt[5] : ext[5];
95 }
96 
97 //----------------------------------------------------------------------------
98 inline bool vtkStructuredExtent::Smaller(const int ext[6], const int wholeExt[6])
99 {
100  if (ext[0] < wholeExt[0] || ext[0] > wholeExt[0 + 1] ||
101  ext[0 + 1] < wholeExt[0] || ext[0 + 1] > wholeExt[0 + 1])
102  {
103  return false;
104  }
105 
106  if (ext[2] < wholeExt[2] || ext[2] > wholeExt[2 + 1] ||
107  ext[2 + 1] < wholeExt[2] || ext[2 + 1] > wholeExt[2 + 1])
108  {
109  return false;
110  }
111 
112  if (ext[4] < wholeExt[4] || ext[4] > wholeExt[4 + 1] ||
113  ext[4 + 1] < wholeExt[4] || ext[4 + 1] > wholeExt[4 + 1])
114  {
115  return false;
116  }
117 
118  return true;
119 }
120 
121 //----------------------------------------------------------------------------
122 inline bool vtkStructuredExtent::StrictlySmaller(const int ext[6], const int wholeExt[6])
123 {
124  if (!vtkStructuredExtent::Smaller(ext, wholeExt))
125  {
126  return false;
127  }
128 
129  if (ext[0] > wholeExt[0] || ext[1] < wholeExt[1] ||
130  ext[2] > wholeExt[2] || ext[3] < wholeExt[3] ||
131  ext[4] > wholeExt[4] || ext[5] < wholeExt[5])
132  {
133  return true;
134  }
135 
136  return false;
137 }
138 
139 
140 //----------------------------------------------------------------------------
141 inline void vtkStructuredExtent::Grow(int ext[6], int count)
142 {
143  ext[0] -= count;
144  ext[2] -= count;
145  ext[4] -= count;
146 
147  ext[1] += count;
148  ext[3] += count;
149  ext[5] += count;
150 }
151 
152 //----------------------------------------------------------------------------
153 inline void vtkStructuredExtent::Transform(int ext[6], int wholeExt[6])
154 {
155  ext[0] -= wholeExt[0];
156  ext[1] -= wholeExt[0];
157 
158  ext[2] -= wholeExt[2];
159  ext[3] -= wholeExt[2];
160 
161  ext[4] -= wholeExt[4];
162  ext[5] -= wholeExt[4];
163 }
164 
165 //----------------------------------------------------------------------------
166 inline void vtkStructuredExtent::GetDimensions(const int ext[6], int dims[3])
167 {
168  dims[0] = ext[1]-ext[0] + 1;
169  dims[1] = ext[3]-ext[2] + 1;
170  dims[2] = ext[5]-ext[4] + 1;
171 }
172 
173 #endif
static void GetDimensions(const int ext[6], int dims[3])
Given the extents, computes the dimensions.
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static bool Smaller(const int ext[6], const int wholeExt[6])
Returns if ext fits within wholeExt.
static void Grow(int ext[6], int count)
Grows the ext on each side by the given count.
a simple class to control print indentation
Definition: vtkIndent.h:39
static bool StrictlySmaller(const int ext[6], const int wholeExt[6])
Returns true if ext is fits within wholeExt with atleast 1 dimension smaller than the wholeExt...
helper class to aid working with structured extents.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
Transform
Definition: ADIOSDefs.h:39
static void Transform(int ext[6], int wholeExt[6])
Makes ext relative to wholeExt.