| 328 | //------------------------------------------------------------------------------ |
| 329 | |
| 330 | void vtkUnstructuredGridPreIntegration::Initialize(vtkVolume* volume, vtkDataArray* scalars) |
| 331 | { |
| 332 | vtkVolumeProperty* property = volume->GetProperty(); |
| 333 | |
| 334 | if ((property == this->Property) && (this->IntegrationTableBuilt > property->GetMTime()) && |
| 335 | (this->IntegrationTableBuilt > this->MTime)) |
| 336 | { |
| 337 | // Nothing changed from the last time Initialize was run. |
| 338 | return; |
| 339 | } |
| 340 | |
| 341 | this->Property = property; |
| 342 | this->Volume = volume; |
| 343 | this->IntegrationTableBuilt.Modified(); |
| 344 | |
| 345 | if (!property->GetIndependentComponents()) |
| 346 | { |
| 347 | vtkErrorMacro("Cannot store dependent components in pre-integration table."); |
| 348 | return; |
| 349 | } |
| 350 | |
| 351 | // Determine the maximum possible length of a ray segment. |
| 352 | vtkDataSet* input = volume->GetMapper()->GetDataSetInput(); |
| 353 | vtkIdType numcells = input->GetNumberOfCells(); |
| 354 | this->MaxLength = 0; |
| 355 | for (vtkIdType i = 0; i < numcells; i++) |
| 356 | { |
| 357 | double cellbounds[6]; |
| 358 | input->GetCellBounds(i, cellbounds); |
| 359 | #define SQR(x) ((x) * (x)) |
| 360 | double diagonal_length = sqrt(SQR(cellbounds[1] - cellbounds[0]) + |
| 361 | SQR(cellbounds[3] - cellbounds[2]) + SQR(cellbounds[5] - cellbounds[4])); |
| 362 | #undef SQR |
| 363 | this->MaxLength = std::max(diagonal_length, this->MaxLength); |
| 364 | } |
| 365 | |
| 366 | this->BuildPreIntegrationTables(scalars); |
| 367 | } |
| 368 | |
| 369 | //------------------------------------------------------------------------------ |
| 370 |
no test coverage detected