1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Lee's PCB routing algorithm. Construct with list of connections between
30 nodes (i.e. topology) and list of coordinates of nodes (can be vector::zero)
34 // Enter topology/geometry
41 // Try to route connections one by one. Specify unique value (<0) to
43 forAll(wantedConnections, i)
45 bool success = cellRouter.route(wantedConnections[i], -(i+1));
49 The coordinates are only used at the moment for diagonal preference of
72 Lee algo: take array with same dimensions as grid of nodes. Initialize to
73 large number. Put 0 at starting point. Now recursively assign neighbours
74 as current value plus one. Stop if you hit node which has smaller number.
75 Phase two is where you search path with lowest value. These are assigned
76 negative number so they for next route are not overwritten.
81 \*---------------------------------------------------------------------------*/
86 #include <OpenFOAM/labelList.H>
87 #include <OpenFOAM/pointField.H>
88 #include <OpenFOAM/DynamicList.H>
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
95 // Forward declaration of classes
97 /*---------------------------------------------------------------------------*\
98 Class router Declaration
99 \*---------------------------------------------------------------------------*/
106 const labelListList connections_;
108 //- Coordinates of nodes
109 const pointField coords_;
114 // Private Member Functions
116 //- Return number of weights. Utility function
117 label count(const label weight) const;
119 //- Set distance from nodeI
126 //- Finds path from nodeI to startNodeI by travelling in direction
130 const label startNodeI,
131 const label endNodeI,
133 const label prevNodeI
136 //- Routes single path
139 const labelList& path,
140 const label pathValue
143 //- Linear search for element with weight
144 label getValue(const label) const;
146 //- Find node which has no neighbours with pathValue
149 const label startNodeI,
150 const label prevNodeI,
151 const label pathValue
154 //- Append all pathValue weights to route.
157 const label startNodeI,
158 const label prevNodeI,
159 const label pathValue,
160 DynamicList<label>& route
163 //- Disallow default bitwise copy construct
164 router(const router&);
166 //- Disallow default bitwise assignment
167 void operator=(const router&);
174 //- Construct from connections, route later.
177 const labelListList& connections,
178 const List<point>& coords
186 const labelList& weights() const
193 //- Find path from first element in path to all other elements
194 // Mark resulting path in weights with (negative) pathValue.
195 // Returns false and does not mark any elements if cannot route.
196 bool route(const labelList& path, const label pathValue);
198 //- Extract labels of route with given value.
199 labelList getRoute(const label pathValue) const;
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 } // End namespace Foam
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 // ************************ vim: set sw=4 sts=4 et: ************************ //