summaryrefslogtreecommitdiff
path: root/support/dktools/dk4bb.h
blob: f90cf58d01977ea8ca74a36dc384bed34060c818 (plain)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/*
Copyright (C) 2017-2020, Dirk Krause
SPDX-License-Identifier: BSD-3-Clause
*/

/*
	WARNING: This file was generated by the dkct program (see
	http://dktools.sourceforge.net/ for details).
	Changes you make here will be lost if dkct is run again!
	You should modify the original source and run dkct on it.
	Original source: dk4bb.ctr
*/

#ifndef DK4BB_H_INCLUDED
/** Avoid multiple inclusions. */
#define DK4BB_H_INCLUDED 1


#line 9 "dk4bb.ctr"

/**	@file dk4bb.h Bounding box for drawing operations.
*/

#ifndef	DK4CONF_H_INCLUDED
#if	DK4_BUILDING_DKTOOLS4
#include "dk4conf.h"
#else
#include <dktools-4/dk4conf.h>
#endif
#endif

#ifndef	DK4TYPES_H_INCLUDED
#if	DK4_BUILDING_DKTOOLS4
#include "dk4types.h"
#else
#include <dktools-4/dk4types.h>
#endif
#endif



/**	Bounding box.
*/
typedef struct {
  double		xmin;	/**< Minimum x value. */
  double		xmax;	/**< Maximum x value. */
  double		ymin;	/**< Minimum y value. */
  double		ymax;	/**< Maximum y value. */
  unsigned char	fl;		/**< Flags: Have x (bit 0), have y (bit 1). */
} dk4_bb_t;

#ifdef	__cplusplus
extern "C" {
#endif


/**	Initialize bounding box.
	@param	bbptr	Bounding box to initialize.
*/

void
dk4bb_init(
	dk4_bb_t		*bbptr
);


/**	Add x coordinate to bounding box.
	@param	bbptr	Bounding box to modify.
	@param	x		Coordinate value to add.
*/

void
dk4bb_add_x(
	dk4_bb_t		*bbptr,
	double			 x
);


/**	Add y coordinate to bounding box.
	@param	bbptr	Bounding box to modify.
	@param	y		Coordinate value to add.
*/

void
dk4bb_add_y(
	dk4_bb_t		*bbptr,
	double			 y
);


/**	Add point to bounding box.
	@param	bbptr	Bounding box to modify.
	@param	x		X coordinate of point.
	@param	y		Y coordinate of point.
*/

void
dk4bb_add_point(
	dk4_bb_t		*bbptr,
	double			 x,
	double			 y
);


/**	Add Bezier spline segment to bounding box.
	@param	bbptr	Bounding box to modify.
	@param	x0		Start point, x coordinate.
	@param	y0		Start point, y coordinate.
	@param	c0x		Control point next to start point, x coordinate.
	@param	c0y		Control point next to start point, y coordinate.
	@param	c1x		Control point next to end point, x coordinate.
	@param	c1y		Control point next to end point, y coordinate.
	@param	x1		End point, x coordinate.
	@param	y1		End point, y coordinate.
*/

void
dk4bb_add_bezier(
	dk4_bb_t		*bbptr,
	double			 x0,
	double			 y0,
	double			 c0x,
	double			 c0y,
	double			 c1x,
	double			 c1y,
	double			 x1,
	double			 y1
);


/**	Add bounding box for a rotated ellipse.
	@param	bbptr	Bounding box to modify.
	@param	xc		Center point x coordinate.
	@param	yc		Center point y coordinate.
	@param	rx		X radius.
	@param	ry		Y radius.
	@param	rot		Rotation counterclockwise in radians.
*/

void
dk4bb_add_rotated_ellipse(
	dk4_bb_t	*bbptr,
	double		 xc,
	double		 yc,
	double		 rx,
	double		 ry,
	double		 rot
);


/**	Add one bounding box to another one.
	@param	pdest	Destination bounding box.
	@param	psrc	Source bounding box.
*/

void
dk4bb_add_bb(
	dk4_bb_t		*pdest,
	dk4_bb_t const	*psrc
);


/**	Check whether an x value is saved in the bounding box.
	@param	bbptr	Bounding box to query.
	@return	1 if x value available, 0 otherwise.
*/

int
dk4bb_have_x(
	const dk4_bb_t	*bbptr
);


/**	Check whether an y value is saved in the bounding box.
	@param	bbptr	Bounding box to query.
	@return	1 if y value available, 0 otherwise.
*/

int
dk4bb_have_y(
	const dk4_bb_t	*bbptr
);


/**	Retrieve minimum x value.
	@param	bbptr	Bounding box to query.
	@return	Minimum x value saved in the bounding box.
*/

double
dk4bb_get_xmin(
	const dk4_bb_t	*bbptr
);


/**	Retrieve maximum x value.
	@param	bbptr	Bounding box to query.
	@return	Maximum x value saved in the bounding box.
*/

double
dk4bb_get_xmax(
	const dk4_bb_t	*bbptr
);


/**	Retrieve minimum y value.
	@param	bbptr	Bounding box to query.
	@return	Minimum y value saved in the bounding box.
*/

double
dk4bb_get_ymin(
	const dk4_bb_t	*bbptr
);


/**	Retrieve maximum y value.
	@param	bbptr	Bounding box to query.
	@return	Maximum y value saved in the bounding box.
*/

double
dk4bb_get_ymax(
	const dk4_bb_t	*bbptr
);


/**	Check whether an outer box contains an inner box candidate.
	Both boxes must have both x and y information.
	@param	pouter	Outer box.
	@param	pinner	Inner box candidate.
	@param	aborder	Flag: Allow overlapping borders.
	@return	1 if pouter contains pinner, 0 otherwise.
*/

int
dk4bb_contains_bb(
	const dk4_bb_t	*pouter,
	const dk4_bb_t	*pinner,
	int				 aborder
);


#ifdef	__cplusplus
}
#endif

/* vim: set ai sw=4 ts=4 : */


#endif