Minor update.
[pysvrt.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 svrt.  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 "random.h"
30 #include "vignette.h"
31
32 class Shape {
33   static const int margin = 1;
34   static const int nb_max_pixels = Vignette::width * Vignette::height;
35
36 #if __cplusplus >= 201103L
37   static constexpr scalar_t gap_max = 0.25;
38 #else
39   static const scalar_t gap_max = 0.25;
40 #endif
41
42   int n_pixels1, n_pixels2, n_pixels3, n_pixels4;
43   int nb_pixels;
44   scalar_t xc, yc;
45   scalar_t *x_pixels;
46   scalar_t *y_pixels;
47
48   int generate_part_part(scalar_t *xp, scalar_t *yp, int *nb_pixels, scalar_t radius, scalar_t hole_radius,
49                          scalar_t x1, scalar_t y1, scalar_t x2, scalar_t y2);
50   void generate_part(scalar_t *xp, scalar_t *yp, int *nb_pixels, scalar_t radius, scalar_t hole_radius);
51   int overwrites(Vignette *vignette, scalar_t xc, scalar_t yc, int first, int nb);
52   void draw(int part_number, Vignette *vignette, scalar_t xc, scalar_t yc, int first, int nb);
53
54 public:
55   Shape();
56   ~Shape();
57
58   void randomize(scalar_t radius, scalar_t hole_radius);
59   void copy(Shape *shape);
60   void scale(scalar_t s);
61   void rotate(scalar_t alpha);
62   void symmetrize(scalar_t axis_x, scalar_t axis_y);
63
64   int overwrites(Vignette *vignette, scalar_t xc, scalar_t yc);
65   void draw(int part_number, Vignette *vignette, scalar_t xc, scalar_t yc);
66 };
67
68 #endif