Create an image into the vtkImageData argument. Used generally for creating thumbnail images
| 1481 | // Create an image into the vtkImageData argument. Used generally for |
| 1482 | // creating thumbnail images |
| 1483 | void vtkFixedPointVolumeRayCastMapper::CreateCanonicalView( |
| 1484 | vtkVolume* vol, vtkImageData* image, int blend_mode, double direction[3], double viewUp[3]) |
| 1485 | { |
| 1486 | // Make sure we have as long as we'd like so that the |
| 1487 | // image sample distance will be 1.0 |
| 1488 | vol->SetAllocatedRenderTime(VTK_DOUBLE_MAX, nullptr); |
| 1489 | |
| 1490 | // Create a renderer / camera with the right parameters |
| 1491 | // These will never be mapped to the screen - just used |
| 1492 | // to hold parameters such as size, view direction, aspect, |
| 1493 | // etc. |
| 1494 | vtkRenderWindow* renWin = vtkRenderWindow::New(); |
| 1495 | vtkRenderer* ren = vtkRenderer::New(); |
| 1496 | vtkCamera* cam = ren->GetActiveCamera(); |
| 1497 | |
| 1498 | renWin->AddRenderer(ren); |
| 1499 | int dim[3]; |
| 1500 | image->GetDimensions(dim); |
| 1501 | |
| 1502 | // The size of the window is the size of the image |
| 1503 | renWin->SetSize(dim[0], dim[1]); |
| 1504 | |
| 1505 | double* center = vol->GetCenter(); |
| 1506 | |
| 1507 | double bnds[6]; |
| 1508 | vol->GetBounds(bnds); |
| 1509 | #if 0 |
| 1510 | double d = sqrt((bnds[1]-bnds[0])*(bnds[1]-bnds[0]) + |
| 1511 | (bnds[3]-bnds[2])*(bnds[3]-bnds[2]) + |
| 1512 | (bnds[5]-bnds[4])*(bnds[5]-bnds[4])); |
| 1513 | #endif |
| 1514 | |
| 1515 | // For now use x distance - need to change this |
| 1516 | double d = bnds[1] - bnds[0]; |
| 1517 | |
| 1518 | // Set up the camera in parallel |
| 1519 | cam->SetFocalPoint(center); |
| 1520 | cam->ParallelProjectionOn(); |
| 1521 | cam->SetPosition( |
| 1522 | center[0] - d * direction[0], center[1] - d * direction[1], center[2] - d * direction[2]); |
| 1523 | cam->SetViewUp(viewUp); |
| 1524 | |
| 1525 | cam->SetParallelScale(d / 2); |
| 1526 | |
| 1527 | // Add a light |
| 1528 | vtkLight* light = vtkLight::New(); |
| 1529 | light->SetPosition( |
| 1530 | center[0] - d * direction[0], center[1] - d * direction[1], center[2] - d * direction[2]); |
| 1531 | light->SetFocalPoint(center); |
| 1532 | ren->AddLight(light); |
| 1533 | |
| 1534 | int savedBlendMode = this->BlendMode; |
| 1535 | this->BlendMode = blend_mode; |
| 1536 | int savedCropping = this->Cropping; |
| 1537 | this->Cropping = 0; |
| 1538 | |
| 1539 | // Do all the initialization. This is not a multipass image |
| 1540 | // so just pass in dummy origin, spacing, and extent here |
nothing calls this directly
no test coverage detected