MantisBT - VTK | |||||
| View Issue Details | |||||
| ID | Project | Category | View Status | Date Submitted | Last Update |
| 0000858 | VTK | (No Category) | public | 2004-05-18 22:02 | 2016-08-12 09:54 |
| Reporter | Eric Branlund | ||||
| Assigned To | Kitware Robot | ||||
| Priority | low | Severity | feature | Reproducibility | always |
| Status | closed | Resolution | moved | ||
| Platform | OS | OS Version | |||
| Product Version | |||||
| Target Version | Fixed in Version | ||||
| Project | |||||
| Type | |||||
| Summary | 0000858: Add perspective projection for VolumePro VP1000 | ||||
| Description | Recent versions (>= 3.1) of the VolumePro VP1000 SDK support perspective projection but the vtkVolumeProVP1000Mapper always forces parallel projection. The following patch adds a runtime check to vtkVolumeProVP1000Mapper::UpdateCamera() and, if using the 3.1 or later library, sets up a perspective projection matrix. The patch was computed with diff -Naur vtkVolumeProVP1000Mapper.cxx vtkVolumeProVP1000Mapper.cxx.new where vtkVolumeProVP1000Mapper.cxx is version 1.27 from CVS. --- vtkVolumeProVP1000Mapper.cxx Tue May 18 17:35:37 2004 +++ vtkVolumeProVP1000Mapper.cxx.new Tue May 18 17:53:31 2004 @@ -34,6 +34,9 @@ #include <stdio.h> #include <math.h> +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif vtkCxxRevisionMacro(vtkVolumeProVP1000Mapper, "$Revision: 1.27 $"); @@ -217,12 +220,6 @@ ren->GetActiveCamera()->GetFocalPoint( focalPointVTK ); ren->GetActiveCamera()->GetViewUp( viewUpVTK ); - // make sure we are in parallel mode - if (!ren->GetActiveCamera()->GetParallelProjection()) - { - vtkWarningMacro("The Volume Pro VP1000 does not support perspective projection and the camera is currently not in ParallelProjection mode."); - } - // Create the three vectors we need to do the lookat VLIVector3D positionVLI ( positionVTK ); VLIVector3D focalPointVLI ( focalPointVTK ); @@ -233,20 +230,61 @@ viewUpVLI ); status = this->Context->GetCamera().SetViewMatrix( viewMatrixVLI ); - double clippingRange[2], parallelScale; + int setupParallel = ren->GetActiveCamera()->GetParallelProjection(); + double clippingRange[2]; double aspect[2]; ren->GetActiveCamera()->GetClippingRange(clippingRange); ren->GetAspect(aspect); - parallelScale = ren->GetActiveCamera()->GetParallelScale(); - VLIMatrix projectionMatrixVLI = VLIMatrix::Ortho(-parallelScale*aspect[0], - parallelScale*aspect[0], - -parallelScale, - parallelScale, - clippingRange[0], - clippingRange[1]); + if (! setupParallel) + { + // VLI versions prior to 3.1.0 do not support perspective projection so + // force parallel projection in that case. + int vliMajorRevision = VLIConfiguration::GetVLIMajorVersion(); + + if (vliMajorRevision < 3 || + (vliMajorRevision == 3 && VLIConfiguration::GetVLIMinorVersion() < 1)) + { + setupParallel = 1; + vtkWarningMacro("The Volume Pro VP1000 does not support perspective projection and the camera is currently not in ParallelProjection mode."); + } + } + + if (! setupParallel) + { + double viewAngleRadians = ren->GetActiveCamera()->GetViewAngle() * + M_PI / 180.0; + + // Manually construct the matrix to avoid using VLIMatrix::Perspective() + // which is not available in VLI versions prior to 3.1.0. + VLIMatrix projectionMatrixVLI; + double f = cos(0.5 * viewAngleRadians) / sin(0.5 * viewAngleRadians); + + projectionMatrixVLI[0][0] = f / aspect[0]; + projectionMatrixVLI[1][1] = f; + projectionMatrixVLI[2][2] = (clippingRange[1] + clippingRange[0]) / + (clippingRange[0] - clippingRange[1]); + projectionMatrixVLI[2][3] = 2.0 * clippingRange[1] * clippingRange[0] / + (clippingRange[0] - clippingRange[1]); + projectionMatrixVLI[3][2] = -1.0; + projectionMatrixVLI[3][3] = 0.0; + + status = this->Context->GetCamera().SetProjectionMatrix( projectionMatrixVLI ); + } + + if (setupParallel) + { + double parallelScale = ren->GetActiveCamera()->GetParallelScale(); + + VLIMatrix projectionMatrixVLI = VLIMatrix::Ortho(-parallelScale*aspect[0], + parallelScale*aspect[0], + -parallelScale, + parallelScale, + clippingRange[0], + clippingRange[1]); - status = this->Context->GetCamera().SetProjectionMatrix( projectionMatrixVLI ); + status = this->Context->GetCamera().SetProjectionMatrix( projectionMatrixVLI ); + } if ( status != kVLIOK ) { | ||||
| Steps To Reproduce | |||||
| Additional Information | |||||
| Tags | No tags attached. | ||||
| Relationships | |||||
| Attached Files | https://www.vtk.org/Bug/file/5102/patch.txt https://www.vtk.org/Bug/file/5148/patch2.txt | ||||
| Issue History | |||||
| Date Modified | Username | Field | Change | ||
| 2008-11-30 09:17 | Mathieu Malaterre | Assigned To | Mathieu Malaterre => François Bertel | ||
| 2008-11-30 20:15 | François Bertel | Assigned To | François Bertel => | ||
| 2011-06-16 13:11 | Zack Galbreath | Category | => (No Category) | ||
| 2016-08-12 09:54 | Kitware Robot | Note Added: 0036727 | |||
| 2016-08-12 09:54 | Kitware Robot | Status | expired => closed | ||
| 2016-08-12 09:54 | Kitware Robot | Resolution | open => moved | ||
| 2016-08-12 09:54 | Kitware Robot | Assigned To | => Kitware Robot | ||
| Notes | |||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||