Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Andrew Bauer
VTK
Commits
ee4c8451
Commit
ee4c8451
authored
Jul 24, 1995
by
Ken Martin
Browse files
overhaul of accumulation code
parent
70b23bd1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/RenderW.cc
View file @
ee4c8451
...
...
@@ -39,104 +39,164 @@ vtkRenderWindow::vtkRenderWindow()
this
->
Interactor
=
NULL
;
strcpy
(
this
->
Name
,
"Visualization Toolkit"
);
this
->
AAFrames
=
0
;
this
->
AABuffer
=
NULL
;
this
->
FDFrames
=
0
;
this
->
FDBuffer
=
NULL
;
this
->
SubFrames
=
0
;
this
->
Sub
Buffer
=
NULL
;
this
->
Accumulation
Buffer
=
NULL
;
this
->
CurrentSubFrame
=
0
;
this
->
ResultFrame
=
NULL
;
this
->
Filename
=
NULL
;
}
// Description:
// free the memory used by this object
vtkRenderWindow
::~
vtkRenderWindow
()
{
if
(
this
->
AccumulationBuffer
)
{
delete
[]
this
->
AccumulationBuffer
;
this
->
AccumulationBuffer
=
NULL
;
}
if
(
this
->
ResultFrame
)
{
delete
[]
this
->
ResultFrame
;
this
->
ResultFrame
=
NULL
;
}
}
// Description:
// Ask each renderer to render an image. Synchronize this process.
void
vtkRenderWindow
::
Render
()
{
int
i
;
int
*
size
;
int
x
,
y
;
float
*
p1
;
vtkDebugMacro
(
<<
"Starting Render Method.
\n
"
);
if
(
this
->
Interactor
&&
!
this
->
Interactor
->
GetInitialized
()
)
this
->
Interactor
->
Initialize
();
if
((
!
this
->
AccumulationBuffer
)
&&
(
this
->
SubFrames
||
this
->
AAFrames
||
this
->
FDFrames
))
{
// get the size
size
=
this
->
GetSize
();
this
->
AccumulationBuffer
=
new
float
[
3
*
size
[
0
]
*
size
[
1
]];
memset
(
this
->
AccumulationBuffer
,
0
,
3
*
size
[
0
]
*
size
[
1
]
*
sizeof
(
float
));
}
// handle any sub frames
if
(
this
->
SubFrames
)
{
int
*
size
;
int
x
,
y
;
int
r
,
g
,
b
;
unsigned
char
*
p1
;
// get the size
size
=
this
->
GetSize
();
// free old and get new memory on first sub frame
if
(
!
this
->
CurrentSubFrame
)
{
if
(
this
->
SubBuffer
)
delete
[]
SubBuffer
;
this
->
SubBuffer
=
new
unsigned
char
*
[
this
->
SubFrames
];
}
// draw the images
this
->
DoAARender
();
// get the pixels for accumulation
if
(
this
->
ResultFrame
)
{
this
->
SubBuffer
[
this
->
CurrentSubFrame
]
=
this
->
ResultFrame
;
this
->
ResultFrame
=
NULL
;
}
else
// now accumulate the images
if
((
!
this
->
AAFrames
)
&&
(
!
this
->
FDFrames
))
{
this
->
SubBuffer
[
this
->
CurrentSubFrame
]
=
this
->
GetPixelData
(
0
,
0
,
size
[
0
]
-
1
,
size
[
1
]
-
1
,
0
);
p1
=
this
->
AccumulationBuffer
;
unsigned
char
*
p2
;
if
(
this
->
ResultFrame
)
{
p2
=
this
->
ResultFrame
;
}
else
{
p2
=
this
->
GetPixelData
(
0
,
0
,
size
[
0
]
-
1
,
size
[
1
]
-
1
,
0
);
}
for
(
y
=
0
;
y
<
size
[
1
];
y
++
)
{
for
(
x
=
0
;
x
<
size
[
0
];
x
++
)
{
*
p1
+=
*
p2
;
p1
++
;
p2
++
;
*
p1
+=
*
p2
;
p1
++
;
p2
++
;
*
p1
+=
*
p2
;
p1
++
;
p2
++
;
}
}
delete
[]
p2
;
}
// if this is the last sub frame then
merge the images
// if this is the last sub frame then
convert back into unsigned char
this
->
CurrentSubFrame
++
;
if
(
this
->
CurrentSubFrame
==
this
->
SubFrames
)
{
this
->
CurrentSubFrame
=
0
;
this
->
ResultFrame
=
this
->
SubBuffer
[
0
];
float
num
;
unsigned
char
*
p2
=
new
unsigned
char
[
3
*
size
[
0
]
*
size
[
1
]
];
// now accumulate the images
p1
=
this
->
ResultFrame
;
num
=
this
->
SubFrames
;
if
(
this
->
AAFrames
)
num
*=
this
->
AAFrames
;
if
(
this
->
FDFrames
)
num
*=
this
->
FDFrames
;
this
->
ResultFrame
=
p2
;
p1
=
this
->
AccumulationBuffer
;
for
(
y
=
0
;
y
<
size
[
1
];
y
++
)
{
for
(
x
=
0
;
x
<
size
[
0
];
x
++
)
{
r
=
*
p1
;
g
=
*
(
p1
+
1
);
b
=
*
(
p1
+
2
);
for
(
i
=
1
;
i
<
this
->
SubFrames
;
i
++
)
{
r
+=
this
->
SubBuffer
[
i
][(
y
*
size
[
0
]
+
x
)
*
3
];
g
+=
this
->
SubBuffer
[
i
][(
y
*
size
[
0
]
+
x
)
*
3
+
1
];
b
+=
this
->
SubBuffer
[
i
][(
y
*
size
[
0
]
+
x
)
*
3
+
2
];
}
r
/=
this
->
SubFrames
;
g
/=
this
->
SubFrames
;
b
/=
this
->
SubFrames
;
*
p1
=
r
;
p1
++
;
*
p1
=
g
;
p1
++
;
*
p1
=
b
;
p1
++
;
*
p2
=
(
unsigned
char
)(
*
p1
/
num
);
p1
++
;
p2
++
;
*
p2
=
(
unsigned
char
)(
*
p1
/
num
);
p1
++
;
p2
++
;
*
p2
=
(
unsigned
char
)(
*
p1
/
num
);
p1
++
;
p2
++
;
}
}
for
(
i
=
1
;
i
<
this
->
SubFrames
;
i
++
)
{
delete
this
->
SubBuffer
[
i
];
}
delete
[]
this
->
SubBuffer
;
this
->
SubBuffer
=
NULL
;
this
->
CurrentSubFrame
=
0
;
this
->
CopyResultFrame
();
// free any memory
delete
[]
this
->
AccumulationBuffer
;
this
->
AccumulationBuffer
=
NULL
;
}
}
else
{
// get the size
size
=
this
->
GetSize
();
this
->
DoAARender
();
if
(
this
->
AccumulationBuffer
)
{
float
num
;
unsigned
char
*
p2
=
new
unsigned
char
[
3
*
size
[
0
]
*
size
[
1
]];
if
(
this
->
AAFrames
)
{
num
=
this
->
AAFrames
;
}
else
{
num
=
1
;
}
if
(
this
->
FDFrames
)
num
*=
this
->
FDFrames
;
this
->
ResultFrame
=
p2
;
p1
=
this
->
AccumulationBuffer
;
for
(
y
=
0
;
y
<
size
[
1
];
y
++
)
{
for
(
x
=
0
;
x
<
size
[
0
];
x
++
)
{
*
p2
=
(
unsigned
char
)(
*
p1
/
num
);
p1
++
;
p2
++
;
*
p2
=
(
unsigned
char
)(
*
p1
/
num
);
p1
++
;
p2
++
;
*
p2
=
(
unsigned
char
)(
*
p1
/
num
);
p1
++
;
p2
++
;
}
}
delete
[]
this
->
AccumulationBuffer
;
this
->
AccumulationBuffer
=
NULL
;
}
this
->
CopyResultFrame
();
}
if
(
this
->
ResultFrame
)
{
delete
[]
this
->
ResultFrame
;
this
->
ResultFrame
=
NULL
;
}
}
// Description:
...
...
@@ -150,8 +210,7 @@ void vtkRenderWindow::DoAARender()
{
int
*
size
;
int
x
,
y
;
int
r
,
g
,
b
;
unsigned
char
*
p1
;
float
*
p1
;
vtkRenderer
*
aren
;
vtkCamera
*
acam
;
float
*
dpoint
;
...
...
@@ -162,9 +221,6 @@ void vtkRenderWindow::DoAARender()
// get the size
size
=
this
->
GetSize
();
// free old and get new memory
if
(
this
->
AABuffer
)
delete
[]
AABuffer
;
this
->
AABuffer
=
new
unsigned
char
*
[
this
->
AAFrames
];
origfocus
[
3
]
=
1.0
;
for
(
i
=
0
;
i
<
AAFrames
;
i
++
)
...
...
@@ -237,49 +293,32 @@ void vtkRenderWindow::DoAARender()
dpoint
[
2
]
+
worldOffset
[
2
]);
}
// get the pixels for accumulation
if
(
this
->
ResultFrame
)
{
this
->
AABuffer
[
i
]
=
this
->
ResultFrame
;
this
->
ResultFrame
=
NULL
;
}
else
{
this
->
AABuffer
[
i
]
=
this
->
GetPixelData
(
0
,
0
,
size
[
0
]
-
1
,
size
[
1
]
-
1
,
0
);
}
}
this
->
ResultFrame
=
this
->
AABuffer
[
0
];
// now accumulate the images
p1
=
this
->
ResultFrame
;
for
(
y
=
0
;
y
<
size
[
1
];
y
++
)
{
for
(
x
=
0
;
x
<
size
[
0
];
x
++
)
// now accumulate the images
p1
=
this
->
AccumulationBuffer
;
if
(
!
this
->
FDFrames
)
{
r
=
*
p1
;
g
=
*
(
p1
+
1
);
b
=
*
(
p1
+
2
);
for
(
i
=
1
;
i
<
this
->
AAFrames
;
i
++
)
unsigned
char
*
p2
;
if
(
this
->
ResultFrame
)
{
p2
=
this
->
ResultFrame
;
}
else
{
p2
=
this
->
GetPixelData
(
0
,
0
,
size
[
0
]
-
1
,
size
[
1
]
-
1
,
0
);
}
for
(
y
=
0
;
y
<
size
[
1
];
y
++
)
{
r
+=
this
->
AABuffer
[
i
][(
y
*
size
[
0
]
+
x
)
*
3
];
g
+=
this
->
AABuffer
[
i
][(
y
*
size
[
0
]
+
x
)
*
3
+
1
];
b
+=
this
->
AABuffer
[
i
][(
y
*
size
[
0
]
+
x
)
*
3
+
2
];
for
(
x
=
0
;
x
<
size
[
0
];
x
++
)
{
*
p1
+=
(
float
)
*
p2
;
p1
++
;
p2
++
;
*
p1
+=
(
float
)
*
p2
;
p1
++
;
p2
++
;
*
p1
+=
(
float
)
*
p2
;
p1
++
;
p2
++
;
}
}
r
/=
this
->
AAFrames
;
g
/=
this
->
AAFrames
;
b
/=
this
->
AAFrames
;
*
p1
=
r
;
p1
++
;
*
p1
=
g
;
p1
++
;
*
p1
=
b
;
p1
++
;
delete
[]
p2
;
}
}
for
(
i
=
1
;
i
<
this
->
AAFrames
;
i
++
)
{
delete
this
->
AABuffer
[
i
];
}
delete
[]
this
->
AABuffer
;
this
->
AABuffer
=
NULL
;
}
else
{
...
...
@@ -299,8 +338,8 @@ void vtkRenderWindow::DoFDRender()
{
int
*
size
;
int
x
,
y
;
int
r
,
g
,
b
;
unsigned
char
*
p1
;
unsigned
char
*
p2
;
float
*
p1
;
vtkRenderer
*
aren
;
vtkCamera
*
acam
;
float
focalDisk
;
...
...
@@ -314,9 +353,6 @@ void vtkRenderWindow::DoFDRender()
// get the size
size
=
this
->
GetSize
();
// free old and get new memory
if
(
this
->
FDBuffer
)
delete
[]
FDBuffer
;
this
->
FDBuffer
=
new
unsigned
char
*
[
this
->
FDFrames
];
viewUp
[
3
]
=
1.0
;
orig
=
new
float
[
3
*
this
->
Renderers
.
GetNumberOfItems
()];
...
...
@@ -367,51 +403,30 @@ void vtkRenderWindow::DoFDRender()
}
// get the pixels for accumulation
// now accumulate the images
p1
=
this
->
AccumulationBuffer
;
if
(
this
->
ResultFrame
)
{
this
->
FDBuffer
[
i
]
=
this
->
ResultFrame
;
this
->
ResultFrame
=
NULL
;
p2
=
this
->
ResultFrame
;
}
else
{
this
->
FDBuffer
[
i
]
=
this
->
GetPixelData
(
0
,
0
,
size
[
0
]
-
1
,
size
[
1
]
-
1
,
0
);
p2
=
this
->
GetPixelData
(
0
,
0
,
size
[
0
]
-
1
,
size
[
1
]
-
1
,
0
);
}
}
// free memory
delete
[]
orig
;
this
->
ResultFrame
=
this
->
FDBuffer
[
0
];
// now accumulate the images
p1
=
this
->
ResultFrame
;
for
(
y
=
0
;
y
<
size
[
1
];
y
++
)
{
for
(
x
=
0
;
x
<
size
[
0
];
x
++
)
for
(
y
=
0
;
y
<
size
[
1
];
y
++
)
{
r
=
*
p1
;
g
=
*
(
p1
+
1
);
b
=
*
(
p1
+
2
);
for
(
i
=
1
;
i
<
this
->
FDFrames
;
i
++
)
for
(
x
=
0
;
x
<
size
[
0
];
x
++
)
{
r
+=
this
->
FDBuffer
[
i
][(
y
*
size
[
0
]
+
x
)
*
3
]
;
g
+=
this
->
FDBuffer
[
i
][(
y
*
size
[
0
]
+
x
)
*
3
+
1
]
;
b
+=
this
->
FDBuffer
[
i
][(
y
*
size
[
0
]
+
x
)
*
3
+
2
]
;
*
p1
+=
(
float
)
*
p2
;
p1
++
;
p2
++
;
*
p1
+=
(
float
)
*
p2
;
p1
++
;
p2
++
;
*
p1
+=
(
float
)
*
p2
;
p1
++
;
p2
++
;
}
r
/=
this
->
FDFrames
;
g
/=
this
->
FDFrames
;
b
/=
this
->
FDFrames
;
*
p1
=
r
;
p1
++
;
*
p1
=
g
;
p1
++
;
*
p1
=
b
;
p1
++
;
}
delete
[]
p2
;;
}
for
(
i
=
1
;
i
<
this
->
FDFrames
;
i
++
)
{
delete
this
->
FDBuffer
[
i
];
}
delete
[]
this
->
FDBuffer
;
this
->
FDBuffer
=
NULL
;
// free memory
delete
[]
orig
;
}
else
{
...
...
@@ -580,7 +595,7 @@ void vtkRenderWindow::StereoMidpoint(void)
// get the size
size
=
this
->
GetSize
();
// get the data
this
->
te
mp_b
uffer
=
this
->
GetPixelData
(
0
,
0
,
size
[
0
]
-
1
,
size
[
1
]
-
1
,
0
);
this
->
S
te
reoB
uffer
=
this
->
GetPixelData
(
0
,
0
,
size
[
0
]
-
1
,
size
[
1
]
-
1
,
0
);
}
}
}
...
...
@@ -604,7 +619,7 @@ void vtkRenderWindow::StereoRenderComplete(void)
size
=
this
->
GetSize
();
// get the data
buff
=
this
->
GetPixelData
(
0
,
0
,
size
[
0
]
-
1
,
size
[
1
]
-
1
,
0
);
p1
=
this
->
te
mp_b
uffer
;
p1
=
this
->
S
te
reoB
uffer
;
p2
=
buff
;
// allocate the result
...
...
@@ -632,8 +647,8 @@ void vtkRenderWindow::StereoRenderComplete(void)
}
}
this
->
ResultFrame
=
result
;
delete
[]
this
->
te
mp_b
uffer
;
this
->
te
mp_b
uffer
=
NULL
;
delete
[]
this
->
S
te
reoB
uffer
;
this
->
S
te
reoB
uffer
=
NULL
;
delete
[]
buff
;
}
break
;
...
...
@@ -651,10 +666,7 @@ void vtkRenderWindow::CopyResultFrame(void)
// get the size
size
=
this
->
GetSize
();
this
->
SetPixelData
(
0
,
0
,
size
[
0
]
-
1
,
size
[
1
]
-
1
,
this
->
ResultFrame
,
1
);
delete
[]
this
->
ResultFrame
;
this
->
ResultFrame
=
NULL
;
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment