Fixes to deal with newer png lib and C++11, as suggested by Mark van Rossum.
[svrt.git] / shape.h
1 /*
2  *  svrt is the ``Synthetic Visual Reasoning Test'', an image
3  *  generator for evaluating classification performance of machine
4  *  learning systems, humans and primates.
5  *
6  *  Copyright (c) 2009 Idiap Research Institute, http://www.idiap.ch/
7  *  Written by Francois Fleuret <francois.fleuret@idiap.ch>
8  *
9  *  This file is part of svrt.
10  *
11  *  svrt is free software: you can redistribute it and/or modify it
12  *  under the terms of the GNU General Public License version 3 as
13  *  published by the Free Software Foundation.
14  *
15  *  svrt is distributed in the hope that it will be useful, but
16  *  WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  *  General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with selector.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #ifndef SHAPE_H
26 #define SHAPE_H
27
28 #include "misc.h"
29 #include "vignette.h"
30
31 class Shape {
32   static const int margin = 1;
33   static const int nb_max_pixels = Vignette::width * Vignette::height;
34
35 #if __cplusplus >= 201103L
36   static constexpr scalar_t gap_max = 0.25;
37 #else
38   static const scalar_t gap_max = 0.25;
39 #endif
40
41   int n_pixels1, n_pixels2, n_pixels3, n_pixels4;
42   int nb_pixels;
43   scalar_t xc, yc;
44   scalar_t *x_pixels;
45   scalar_t *y_pixels;
46
47   int generate_part_part(scalar_t *xp, scalar_t *yp, int *nb_pixels, scalar_t radius, scalar_t hole_radius,
48                          scalar_t x1, scalar_t y1, scalar_t x2, scalar_t y2);
49   void generate_part(scalar_t *xp, scalar_t *yp, int *nb_pixels, scalar_t radius, scalar_t hole_radius);
50   int overwrites(Vignette *vignette, scalar_t xc, scalar_t yc, int first, int nb);
51   void draw(Vignette *vignette, scalar_t xc, scalar_t yc, int first, int nb);
52
53 public:
54   Shape();
55   ~Shape();
56
57   void randomize(scalar_t radius, scalar_t hole_radius);
58   void copy(Shape *shape);
59   void scale(scalar_t s);
60   void rotate(scalar_t alpha);
61   void symmetrize(scalar_t axis_x, scalar_t axis_y);
62
63   int overwrites(Vignette *vignette, scalar_t xc, scalar_t yc);
64   void draw(Vignette *vignette, scalar_t xc, scalar_t yc);
65 };
66
67 #endif