vtkIdType avtCellLocatorClassic::FindCell( const double pos[3], avtInterpolationWeights* weights, bool ignoreGhostCells ) const { int ijk[3]; for( int j=0; j<3; j++ ) { ijk[j] = (int)( (pos[j]-B[2*j]) / H[j] ); if( ijk[j] < 0 ) ijk[j] = 0; else if( ijk[j] >= (int)NumberOfDivisions ) ijk[j] = NumberOfDivisions-1; } int leafStart = NumberOfOctants - NumberOfDivisions*NumberOfDivisions*NumberOfDivisions; vtkIdList* leafids = Tree[ leafStart + ijk[0] + ijk[1]*NumberOfDivisions + ijk[2]*NumberOfDivisions*NumberOfDivisions ]; if( leafids == NULL ) return -1; for( int j=0; j < leafids->GetNumberOfIds(); j++ ) { vtkIdType id = leafids->GetId( j ); if( TestCell( id, pos, weights, ignoreGhostCells ) ) return id; } return -1; }
vtkIdType avtCellLocatorRect::FindCell(const double pos[3], avtInterpolationWeights *weights, bool ignoreGhostCells) const { #if 0 vtkRectilinearGrid* rg = (vtkRectilinearGrid*)dataSet; int ijk[3]; if( vtkVisItUtility::ComputeStructuredCoordinates(rg, (double*)pos, ijk) == 0 ) return -1; vtkIdType cell = rg->ComputeCellId( ijk ); if( cell < 0 ) return -1; return TestCell( cell, pos, weights, ignoreGhostCells ) ? cell : -1; #else int i[3]; double l[3]; for( unsigned int d=0; d<3; d++ ) { if( coord[d].size() == 1 ) { // flat grid if( pos[d] != coord[d].front() ) return false; i[d] = 0; l[d] = 0.0; } else { // binary search std::vector<float>::const_iterator ci; if (ascending[d]) { ci = std::lower_bound( coord[d].begin(), coord[d].end(), pos[d], std::less<float>() ); } else { ci = std::lower_bound( coord[d].begin(), coord[d].end(), pos[d], std::greater<float>() ); } if( ci == coord[d].end() ) return -1; if( ci == coord[d].begin() ) { if( ascending[d] ) { if (pos[d] < *ci ) return -1; } else { if (pos[d] > *ci ) return -1; } } else --ci; i[d] = ci - coord[d].begin(); // This math works whether coord is monotonically increasing or // decreasing, since it just calculating a value in [0, 1] for // the distance between ci[0] and ci[1]. l[d] = (pos[d] - ci[0])/(ci[1]-ci[0]); } } vtkIdType cell = (i[2]*(coord[1].size()-1) + i[1])*(coord[0].size()-1) + i[0]; if( ignoreGhostCells && ghostPtr && ghostPtr[cell] ) return -1; if( weights ) { const float k[3] = { 1.0f-l[0], 1.0f-l[1], 1.0f-l[2] }; vtkIdType base = (i[2]*coord[1].size() + i[1])*coord[0].size() + i[0]; vtkIdType dx = (coord[0].size() > 1) ? 1 : 0; vtkIdType dy = (coord[1].size() > 1) ? coord[0].size() : 0; vtkIdType dz = (coord[2].size() > 1) ? coord[1].size()*coord[0].size() : 0; weights->resize( 8 ); (*weights)[0].i = base; (*weights)[0].w = k[0]*k[1]*k[2]; (*weights)[1].i = base+dx; (*weights)[1].w = l[0]*k[1]*k[2]; (*weights)[2].i = base+dy; (*weights)[2].w = k[0]*l[1]*k[2]; (*weights)[3].i = base+dx+dy; (*weights)[3].w = l[0]*l[1]*k[2]; (*weights)[4].i = base+dz; (*weights)[4].w = k[0]*k[1]*l[2]; (*weights)[5].i = base+dz+dx; (*weights)[5].w = l[0]*k[1]*l[2]; (*weights)[6].i = base+dz+dy; (*weights)[6].w = k[0]*l[1]*l[2]; (*weights)[7].i = base+dx+dy+dz; (*weights)[7].w = l[0]*l[1]*l[2]; } return cell; #endif }
peano::kernel::regulargrid::tests::records::TestCell peano::kernel::regulargrid::tests::records::TestCellPacked::convert() const{ return TestCell( getIsInside() ); }