Graphviz
13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
trap.h
Go to the documentation of this file.
1
9
/*************************************************************************
10
* Copyright (c) 2011 AT&T Intellectual Property
11
* All rights reserved. This program and the accompanying materials
12
* are made available under the terms of the Eclipse Public License v1.0
13
* which accompanies this distribution, and is available at
14
* https://www.eclipse.org/legal/epl-v10.html
15
*
16
* Contributors: Details at https://graphviz.org
17
*************************************************************************/
18
19
#pragma once
20
21
#include <stdbool.h>
22
#include <stddef.h>
23
24
/* Segment attributes */
25
26
typedef
struct
{
27
pointf
v0
, v1;
/* two endpoints */
28
bool
is_inserted
;
/* inserted in trapezoidation yet ? */
29
int
root0
, root1;
/* root nodes in Q */
30
int
next
;
/* Next logical segment */
31
int
prev
;
/* Previous segment */
32
}
segment_t
;
33
34
35
/* Trapezoid attributes */
36
37
typedef
struct
{
38
int
lseg
, rseg;
/* two adjoining segments */
39
pointf
hi
, lo;
/* max/min y-values */
40
int
u0
, u1;
41
int
d0
, d1;
42
int
sink
;
/* pointer to corresponding in Q */
43
int
usave
, uside;
/* I forgot what this means */
44
int
state
;
45
}
trap_t
;
46
48
typedef
struct
{
49
size_t
length
;
50
trap_t
*
data
;
51
}
traps_t
;
52
53
#define ST_VALID 1
/* for trapezium state */
54
#define ST_INVALID 2
55
56
#define C_EPS 1.0e-7
/* tolerance value: Used for making */
57
/* all decisions about collinearity or */
58
/* left/right of segment. Decrease */
59
/* this value if the input points are */
60
/* spaced very close together */
61
#define FP_EQUAL(s, t) (fabs(s - t) <= C_EPS)
62
71
static
inline
int
dfp_cmp
(
double
f1,
double
f2) {
72
double
d = f1 - f2;
73
if
(d < -
C_EPS
)
74
return
-1;
75
if
(d >
C_EPS
)
76
return
1;
77
return
0;
78
}
79
80
#define _equal_to(v0,v1) \
81
(FP_EQUAL((v0)->y, (v1)->y) && FP_EQUAL((v0)->x, (v1)->x))
82
83
#define _greater_than(v0, v1) \
84
(((v0)->y > (v1)->y + C_EPS) ? true : (((v0)->y < (v1)->y - C_EPS) ? false : ((v0)->x > (v1)->x)))
85
86
extern
traps_t
construct_trapezoids
(
int
,
segment_t
*,
int
*);
pointf_s
Definition
geom.h:29
segment_t
Definition
trap.h:26
segment_t::v0
pointf v0
Definition
trap.h:27
segment_t::root0
int root0
Definition
trap.h:29
segment_t::prev
int prev
Definition
trap.h:31
segment_t::next
int next
Definition
trap.h:30
segment_t::is_inserted
bool is_inserted
Definition
trap.h:28
trap_t
Definition
trap.h:37
trap_t::usave
int usave
Definition
trap.h:43
trap_t::state
int state
Definition
trap.h:44
trap_t::hi
pointf hi
Definition
trap.h:39
trap_t::d0
int d0
Definition
trap.h:41
trap_t::sink
int sink
Definition
trap.h:42
trap_t::u0
int u0
Definition
trap.h:40
trap_t::lseg
int lseg
Definition
trap.h:38
traps_t
an array of trapezoids
Definition
trap.h:48
traps_t::length
size_t length
Definition
trap.h:49
traps_t::data
trap_t * data
Definition
trap.h:50
construct_trapezoids
traps_t construct_trapezoids(int, segment_t *, int *)
Definition
trapezoid.c:924
C_EPS
#define C_EPS
Definition
trap.h:56
dfp_cmp
static int dfp_cmp(double f1, double f2)
double floating point three-way comparison
Definition
trap.h:71
lib
ortho
trap.h
Generated by
1.9.8