index.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #pragma once
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /*
  15. * this library is derived from an archived home directory of Antonin Guttman
  16. * that implemented the ideas described in
  17. * "R-trees: a dynamic index structure for spatial searching"
  18. * Antonin Guttman, University of California, Berkeley
  19. * SIGMOD '84 Proceedings of the 1984 ACM SIGMOD international conference on Management of data
  20. * ISBN:0-89791-128-8
  21. * http://dx.doi.org/10.1145/602259.602266
  22. * this copy of the code was retrieved from
  23. * http://web.archive.org/web/20030210112132/http://www.es.ucsc.edu/~tonig/rtrees/
  24. * we are using the quadratic node splitter only
  25. * we made a few cosmetic changes to fit our needs
  26. * per Antonin there is no copyright
  27. */
  28. /*-----------------------------------------------------------------------------
  29. | Global definitions.
  30. -----------------------------------------------------------------------------*/
  31. #ifndef NUMDIMS
  32. #define NUMDIMS 2
  33. #endif /*NUMDIMS*/
  34. /* #define NDEBUG */
  35. #define NUMSIDES 2*NUMDIMS
  36. /* branching factor of a node */
  37. /* #define NODECARD (int)((PGSIZE-(2*sizeof(int)))/sizeof(struct Branch))*/
  38. #define NODECARD 64
  39. typedef struct RTree RTree_t;
  40. #include <label/rectangle.h>
  41. #include <label/node.h>
  42. #include <label/split.q.h>
  43. #define CX(i) (i)
  44. #define NX(i) (i+NUMDIMS)
  45. #define CY(i) (i+1)
  46. #define NY(i) (i+1+NUMDIMS)
  47. typedef struct Leaf {
  48. Rect_t rect;
  49. void *data;
  50. } Leaf_t;
  51. typedef struct LeafList {
  52. struct LeafList *next;
  53. Leaf_t *leaf;
  54. } LeafList_t;
  55. struct RTree {
  56. Node_t *root;
  57. SplitQ_t split;
  58. };
  59. RTree_t *RTreeOpen(void);
  60. int RTreeClose(RTree_t * rtp);
  61. Node_t *RTreeNewIndex(void);
  62. LeafList_t *RTreeSearch(RTree_t *, Node_t *, Rect_t *);
  63. int RTreeInsert(RTree_t *, Rect_t *, void *, Node_t **, int);
  64. LeafList_t *RTreeNewLeafList(Leaf_t * lp);
  65. LeafList_t *RTreeLeafListAdd(LeafList_t * llp, Leaf_t * lp);
  66. void RTreeLeafListFree(LeafList_t * llp);
  67. #ifdef RTDEBUG
  68. void PrintNode(Node_t *);
  69. #endif
  70. #ifdef __cplusplus
  71. }
  72. #endif