OSSIM - Open Source Software Image Map
Version 1.9.0 (20180803)
ossim-plugins
potrace
src
auxiliary.h
Go to the documentation of this file.
1
/* Copyright (C) 2001-2015 Peter Selinger.
2
This file is part of Potrace. It is free software and it is covered
3
by the GNU General Public License. See the file COPYING for details. */
4
5
/* This header file collects some general-purpose macros (and static
6
inline functions) that are used in various places. */
7
8
#ifndef AUXILIARY_H
9
#define AUXILIARY_H
10
11
#ifdef HAVE_CONFIG_H
12
#include <config.h>
13
#endif
14
15
#include <stdlib.h>
16
17
/* ---------------------------------------------------------------------- */
18
/* point arithmetic */
19
20
#include "
potracelib.h
"
21
22
struct
point_s
{
23
long
x
;
24
long
y
;
25
};
26
typedef
struct
point_s
point_t
;
27
28
typedef
potrace_dpoint_t
dpoint_t
;
29
30
/* convert point_t to dpoint_t */
31
static
inline
dpoint_t
dpoint(
point_t
p) {
32
dpoint_t
res;
33
res.
x
= p.
x
;
34
res.
y
= p.
y
;
35
return
res;
36
}
37
38
/* range over the straight line segment [a,b] when lambda ranges over [0,1] */
39
static
inline
dpoint_t
interval(
double
lambda,
dpoint_t
a,
dpoint_t
b) {
40
dpoint_t
res;
41
42
res.
x
= a.
x
+ lambda * (b.
x
- a.
x
);
43
res.
y
= a.
y
+ lambda * (b.
y
- a.
y
);
44
return
res;
45
}
46
47
/* ---------------------------------------------------------------------- */
48
/* some useful macros. Note: the "mod" macro works correctly for
49
negative a. Also note that the test for a>=n, while redundant,
50
speeds up the mod function by 70% in the average case (significant
51
since the program spends about 16% of its time here - or 40%
52
without the test). The "floordiv" macro returns the largest integer
53
<= a/n, and again this works correctly for negative a, as long as
54
a,n are integers and n>0. */
55
56
/* integer arithmetic */
57
58
static
inline
int
mod(
int
a,
int
n
) {
59
return
a>=
n
? a%
n
: a>=0 ? a :
n
-1-(-1-a)%
n
;
60
}
61
62
static
inline
int
floordiv(
int
a,
int
n
) {
63
return
a>=0 ? a/
n
: -1-(-1-a)/
n
;
64
}
65
66
/* Note: the following work for integers and other numeric types. */
67
#undef sign
68
#undef abs
69
#undef min
70
#undef max
71
#undef sq
72
#undef cu
73
#define sign(x) ((x)>0 ? 1 : (x)<0 ? -1 : 0)
74
#define abs(a) ((a)>0 ? (a) : -(a))
75
#define min(a,b) ((a)<(b) ? (a) : (b))
76
#define max(a,b) ((a)>(b) ? (a) : (b))
77
#define sq(a) ((a)*(a))
78
#define cu(a) ((a)*(a)*(a))
79
80
#endif
/* AUXILIARY_H */
point_s::y
long y
Definition:
auxiliary.h:24
dpoint_t
potrace_dpoint_t dpoint_t
Definition:
auxiliary.h:28
point_s
Definition:
auxiliary.h:22
point_s::x
long x
Definition:
auxiliary.h:23
n
os2<< "> n<< " > nendobj n
Definition:
ossimPdfWriter.cpp:532
potrace_dpoint_s::x
double x
Definition:
potracelib.h:67
potracelib.h
potrace_dpoint_s
Definition:
potracelib.h:66
potrace_dpoint_s::y
double y
Definition:
potracelib.h:67
Generated on Fri Aug 3 2018 08:46:44 for OSSIM - Open Source Software Image Map by
1.8.14