| 302 | // grid is the OpenVDB grid to sample, dataArray is the vtk array to fill |
| 303 | template <vtkIdType NComps, typename GridType, typename ArrayType> |
| 304 | void operator()(typename GridType::Ptr grid, ArrayType* dataArray) |
| 305 | { |
| 306 | if (grid == nullptr || dataArray == nullptr || imagedata == nullptr || dataInfo == nullptr) |
| 307 | { |
| 308 | // we need the grid, the vtk array, the image data, and the block information |
| 309 | // to populate the imagedata |
| 310 | return; |
| 311 | } |
| 312 | |
| 313 | // get the dimensions of the vtkImageData |
| 314 | int imgDims[3]; |
| 315 | imagedata->GetDimensions(imgDims); |
| 316 | |
| 317 | if (imgDims[0] <= 0 || imgDims[1] <= 0 || imgDims[2] <= 0) |
| 318 | { |
| 319 | return; |
| 320 | } |
| 321 | |
| 322 | const int maxSubIdx = imgDims[0] * imgDims[1]; |
| 323 | const int maxIdx = maxSubIdx * imgDims[2]; |
| 324 | |
| 325 | vtkSMPTools::For(0, maxIdx, |
| 326 | [this, maxSubIdx, &imgDims, grid, dataArray](vtkIdType idx, vtkIdType endIdx) |
| 327 | { |
| 328 | typename GridType::Accessor accessor = grid->getAccessor(); |
| 329 | float downsamplingFactor = this->dataInfo->DownsamplingFactor; |
| 330 | |
| 331 | for (; idx < endIdx; ++idx) |
| 332 | { |
| 333 | int i, j, k, t; |
| 334 | openvdb::Coord ijk; |
| 335 | k = idx / maxSubIdx; |
| 336 | t = idx % maxSubIdx; |
| 337 | j = t / imgDims[0]; |
| 338 | i = t % imgDims[0]; |
| 339 | // ijk is the sampling location in the OpenVDB grid |
| 340 | ijk.reset(i / downsamplingFactor + dataInfo->BBoxMin[0], |
| 341 | j / downsamplingFactor + dataInfo->BBoxMin[1], |
| 342 | k / downsamplingFactor + dataInfo->BBoxMin[2]); |
| 343 | ::SamplerVdbGrid<NComps, GridType, ArrayType>::SampleVdbGrid( |
| 344 | ijk, accessor, dataArray, idx); |
| 345 | } |
| 346 | }); |
| 347 | } |
| 348 | }; |
| 349 | |
| 350 | //------------------------------------------------------------------------ |
nothing calls this directly
no test coverage detected