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 00071 int IsInside( int xIdx, int yIdx, int zIdx ); 00072 00078 void InsertNextExtent(int r1, int r2, int yIdx, int zIdx); 00079 00086 void InsertAndMergeExtent(int r1, int r2, int yIdx, int zIdx); 00087 00089 void RemoveExtent(int r1, int r2, int yIdx, int zIdx); 00090 00092 00095 vtkSetVector3Macro(Spacing, double); 00096 vtkGetVector3Macro(Spacing, double); 00098 00100 00103 vtkSetVector3Macro(Origin, double); 00104 vtkGetVector3Macro(Origin, double); 00106 00108 00111 void SetExtent(int extent[6]); 00112 void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2); 00113 vtkGetVector6Macro(Extent, int); 00115 00118 void AllocateExtents(); 00119 00121 void Fill(); 00122 00124 00126 virtual void CopyInformationToPipeline(vtkInformation* request, 00127 vtkInformation* input, 00128 vtkInformation* output, 00129 int forceCopy); 00130 virtual void CopyInformationFromPipeline(vtkInformation* request); 00132 00133 //BTX 00135 00136 static vtkImageStencilData* GetData(vtkInformation* info); 00137 static vtkImageStencilData* GetData(vtkInformationVector* v, int i=0); 00138 //ETX 00140 00142 virtual void Add ( vtkImageStencilData * ); 00143 00146 virtual void Subtract( vtkImageStencilData * ); 00147 00150 virtual void Replace( vtkImageStencilData * ); 00151 00154 virtual int Clip( int extent[6] ); 00155 00156 protected: 00157 vtkImageStencilData(); 00158 ~vtkImageStencilData(); 00159 00161 void CopyOriginAndSpacingFromPipeline(); 00162 00165 virtual void InternalAdd( vtkImageStencilData * ); 00166 00167 void CollapseAdditionalIntersections(int r2, int idx, int *clist, 00168 int &clistlen); 00169 00171 00172 double Spacing[3]; 00173 double Origin[3]; 00175 00176 int Extent[6]; 00177 00179 00180 int NumberOfExtentEntries; 00181 int *ExtentListLengths; 00182 int **ExtentLists; 00184 00185 private: 00186 vtkImageStencilData(const vtkImageStencilData&); // Not implemented. 00187 void operator=(const vtkImageStencilData&); // Not implemented. 00188 00189 friend class vtkImageStencilIteratorFriendship; 00190 }; 00191 00192 //BTX 00194 00198 class VTK_IMAGING_EXPORT vtkImageStencilRaster 00199 { 00200 public: 00202 00203 vtkImageStencilRaster(const int wholeExtent[2]); 00204 00206 ~vtkImageStencilRaster(); 00207 00211 void PrepareForNewData(const int allocateExtent[2] = 0); 00212 00214 00217 void InsertLine(const double p1[2], const double p2[2], 00218 bool inflect1, bool inflect2); 00220 00222 00224 void FillStencilData(vtkImageStencilData *data, const int extent[6], 00225 int xj = 0, int yj = 1); 00227 00229 00230 void SetTolerance(double tol) { this->Tolerance = tol; } 00231 double GetTolerance() { return this->Tolerance; } 00233 00234 protected: 00237 void PrepareExtent(int ymin, int ymax); 00238 00241 void InsertPoint(int y, double x); 00242 00243 int Extent[2]; 00244 int UsedExtent[2]; 00245 double **Raster; 00246 double Tolerance; 00247 00248 private: 00249 vtkImageStencilRaster(const vtkImageStencilRaster&); // Not implemented. 00250 void operator=(const vtkImageStencilRaster&); // Not implemented. 00251 }; 00252 //ETX 00253 00254 #endif 00255 00256 00257