maze.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * @file
  3. * @brief makes @ref maze with @ref mkMaze for routing orthogonal edges
  4. */
  5. /*************************************************************************
  6. * Copyright (c) 2011 AT&T Intellectual Property
  7. * All rights reserved. This program and the accompanying materials
  8. * are made available under the terms of the Eclipse Public License v1.0
  9. * which accompanies this distribution, and is available at
  10. * https://www.eclipse.org/legal/epl-v10.html
  11. *
  12. * Contributors: Details at https://graphviz.org
  13. *************************************************************************/
  14. #pragma once
  15. #include <ortho/sgraph.h>
  16. enum {M_RIGHT=0, M_TOP, M_LEFT, M_BOTTOM};
  17. #define MZ_ISNODE 1
  18. #define MZ_VSCAN 2
  19. #define MZ_HSCAN 4
  20. #define MZ_SMALLV 8
  21. #define MZ_SMALLH 16
  22. /// @brief cell corresponds to node
  23. #define IsNode(cp) (cp->flags & MZ_ISNODE)
  24. /// @brief cell already inserted in vertical channel
  25. #define IsVScan(cp) (cp->flags & MZ_VSCAN)
  26. /// @brief cell already inserted in horizontal channel
  27. #define IsHScan(cp) (cp->flags & MZ_HSCAN)
  28. /// @brief cell has small height corresponding to a small height node
  29. #define IsSmallV(cp) (cp->flags & MZ_SMALLV)
  30. /// @brief cell has small width corresponding to a small width node
  31. #define IsSmallH(cp) (cp->flags & MZ_SMALLH)
  32. /// @brief result of partitioning available space, part of @ref maze
  33. typedef struct cell {
  34. int flags;
  35. int nedges;
  36. sedge* edges[6]; /**< @brief up to six links (@ref sedge) between
  37. four @ref sides (@ref snode) of the cell
  38. 1. ┘ left — top
  39. 2. └ top — right
  40. 3. ┐ left — bottom
  41. 4. ┌ bottom — right
  42. 5. │ top — bottom
  43. 6. ─ left — right
  44. */
  45. int nsides;
  46. snode** sides; ///< @brief up to four sides: @ref M_RIGHT, @ref M_TOP, @ref M_LEFT, @ref M_BOTTOM
  47. boxf bb;
  48. } cell;
  49. /**
  50. * @struct maze
  51. * @brief available channels for orthogonal edges around nodes of @ref graph_t
  52. *
  53. * A maze is the result of partitioning free space around a graph's nodes by @ref mkMaze.
  54. */
  55. typedef struct {
  56. int ncells, ngcells;
  57. cell* cells; ///< @brief cells not corresponding to graph nodes
  58. cell* gcells; ///< @brief cells corresponding to graph nodes
  59. sgraph* sg; ///< @brief search graph
  60. Dt_t* hchans; ///< @brief set of horizontal @ref channel "channels", created by @ref extractHChans.
  61. Dt_t* vchans; ///< @brief set of vertical @ref channel "channels", created by @ref extractVChans
  62. } maze;
  63. extern maze* mkMaze(graph_t*);
  64. extern void freeMaze (maze*);
  65. void updateWts (sgraph* g, cell* cp, sedge* ep);
  66. #ifdef DEBUG
  67. extern int odb_flags;
  68. #define ODB_MAZE 1
  69. #define ODB_SGRAPH 2
  70. #define ODB_ROUTE 4
  71. #define ODB_CHANG 8
  72. #define ODB_IGRAPH 16
  73. #endif