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