Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
QuadTree.h
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11#pragma once
12
13#include <stdio.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
20
23 double *coord;
24 int id;
25 void *data;
27};
28
29typedef struct QuadTree_struct *QuadTree;
30
32 /* a data structure containing coordinates of n items, their average is in "average".
33 The current level is a square or cube of width "width", which is subdivided into
34 2^dim QuadTrees qts. At the last level, all coordinates are stored in a single linked list l.
35 total_weight is the combined weights of the nodes */
36 int n;/* number of items */
38 int dim;
39 double *center;/* center of the bounding box, array of dimension dim. Allocated inside */
40 double width;/* center +/- width gives the lower/upper bound, so really width is the
41 "radius" */
42 double *average;/* the average coordinates. Array of length dim. Allocated inside */
43 QuadTree *qts;/* subtree . If dim = 2, there are 4, dim = 3 gives 8 */
46 void *data;
47};
48
49
50QuadTree QuadTree_new(int dim, double *center, double width, int max_level);
51
53
54QuadTree QuadTree_add(QuadTree q, double *coord, double weight, int id);/* coord is copied in */
55
56void QuadTree_print(FILE *fp, QuadTree q);
57
58QuadTree QuadTree_new_from_point_list(int dim, int n, int max_level, double *coord);
59
60double point_distance(double *p1, double *p2, int dim);
61
62void QuadTree_get_supernodes(QuadTree qt, double bh, double *pt, int nodeid, int *nsuper,
63 int *nsupermax, double **center, double **supernode_wgts, double **distances, double *counts);
64
65void QuadTree_get_repulsive_force(QuadTree qt, double *force, double *x, double bh, double p, double KP, double *counts);
66
67/* find the nearest point and put in ymin, index in imin and distance in min */
68void QuadTree_get_nearest(QuadTree qt, double *x, double *ymin, int *imin, double *min);
69
70QuadTree QuadTree_new_in_quadrant(int dim, double *center, double width, int max_level, int i);
71
72#ifdef __cplusplus
73}
74#endif
void QuadTree_get_nearest(QuadTree qt, double *x, double *ymin, int *imin, double *min)
Definition QuadTree.c:682
void QuadTree_get_repulsive_force(QuadTree qt, double *force, double *x, double bh, double p, double KP, double *counts)
Definition QuadTree.c:281
QuadTree QuadTree_add(QuadTree q, double *coord, double weight, int id)
Definition QuadTree.c:515
QuadTree QuadTree_new_in_quadrant(int dim, double *center, double width, int max_level, int i)
Definition QuadTree.c:413
QuadTree QuadTree_new_from_point_list(int dim, int n, int max_level, double *coord)
Definition QuadTree.c:309
void QuadTree_print(FILE *fp, QuadTree q)
Definition QuadTree.c:615
QuadTree QuadTree_new(int dim, double *center, double width, int max_level)
Definition QuadTree.c:357
struct QuadTree_struct * QuadTree
Definition QuadTree.h:29
void QuadTree_delete(QuadTree q)
Definition QuadTree.c:375
double point_distance(double *p1, double *p2, int dim)
Definition general.c:153
void QuadTree_get_supernodes(QuadTree qt, double bh, double *pt, int nodeid, int *nsuper, int *nsupermax, double **center, double **supernode_wgts, double **distances, double *counts)
Definition QuadTree.c:93
struct node_data_struct * node_data
Definition QuadTree.h:19
double ymin
Definition geometry.c:15
static int imin(int a, int b)
minimum of two integers
Definition gv_math.h:27
static const int dim
pointf coord(node_t *n)
Definition utils.c:150
static const double bh
node_data l
Definition QuadTree.h:44
double total_weight
Definition QuadTree.h:37
double * average
Definition QuadTree.h:42
QuadTree * qts
Definition QuadTree.h:43
double * center
Definition QuadTree.h:39
double * coord
Definition QuadTree.h:23
node_data next
Definition QuadTree.h:26
double node_weight
Definition QuadTree.h:22
static point center(point vertex[], size_t n)