1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkUniformGridAMR.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkOverlappingAMR.h"
#include "vtkUniformGridAMRDataIterator.h"
#include "vtkObjectFactory.h"
#include "vtkAMRInformation.h"
#include "vtkUnsignedCharArray.h"
#include "vtkUniformGrid.h"
#include "vtkInformationIdTypeKey.h"
#include "vtkCellData.h"
#include "vtkDataSetAttributes.h"
#include <vector>
vtkStandardNewMacro(vtkOverlappingAMR);
vtkInformationKeyMacro(vtkOverlappingAMR,NUMBER_OF_BLANKED_POINTS,IdType);
//----------------------------------------------------------------------------
vtkOverlappingAMR::vtkOverlappingAMR()
{
}
//----------------------------------------------------------------------------
vtkOverlappingAMR::~vtkOverlappingAMR()
{
}
//----------------------------------------------------------------------------
void vtkOverlappingAMR::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
if(this->AMRInfo)
{
this->AMRInfo->PrintSelf(os,indent);
}
}
//----------------------------------------------------------------------------
vtkCompositeDataIterator* vtkOverlappingAMR::NewIterator()
{
vtkUniformGridAMRDataIterator* iter = vtkUniformGridAMRDataIterator::New();
iter->SetDataSet( this );
return iter;
}
//----------------------------------------------------------------------------
void vtkOverlappingAMR::SetRefinementRatio(unsigned int level,
int ratio)
{
this->AMRInfo->SetRefinementRatio(level,ratio);
}
//----------------------------------------------------------------------------
int vtkOverlappingAMR::GetRefinementRatio(unsigned int level)
{
if(!AMRInfo->HasRefinementRatio())
{
AMRInfo->GenerateRefinementRatio();
}
return this->AMRInfo->GetRefinementRatio(level);
}
//----------------------------------------------------------------------------
int vtkOverlappingAMR::GetRefinementRatio(vtkCompositeDataIterator* iter)
{
vtkUniformGridAMRDataIterator *amrIter =
vtkUniformGridAMRDataIterator::SafeDownCast( iter );
unsigned int level = amrIter->GetCurrentLevel();
return this->AMRInfo->GetRefinementRatio(level);
}
//----------------------------------------------------------------------------
void vtkOverlappingAMR::GenerateParentChildInformation()
{
this->AMRInfo->GenerateParentChildInformation();
}
//----------------------------------------------------------------------------
bool vtkOverlappingAMR::
HasChildrenInformation()
{
return AMRInfo->HasChildrenInformation();
}
//----------------------------------------------------------------------------
unsigned int *vtkOverlappingAMR::
GetParents(unsigned int level, unsigned int index, unsigned int& num)
{
return this->AMRInfo->GetParents(level,index,num);
}
//------------------------------------------------------------------------------
unsigned int *vtkOverlappingAMR::
GetChildren(unsigned int level, unsigned int index, unsigned int& num)
{
return this->AMRInfo->GetChildren(level,index,num);
}
//------------------------------------------------------------------------------
void vtkOverlappingAMR::
PrintParentChildInfo(unsigned int level, unsigned int index)
{
this->AMRInfo->PrintParentChildInfo(level,index);
}
//------------------------------------------------------------------------------
void vtkOverlappingAMR::SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box)
{
this->AMRInfo->SetAMRBox(level,id,box);
}
//------------------------------------------------------------------------------
const vtkAMRBox& vtkOverlappingAMR::GetAMRBox(unsigned int level, unsigned int id)
{
const vtkAMRBox& box = this->AMRInfo->GetAMRBox(level,id);
if(box.IsInvalid())
{
vtkErrorMacro("Invalid AMR box");
}
return box;
}
//------------------------------------------------------------------------------
void vtkOverlappingAMR::SetSpacing(unsigned int level,const double spacing[3])
{
this->AMRInfo->SetSpacing(level,spacing);
}
//------------------------------------------------------------------------------
void vtkOverlappingAMR::GetSpacing(unsigned int level, double spacing[3])
{
return this->AMRInfo->GetSpacing(level,spacing);
}
//----------------------------------------------------------------------------
void vtkOverlappingAMR::GetBounds(unsigned int level, unsigned int id, double* bb)
{
this->AMRInfo->GetBounds(level, id, bb);
}
//----------------------------------------------------------------------------
void vtkOverlappingAMR::GetOrigin(unsigned int level, unsigned int id, double origin[3])
{
double bb[6];
this->GetBounds(level,id,bb);
origin[0] = bb[0];
origin[1] = bb[2];
origin[2] = bb[4];
}
//----------------------------------------------------------------------------
void vtkOverlappingAMR::SetOrigin(const double* origin)
{
return this->AMRInfo->SetOrigin(origin);
}
//----------------------------------------------------------------------------
double* vtkOverlappingAMR::GetOrigin()
{
return this->AMRInfo? this->AMRInfo->GetOrigin() : NULL;
}
//----------------------------------------------------------------------------
void vtkOverlappingAMR::SetAMRBlockSourceIndex(unsigned int level, unsigned int id, int sourceId)
{
unsigned int index = this->AMRInfo->GetIndex(level,id);
this->AMRInfo->SetAMRBlockSourceIndex(index, sourceId);
}
//----------------------------------------------------------------------------
int vtkOverlappingAMR::GetAMRBlockSourceIndex(unsigned int level, unsigned int id)
{
unsigned int index = this->AMRInfo->GetIndex(level,id);
return this->AMRInfo->GetAMRBlockSourceIndex(index);
}
//----------------------------------------------------------------------------
void vtkOverlappingAMR::Audit()
{
this->AMRInfo->Audit();
int emptyDimension(-1);
switch (this->GetGridDescription())
{
case VTK_YZ_PLANE: emptyDimension = 0; break;
case VTK_XZ_PLANE: emptyDimension = 1; break;
case VTK_XY_PLANE: emptyDimension = 2; break;
}
vtkSmartPointer<vtkUniformGridAMRDataIterator> iter;
iter.TakeReference(vtkUniformGridAMRDataIterator::SafeDownCast(this->NewIterator()));
iter->SetSkipEmptyNodes(1);
for(iter->GoToFirstItem(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
{
vtkUniformGrid* grid = vtkUniformGrid::SafeDownCast(iter->GetCurrentDataObject());
int hasGhost = grid->HasAnyGhostCells();
unsigned int level = iter->GetCurrentLevel();
unsigned int id = iter->GetCurrentIndex();
const vtkAMRBox& box = this->AMRInfo->GetAMRBox(level,id);
int dims[3];
box.GetNumberOfNodes(dims);
double spacing[3];
this->GetSpacing(level,spacing);
double origin[3];
this->GetOrigin(level,id,origin);
for(int d = 0; d<3; d++)
{
if(d==emptyDimension)
{
if(grid->GetSpacing()[d]!=spacing[d])
{
vtkErrorMacro("The grid spacing does not match AMRInfo at ("<<level<<", "<<id<<")");
}
if(!hasGhost && grid->GetOrigin()[d]!=origin[d])
{
vtkErrorMacro("The grid origin does not match AMRInfo at ("<<level<<", "<<id<<")");
}
if(!hasGhost && grid->GetDimensions()[d]!=dims[d])
{
vtkErrorMacro("The grid dimensions does not match AMRInfo at ("<<level<<", "<<id<<")");
}
}
}
}
}
bool vtkOverlappingAMR::FindGrid(double q[3], unsigned int& level, unsigned int& gridId)
{
return this->AMRInfo->FindGrid(q,level,gridId);
}
|