Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
trapezoid.c File Reference

trapezoidation More...

#include "config.h"
#include <string.h>
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <math.h>
#include <common/geom.h>
#include <common/types.h>
#include <ortho/trap.h>
#include <util/alloc.h>
Include dependency graph for trapezoid.c:

Go to the source code of this file.

Data Structures

struct  qnode_t
 
struct  qnodes_t
 an array of qnodes More...
 

Macros

#define T_X   1
 
#define T_Y   2
 
#define T_SINK   3
 
#define FIRSTPT   1 /* checking whether pt. is inserted */
 
#define LASTPT   2
 
#define S_LEFT   1 /* for merge-direction */
 
#define S_RIGHT   2
 
#define INF   1<<30
 
#define CROSS(v0, v1, v2)
 

Functions

static int newnode (qnodes_t *qs)
 
static int newtrap (traps_t *tr)
 
static void _max (pointf *yval, pointf *v0, pointf *v1)
 
static void _min (pointf *yval, pointf *v0, pointf *v1)
 
static bool _greater_than_equal_to (pointf *v0, pointf *v1)
 
static bool _less_than (pointf *v0, pointf *v1)
 
static int init_query_structure (int segnum, segment_t *seg, traps_t *tr, qnodes_t *qs)
 
static bool is_left_of (int segnum, segment_t *seg, pointf *v)
 
static bool inserted (int segnum, segment_t *seg, int whichpt)
 
static int locate_endpoint (pointf *v, pointf *vo, int r, segment_t *seg, qnodes_t *qs)
 
static void merge_trapezoids (int segnum, int tfirst, int tlast, int side, traps_t *tr, qnodes_t *qs)
 
static void update_trapezoid (segment_t *s, segment_t *seg, traps_t *tr, int t, int tn)
 
static void add_segment (int segnum, segment_t *seg, traps_t *tr, qnodes_t *qs)
 
static void find_new_roots (int segnum, segment_t *seg, traps_t *tr, qnodes_t *qs)
 
static int math_logstar_n (int n)
 
static int math_N (int n, int h)
 
traps_t construct_trapezoids (int nseg, segment_t *seg, int *permute)
 

Detailed Description

Macro Definition Documentation

◆ CROSS

#define CROSS (   v0,
  v1,
  v2 
)
Value:
(((v1).x - (v0).x)*((v2).y - (v0).y) - \
((v1).y - (v0).y)*((v2).x - (v0).x))

Definition at line 45 of file trapezoid.c.

◆ FIRSTPT

#define FIRSTPT   1 /* checking whether pt. is inserted */

Definition at line 37 of file trapezoid.c.

◆ INF

#define INF   1<<30

Definition at line 43 of file trapezoid.c.

◆ LASTPT

#define LASTPT   2

Definition at line 38 of file trapezoid.c.

◆ S_LEFT

#define S_LEFT   1 /* for merge-direction */

Definition at line 40 of file trapezoid.c.

◆ S_RIGHT

#define S_RIGHT   2

Definition at line 41 of file trapezoid.c.

◆ T_SINK

#define T_SINK   3

Definition at line 35 of file trapezoid.c.

◆ T_X

#define T_X   1

Definition at line 33 of file trapezoid.c.

◆ T_Y

#define T_Y   2

Definition at line 34 of file trapezoid.c.

Function Documentation

◆ _greater_than_equal_to()

static bool _greater_than_equal_to ( pointf v0,
pointf v1 
)
static

Definition at line 109 of file trapezoid.c.

References C_EPS, pointf_s::x, and pointf_s::y.

Referenced by _less_than(), add_segment(), and merge_trapezoids().

Here is the caller graph for this function:

◆ _less_than()

static bool _less_than ( pointf v0,
pointf v1 
)
static

Definition at line 119 of file trapezoid.c.

References _greater_than_equal_to().

Referenced by add_segment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _max()

static void _max ( pointf yval,
pointf v0,
pointf v1 
)
static

Definition at line 78 of file trapezoid.c.

References C_EPS, FP_EQUAL, pointf_s::x, and pointf_s::y.

Referenced by init_query_structure().

Here is the caller graph for this function:

◆ _min()

static void _min ( pointf yval,
pointf v0,
pointf v1 
)
static

Definition at line 94 of file trapezoid.c.

References C_EPS, FP_EQUAL, pointf_s::x, and pointf_s::y.

Referenced by init_query_structure().

Here is the caller graph for this function:

◆ add_segment()

static void add_segment ( int  segnum,
segment_t seg,
traps_t tr,
qnodes_t qs 
)
static

Definition at line 486 of file trapezoid.c.

References _equal_to, _greater_than, _greater_than_equal_to(), _less_than(), trap_t::d0, trap_t::d1, traps_t::data, qnodes_t::data, FIRSTPT, FP_EQUAL, trap_t::hi, inserted(), segment_t::is_inserted, is_left_of(), LASTPT, qnode_t::left, trap_t::lo, locate_endpoint(), trap_t::lseg, merge_trapezoids(), newnode(), newtrap(), segment_t::next, qnode_t::nodetype, qnode_t::parent, segment_t::prev, qnode_t::right, trap_t::rseg, S_LEFT, S_RIGHT, qnode_t::segnum, trap_t::sink, ST_VALID, trap_t::state, T_SINK, T_X, T_Y, qnode_t::trnum, trap_t::u0, trap_t::u1, update_trapezoid(), trap_t::usave, trap_t::uside, pointf_s::x, pointf_s::y, and qnode_t::yval.

