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 =========================================================================*/
46 #ifndef vtkImageStencilData_h
47 #define vtkImageStencilData_h
48 
49 #include "vtkDataObject.h"
50 #include "vtkImagingCoreModule.h" // For export macro
51 
52 class VTKIMAGINGCORE_EXPORT vtkImageStencilData : public vtkDataObject
53 {
54 public:
57  void PrintSelf(ostream& os, vtkIndent indent) override;
58 
59  void Initialize() override;
60  void DeepCopy(vtkDataObject* o) override;
61  void ShallowCopy(vtkDataObject* f) override;
63 
67  int GetDataObjectType() override { return VTK_IMAGE_STENCIL_DATA; }
68 
72  int GetExtentType() override { return VTK_3D_EXTENT; }
73 
83  int GetNextExtent(int& r1, int& r2, int xMin, int xMax, int yIdx, int zIdx, int& iter);
84 
91  int IsInside(int xIdx, int yIdx, int zIdx);
92 
100  void InsertNextExtent(int r1, int r2, int yIdx, int zIdx);
101 
110  void InsertAndMergeExtent(int r1, int r2, int yIdx, int zIdx);
111 
115  void RemoveExtent(int r1, int r2, int yIdx, int zIdx);
116 
118 
124  vtkSetVector3Macro(Spacing, double);
125  vtkGetVector3Macro(Spacing, double);
127 
129 
135  vtkSetVector3Macro(Origin, double);
136  vtkGetVector3Macro(Origin, double);
138 
140 
145  void SetExtent(const int extent[6]);
146  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
147  vtkGetVector6Macro(Extent, int);
149 
155 
159  void Fill();
160 
162 
169 
171 
177 
181  virtual void Add(vtkImageStencilData*);
182 
188 
193  virtual void Replace(vtkImageStencilData*);
194 
199  virtual int Clip(int extent[6]);
200 
201 protected:
204 
206  {
208  Erase
209  };
210 
214  void LogicalOperationExtent(int r1, int r2, int yIdx, int zIdx, Operation operation);
215 
220 
226  void ChangeExtent(const int extent[6]);
227 
232 
234 
237  double Spacing[3];
238  double Origin[3];
240 
241  int Extent[6];
242 
244 
249  int** ExtentLists;
251 
252 private:
253  vtkImageStencilData(const vtkImageStencilData&) = delete;
254  void operator=(const vtkImageStencilData&) = delete;
255 
256  friend class vtkImageStencilIteratorFriendship;
257 };
258 
265 class VTKIMAGINGCORE_EXPORT vtkImageStencilRaster
266 {
267 public:
271  vtkImageStencilRaster(const int wholeExtent[2]);
272 
277 
283  void PrepareForNewData(const int allocateExtent[2] = nullptr);
284 
286 
289  void InsertLine(const double pt1[2], const double pt2[2]);
291 
296  void FillStencilData(vtkImageStencilData* data, const int extent[6], int xj = 0, int yj = 1);
297 
301  void SetTolerance(double tol) { this->Tolerance = tol; }
302  double GetTolerance() { return this->Tolerance; }
303 
304 protected:
309  void PrepareExtent(int ymin, int ymax);
310 
316  void InsertPoint(int y, double x, int i);
317 
318  int Extent[2];
319  int UsedExtent[2];
320  double** Raster;
321  double Tolerance;
322 
323 private:
325  void operator=(const vtkImageStencilRaster&) = delete;
326 };
327 
328 #endif
vtkImageStencilData::ExtentListLengths
int * ExtentListLengths
The actual 'data' is stored here.
Definition: vtkImageStencilData.h:248
vtkImageStencilData::GetData
static vtkImageStencilData * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
vtkImageStencilData::Subtract
virtual void Subtract(vtkImageStencilData *)
Subtract removes the portion of the stencil, supplied as argument, that lies within Self from Self.
vtkImageStencilData::GetDataObjectType
int GetDataObjectType() override
Returns VTK_IMAGE_STENCIL_DATA.
Definition: vtkImageStencilData.h:67
vtkX3D::data
@ data
Definition: vtkX3D.h:321
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:145
vtkImageStencilData::vtkImageStencilData
vtkImageStencilData()
vtkImageStencilData::NumberOfExtentEntries
int NumberOfExtentEntries
The actual 'data' is stored here.
Definition: vtkImageStencilData.h:247
vtkImageStencilData::CopyOriginAndSpacingFromPipeline
void CopyOriginAndSpacingFromPipeline(vtkInformation *info)
Get important info from pipeline.
vtkImageStencilData::IsInside
int IsInside(int xIdx, int yIdx, int zIdx)
Checks if an image index is inside the stencil.
vtkImageStencilRaster::SetTolerance
void SetTolerance(double tol)
The tolerance for float-to-int conversions.
Definition: vtkImageStencilData.h:301
vtkImageStencilData::GetNextExtent
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,...
vtkImageStencilData::InsertAndMergeExtent
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...
vtkImageStencilData::Replace
virtual void Replace(vtkImageStencilData *)
Replaces the portion of the stencil, supplied as argument, that lies within Self from Self.
vtkImageStencilData::Merge
@ Merge
Definition: vtkImageStencilData.h:207
vtkImageStencilData::DeepCopy
void DeepCopy(vtkDataObject *o) override
Shallow and Deep copy.
vtkImageStencilRaster::PrepareExtent
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...
vtkImageStencilData::New
static vtkImageStencilData * New()
vtkImageStencilData::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkImageStencilRaster
This is a helper class for stencil creation.
Definition: vtkImageStencilData.h:266
vtkImageStencilData::GetExtentType
int GetExtentType() override
The extent type is 3D, just like vtkImageData.
Definition: vtkImageStencilData.h:72
VTK_3D_EXTENT
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:165
vtkImageStencilRaster::InsertLine
void InsertLine(const double pt1[2], const double pt2[2])
Insert a line into the raster, given the two end points.
vtkImageStencilRaster::Tolerance
double Tolerance
Definition: vtkImageStencilData.h:321
vtkImageStencilData::SetExtent
void SetExtent(const int extent[6])
Set the extent of the data.
vtkImageStencilRaster::~vtkImageStencilRaster
~vtkImageStencilRaster()
Destructor.
VTK_IMAGE_STENCIL_DATA
#define VTK_IMAGE_STENCIL_DATA
Definition: vtkType.h:125
vtkImageStencilData::GetData
static vtkImageStencilData * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
vtkImageStencilData::LogicalOperationExtent
void LogicalOperationExtent(int r1, int r2, int yIdx, int zIdx, Operation operation)
Apply the given operation over the given (r1, r2) extent.
vtkImageStencilData::SetExtent
void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2)
Set the extent of the data.
vtkImageStencilData::InsertNextExtent
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,...
vtkImageStencilRaster::InsertPoint
void InsertPoint(int y, double x, int i)
Insert an x point into the raster.
vtkImageStencilData::ExtentLists
int ** ExtentLists
The actual 'data' is stored here.
Definition: vtkImageStencilData.h:249
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkImageStencilData::Operation
Operation
Definition: vtkImageStencilData.h:206
vtkImageStencilRaster::vtkImageStencilRaster
vtkImageStencilRaster(const int wholeExtent[2])
Create a raster with the specified whole y extent.
vtkImageStencilData::LogicalOperationInPlace
void LogicalOperationInPlace(vtkImageStencilData *stencil, Operation operation)
Combine with the given stencil, using the given operation.
vtkImageStencilData::Add
virtual void Add(vtkImageStencilData *)
Add merges the stencil supplied as argument into Self.
vtkImageStencilRaster::PrepareForNewData
void PrepareForNewData(const int allocateExtent[2]=nullptr)
Reset the raster to its original state, but keep the same whole extent.
vtkImageStencilData::Initialize
void Initialize() override
Restore data object to initial state,.
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkImageStencilRaster::Raster
double ** Raster
Definition: vtkImageStencilData.h:320
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkImageStencilData::CopyInformationFromPipeline
void CopyInformationFromPipeline(vtkInformation *info) override
Override these to handle origin, spacing, scalar type, and scalar number of components.
vtkImageStencilData::ShallowCopy
void ShallowCopy(vtkDataObject *f) override
Shallow and Deep copy.
vtkImageStencilData::RemoveExtent
void RemoveExtent(int r1, int r2, int yIdx, int zIdx)
Remove the extent from (r1,r2) at yIdx, zIdx.
vtkDataObject.h
vtkImageStencilData
efficient description of an image stencil
Definition: vtkImageStencilData.h:53
vtkImageStencilData::CopyInformationToPipeline
void CopyInformationToPipeline(vtkInformation *info) override
Override these to handle origin, spacing, scalar type, and scalar number of components.
vtkImageStencilRaster::GetTolerance
double GetTolerance()
Definition: vtkImageStencilData.h:302
vtkImageStencilData::~vtkImageStencilData
~vtkImageStencilData() override
vtkX3D::extent
@ extent
Definition: vtkX3D.h:351
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:169
vtkImageStencilData::AllocateExtents
void AllocateExtents()
Allocate space for the sub-extents.
vtkImageStencilData::ChangeExtent
void ChangeExtent(const int extent[6])
Change the extent while preserving the data.
vtkImageStencilData::Fill
void Fill()
Fill the sub-extents.
vtkImageStencilData::InternalImageStencilDataCopy
void InternalImageStencilDataCopy(vtkImageStencilData *s)
vtkImageStencilRaster::FillStencilData
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...
vtkImageStencilData::Clip
virtual int Clip(int extent[6])
Clip the stencil with the supplied extents.