VTK
vtkImageStencilData.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImageStencilData.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 =========================================================================*/
27 #ifndef vtkImageStencilData_h
28 #define vtkImageStencilData_h
29 
30 
31 #include "vtkImagingCoreModule.h" // For export macro
32 #include "vtkDataObject.h"
33 
34 class VTKIMAGINGCORE_EXPORT vtkImageStencilData : public vtkDataObject
35 {
36 public:
37  static vtkImageStencilData *New();
39  void PrintSelf(ostream& os, vtkIndent indent) override;
40 
41  void Initialize() override;
42  void DeepCopy(vtkDataObject *o) override;
43  void ShallowCopy(vtkDataObject *f) override;
44  void InternalImageStencilDataCopy(vtkImageStencilData *s);
45 
50  int GetDataObjectType() override { return VTK_DATA_OBJECT; }
51 
55  int GetExtentType() override { return VTK_3D_EXTENT; };
56 
66  int GetNextExtent(int &r1, int &r2, int xMin, int xMax,
67  int yIdx, int zIdx, int &iter);
68 
75  int IsInside(int xIdx, int yIdx, int zIdx);
76 
84  void InsertNextExtent(int r1, int r2, int yIdx, int zIdx);
85 
94  void InsertAndMergeExtent(int r1, int r2, int yIdx, int zIdx);
95 
99  void RemoveExtent(int r1, int r2, int yIdx, int zIdx);
100 
102 
108  vtkSetVector3Macro(Spacing, double);
109  vtkGetVector3Macro(Spacing, double);
111 
113 
119  vtkSetVector3Macro(Origin, double);
120  vtkGetVector3Macro(Origin, double);
122 
124 
129  void SetExtent(int extent[6]);
130  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
131  vtkGetVector6Macro(Extent, int);
133 
138  void AllocateExtents();
139 
143  void Fill();
144 
146 
153 
155 
159  static vtkImageStencilData* GetData(vtkInformationVector* v, int i=0);
161 
165  virtual void Add(vtkImageStencilData *);
166 
171  virtual void Subtract(vtkImageStencilData *);
172 
177  virtual void Replace(vtkImageStencilData *);
178 
183  virtual int Clip(int extent[6]);
184 
185 protected:
187  ~vtkImageStencilData() override;
188 
189  enum Operation { Merge, Erase };
190 
194  void LogicalOperationExtent(
195  int r1, int r2, int yIdx, int zIdx, Operation operation);
196 
200  void LogicalOperationInPlace(
201  vtkImageStencilData *stencil, Operation operation);
202 
208  void ChangeExtent(const int extent[6]);
209 
213  void CopyOriginAndSpacingFromPipeline(vtkInformation *info);
214 
216 
219  double Spacing[3];
220  double Origin[3];
222 
223  int Extent[6];
224 
226 
231  int **ExtentLists;
233 
234 private:
235  vtkImageStencilData(const vtkImageStencilData&) = delete;
236  void operator=(const vtkImageStencilData&) = delete;
237 
238  friend class vtkImageStencilIteratorFriendship;
239 };
240 
247 class VTKIMAGINGCORE_EXPORT vtkImageStencilRaster
248 {
249 public:
253  vtkImageStencilRaster(const int wholeExtent[2]);
254 
259 
265  void PrepareForNewData(const int allocateExtent[2] = nullptr);
266 
268 
271  void InsertLine(const double p1[2], const double p2[2]);
272  VTK_LEGACY(void InsertLine(const double[2], const double[2], bool, bool));
274 
279  void FillStencilData(vtkImageStencilData *data, const int extent[6],
280  int xj = 0, int yj = 1);
281 
285  void SetTolerance(double tol) { this->Tolerance = tol; }
286  double GetTolerance() { return this->Tolerance; }
287 
288 protected:
293  void PrepareExtent(int ymin, int ymax);
294 
300  void InsertPoint(int y, double x, int i);
301 
302  int Extent[2];
303  int UsedExtent[2];
304  double **Raster;
305  double Tolerance;
306 
307 private:
309  void operator=(const vtkImageStencilRaster&) = delete;
310 };
311 
312 #endif
313 
314 
315 
vtkImageStencilData::ExtentListLengths
int * ExtentListLengths
Definition: vtkImageStencilData.h:230
vtkDataObject::Initialize
virtual void Initialize()
Restore data object to initial state,.
VTK_DATA_OBJECT
#define VTK_DATA_OBJECT
Definition: vtkType.h:98
vtkImageStencilData::GetDataObjectType
int GetDataObjectType() override
Get the data type as an integer (this will return VTK_DATA_OBJECT for now, maybe a proper type consta...
Definition: vtkImageStencilData.h:50
vtkDataObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkX3D::data
Definition: vtkX3D.h:315
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkImageStencilData::NumberOfExtentEntries
int NumberOfExtentEntries
The actual 'data' is stored here.
Definition: vtkImageStencilData.h:229
vtkImageStencilRaster::SetTolerance
void SetTolerance(double tol)
The tolerance for float-to-int conversions.
Definition: vtkImageStencilData.h:285
vtkDataObject::CopyInformationFromPipeline
virtual void CopyInformationFromPipeline(vtkInformation *vtkNotUsed(info))
Copy from the pipeline information to the data object's own information.
Definition: vtkDataObject.h:146
vtkDataObject::DeepCopy
virtual void DeepCopy(vtkDataObject *src)
vtkImageStencilRaster
This is a helper class for stencil creation.
Definition: vtkImageStencilData.h:247
vtkImageStencilData::GetExtentType
int GetExtentType() override
The extent type is 3D, just like vtkImageData.
Definition: vtkImageStencilData.h:55
VTK_3D_EXTENT
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:55
vtkImageStencilRaster::Tolerance
double Tolerance
Definition: vtkImageStencilData.h:305
vtkImageStencilData::ExtentLists
int ** ExtentLists
Definition: vtkImageStencilData.h:231
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkImageStencilData::Operation
Operation
Definition: vtkImageStencilData.h:189
vtkDataObject::CopyInformationToPipeline
virtual void CopyInformationToPipeline(vtkInformation *vtkNotUsed(info))
Copy information from this data object to the pipeline information.
Definition: vtkDataObject.h:154
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkImageStencilRaster::Raster
double ** Raster
Definition: vtkImageStencilData.h:304
vtkX3D::info
Definition: vtkX3D.h:376
vtkDataObject.h
vtkImageStencilData
efficient description of an image stencil
Definition: vtkImageStencilData.h:34
vtkImageStencilRaster::GetTolerance
double GetTolerance()
Definition: vtkImageStencilData.h:286
vtkX3D::extent
Definition: vtkX3D.h:345
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:58
vtkDataObject::ShallowCopy
virtual void ShallowCopy(vtkDataObject *src)
Shallow and Deep copy.
vtkDataObject::GetData
static vtkDataObject * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
vtkDataObject::New
static vtkDataObject * New()