41 return u->
pos < v->pos;
45 void *up = (u->
v) ? (
void *) u->
v :
46 ((u->
c) ? (
void *) u->
c : (
void *) u->
ss);
47 void *vp = (v->v) ? (
void *) v->v :
48 ((v->c) ? (
void *) v->c : (
void *) v->ss);
103 while (curr && (curr->
ss || (curr->
max[dim] >
pos)))
110 return curr->
max[dim];
121 while (curr && (curr->
ss || (curr->
min[dim] <
pos)))
128 return curr->
min[dim];
138 while (curr && (curr->
ss || (curr->
pos >
min[dim])))
140 if (curr->
ss && (curr->
pos <=
min[dim]))
154 while (curr && (curr->
ss || (curr->
pos <
max[dim])))
156 if (curr->
ss && (curr->
pos >=
max[dim]))
166 double& firstAbovePos,
double& firstBelowPos,
167 double& lastAbovePos,
double& lastBelowPos)
169 firstAbovePos = -DBL_MAX;
170 firstBelowPos = DBL_MAX;
173 lastAbovePos =
max[dim];
174 lastBelowPos =
min[dim];
176 Node *curr =
nullptr;
177 bool eventsAtSamePos =
false;
178 for (
int direction = 0; direction < 2; ++direction)
189 (((linePos ==
max[!dim]) &&
190 (linePos == curr->
max[!dim])) ||
191 ((linePos ==
min[!dim]) &&
192 (linePos == curr->
min[!dim])));
194 if (curr->
max[dim] <=
min[dim])
198 firstAbovePos = std::max(curr->
max[dim], firstAbovePos);
200 else if (curr->
min[dim] >=
max[dim])
204 firstBelowPos = std::min(curr->
min[dim], firstBelowPos);
206 else if (!eventsAtSamePos)
211 lastAbovePos = std::min(curr->
min[dim], lastAbovePos);
212 lastBelowPos = std::max(curr->
max[dim], lastBelowPos);
225 size_t altDim = (dim + 1) % 2;
230 bool inLineWithEdge = (
min[altDim] == curr->
min[altDim]) ||
231 (
min[altDim] == curr->
max[altDim]);
232 if ( ! inLineWithEdge && (curr->
max[dim] <=
pos) )
247 size_t altDim = (dim + 1) % 2;
252 bool inLineWithEdge = (
min[altDim] == curr->
min[altDim]) ||
253 (
min[altDim] == curr->
max[altDim]);
254 if ( ! inLineWithEdge && (curr->
min[dim] >=
pos) )
269 if ((curr->min[dimension] <
pos) && (pos < curr->
max[dimension]))
276 if ((curr->min[dimension] <
pos) && (pos < curr->
max[dimension]))
300 return (ea->
pos < eb->
pos) ? -1 : 1;
306 COLA_ASSERT(ea->
v != eb->
v);
307 return (
int)(ea->
v - eb->
v);
313 for (ConnRefList::const_iterator curr = router->
connRefs.begin();
314 curr != router->
connRefs.end(); ++curr)
329 std::vector<std::pair<size_t, Point> >();
331 for (
size_t ind = 0; ind < displayRoute.
size(); ++ind)
335 for (
size_t cpi = 0; cpi < checkpoints.size(); ++cpi)
338 displayRoute.
ps[ind], checkpoints[cpi].point) )
342 std::make_pair((ind * 2) - 1,
343 checkpoints[cpi].point));
348 for (
size_t cpi = 0; cpi < checkpoints.size(); ++cpi)
350 if (displayRoute.
ps[ind].equals(checkpoints[cpi].point))
354 std::make_pair(ind * 2, checkpoints[cpi].point));
364 for (ConnRefList::const_iterator curr = router->
connRefs.begin();
365 curr != router->
connRefs.end(); ++curr)
393 if ( ((pass == 3) && (e->
type ==
Open)) ||
396 std::pair<NodeSet::iterator, bool>
result = scanline.insert(v);
398 COLA_ASSERT(
result.second);
400 NodeSet::iterator it = v->iter;
402 if (it != scanline.begin())
409 if (++it != scanline.end())
417 if ( ((pass == 4) && (e->
type ==
Open)) ||
425 double minLimit = v->firstObstacleAbove(dim);
426 double maxLimit = v->firstObstacleBelow(dim);
428 v->ss->minSpaceLimit =
429 std::max(minLimit, v->ss->minSpaceLimit);
430 v->ss->maxSpaceLimit =
431 std::min(maxLimit, v->ss->maxSpaceLimit);
435 v->markShiftSegmentsAbove(dim);
436 v->markShiftSegmentsBelow(dim);
444 Node *l = v->firstAbove, *r = v->firstBelow;
451 r->firstAbove = v->firstAbove;
455 result = scanline.erase(v);
465 if (segmentList.empty())
472 size_t altDim = (dim + 1) % 2;
474 const size_t cpn = segmentList.size();
476 size_t totalEvents = 2 * (n + cpn);
479 ObstacleList::iterator obstacleIt = router->
m_obstacles.begin();
480 for (
unsigned i = 0; i < n; i++)
494 double mid = min[dim] + ((max[dim] - min[dim]) / 2);
496 events[ctr++] =
new Event(
Open, v, min[altDim]);
497 events[ctr++] =
new Event(
Close, v, max[altDim]);
501 for (ShiftSegmentList::iterator curr = segmentList.begin();
502 curr != segmentList.end(); ++curr)
504 const Point& lowPt = (*curr)->lowPoint();
505 const Point& highPt = (*curr)->highPoint();
507 COLA_ASSERT(lowPt[dim] == highPt[dim]);
508 COLA_ASSERT(lowPt[altDim] < highPt[altDim]);
509 Node *v =
new Node(*curr, lowPt[dim]);
519 double thisPos = (totalEvents > 0) ? events[0]->pos : 0;
520 unsigned int posStartIndex = 0;
521 unsigned int posFinishIndex = 0;
522 for (
unsigned i = 0; i <= totalEvents; ++i)
526 if ((i == totalEvents) || (events[i]->pos != thisPos))
529 for (
int pass = 2; pass <= 4; ++pass)
531 for (
unsigned j = posStartIndex; j < posFinishIndex; ++j)
537 if (i == totalEvents)
543 thisPos = events[i]->
pos;
552 COLA_ASSERT(scanline.size() == 0);
553 for (
unsigned i = 0; i < totalEvents; ++i)
A bounding box, represented by the top-left and bottom-right corners.
Point min
The top-left point.
Point max
The bottom-right point.
The ConnRef class represents a connector object.
ConnType routingType(void) const
Returns the type of routing performed for this connector.
std::vector< Checkpoint > routingCheckpoints(void) const
Returns the current set of routing checkpoints for this connector.
PolyLine & displayRoute(void)
Returns a reference to the current display version of the route for the connector.
The JunctionRef class represents a fixed or free-floating point that connectors can be attached to.
bool positionFixed(void) const
Returns whether this junction has a fixed position (that can't be moved by the Router during routing)...
void findFirstPointAboveAndBelow(const size_t dim, const double linePos, double &firstAbovePos, double &firstBelowPos, double &lastAbovePos, double &lastBelowPos)
double firstObstacleBelow(size_t dim)
double firstPointBelow(size_t dim)
double firstPointAbove(size_t dim)
Node(Obstacle *v, const double p)
bool isInsideShape(size_t dimension)
double firstObstacleAbove(size_t dim)
void markShiftSegmentsAbove(size_t dim)
void markShiftSegmentsBelow(size_t dim)
Box routingBox(void) const
The Point class defines a point in the plane.
A dynamic Polygon, to which points can be easily added and removed.
size_t size(void) const
Returns the number of points in this polygon.
std::vector< Point > ps
A vector of the points that make up the Polygon.
std::vector< std::pair< size_t, Point > > checkpointsOnRoute
The Router class represents a libavoid router instance.
Contains the interface for the ConnRef class.
Contains the interface for the JunctionRef class.
libavoid: Object-avoiding orthogonal and polyline connector routing library.
int compare_events(const void *a, const void *b)
static void processShiftEvent(NodeSet &scanline, Event *e, size_t dim, unsigned int pass)
void clearConnectorRouteCheckpointCache(Router *router)
@ ConnType_Orthogonal
The connector path will be a shortest-path orthogonal poly-line (only vertical and horizontal line se...
void buildOrthogonalChannelInfo(Router *router, const size_t dim, ShiftSegmentList &segmentList)
std::set< Node *, CmpNodePos > NodeSet
void buildConnectorRouteCheckpointCache(Router *router)
std::list< ShiftSegment * > ShiftSegmentList
bool pointOnLine(const Point &a, const Point &b, const Point &c, const double tolerance)
Contains the interface for the Obstacle class, the superclass for ShapeRef and JunctionRef.
Contains the interface for the Router class.
bool operator()(const Node *u, const Node *v) const
Event(EventType t, Node *v, double p)