Update license to GNU GPL version 3.
[Ale.git] / d2 / filter / ssfe.h
blobd0b9b9dab88e2a5dab7118f020897d733b96d90c
1 // Copyright 2004 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
21 #ifndef __ssfe_h__
22 #define __ssfe_h__
24 #include "scaled_filter.h"
25 #include "filter.h"
28 * Scaled filter class with exclusion.
31 class ssfe {
32 private:
34 * Honor exclusion?
36 int honor_exclusion;
37 scaled_filter *f;
38 mutable point _offset;
39 mutable int have_offset;
41 public:
43 ssfe(scaled_filter *f, int honor_exclusion) {
44 this->honor_exclusion = honor_exclusion;
45 this->f = f;
48 const scaled_filter *get_scaled_filter() const {
49 return f;
52 int equals(const ssfe *s) {
53 return (honor_exclusion == s->honor_exclusion
54 && f->equals(s->f));
57 int ex_is_honored() const {
58 return honor_exclusion;
62 * Set the parameters for filtering.
64 void set_parameters(transformation t, const image *im, point offset) const {
65 have_offset = 1;
66 _offset = offset;
67 f->set_parameters(t, im, offset);
69 void set_parameters(transformation t, transformation s, const image *im) const {
70 have_offset = 0;
71 f->set_parameters(t, s, im);
75 * Return filtered RESULT and WEIGHT at point P in a coordinate system
76 * specified by the inverse of transformation T based on data taken
77 * from image IM.
79 void filtered(int i, int j, int frame, pixel *result,
80 pixel *weight, pixel prev_value = pixel(0, 0, 0), pixel prev_weight = pixel(0, 0, 0)) const {
83 * We need a valid offset in order to determine exclusion
84 * regions.
87 assert (have_offset || !honor_exclusion);
89 *result = pixel(0, 0, 0);
90 *weight = pixel(0, 0, 0);
92 if (honor_exclusion && render::is_excluded_r(_offset, i, j, frame))
93 return;
95 f->filtered(i, j, result, weight, honor_exclusion, frame, prev_value, prev_weight);
98 #endif