Adaptagrams
scanline.h
1 /*
2  * vim: ts=4 sw=4 et tw=0 wm=0
3  *
4  * libavoid - Fast, Incremental, Object-avoiding Line Router
5  *
6  * Copyright (C) 2009-2013 Monash University
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  * See the file LICENSE.LGPL distributed with the library.
13  *
14  * Licensees holding a valid commercial license may use this file in
15  * accordance with the commercial license agreement provided with the
16  * library.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21  *
22  * Author(s): Michael Wybrow
23 */
24 
25 
26 #ifndef AVOID_SCANLINE_H
27 #define AVOID_SCANLINE_H
28 
29 #include <set>
30 #include <list>
31 
32 #include "libavoid/geomtypes.h"
33 
34 
35 namespace Avoid {
36 
37 static const double CHANNEL_MAX = 100000000;
38 
39 
40 class Obstacle;
41 class VertInf;
42 
43 // ShiftSegment interface.
44 class ShiftSegment
45 {
46  public:
47  ShiftSegment(const size_t dim)
48  : dimension(dim)
49  {
50  }
51  virtual ~ShiftSegment()
52  {
53  }
54  virtual Point& lowPoint(void) = 0;
55  virtual Point& highPoint(void) = 0;
56  virtual const Point& lowPoint(void) const = 0;
57  virtual const Point& highPoint(void) const = 0;
58  virtual bool overlapsWith(const ShiftSegment *rhs,
59  const size_t dim) const = 0;
60  virtual bool immovable(void) const = 0;
61 
62  size_t dimension;
63  double minSpaceLimit;
64  double maxSpaceLimit;
65 };
66 typedef std::list<ShiftSegment *> ShiftSegmentList;
67 
68 
69 class Node;
70 struct CmpNodePos
71 {
72  bool operator()(const Node* u, const Node* v) const;
73 };
74 
75 
76 typedef std::set<Node*,CmpNodePos> NodeSet;
77 
78 class Node
79 {
80  public:
81 
82  Obstacle *v;
83  VertInf *c;
84  ShiftSegment *ss;
85  double pos;
86  double min[2], max[2];
87  Node *firstAbove, *firstBelow;
88  NodeSet::iterator iter;
89 
90  Node(Obstacle *v, const double p);
91  Node(VertInf *c, const double p);
92  Node(ShiftSegment *ss, const double p);
93  virtual ~Node();
94  double firstObstacleAbove(size_t dim);
95  double firstObstacleBelow(size_t dim);
96  void markShiftSegmentsAbove(size_t dim);
97  void markShiftSegmentsBelow(size_t dim);
98  void findFirstPointAboveAndBelow(const size_t dim, const double linePos,
99  double& firstAbovePos, double& firstBelowPos,
100  double& lastAbovePos, double& lastBelowPos);
101  double firstPointAbove(size_t dim);
102  double firstPointBelow(size_t dim);
103  bool isInsideShape(size_t dimension);
104 };
105 
106 
107 // Note: Open must come first.
108 typedef enum {
109  Open = 1,
110  SegOpen = 2,
111  ConnPoint = 3,
112  SegClose = 4,
113  Close = 5
114 } EventType;
115 
116 
117 struct Event
118 {
119  Event(EventType t, Node *v, double p);
120 
121  EventType type;
122  Node *v;
123  double pos;
124 };
125 
126 
127 extern int compare_events(const void *a, const void *b);
128 extern void buildConnectorRouteCheckpointCache(Router *router);
129 extern void clearConnectorRouteCheckpointCache(Router *router);
130 extern void buildOrthogonalChannelInfo(Router *router,
131  const size_t dim, ShiftSegmentList& segmentList);
132 
133 
134 }
135 
136 #endif
Contains the interface for various geometry types and classes.
libavoid: Object-avoiding orthogonal and polyline connector routing library.
Definition: actioninfo.cpp:33