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-2008 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 <mjwybrow@users.sourceforge.net>
23 */
26 #include "libavoid/viscluster.h"
27 #include "libavoid/router.h"
28 #include "libavoid/assertions.h"
31 namespace Avoid {
34 ClusterRef::ClusterRef(Router *router, unsigned int id, Polygon& ply)
35 : _router(router)
36 , _poly(ply, router)
37 , _active(false)
38 {
39 _id = router->assignId(id);
40 }
43 ClusterRef::~ClusterRef()
44 {
45 }
48 void ClusterRef::makeActive(void)
49 {
50 COLA_ASSERT(!_active);
52 // Add to connRefs list.
53 _pos = _router->clusterRefs.insert(_router->clusterRefs.begin(), this);
55 _active = true;
56 }
59 void ClusterRef::makeInactive(void)
60 {
61 COLA_ASSERT(_active);
63 // Remove from connRefs list.
64 _router->clusterRefs.erase(_pos);
66 _active = false;
67 }
70 void ClusterRef::setNewPoly(Polygon& poly)
71 {
72 _poly = ReferencingPolygon(poly, _router);
73 }
76 unsigned int ClusterRef::id(void)
77 {
78 return _id;
79 }
82 ReferencingPolygon& ClusterRef::polygon(void)
83 {
84 return _poly;
85 }
88 Router *ClusterRef::router(void)
89 {
90 return _router;
91 }
94 }