Graphviz  2.41.20170921.2350
QuadTree.h
Go to the documentation of this file.
1 /* $Id$ $Revision$ */
2 /* vim:set shiftwidth=4 ts=8: */
3 
4 /*************************************************************************
5  * Copyright (c) 2011 AT&T Intellectual Property
6  * All rights reserved. This program and the accompanying materials
7  * are made available under the terms of the Eclipse Public License v1.0
8  * which accompanies this distribution, and is available at
9  * http://www.eclipse.org/legal/epl-v10.html
10  *
11  * Contributors: See CVS logs. Details at http://www.graphviz.org/
12  *************************************************************************/
13 
14 #ifndef QUAD_TREE_H
15 #define QUAD_TREE_H
16 
17 #include "LinkedList.h"
18 /* #include "sfdpinternal.h" */
19 #include <stdio.h>
20 
21 typedef struct QuadTree_struct *QuadTree;
22 
24  /* a data structure containing coordinates of n items, their average is in "average".
25  The current level is a square or cube of width "width", which is subdivided into
26  2^dim QuadTrees qts. At the last level, all coordinates are stored in a single linked list l.
27  total_weight is the combined weights of the nodes */
28  int n;/* number of items */
30  int dim;
31  real *center;/* center of the bounding box, array of dimension dim. Allocated inside */
32  real width;/* center +/- width gives the lower/upper bound, so really width is the
33  "radius" */
34  real *average;/* the average coordinates. Array of length dim. Allocated inside */
35  QuadTree *qts;/* subtree . If dim = 2, there are 4, dim = 3 gives 8 */
37  int max_level;
38  void *data;
39 };
40 
41 
42 QuadTree QuadTree_new(int dim, real *center, real width, int max_level);
43 
44 void QuadTree_delete(QuadTree q);
45 
46 QuadTree QuadTree_add(QuadTree q, real *coord, real weight, int id);/* coord is copied in */
47 
48 void QuadTree_print(FILE *fp, QuadTree q);
49 
50 QuadTree QuadTree_new_from_point_list(int dim, int n, int max_level, real *coord, real *weight);
51 
52 real point_distance(real *p1, real *p2, int dim);
53 
54 void QuadTree_get_supernodes(QuadTree qt, real bh, real *point, int nodeid, int *nsuper,
55  int *nsupermax, real **center, real **supernode_wgts, real **distances, real *counts, int *flag);
56 
57 void QuadTree_get_repulsive_force(QuadTree qt, real *force, real *x, real bh, real p, real KP, real *counts, int *flag);
58 
59 /* find the nearest point and put in ymin, index in imin and distance in min */
60 void QuadTree_get_nearest(QuadTree qt, real *x, real *ymin, int *imin, real *min, int *flag);
61 
62 QuadTree QuadTree_new_in_quadrant(int dim, real *center, real width, int max_level, int i);
63 
64 #endif
void QuadTree_get_repulsive_force(QuadTree qt, real *force, real *x, real bh, real p, real KP, real *counts, int *flag)
Definition: QuadTree.c:317
QuadTree QuadTree_new_in_quadrant(int dim, real *center, real width, int max_level, int i)
Definition: QuadTree.c:455
real point_distance(real *p1, real *p2, int dim)
Definition: general.c:291
real * center
Definition: QuadTree.h:31
real total_weight
Definition: QuadTree.h:29
QuadTree QuadTree_new(int dim, real *center, real width, int max_level)
Definition: QuadTree.c:402
QuadTree * qts
Definition: QuadTree.h:35
real * average
Definition: QuadTree.h:34
double ymin
Definition: geometry.c:20
void QuadTree_print(FILE *fp, QuadTree q)
Definition: QuadTree.c:654
void * data
Definition: QuadTree.h:38
void QuadTree_get_supernodes(QuadTree qt, real bh, real *point, int nodeid, int *nsuper, int *nsupermax, real **center, real **supernode_wgts, real **distances, double *counts, int *flag)
Definition: QuadTree.c:126
struct QuadTree_struct * QuadTree
Definition: QuadTree.h:21
void QuadTree_delete(QuadTree q)
Definition: QuadTree.c:421
Definition: geom.h:26
SingleLinkedList l
Definition: QuadTree.h:36
QuadTree QuadTree_new_from_point_list(int dim, int n, int max_level, real *coord, real *weight)
Definition: QuadTree.c:347
void QuadTree_get_nearest(QuadTree qt, real *x, real *ymin, int *imin, real *min, int *flag)
Definition: QuadTree.c:727
pointf coord(node_t *n)
Definition: utils.c:202
QuadTree QuadTree_add(QuadTree q, real *coord, real weight, int id)
Definition: QuadTree.c:554
#define real
Definition: general.h:34