View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000858VTK(No Category)public2004-05-18 22:022016-08-12 09:54
ReporterEric Branlund 
Assigned ToKitware Robot 
PrioritylowSeverityfeatureReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000858: Add perspective projection for VolumePro VP1000
DescriptionRecent 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 )
     {
TagsNo tags attached.
Project
Type
Attached Filestxt file icon patch.txt [^] (3,703 bytes) 1969-12-31 19:00 [Show Content]
txt file icon patch2.txt [^] (3,927 bytes) 1969-12-31 19:00 [Show Content]

 Relationships

  Notes
(0001080)
Mathieu Malaterre (developer)
2004-05-19 05:24

Eric, could you please add your patch as attachment instead of copy/pasting it. Our phpbugtracker is getting rid of blank spaces and makes your diff very difficult to use.

To do so, click on the link provided (ro go to bug 858) and search for 'Create Attachment'.
Thanks
(0001082)
Eric Branlund (reporter)
2004-05-19 13:47

I attached the patch as patch.txt. Sorry for the trouble.
(0001401)
Eric Branlund (reporter)
2004-08-30 13:51

From the documentation for the VLI 3.3 SDK, perspective projections
are only supported by VLI SDK when advanced features are enabled.
Attached a modified patch, patch2.txt, which checks for the enabling
of advanced features in the SDK rather than checking the SDK version
number. patch2.txt is the result of diff -Naur against revision 1.27 of
vtkVolumeProVP1000Mapper.cxx.
(0036727)
Kitware Robot (administrator)
2016-08-12 09:54

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page.

 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


Copyright © 2000 - 2018 MantisBT Team