1 // Copyright 2002 David Hilvert <dhilvert@auricle.dyndns.org>,
2 // <dhilvert@ugcs.caltech.edu>
4 /* This file is part of the Anti-Lamenessing Engine.
6 The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with the Anti-Lamenessing Engine; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * combine.h: A renderer that combines two renderings.
28 #include "../transformation.h"
33 * Combine two renderings.
35 * Available data is taken from the PARTIAL rendering. When no data from
36 * the PARTIAL rendering is available, data from the DEFAULT rendering
40 class combine
: public render
{
51 combine(render
*_default
, render
*partial
) {
52 this->_default
= _default
;
53 this->partial
= partial
;
54 this->output_image
= NULL
;
55 this->defined_image
= NULL
;
66 * Result of rendering.
69 virtual const image
*get_image() {
70 const image
*default_image
= _default
->get_image();
71 const image
*partial_image
= partial
->get_image();
73 assert (default_image
->width() == partial_image
->width());
74 assert (default_image
->height() == partial_image
->height());
79 output_image
= new image_ale_real(default_image
->height(),
80 default_image
->width(), 3, NULL
);
82 output_image
->set_offset(default_image
->offset());
84 const image
*partial_weight
= partial
->get_defined();
86 for (unsigned int i
= 0; i
< default_image
->height(); i
++)
87 for (unsigned int j
= 0; j
< default_image
->width(); j
++)
88 output_image
->set_pixel(i
, j
,
89 (partial_weight
->get_pixel(i
, j
).min_norm() >= render::get_wt())
90 ? partial_image
->get_pixel(i
, j
)
91 : default_image
->get_pixel(i
, j
));
97 * Definition map. Unit-depth image whose pixels are nonzero where
98 * the image is defined.
101 virtual const image
*get_defined() {
102 unsigned int i
, j
, k
;
105 return defined_image
;
107 const image
*partial_weight
= partial
->get_defined();
108 const image
*default_weight
= _default
->get_defined();
110 assert (default_weight
->width() == partial_weight
->width());
111 assert (default_weight
->height() == partial_weight
->height());
113 defined_image
= new image_ale_real(default_weight
->height(),
114 default_weight
->width(), 3, NULL
);
116 defined_image
->set_offset(default_weight
->offset());
118 for (i
= 0; i
< default_weight
->height(); i
++)
119 for (j
= 0; j
< default_weight
->width(); j
++)
120 for (k
= 0; k
< default_weight
->depth(); k
++)
121 defined_image
->set_pixel(i
, j
,
122 (partial_weight
->get_pixel(i
, j
).min_norm() >= render::get_wt())
123 ? partial_weight
->get_pixel(i
, j
)
124 : default_weight
->get_pixel(i
, j
));
126 return defined_image
;
130 * Perform rendering steps requiring no frames beyond frame N.
133 virtual void sync(int n
) {
140 delete defined_image
;
141 defined_image
= NULL
;
147 virtual void step() {
150 virtual void init_point_renderer(unsigned int h
, unsigned int w
, unsigned int d
) {
151 _default
->init_point_renderer(h
, w
, d
);
152 partial
->init_point_renderer(h
, w
, d
);
153 output_image
= new image_zero(h
, w
, d
);
154 defined_image
= new image_zero(h
, w
, d
);
157 virtual void point_render(unsigned int i
, unsigned int j
, unsigned int f
, transformation t
) {
158 _default
->point_render(i
, j
, f
, t
);
159 partial
->point_render(i
, j
, f
, t
);
162 virtual void finish_point_rendering() {
163 _default
->finish_point_rendering();
164 partial
->finish_point_rendering();
165 delete defined_image
;
169 * These will be generated upon a call to get_image() or
173 defined_image
= NULL
;
177 const render
*get_default() const {
181 const render
*get_partial() const {
187 delete defined_image
;
189 defined_image
= NULL
;