-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sketch.h
85 lines (75 loc) · 2.6 KB
/
Sketch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef SKETCH_H_DEFINED
#define SKETCH_H_DEFINED
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
/**
* This file is part of the INFO0902 course given by Pr. Geurts
*/
/* 2D point structure */
typedef struct point_t
{
int x, y; // Coordinates of the point
} Point;
/* Sketch structure */
typedef struct sketch_t
{
int class; // The class of this sketch
size_t size; // The number of points of this sketch
bool *strokeStarts; // strokeStarts[i] == 1 iff points[i] is the start
// of a new polyline
Point *points; // The array of points of this sketch
} Sketch;
/* Dataset of sketches */
typedef struct dataset_t
{
Sketch *sketches; // The array of sketches
size_t size; // The number of sketches
} Dataset;
/** ------------------------------------------------------------------------ *
* Load the dataset of sketches.
*
* GRAMMAR
* <dataset> ::= "number of sketches"
* <sketches>
* <sketches> ::= <sketch> | <sketch>
* | <sketches>
* <sketch> ::= "class"
* "number of points"
* <points>
* <points> ::= <point> | <point>
* | <points>
* <point> ::= "x coordinate" "y coordinate" <start of new strokes>
* <start of new strokes> ::= 0 | 1
*
* PARAMETERS
* filepath The path of the dataset
* out The stream to output loading information (NULL for silence)
* ------------------------------------------------------------------------- */
Dataset *loadDataset(const char *filepath, FILE *out);
/** ------------------------------------------------------------------------ *
* Free a dataset (sketches included).
*
* PARAMETERS
* dataset A dataset of sketches.
* ------------------------------------------------------------------------- */
void freeDataset(Dataset *dataset);
/** ------------------------------------------------------------------------ *
* Generate a ppm file from a sketch
*
* PARAMETERS
* sk A sketch
* filename The filename in which to save the sketch
* ------------------------------------------------------------------------- */
void sketch2ppm(Sketch sk, const char *filename);
/** ------------------------------------------------------------------------ *
* Provide the name of the class from its index
*
* PARAMETERS
* class The interger representation of the class
*
* RETURN
* className The string representation of the class
* ------------------------------------------------------------------------- */
const char *getClassName(int class);
#endif // SKETCH_H_DEFINED