Adaptagrams
obstacle.h
Go to the documentation of this file.
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) 2004-2014 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 
28 
29 
30 #ifndef AVOID_OBSTACLE_H
31 #define AVOID_OBSTACLE_H
32 
33 #include <list>
34 #include <set>
35 
36 #include <cstdio>
37 
38 #include "libavoid/geometry.h"
39 #include "libavoid/connectionpin.h"
40 
41 
42 namespace Avoid {
43 
44 class VertInf;
45 class Router;
46 class Obstacle;
47 class ConnEnd;
48 class ConnRef;
49 typedef std::list<Obstacle *> ObstacleList;
50 typedef std::list<ConnRef *> ConnRefList;
51 
52 
53 // @brief The Obstacle class represents an obstacle that must be
54 // routed around. Superclass of ShapeRef and JunctionRef.
55 //
56 class Obstacle
57 {
58  public:
69  Obstacle(Router *router, Polygon poly, const unsigned int id = 0);
70 
71 // To prevent C++ objects from being destroyed in garbage collected languages
72 // when the libraries are called from SWIG, we hide the declarations of the
73 // destructors and prevent generation of default destructors.
74 #ifndef SWIG
75  virtual ~Obstacle();
78 #endif
79 
82  unsigned int id(void) const;
86  const Polygon& polygon(void) const;
90  Router *router(void) const;
93  virtual Point position(void) const = 0;
94 
95  void setNewPoly(const Polygon& poly);
96  VertInf *firstVert(void);
97  VertInf *lastVert(void);
98  Box routingBox(void) const;
99  Polygon routingPolygon(void) const;
100  ConnRefList attachedConnectors(void) const;
101 
102  private:
103  friend class Router;
104  friend class ConnEnd;
105  friend class ShapeConnectionPin;
106  friend class HyperedgeRerouter;
107  friend class HyperedgeImprover;
108  friend class MinimumTerminalSpanningTree;
109 
110  // Defined in visibility.cpp:
111  void computeVisibilityNaive(void);
112  void computeVisibilitySweep(void);
113 
114  virtual void outputCode(FILE *fp) const = 0;
115  void makeActive(void);
116  void makeInactive(void);
117  bool isActive(void) const;
118  void updatePinPolyLineVisibility(void);
119  void removeFromGraph(void);
120  Point shapeCentre(void);
121 
122  VertInf *getPointVertex(const Point& point);
123 
124  void addFollowingConnEnd(ConnEnd *connEnd);
125  void removeFollowingConnEnd(ConnEnd *connEnd);
126  size_t addConnectionPin(ShapeConnectionPin *pin);
127  void removeConnectionPin(ShapeConnectionPin *pin);
128  void assignPinVisibilityTo(const unsigned int pinClassId,
129  VertInf *dummyConnectionVert);
130  std::vector<Point> possiblePinPoints(unsigned int pinClassId) const;
131 
132  protected:
133  Router *m_router;
134  unsigned int m_id;
135  Polygon m_polygon;
136  bool m_active;
137  ObstacleList::iterator m_router_obstacles_pos;
138  VertInf *m_first_vert;
139  VertInf *m_last_vert;
140  std::set<ConnEnd *> m_following_conns;
141  ShapeConnectionPinSet m_connection_pins;
142 };
143 
144 
145 }
146 
147 
148 #endif
149 
150 
std::list< ConnRef * > ConnRefList
A list of ConnRef objects.
Definition: connector.h:47
Contains the interface for the ShapeConnectionPin class.
libavoid: Object-avoiding orthogonal and polyline connector routing library.
Definition: actioninfo.cpp:33