|
1 | 1 | /* |
2 | 2 | * This source file forms part of libsxbp, a library which generates |
3 | 3 | * experimental 2D spiral-like shapes based on input binary data. |
| 4 | + */ |
| 5 | + |
| 6 | +/** |
| 7 | + * @file |
4 | 8 | * |
5 | | - * This compilation unit provides functions for plotting and caching the points |
6 | | - * which make up the lines of a spiral. |
7 | | - * |
| 9 | + * @brief This compilation unit provides functions for plotting and caching the |
| 10 | + * points which make up the lines of a spiral. |
8 | 11 | * |
| 12 | + * @author Joshua Saxby <[email protected] |
| 13 | + * @date 2016 |
9 | 14 | * |
10 | | - * Copyright (C) 2016, Joshua Saxby [email protected] |
| 15 | + * @copyright Copyright (C) Joshua Saxby 2016 |
11 | 16 | * |
12 | | - * This program is free software: you can redistribute it and/or modify |
13 | | - * it under the terms of the GNU Affero General Public License (version 3), |
14 | | - * as published by the Free Software Foundation. |
| 17 | + * @copyright This program is free software: you can redistribute it and/or |
| 18 | + * modify it under the terms of the GNU Affero General Public License |
| 19 | + * (version 3), as published by the Free Software Foundation. |
15 | 20 | * |
16 | | - * This program is distributed in the hope that it will be useful, |
| 21 | + * @copyright This program is distributed in the hope that it will be useful, |
17 | 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | 24 | * GNU Affero General Public License for more details. |
20 | 25 | * |
21 | | - * You should have received a copy of the GNU Affero General Public License |
22 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 26 | + * @copyright You should have received a copy of the GNU Affero General Public |
| 27 | + * License along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | 28 | */ |
24 | 29 | #ifndef SAXBOPHONE_SAXBOSPIRAL_PLOT_H |
25 | 30 | #define SAXBOPHONE_SAXBOSPIRAL_PLOT_H |
|
33 | 38 | extern "C"{ |
34 | 39 | #endif |
35 | 40 |
|
36 | | -/* |
37 | | - * returns the sum of all line lengths within the given indexes |
| 41 | +/** |
| 42 | + * @brief Calculates the sum of all line lengths in this spiral within the given |
| 43 | + * start and end indexes. |
| 44 | + * @details params start and end specify the range of line indexes to use for the |
| 45 | + * lines which are to be summed. These are inclusive of the lower bound but |
| 46 | + * exclusive of the upper bound. |
| 47 | + * |
| 48 | + * @param spiral The spiral of which line lengths should be summed. |
| 49 | + * @param start The index of the first line to include in those of which lengths |
| 50 | + * should be summed. |
| 51 | + * @param end The index of the line after the last line to include in those of |
| 52 | + * which lengths should be summed. |
| 53 | + * @return The sum of the lengths of all the lines in the given range. |
38 | 54 | * |
39 | | - * Asserts: |
| 55 | + * @note Asserts: |
40 | 56 | * - That start and end indexes are less than or equal to the spiral size |
41 | 57 | * - That spiral.lines is not NULL |
| 58 | + * |
| 59 | + * @todo Might also need to add an assertion to check that end is never less |
| 60 | + * than start. |
42 | 61 | */ |
43 | 62 | size_t sxbp_sum_lines(sxbp_spiral_t spiral, size_t start, size_t end); |
44 | 63 |
|
45 | | -/* |
46 | | - * given a spiral_t struct, a pointer to a co_ord_array_t, a pair of co-ords |
47 | | - * specifying the start point and indexes of the lowest and highest line |
48 | | - * segments to use, write to the co_ord_array_t struct all the co-ordinates of |
49 | | - * the line segments of the struct according to the current directions and |
50 | | - * lengths of the lines in the spiral. |
51 | | - * each line segment is only one unit long, meaning multiple ones are needed for |
52 | | - * lines longer than one unit. |
53 | | - * returns a status struct with error information (if any) |
| 64 | +/** |
| 65 | + * @brief Calculates a series of co-ords for which trace a given part of a |
| 66 | + * spiral line. |
| 67 | + * @details The whole spiral may be calculated, or just a given segment of it. |
| 68 | + * This is controlled by specifying which line to start at and which to end at. |
| 69 | + * |
| 70 | + * @param spiral The spiral for which line co-ords should be calculated. |
| 71 | + * @param output [out] The co-ords array which calculated co-ords should be |
| 72 | + * written to. |
| 73 | + * @param start_point The x/y co-ordinates at which the line being plotted |
| 74 | + * originates at. |
| 75 | + * @param start The index of the first line which makes up the segment which is |
| 76 | + * being calculated. |
| 77 | + * @param end The index of the line after the last line which makes up the |
| 78 | + * segment which is being calculated. |
| 79 | + * @return SXBP_OPERATION_OK on success. |
| 80 | + * @return SXBP_MALLOC_REFUSED on memory allocation failure. |
| 81 | + * |
| 82 | + * @note For this function to do anything useful, the spiral should at least |
| 83 | + * have some line lengths calculated, but this is not essential. |
54 | 84 | * |
55 | | - * Asserts: |
56 | | - * - That the output struct's items pointer is NULL |
| 85 | + * @note Asserts: |
| 86 | + * - That output->items is NULL |
57 | 87 | * - That start and end indexes are less than or equal to the spiral size |
58 | 88 | * - That spiral.lines is not NULL |
| 89 | + * |
| 90 | + * @todo Might also need to add an assertion to check that end is never less |
| 91 | + * than start. |
59 | 92 | */ |
60 | 93 | sxbp_status_t sxbp_spiral_points( |
61 | 94 | sxbp_spiral_t spiral, sxbp_co_ord_array_t* output, |
62 | 95 | sxbp_co_ord_t start_point, size_t start, size_t end |
63 | 96 | ); |
64 | 97 |
|
65 | | -/* |
66 | | - * given a pointer to a spiral struct and limit, which is the index of the last |
67 | | - * line to use, calculate and store the co-ordinates of all line segments that |
68 | | - * would make up the spiral if the current lengths and directions were used. |
69 | | - * each line segment is only one unit long, meaning multiple ones are needed for |
70 | | - * lines longer than one unit. The co-ords are stored in the spiral's |
71 | | - * co_ord_cache member and are re-used if they are still valid |
72 | | - * returns a status struct with error information (if any) |
| 98 | +/** |
| 99 | + * @brief Caches any uncached co-ords of the line of a spiral up to a given line |
| 100 | + * index. |
| 101 | + * @details If there are any outstanding co-ordinates which haven't been stored |
| 102 | + * in the spiral's internal cache, then these will be calculated and stored in |
| 103 | + * the cache. Subsequent identical calls will not incur the overhead of |
| 104 | + * re-calculating these co-ords, provided the lengths of any of the spiral's |
| 105 | + * lines are not changed in the process. |
| 106 | + * |
| 107 | + * @param spiral The spiral for which co-ords should be cached. |
| 108 | + * @param limit The highest index of line for which co-ords should be cached to. |
| 109 | + * @return SXBP_OPERATION_OK on success. |
| 110 | + * @return SXBP_MALLOC_REFUSED on memory allocation failure. |
73 | 111 | * |
74 | | - * Asserts: |
| 112 | + * @note Asserts: |
75 | 113 | * - That spiral->lines is not NULL |
76 | 114 | * - That limit is less than or equal to spiral->size |
77 | 115 | */ |
|
0 commit comments