Added the non-disclosed problems.
[svrt.git] / vision_problem_10.cc
1
2 ////////////////////////////////////////////////////////////////////
3 // START_IP_HEADER                                                //
4 //                                                                //
5 // Written by Francois Fleuret                                    //
6 // Contact <francois.fleuret@idiap.ch> for comments & bug reports //
7 //                                                                //
8 // END_IP_HEADER                                                  //
9 ////////////////////////////////////////////////////////////////////
10
11 #include "vision_problem_10.h"
12 #include "shape.h"
13
14 VisionProblem_10::VisionProblem_10() { }
15
16 void VisionProblem_10::generate(int label, Vignette *vignette) {
17   int nb_shapes = 4;
18   int xs[nb_shapes], ys[nb_shapes];
19
20   int error;
21   do {
22     do {
23       if(label == 1) {
24         scalar_t alpha = drand48() * 2 * M_PI;
25         scalar_t radius = drand48() * Vignette::width / 2;
26         scalar_t xc = drand48() * Vignette::width;
27         scalar_t yc = drand48() * Vignette::height;
28         for(int n = 0; n < nb_shapes; n++) {
29           xs[n] = int(xc + part_size/2 +
30                       radius * sin(alpha + n * 2 * M_PI / scalar_t(nb_shapes)));
31           ys[n] = int(yc + part_size/2 +
32                       radius * cos(alpha + n * 2 * M_PI / scalar_t(nb_shapes)));
33         }
34       } else {
35         for(int n = 0; n < nb_shapes; n++) {
36           xs[n] = int(drand48() * Vignette::width);
37           ys[n] = int(drand48() * Vignette::height);
38         }
39       }
40     } while(cluttered_shapes(part_size, nb_shapes, xs, ys));
41
42     vignette->clear();
43
44     Shape shape;
45     error = 0;
46     for(int n = 0; n < nb_shapes; n++) {
47       if(n == 0) {
48         shape.randomize(part_size / 2, part_hole_size / 2);
49       }
50       error |= shape.overwrites(vignette, xs[n], ys[n]);
51       shape.draw(vignette, xs[n], ys[n]);
52     }
53   } while(error);
54 }