Graphviz 12.0.1~dev.20240716.0800
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
26typedef 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
37typedef 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
48typedef struct {
49 size_t length;
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
71static 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
86extern traps_t construct_trapezoids(int, segment_t*, int*);
pointf v0
Definition trap.h:27
int root0
Definition trap.h:29
int prev
Definition trap.h:31
int next
Definition trap.h:30
bool is_inserted
Definition trap.h:28
Definition trap.h:37
int usave
Definition trap.h:43
int state
Definition trap.h:44
pointf hi
Definition trap.h:39
int d0
Definition trap.h:41
int sink
Definition trap.h:42
int u0
Definition trap.h:40
int lseg
Definition trap.h:38
an array of trapezoids
Definition trap.h:48
size_t length
Definition trap.h:49
trap_t * data
Definition trap.h:50
traps_t construct_trapezoids(int, segment_t *, int *)
Definition trapezoid.c:924
#define C_EPS
Definition trap.h:56
static int dfp_cmp(double f1, double f2)
double floating point three-way comparison
Definition trap.h:71