Referenced by construct_trapezoids().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ construct_trapezoids()

traps_t construct_trapezoids ( int  nseg,
segment_t seg,
int *  permute 
)

Definition at line 924 of file trapezoid.c.

References add_segment(), qnodes_t::data, find_new_roots(), free(), gv_calloc(), init_query_structure(), traps_t::length, qnodes_t::length, math_logstar_n(), and math_N().

Referenced by partition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_new_roots()

static void find_new_roots ( int  segnum,
segment_t seg,
traps_t tr,
qnodes_t qs 
)
static

Definition at line 888 of file trapezoid.c.

References traps_t::data, locate_endpoint(), and trap_t::sink.

Referenced by construct_trapezoids().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_query_structure()

static int init_query_structure ( int  segnum,
segment_t seg,
traps_t tr,
qnodes_t qs 
)
static

Definition at line 138 of file trapezoid.c.

References _max(), _min(), trap_t::d0, trap_t::d1, traps_t::data, qnodes_t::data, trap_t::hi, INF, qnode_t::left, trap_t::lo, trap_t::lseg, newnode(), newtrap(), qnode_t::nodetype, qnode_t::parent, qnode_t::right, trap_t::rseg, qnode_t::segnum, trap_t::sink, ST_VALID, trap_t::state, T_SINK, T_X, T_Y, qnode_t::trnum, trap_t::u0, trap_t::u1, pointf_s::x, pointf_s::y, and qnode_t::yval.

Referenced by construct_trapezoids().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inserted()

static bool inserted ( int  segnum,
segment_t seg,
int  whichpt 
)
static

Definition at line 280 of file trapezoid.c.

References FIRSTPT, segment_t::is_inserted, segment_t::next, and segment_t::prev.

Referenced by add_segment().

Here is the caller graph for this function:

◆ is_left_of()

static bool is_left_of ( int  segnum,
segment_t seg,
pointf v 
)
static

Definition at line 230 of file trapezoid.c.

References _greater_than, CROSS, FP_EQUAL, pointf_s::x, and pointf_s::y.

Referenced by add_segment(), locate_endpoint(), and update_trapezoid().

Here is the caller graph for this function:

◆ locate_endpoint()

static int locate_endpoint ( pointf v,
pointf vo,
int  r,
segment_t seg,
qnodes_t qs 
)
static

Definition at line 292 of file trapezoid.c.

References _equal_to, _greater_than, qnodes_t::data, FP_EQUAL, is_left_of(), qnode_t::left, locate_endpoint(), qnode_t::nodetype, qnode_t::right, qnode_t::segnum, T_SINK, T_X, T_Y, qnode_t::trnum, segment_t::v0, segment_t::v1, pointf_s::x, pointf_s::y, and qnode_t::yval.

Referenced by add_segment(), find_new_roots(), and locate_endpoint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ math_logstar_n()

static int math_logstar_n ( int  n)
static

Definition at line 901 of file trapezoid.c.

Referenced by construct_trapezoids().

Here is the caller graph for this function:

◆ math_N()

static int math_N ( int  n,
int  h 
)
static

Definition at line 912 of file trapezoid.c.

Referenced by construct_trapezoids().

Here is the caller graph for this function:

◆ merge_trapezoids()

static void merge_trapezoids ( int  segnum,
int  tfirst,
int  tlast,
int  side,
traps_t tr,
qnodes_t qs 
)
static

Definition at line 350 of file trapezoid.c.

References _greater_than_equal_to(), trap_t::d0, trap_t::d1, traps_t::data, qnodes_t::data, qnode_t::left, trap_t::lo, trap_t::lseg, qnode_t::parent, qnode_t::right, trap_t::rseg, S_LEFT, trap_t::sink, ST_INVALID, trap_t::state, trap_t::u0, and trap_t::u1.

Referenced by add_segment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ newnode()

static int newnode ( qnodes_t qs)
static

Definition at line 64 of file trapezoid.c.

References qnodes_t::data, gv_recalloc(), and qnodes_t::length.

Referenced by add_segment(), and init_query_structure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ newtrap()

static int newtrap ( traps_t tr)
static

Definition at line 71 of file trapezoid.c.

References traps_t::data, gv_recalloc(), and traps_t::length.

Referenced by add_segment(), and init_query_structure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_trapezoid()

static void update_trapezoid ( segment_t s,
segment_t seg,
traps_t tr,
int  t,
int  tn 
)
static

Definition at line 413 of file trapezoid.c.

References trap_t::d0, trap_t::d1, traps_t::data, is_left_of(), trap_t::rseg, S_LEFT, trap_t::u0, trap_t::u1, trap_t::usave, and trap_t::uside.

Referenced by add_segment().

Here is the call graph for this function:
Here is the caller graph for this function: