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 =========================================================================*/
28 #ifndef vtkStructuredExtent_h
29 #define vtkStructuredExtent_h
30 
31 #include "vtkCommonDataModelModule.h" // For export macro
32 #include "vtkObject.h"
33 
35 {
36 public:
37  static vtkStructuredExtent* New();
39  void PrintSelf(ostream& os, vtkIndent indent);
40 
42  static void Clamp(int ext[6], const int wholeExt[]);
43 
46  static bool StrictlySmaller(const int ext[6], const int wholeExt[6]);
47 
50  static bool Smaller(const int ext[6], const int wholeExt[6]);
51 
53  static void Grow(int ext[6], int count);
54 
56  static void Transform(int ext[6], int wholeExt[6]);
57 
59  static void GetDimensions(const int ext[6], int dims[3]);
60 
61 //BTX
62 protected:
65 
66 private:
67  vtkStructuredExtent(const vtkStructuredExtent&); // Not implemented.
68  void operator=(const vtkStructuredExtent&); // Not implemented.
69 //ETX
70 };
71 
72 //----------------------------------------------------------------------------
73 inline void vtkStructuredExtent::Clamp(int ext[6], const int wholeExt[6])
74 {
75  ext[0] = (ext[0] < wholeExt[0])? wholeExt[0] : ext[0];
76  ext[1] = (ext[1] > wholeExt[1])? wholeExt[1] : ext[1];
77 
78  ext[2] = (ext[2] < wholeExt[2])? wholeExt[2] : ext[2];
79  ext[3] = (ext[3] > wholeExt[3])? wholeExt[3] : ext[3];
80 
81  ext[4] = (ext[4] < wholeExt[4])? wholeExt[4] : ext[4];
82  ext[5] = (ext[5] > wholeExt[5])? wholeExt[5] : ext[5];
83 }
84 
85 //----------------------------------------------------------------------------
86 inline bool vtkStructuredExtent::Smaller(const int ext[6], const int wholeExt[6])
87 {
88  if (ext[0] < wholeExt[0] || ext[0] > wholeExt[0 + 1] ||
89  ext[0 + 1] < wholeExt[0] || ext[0 + 1] > wholeExt[0 + 1])
90  {
91  return false;
92  }
93 
94  if (ext[2] < wholeExt[2] || ext[2] > wholeExt[2 + 1] ||
95  ext[2 + 1] < wholeExt[2] || ext[2 + 1] > wholeExt[2 + 1])
96  {
97  return false;
98  }
99 
100  if (ext[4] < wholeExt[4] || ext[4] > wholeExt[4 + 1] ||
101  ext[4 + 1] < wholeExt[4] || ext[4 + 1] > wholeExt[4 + 1])
102  {
103  return false;
104  }
105 
106  return true;
107 }
108 
109 //----------------------------------------------------------------------------
110 inline bool vtkStructuredExtent::StrictlySmaller(const int ext[6], const int wholeExt[6])
111 {
112  if (!vtkStructuredExtent::Smaller(ext, wholeExt))
113  {
114  return false;
115  }
116 
117  if (ext[0] > wholeExt[0] || ext[1] < wholeExt[1] ||
118  ext[2] > wholeExt[2] || ext[3] < wholeExt[3] ||
119  ext[4] > wholeExt[4] || ext[5] < wholeExt[5])
120  {
121  return true;
122  }
123 
124  return false;
125 }
126 
127 
128 //----------------------------------------------------------------------------
129 inline void vtkStructuredExtent::Grow(int ext[6], int count)
130 {
131  ext[0] -= count;
132  ext[2] -= count;
133  ext[4] -= count;
134 
135  ext[1] += count;
136  ext[3] += count;
137  ext[5] += count;
138 }
139 
140 //----------------------------------------------------------------------------
141 inline void vtkStructuredExtent::Transform(int ext[6], int wholeExt[6])
142 {
143  ext[0] -= wholeExt[0];
144  ext[1] -= wholeExt[0];
145 
146  ext[2] -= wholeExt[2];
147  ext[3] -= wholeExt[2];
148 
149  ext[4] -= wholeExt[4];
150  ext[5] -= wholeExt[4];
151 }
152 
153 //----------------------------------------------------------------------------
154 inline void vtkStructuredExtent::GetDimensions(const int ext[6], int dims[3])
155 {
156  dims[0] = ext[1]-ext[0] + 1;
157  dims[1] = ext[3]-ext[2] + 1;
158  dims[2] = ext[5]-ext[4] + 1;
159 }
160 
161 #endif
static void GetDimensions(const int ext[6], int dims[3])
abstract base class for most VTK objects
Definition: vtkObject.h:61
static bool Smaller(const int ext[6], const int wholeExt[6])
static void Grow(int ext[6], int count)
static void Clamp(int ext[6], const int wholeExt[])
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
static bool StrictlySmaller(const int ext[6], const int wholeExt[6])
helper class to aid working with structured extents.
static vtkObject * New()
#define VTKCOMMONDATAMODEL_EXPORT
static void Transform(int ext[6], int wholeExt[6])