VTK  9.0.20200605
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:
36  static vtkImageStencilData* New();
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;
43  void InternalImageStencilDataCopy(vtkImageStencilData* s);
44 
49  int GetDataObjectType() override { return VTK_DATA_OBJECT; }
50 
54  int GetExtentType() override { return VTK_3D_EXTENT; }
55 
65  int GetNextExtent(int& r1, int& r2, int xMin, int xMax, int yIdx, int zIdx, int& iter);
66 
73  int IsInside(int xIdx, int yIdx, int zIdx);
74 
82  void InsertNextExtent(int r1, int r2, int yIdx, int zIdx);
83 
92  void InsertAndMergeExtent(int r1, int r2, int yIdx, int zIdx);
93 
97  void RemoveExtent(int r1, int r2, int yIdx, int zIdx);
98 
100 
106  vtkSetVector3Macro(Spacing, double);
107  vtkGetVector3Macro(Spacing, double);
109 
111 
117  vtkSetVector3Macro(Origin, double);
118  vtkGetVector3Macro(Origin, double);
120 
122 
127  void SetExtent(const int extent[6]);
128  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
129  vtkGetVector6Macro(Extent, int);
131 
136  void AllocateExtents();
137 
141  void Fill();
142 
144 
151 
153 
157  static vtkImageStencilData* GetData(vtkInformationVector* v, int i = 0);
159 
163  virtual void Add(vtkImageStencilData*);
164 
169  virtual void Subtract(vtkImageStencilData*);
170 
175  virtual void Replace(vtkImageStencilData*);
176 
181  virtual int Clip(int extent[6]);
182 
183 protected:
185  ~vtkImageStencilData() override;
186 
188  {
190  Erase
191  };
192 
196  void LogicalOperationExtent(int r1, int r2, int yIdx, int zIdx, Operation operation);
197 
201  void LogicalOperationInPlace(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 pt1[2], const double pt2[2]);
273 
278  void FillStencilData(vtkImageStencilData* data, const int extent[6], int xj = 0, int yj = 1);
279 
283  void SetTolerance(double tol) { this->Tolerance = tol; }
284  double GetTolerance() { return this->Tolerance; }
285 
286 protected:
291  void PrepareExtent(int ymin, int ymax);
292 
298  void InsertPoint(int y, double x, int i);
299 
300  int Extent[2];
301  int UsedExtent[2];
302  double** Raster;
303  double Tolerance;
304 
305 private:
307  void operator=(const vtkImageStencilRaster&) = delete;
308 };
309 
310 #endif
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:84
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:49
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:321
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:283
vtkDataObject::CopyInformationFromPipeline
virtual void CopyInformationFromPipeline(vtkInformation *vtkNotUsed(info))
Copy from the pipeline information to the data object's own information.
Definition: vtkDataObject.h:146
vtkImageStencilData::Merge
Definition: vtkImageStencilData.h:189
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:54
VTK_3D_EXTENT
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:56
vtkImageStencilRaster::Tolerance
double Tolerance
Definition: vtkImageStencilData.h:303
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:187
vtkDataObject::CopyInformationToPipeline
virtual void CopyInformationToPipeline(vtkInformation *vtkNotUsed(info))
Copy information from this data object to the pipeline information.
Definition: vtkDataObject.h:153
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkImageStencilRaster::Raster
double ** Raster
Definition: vtkImageStencilData.h:302
vtkX3D::info
Definition: vtkX3D.h:382
vtkDataObject.h
vtkImageStencilData
efficient description of an image stencil
Definition: vtkImageStencilData.h:33
vtkImageStencilRaster::GetTolerance
double GetTolerance()
Definition: vtkImageStencilData.h:284
vtkX3D::extent
Definition: vtkX3D.h:351
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
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()