forked from pixmeo/osirix
-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathOsiriXFixedPointVolumeRayCastMapper.cxx
111 lines (92 loc) · 3.39 KB
/
OsiriXFixedPointVolumeRayCastMapper.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//
// ©Alex Bettarini -- all rights reserved
// License GPLv3.0 -- see License File
//
// At the end of 2014 the project was forked from OsiriX to become Miele-LXIV
// The original version of this file had no header
#include "OsiriXFixedPointVolumeRayCastMapper.h"
#include "vtkObjectFactory.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkTimerLog.h"
#include "vtkOpenGLRenderWindow.h"
#include <cmath>
bool dontRenderVolumeRenderingOsiriX = false;
vtkStandardNewMacro(OsiriXFixedPointVolumeRayCastMapper);
OsiriXFixedPointVolumeRayCastMapper::OsiriXFixedPointVolumeRayCastMapper()
{
//this->MIPHelper = vtkMieleFixedPointVolumeRayCastHelper::New();
}
// See VTK's vtkFixedPointVolumeRayCastMapper.cxx
void OsiriXFixedPointVolumeRayCastMapper::Render( vtkRenderer *ren, vtkVolume *vol )
{
printf("%s %d\n", __FUNCTION__, __LINE__);
this->Timer->StartTimer();
// Since we are passing in a value of 0 for the multiRender flag
// (this is a single render pass - not part of a multipass AMR render)
// then we know the origin, spacing, and extent values will not
// be used so just initialize everything to 0. No need to check
// the return value of the PerImageInitialization method - since this
// is not a multirender it will always return 1.
double dummyOrigin[3] = {0.0, 0.0, 0.0};
double dummySpacing[3] = {0.0, 0.0, 0.0};
int dummyExtent[6] = {0, 0, 0, 0, 0, 0};
this->PerImageInitialization( ren, vol, 0,
dummyOrigin,
dummySpacing,
dummyExtent );
this->PerVolumeInitialization( ren, vol );
vtkRenderWindow *renWin = ren->GetRenderWindow(); // vtkCocoaRenderWindow
#if 0 /// @@@ TBC
vtkOpenGLRenderWindow *rw = (vtkOpenGLRenderWindow *)renWin;
//if (!rw->Initialized)
rw->OpenGLInit();
#endif
if ( renWin && renWin->CheckAbortStatus() )
{
this->AbortRender();
return;
}
this->PerSubVolumeInitialization( ren, vol, 0 );
if ( renWin && renWin->CheckAbortStatus() )
{
this->AbortRender();
return;
}
if (!dontRenderVolumeRenderingOsiriX) // Our addition
this->RenderSubVolume();
if (renWin && renWin->CheckAbortStatus() )
{
this->AbortRender();
return;
}
#if 0 //ndef NDEBUG
this->DebugOn();
vtkIndent *indent = vtkIndent::New();
std::cerr << this->GetClassName() << std::endl;
this->PrintSelf(std::cerr, *indent);
#endif
#ifndef NDEBUG
std::cerr << __FILE__ << __LINE__
<< ", ren:" << ren->GetClassName() // vtkOpenGLRenderer
<< ", win:" << ren->GetRenderWindow()->GetClassName() // vtkCocoaRenderWindow
<< std::endl;
#endif
#ifdef WITH_OPENGL_32
// It can be commented out for CPR, actually CPR crashes here if commented in
// TBC: maybe the problem is only with CPR if initially there is no "path"
this->DisplayRenderedImage( ren, vol ); // Issue #i18
#endif
this->Timer->StopTimer();
this->TimeToDraw = this->Timer->GetElapsedTime();
// If we've increased the sample distance, account for that in the stored time. Since we
// don't get linear performance improvement, use a factor of .66
this->StoreRenderTime( ren, vol,
this->TimeToDraw *
this->ImageSampleDistance *
this->ImageSampleDistance *
( 1.0 + 0.66*
(this->SampleDistance - this->OldSampleDistance) /
this->OldSampleDistance ) );
this->SampleDistance = this->OldSampleDistance;
}