VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkImageStencilData.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00029 #ifndef __vtkImageStencilData_h 00030 #define __vtkImageStencilData_h 00031 00032 00033 #include "vtkDataObject.h" 00034 00035 class VTK_IMAGING_EXPORT vtkImageStencilData : public vtkDataObject 00036 { 00037 public: 00038 static vtkImageStencilData *New(); 00039 vtkTypeMacro(vtkImageStencilData, vtkDataObject); 00040 void PrintSelf(ostream& os, vtkIndent indent); 00041 00042 void Initialize(); 00043 void DeepCopy(vtkDataObject *o); 00044 void ShallowCopy(vtkDataObject *f); 00045 void InternalImageStencilDataCopy(vtkImageStencilData *s); 00046 00049 int GetDataObjectType() { return VTK_DATA_OBJECT; } 00050 00052 int GetExtentType() { return VTK_3D_EXTENT; }; 00053 00055 00063 int GetNextExtent(int &r1, int &r2, int xMin, int xMax, 00064 int yIdx, int zIdx, int &iter); 00066 00072 void InsertNextExtent(int r1, int r2, int yIdx, int zIdx); 00073 00080 void InsertAndMergeExtent(int r1, int r2, int yIdx, int zIdx); 00081 00083 void RemoveExtent(int r1, int r2, int yIdx, int zIdx); 00084 00086 00089 vtkSetVector3Macro(Spacing, double); 00090 vtkGetVector3Macro(Spacing, double); 00092 00094 00097 vtkSetVector3Macro(Origin, double); 00098 vtkGetVector3Macro(Origin, double); 00100 00102 00105 void SetExtent(int extent[6]); 00106 void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2); 00107 vtkGetVector6Macro(Extent, int); 00109 00112 void AllocateExtents(); 00113 00115 void Fill(); 00116 00118 00120 virtual void CopyInformationToPipeline(vtkInformation* request, 00121 vtkInformation* input, 00122 vtkInformation* output, 00123 int forceCopy); 00124 virtual void CopyInformationFromPipeline(vtkInformation* request); 00126 00127 //BTX 00129 00130 static vtkImageStencilData* GetData(vtkInformation* info); 00131 static vtkImageStencilData* GetData(vtkInformationVector* v, int i=0); 00132 //ETX 00134 00136 virtual void Add ( vtkImageStencilData * ); 00137 00140 virtual void Subtract( vtkImageStencilData * ); 00141 00144 virtual void Replace( vtkImageStencilData * ); 00145 00148 virtual int Clip( int extent[6] ); 00149 00150 protected: 00151 vtkImageStencilData(); 00152 ~vtkImageStencilData(); 00153 00155 void CopyOriginAndSpacingFromPipeline(); 00156 00159 virtual void InternalAdd( vtkImageStencilData * ); 00160 00161 void CollapseAdditionalIntersections(int r2, int idx, int *clist, 00162 int &clistlen); 00163 00165 00166 double Spacing[3]; 00167 double Origin[3]; 00169 00170 int Extent[6]; 00171 00173 00174 int NumberOfExtentEntries; 00175 int *ExtentListLengths; 00176 int **ExtentLists; 00178 00179 private: 00180 vtkImageStencilData(const vtkImageStencilData&); // Not implemented. 00181 void operator=(const vtkImageStencilData&); // Not implemented. 00182 00183 friend class vtkImageStencilIteratorFriendship; 00184 }; 00185 00186 //BTX 00188 00192 class VTK_IMAGING_EXPORT vtkImageStencilRaster 00193 { 00194 public: 00195 // Description: 00196 // Create a raster with the specified whole y extent. 00197 vtkImageStencilRaster(const int wholeExtent[2]); 00199 00201 ~vtkImageStencilRaster(); 00202 00206 void PrepareForNewData(const int allocateExtent[2] = 0); 00207 00209 00212 void InsertLine(const double p1[2], const double p2[2], 00213 bool inflect1, bool inflect2); 00215 00217 00219 void FillStencilData(vtkImageStencilData *data, const int extent[6], 00220 int xj = 0, int yj = 1); 00222 00224 00225 void SetTolerance(double tol) { this->Tolerance = tol; } 00226 double GetTolerance() { return this->Tolerance; } 00228 00229 protected: 00232 void PrepareExtent(int ymin, int ymax); 00233 00236 void InsertPoint(int y, double x); 00237 00238 int Extent[2]; 00239 int UsedExtent[2]; 00240 double **Raster; 00241 double Tolerance; 00242 00243 private: 00244 vtkImageStencilRaster(const vtkImageStencilRaster&); // Not implemented. 00245 void operator=(const vtkImageStencilRaster&); // Not implemented. 00246 }; 00247 //ETX 00248 00249 #endif 00250 00251 00252