1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkUniformGrid.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 =========================================================================*/ 15 // .NAME vtkUniformGrid - image data with blanking 16 // .SECTION Description 17 // vtkUniformGrid is a subclass of vtkImageData. In addition to all 18 // the image data functionality, it supports blanking. 19 20 #ifndef vtkUniformGrid_h 21 #define vtkUniformGrid_h 22 23 #include "vtkCommonDataModelModule.h" // For export macro 24 #include "vtkImageData.h" 25 26 class vtkEmptyCell; 27 class vtkStructuredVisibilityConstraint; 28 class vtkUnsignedCharArray; 29 class vtkAMRBox; 30 31 class VTKCOMMONDATAMODEL_EXPORT vtkUniformGrid : public vtkImageData 32 { 33 public: 34 // Description: 35 // Construct an empty uniform grid. 36 static vtkUniformGrid *New(); 37 vtkTypeMacro(vtkUniformGrid,vtkImageData); 38 void PrintSelf(ostream& os, vtkIndent indent); 39 40 // Description: 41 // Copy the geometric and topological structure of an input image data 42 // object. 43 virtual void CopyStructure(vtkDataSet *ds); 44 45 // Description: 46 // Return what type of dataset this is. GetDataObjectType()47 virtual int GetDataObjectType() {return VTK_UNIFORM_GRID;}; 48 49 // Description: 50 // Standard vtkDataSet API methods. See vtkDataSet for more information. 51 virtual vtkCell *GetCell(vtkIdType cellId); 52 virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell); 53 virtual vtkIdType FindCell( 54 double x[3], vtkCell *cell, vtkIdType cellId, double tol2, 55 int& subId, double pcoords[3], double *weights); 56 virtual vtkIdType FindCell( 57 double x[3], vtkCell *cell, vtkGenericCell *gencell, 58 vtkIdType cellId, double tol2, int& subId, 59 double pcoords[3], double *weights); 60 virtual vtkCell *FindAndGetCell( 61 double x[3], vtkCell *cell, vtkIdType cellId, 62 double tol2, int& subId, double pcoords[3], 63 double *weights); 64 virtual int GetCellType(vtkIdType cellId); GetCellPoints(vtkIdType cellId,vtkIdList * ptIds)65 virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) 66 {vtkStructuredData::GetCellPoints(cellId,ptIds,this->GetDataDescription(), 67 this->GetDimensions());} GetPointCells(vtkIdType ptId,vtkIdList * cellIds)68 virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) 69 {vtkStructuredData::GetPointCells(ptId,cellIds,this->GetDimensions());} 70 virtual void Initialize(); GetMaxCellSize()71 virtual int GetMaxCellSize() {return 8;}; //voxel is the largest 72 73 // Description: 74 // Returns the data description of this uniform grid instance. 75 int GetGridDescription(); 76 77 // BTX 78 // Description: 79 // Initialize with no ghost cell arrays, from the definition in 80 // the given box. The box is expetced to be 3D, if you have 2D 81 // data the set the third dimensions 0. eg. (X,X,0)(X,X,0) 82 // Returns 0 if the initialization failed. 83 int Initialize(const vtkAMRBox *def, double* origin, double* spacing); 84 // Description: 85 // Initialize from the definition in the given box, with ghost cell 86 // arrays nGhosts cells thick in all directions. The box is expetced 87 // to be 3D, if you have 2D data the set the third dimensions 0. 88 // eg. (X,X,0)(X,X,0) 89 // Returns 0 if the initialization failed. 90 int Initialize(const vtkAMRBox *def, double* origin, double* spacing, int nGhosts); 91 92 // Description: 93 // Initialize from the definition in the given box, with ghost cell 94 // arrays of the thickness given in each direction by "nGhosts" array. 95 // The box and ghost array are expected to be 3D, if you have 2D data 96 // the set the third dimensions 0. eg. (X,X,0)(X,X,0) 97 // Returns 0 if the initialization failed. 98 int Initialize(const vtkAMRBox *def, double* origin, double* spacing, const int nGhosts[3]); 99 // Description: 100 // Construct a uniform grid, from the definition in the given box 101 // "def", with ghost cell arrays of the thickness given in each 102 // direction by "nGhosts*". The box and ghost array are expected 103 // to be 3D, if you have 2D data the set the third dimensions 0. eg. 104 // (X,X,0)(X,X,0) 105 // Returns 0 if the initialization failed. 106 int Initialize(const vtkAMRBox *def, double* origin, double* spacing, int nGhostsI,int nGhostsJ,int nGhostsK); 107 //ETX 108 109 // Description: 110 // Shallow and Deep copy. 111 virtual void ShallowCopy(vtkDataObject *src); 112 virtual void DeepCopy(vtkDataObject *src); 113 114 // Description: 115 // Methods for supporting blanking of cells. Blanking turns on or off 116 // points in the structured grid, and hence the cells connected to them. 117 // These methods should be called only after the dimensions of the 118 // grid are set. 119 virtual void BlankPoint(vtkIdType ptId); 120 virtual void UnBlankPoint(vtkIdType ptId); 121 virtual void BlankPoint( const int i, const int j, const int k ); 122 virtual void UnBlankPoint( const int i, const int j, const int k ); 123 124 // Description: 125 // Methods for supporting blanking of cells. Blanking turns on or off 126 // cells in the structured grid. 127 // These methods should be called only after the dimensions of the 128 // grid are set. 129 virtual void BlankCell(vtkIdType ptId); 130 virtual void UnBlankCell(vtkIdType ptId); 131 virtual void BlankCell( const int i, const int j, const int k ); 132 virtual void UnBlankCell( const int i, const int j, const int k ); 133 134 // Description: 135 // Get the array that defines the blanking (visibility) of each point. 136 virtual vtkUnsignedCharArray *GetPointVisibilityArray(); 137 138 // Description: 139 // Set an array that defines the (blanking) visibility of the points 140 // in the grid. Make sure that length of the visibility array matches 141 // the number of points in the grid. 142 virtual void SetPointVisibilityArray(vtkUnsignedCharArray *pointVisibility); 143 144 // Description: 145 // Get the array that defines the blanking (visibility) of each cell. 146 virtual vtkUnsignedCharArray *GetCellVisibilityArray(); 147 148 // Description: 149 // Set an array that defines the (blanking) visibility of the cells 150 // in the grid. Make sure that length of the visibility array matches 151 // the number of points in the grid. 152 virtual void SetCellVisibilityArray(vtkUnsignedCharArray *pointVisibility); 153 154 // Description: 155 // Attaches the CellVisibility array to the Cell data. 156 // Used primarily for debugging. 157 virtual void AttachCellVisibilityToCellData( ); 158 159 // Description: 160 // Attaches the PointVisibility arry to the Point data. 161 // Used primarily for debugging. 162 virtual void AttachPointVisibilityToPointData( ); 163 164 // Description: 165 // Return non-zero value if specified point is visible. 166 // These methods should be called only after the dimensions of the 167 // grid are set. 168 virtual unsigned char IsPointVisible(vtkIdType ptId); 169 170 // Description: 171 // Return non-zero value if specified cell is visible. 172 // These methods should be called only after the dimensions of the 173 // grid are set. 174 virtual unsigned char IsCellVisible(vtkIdType cellId); 175 176 // Description: 177 // Returns 1 if there is any visibility constraint on the points, 178 // 0 otherwise. 179 virtual unsigned char GetPointBlanking(); 180 181 // Description: 182 // Returns 1 if there is any visibility constraint on the cells, 183 // 0 otherwise. 184 virtual unsigned char GetCellBlanking(); 185 186 virtual vtkImageData* NewImageDataCopy(); 187 188 //BTX 189 // Description: 190 // Retrieve an instance of this class from an information object. 191 static vtkUniformGrid* GetData(vtkInformation* info); 192 static vtkUniformGrid* GetData(vtkInformationVector* v, int i=0); 193 //ETX 194 195 protected: 196 vtkUniformGrid(); 197 ~vtkUniformGrid(); 198 199 // Description: 200 // Returns the cell dimensions for this vtkUniformGrid instance. 201 void GetCellDims( int cellDims[3] ); 202 203 // Description: 204 // Override this method because of blanking. 205 virtual void ComputeScalarRange(); 206 207 vtkStructuredVisibilityConstraint* PointVisibility; 208 209 void SetPointVisibility(vtkStructuredVisibilityConstraint *pointVisibility); 210 vtkGetObjectMacro(PointVisibility, vtkStructuredVisibilityConstraint); 211 212 vtkStructuredVisibilityConstraint* CellVisibility; 213 214 void SetCellVisibility(vtkStructuredVisibilityConstraint *cellVisibility); 215 vtkGetObjectMacro(CellVisibility, vtkStructuredVisibilityConstraint); 216 217 vtkEmptyCell* GetEmptyCell(); 218 219 private: 220 vtkUniformGrid(const vtkUniformGrid&); // Not implemented. 221 void operator=(const vtkUniformGrid&); // Not implemented. 222 223 vtkEmptyCell *EmptyCell; 224 }; 225 226 227 #endif 228 229 230 231