dgraph.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef GRASS_DdglGraph_s_H
  2. #define GRASS_DdglGraph_s_H
  3. /* pg comes from "planar graph" */
  4. /* every edge is directed. Nevertheless, we can visit it on both sides */
  5. struct pg_edge {
  6. int v1; /* first vertex */
  7. int v2; /* second vertex */
  8. char visited_left;
  9. char visited_right;
  10. char winding_left; /* winding numbers */
  11. char winding_right;
  12. };
  13. struct pg_vertex {
  14. double x; /* coordinates */
  15. double y;
  16. int ecount; /* number of neighbours */
  17. int eallocated; /* size of the array below */
  18. struct pg_edge **edges; /* array of pointers */
  19. double *angles; /* precalculated angles with Ox */
  20. };
  21. struct planar_graph {
  22. int vcount; /* number of vertices */
  23. struct pg_vertex *v;
  24. int ecount;
  25. int eallocated;
  26. struct pg_edge *e;
  27. };
  28. struct planar_graph* pg_create_struct(int n, int e);
  29. void pg_destroy_struct(struct planar_graph *pg);
  30. int pg_existsedge(struct planar_graph *pg, int v1, int v2);
  31. void pg_addedge(struct planar_graph *pg, int v1, int v2);
  32. struct planar_graph* pg_create(const struct line_pnts *Points);
  33. #endif