| 369 | //------------------------------------------------------------------------------ |
| 370 | |
| 371 | void vtkUnstructuredGridPreIntegration::Integrate(vtkDoubleArray* intersectionLengths, |
| 372 | vtkDataArray* nearIntersections, vtkDataArray* farIntersections, float color[4]) |
| 373 | { |
| 374 | vtkIdType numIntersections = intersectionLengths->GetNumberOfTuples(); |
| 375 | |
| 376 | for (vtkIdType i = 0; i < numIntersections; i++) |
| 377 | { |
| 378 | float* c = this->GetTableEntry(nearIntersections->GetComponent(i, 0), |
| 379 | farIntersections->GetComponent(i, 0), intersectionLengths->GetComponent(i, 0), 0); |
| 380 | float newcolor[4] = { c[0], c[1], c[2], c[3] }; |
| 381 | for (int component = 1; component < this->NumComponents; component++) |
| 382 | { |
| 383 | c = this->GetTableEntry(nearIntersections->GetComponent(i, component), |
| 384 | farIntersections->GetComponent(i, component), intersectionLengths->GetComponent(i, 0), |
| 385 | component); |
| 386 | // The blending I'm using is a combination of porter and duff xors |
| 387 | // and ins. |
| 388 | float coef1 = 1.0f - 0.5f * c[3]; |
| 389 | float coef2 = 1.0f - 0.5f * newcolor[3]; |
| 390 | newcolor[0] = newcolor[0] * coef1 + c[0] * coef2; |
| 391 | newcolor[1] = newcolor[1] * coef1 + c[1] * coef2; |
| 392 | newcolor[2] = newcolor[2] * coef1 + c[2] * coef2; |
| 393 | newcolor[3] = newcolor[3] * coef1 + c[3] * coef2; |
| 394 | } |
| 395 | |
| 396 | float coef = 1.0f - color[3]; |
| 397 | color[0] += newcolor[0] * coef; |
| 398 | color[1] += newcolor[1] * coef; |
| 399 | color[2] += newcolor[2] * coef; |
| 400 | color[3] += newcolor[3] * coef; |
| 401 | } |
| 402 | } |
| 403 | VTK_ABI_NAMESPACE_END |
no test coverage detected