------------------------------------------------------------------------------
| 304 | } |
| 305 | //------------------------------------------------------------------------------ |
| 306 | void vtkAMRVolumeMapper::UpdateResampler(vtkRenderer* ren, vtkOverlappingAMR* amr) |
| 307 | { |
| 308 | // Set the bias of the resample filter to be the projection direction |
| 309 | double bvec[3]; |
| 310 | vtkCamera* cam = ren->GetActiveCamera(); |
| 311 | double d, d2, fp[3], pd, gb[6]; |
| 312 | d = cam->GetDistance(); |
| 313 | cam->GetFocalPoint(fp); |
| 314 | |
| 315 | if (this->Grid) |
| 316 | { |
| 317 | // Compare distances with the grid's bounds |
| 318 | this->Grid->GetBounds(gb); |
| 319 | vtkBoundingBox bbox(gb); |
| 320 | double maxL = bbox.GetMaxLength(); |
| 321 | // If the grid's max length is 0 then we need to update |
| 322 | if (maxL > 0.0) |
| 323 | { |
| 324 | pd = fabs(d - this->LastPostionFPDistance) / this->LastPostionFPDistance; |
| 325 | if ((this->LastPostionFPDistance > 0.0) && (pd <= this->ResamplerUpdateTolerance)) |
| 326 | { |
| 327 | // Lets see if the focal point has not moved enough to cause an update |
| 328 | d2 = vtkMath::Distance2BetweenPoints(fp, this->LastFocalPointPosition) / (maxL * maxL); |
| 329 | if (d2 <= (this->ResamplerUpdateTolerance * this->ResamplerUpdateTolerance)) |
| 330 | { |
| 331 | // nothing needs to be updated |
| 332 | return; |
| 333 | } |
| 334 | else |
| 335 | { |
| 336 | // int oops = 1; |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | cam->GetDirectionOfProjection(bvec); |
| 342 | this->Resampler->SetBiasVector(bvec); |
| 343 | this->Resampler->SetUseBiasVector(true); |
| 344 | this->LastPostionFPDistance = d; |
| 345 | this->LastFocalPointPosition[0] = fp[0]; |
| 346 | this->LastFocalPointPosition[1] = fp[1]; |
| 347 | this->LastFocalPointPosition[2] = fp[2]; |
| 348 | |
| 349 | if (this->RequestedResamplingMode == 0) |
| 350 | { |
| 351 | this->UpdateResamplerFrustrumMethod(ren, amr); |
| 352 | } |
| 353 | else |
| 354 | { |
| 355 | // This is the focal point approach where we |
| 356 | // center the grid on the focal point and set its length |
| 357 | // to be the distance between the camera and its focal point |
| 358 | double p[3]; |
| 359 | p[0] = fp[0] - d; |
| 360 | p[1] = fp[1] - d; |
| 361 | p[2] = fp[2] - d; |
| 362 | // Now set the min/max of the resample filter |
| 363 | this->Resampler->SetMin(p); |
no test coverage detected