1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkOverlappingAMR.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 /** 16 * @class vtkOverlappingAMR 17 * @brief hierarchical dataset of vtkUniformGrids 18 * 19 * 20 * vtkOverlappingAMR extends vtkUniformGridAMR by exposing access to the 21 * amr meta data, which stores all structural information represented 22 * by an vtkAMRInformation object 23 * 24 * @sa 25 * vtkAMRInformation 26 */ 27 28 #ifndef vtkOverlappingAMR_h 29 #define vtkOverlappingAMR_h 30 31 #include "vtkCommonDataModelModule.h" // For export macro 32 #include "vtkUniformGridAMR.h" 33 34 class vtkAMRBox; 35 class vtkCompositeDataIterator; 36 class vtkUniformGrid; 37 class vtkAMRInformation; 38 class vtkInformationIdTypeKey; 39 40 class VTKCOMMONDATAMODEL_EXPORT vtkOverlappingAMR : public vtkUniformGridAMR 41 { 42 public: 43 static vtkOverlappingAMR* New(); 44 45 /** 46 * Return class name of data type (see vtkType.h for definitions). 47 */ GetDataObjectType()48 int GetDataObjectType() override { return VTK_OVERLAPPING_AMR; } 49 50 vtkTypeMacro(vtkOverlappingAMR, vtkUniformGridAMR); 51 void PrintSelf(ostream& os, vtkIndent indent) override; 52 53 /** 54 * Return a new iterator (the iterator has to be deleted by the user). 55 */ 56 VTK_NEWINSTANCE vtkCompositeDataIterator* NewIterator() override; 57 58 ///@{ 59 /** 60 * Get/Set the global origin of the amr data set 61 */ 62 void SetOrigin(const double origin[3]); 63 double* GetOrigin(); 64 ///@} 65 66 ///@{ 67 /** 68 * Get/Set the grid spacing at a given level 69 */ 70 void SetSpacing(unsigned int level, const double spacing[3]); 71 void GetSpacing(unsigned int level, double spacing[3]); 72 ///@} 73 74 ///@{ 75 /** 76 * Set/Get the AMRBox for a given block 77 */ 78 void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box); 79 const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id); 80 ///@} 81 82 /** 83 * Returns the bounding information of a data set. 84 */ 85 void GetBounds(unsigned int level, unsigned int id, double bb[6]); 86 87 /** 88 * Returns the origin of an AMR block 89 */ 90 void GetOrigin(unsigned int level, unsigned int id, double origin[3]); 91 92 static vtkInformationIdTypeKey* NUMBER_OF_BLANKED_POINTS(); 93 94 /** 95 * Retrieve an instance of this class from an information object. 96 */ GetData(vtkInformation * info)97 static vtkOverlappingAMR* GetData(vtkInformation* info) 98 { 99 return vtkOverlappingAMR::SafeDownCast(Superclass::GetData(info)); 100 } 101 static vtkOverlappingAMR* GetData(vtkInformationVector* v, int i = 0) 102 { 103 return vtkOverlappingAMR::SafeDownCast(Superclass::GetData(v, i)); 104 } 105 106 /** 107 * Sets the refinement of a given level. The spacing at level 108 * level+1 is defined as spacing(level+1) = spacing(level)/refRatio(level). 109 * Note that currently, this is not enforced by this class however 110 * some algorithms might not function properly if the spacing in 111 * the blocks (vtkUniformGrid) does not match the one described 112 * by the refinement ratio. 113 */ 114 void SetRefinementRatio(unsigned int level, int refRatio); 115 116 /** 117 * Returns the refinement of a given level. 118 */ 119 int GetRefinementRatio(unsigned int level); 120 121 ///@{ 122 /** 123 * Set/Get the source id of a block. The source id is produced by an 124 * AMR source, e.g. a file reader might set this to be a file block id 125 */ 126 void SetAMRBlockSourceIndex(unsigned int level, unsigned int id, int sourceId); 127 int GetAMRBlockSourceIndex(unsigned int level, unsigned int id); 128 ///@} 129 130 /** 131 * Returns the refinement ratio for the position pointed by the iterator. 132 */ 133 int GetRefinementRatio(vtkCompositeDataIterator* iter); 134 135 /** 136 * Return whether parent child information has been generated 137 */ 138 bool HasChildrenInformation(); 139 140 /** 141 * Generate the parent/child relationships - needed to be called 142 * before GetParents or GetChildren can be used! 143 */ 144 void GenerateParentChildInformation(); 145 146 /** 147 * Return a pointer to Parents of a block. The first entry is the number 148 * of parents the block has followed by its parent ids in level-1. 149 * If none exits it returns nullptr. 150 */ 151 unsigned int* GetParents(unsigned int level, unsigned int index, unsigned int& numParents); 152 153 /** 154 * Return a pointer to Children of a block. The first entry is the number 155 * of children the block has followed by its children ids in level+1. 156 * If none exits it returns nullptr. 157 */ 158 unsigned int* GetChildren(unsigned int level, unsigned int index, unsigned int& numChildren); 159 160 /** 161 * Prints the parents and children of a requested block (Debug Routine) 162 */ 163 void PrintParentChildInfo(unsigned int level, unsigned int index); 164 165 // Unhide superclass method GetBounds(double b[6])166 void GetBounds(double b[6]) { Superclass::GetBounds(b); } 167 168 /** 169 * Given a point q, find the highest level grid that contains it. 170 */ 171 bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId); 172 173 /** 174 * Get/Set the internal representation of amr meta meta data 175 */ GetAMRInfo()176 vtkAMRInformation* GetAMRInfo() override { return Superclass::GetAMRInfo(); } SetAMRInfo(vtkAMRInformation * info)177 void SetAMRInfo(vtkAMRInformation* info) override { return Superclass::SetAMRInfo(info); } 178 179 ///@{ 180 /** 181 * Check whether the data set is internally consistent, e.g. 182 * whether the meta data and actual data blocks match. 183 * Incorrectness will be reported as error messages 184 */ 185 void Audit(); 186 187 protected: 188 vtkOverlappingAMR(); 189 ~vtkOverlappingAMR() override; 190 ///@} 191 192 private: 193 vtkOverlappingAMR(const vtkOverlappingAMR&) = delete; 194 void operator=(const vtkOverlappingAMR&) = delete; 195 }; 196 197 #endif 198