VTK  9.1.0
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 #include "vtkDataObject.h"
31 #include "vtkImagingCoreModule.h" // For export macro
32 
33 class VTKIMAGINGCORE_EXPORT vtkImageStencilData : public vtkDataObject
34 {
35 public:
38  void PrintSelf(ostream& os, vtkIndent indent) override;
39 
40  void Initialize() override;
41  void DeepCopy(vtkDataObject* o) override;
42  void ShallowCopy(vtkDataObject* f) override;
44 
48  int GetDataObjectType() override { return VTK_IMAGE_STENCIL_DATA; }
49 
53  int GetExtentType() override { return VTK_3D_EXTENT; }
54 
64  int GetNextExtent(int& r1, int& r2, int xMin, int xMax, int yIdx, int zIdx, int& iter);
65 
72  int IsInside(int xIdx, int yIdx, int zIdx);
73 
81  void InsertNextExtent(int r1, int r2, int yIdx, int zIdx);
82 
91  void InsertAndMergeExtent(int r1, int r2, int yIdx, int zIdx);
92 
96  void RemoveExtent(int r1, int r2, int yIdx, int zIdx);
97 
99 
105  vtkSetVector3Macro(Spacing, double);
106  vtkGetVector3Macro(Spacing, double);
108 
110 
116  vtkSetVector3Macro(Origin, double);
117  vtkGetVector3Macro(Origin, double);
119 
121 
126  void SetExtent(const int extent[6]);
127  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
128  vtkGetVector6Macro(Extent, int);
130 
136 
140  void Fill();
141 
143 
150 
152 
158 
162  virtual void Add(vtkImageStencilData*);
163 
169 
174  virtual void Replace(vtkImageStencilData*);
175 
180  virtual int Clip(int extent[6]);
181 
182 protected:
185 
187  {
189  Erase
190  };
191 
195  void LogicalOperationExtent(int r1, int r2, int yIdx, int zIdx, Operation operation);
196 
201 
207  void ChangeExtent(const int extent[6]);
208 
213 
215 
218  double Spacing[3];
219  double Origin[3];
221 
222  int Extent[6];
223 
225 
230  int** ExtentLists;
232 
233 private:
234  vtkImageStencilData(const vtkImageStencilData&) = delete;
235  void operator=(const vtkImageStencilData&) = delete;
236 
237  friend class vtkImageStencilIteratorFriendship;
238 };
239 
246 class VTKIMAGINGCORE_EXPORT vtkImageStencilRaster
247 {
248 public:
252  vtkImageStencilRaster(const int wholeExtent[2]);
253 
258 
264  void PrepareForNewData(const int allocateExtent[2] = nullptr);
265 
267 
270  void InsertLine(const double pt1[2], const double pt2[2]);
272 
277  void FillStencilData(vtkImageStencilData* data, const int extent[6], int xj = 0, int yj = 1);
278 
282  void SetTolerance(double tol) { this->Tolerance = tol; }
283  double GetTolerance() { return this->Tolerance; }
284 
285 protected:
290  void PrepareExtent(int ymin, int ymax);
291 
297  void InsertPoint(int y, double x, int i);
298 
299  int Extent[2];
300  int UsedExtent[2];
301  double** Raster;
302  double Tolerance;
303 
304 private:
306  void operator=(const vtkImageStencilRaster&) = delete;
307 };
308 
309 #endif
general representation of visualization data
Definition: vtkDataObject.h:60
efficient description of an image stencil
void CopyInformationToPipeline(vtkInformation *info) override
Override these to handle origin, spacing, scalar type, and scalar number of components.
int NumberOfExtentEntries
The actual 'data' is stored here.
virtual int Clip(int extent[6])
Clip the stencil with the supplied extents.
void InsertAndMergeExtent(int r1, int r2, int yIdx, int zIdx)
Similar to InsertNextExtent, except that the extent (r1,r2) at yIdx, zIdx is merged with other extent...
void Initialize() override
Restore data object to initial state,.
void DeepCopy(vtkDataObject *o) override
Shallow and Deep copy.
void LogicalOperationInPlace(vtkImageStencilData *stencil, Operation operation)
Combine with the given stencil, using the given operation.
void InsertNextExtent(int r1, int r2, int yIdx, int zIdx)
This method is used by vtkImageStencilDataSource to add an x sub extent [r1,r2] for the x row (yIdx,...
~vtkImageStencilData() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Fill()
Fill the sub-extents.
void AllocateExtents()
Allocate space for the sub-extents.
void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2)
Set the extent of the data.
void InternalImageStencilDataCopy(vtkImageStencilData *s)
int GetNextExtent(int &r1, int &r2, int xMin, int xMax, int yIdx, int zIdx, int &iter)
Given the total output x extent [xMin,xMax] and the current y, z indices, return each sub-extent [r1,...
void CopyInformationFromPipeline(vtkInformation *info) override
Override these to handle origin, spacing, scalar type, and scalar number of components.
virtual void Add(vtkImageStencilData *)
Add merges the stencil supplied as argument into Self.
int GetDataObjectType() override
Returns VTK_IMAGE_STENCIL_DATA.
void RemoveExtent(int r1, int r2, int yIdx, int zIdx)
Remove the extent from (r1,r2) at yIdx, zIdx.
static vtkImageStencilData * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
static vtkImageStencilData * New()
int IsInside(int xIdx, int yIdx, int zIdx)
Checks if an image index is inside the stencil.
int ** ExtentLists
The actual 'data' is stored here.
virtual void Subtract(vtkImageStencilData *)
Subtract removes the portion of the stencil, supplied as argument, that lies within Self from Self.
void LogicalOperationExtent(int r1, int r2, int yIdx, int zIdx, Operation operation)
Apply the given operation over the given (r1, r2) extent.
int * ExtentListLengths
The actual 'data' is stored here.
void CopyOriginAndSpacingFromPipeline(vtkInformation *info)
Get important info from pipeline.
void SetExtent(const int extent[6])
Set the extent of the data.
void ShallowCopy(vtkDataObject *f) override
Shallow and Deep copy.
static vtkImageStencilData * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
int GetExtentType() override
The extent type is 3D, just like vtkImageData.
void ChangeExtent(const int extent[6])
Change the extent while preserving the data.
virtual void Replace(vtkImageStencilData *)
Replaces the portion of the stencil, supplied as argument, that lies within Self from Self.
This is a helper class for stencil creation.
void FillStencilData(vtkImageStencilData *data, const int extent[6], int xj=0, int yj=1)
Fill the specified extent of a vtkImageStencilData with the raster, after permuting the raster accord...
~vtkImageStencilRaster()
Destructor.
void SetTolerance(double tol)
The tolerance for float-to-int conversions.
void PrepareForNewData(const int allocateExtent[2]=nullptr)
Reset the raster to its original state, but keep the same whole extent.
void InsertLine(const double pt1[2], const double pt2[2])
Insert a line into the raster, given the two end points.
void PrepareExtent(int ymin, int ymax)
Ensure that the raster is initialized for the specified range of y values, which must be within the E...
vtkImageStencilRaster(const int wholeExtent[2])
Create a raster with the specified whole y extent.
void InsertPoint(int y, double x, int i)
Insert an x point into the raster.
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
@ info
Definition: vtkX3D.h:382
@ extent
Definition: vtkX3D.h:351
@ data
Definition: vtkX3D.h:321
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:56
#define VTK_IMAGE_STENCIL_DATA
Definition: vtkType.h:125