| 280 | // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // |
| 281 | |
| 282 | bool Foam::router::route(const labelList& path, const label pathValue) |
| 283 | { |
| 284 | if (pathValue >= 0) |
| 285 | { |
| 286 | FatalErrorInFunction |
| 287 | << "Illegal pathValue " << pathValue << exit(FatalError); |
| 288 | } |
| 289 | |
| 290 | // Reset all non-allocated weights to maximum distance |
| 291 | forAll(weights_, nodeI) |
| 292 | { |
| 293 | if (weights_[nodeI] >= 0) |
| 294 | { |
| 295 | weights_[nodeI] = labelMax; |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | if (weights_[path[0]] < 0) |
| 300 | { |
| 301 | // Already used |
| 302 | return false; |
| 303 | } |
| 304 | // Get weights according to distance to starting node |
| 305 | setWeights(0, path[0]); |
| 306 | |
| 307 | // Check if all endPoints can be reached |
| 308 | for (label leafI = 1; leafI < path.size(); leafI++) |
| 309 | { |
| 310 | if (weights_[path[leafI]] == labelMax) |
| 311 | { |
| 312 | //Info<< "Cannot route leaf from " << path[0] |
| 313 | // << " to " << path[leafI] << " of path " << path |
| 314 | // << " since there is no valid route between them" << endl; |
| 315 | |
| 316 | // Do not fix any paths but return |
| 317 | return false; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | // Search back from all endpoints to start and fix weights |
| 322 | for (label leafI = 1; leafI < path.size(); leafI++) |
| 323 | { |
| 324 | fixWeights |
| 325 | ( |
| 326 | path[0], |
| 327 | path[leafI], |
| 328 | path[leafI], |
| 329 | -1 |
| 330 | ); |
| 331 | |
| 332 | if (leafI < path.size() - 1) |
| 333 | { |
| 334 | // Update distance to take new connections into account |
| 335 | forAll(weights_, nodeI) |
| 336 | { |
| 337 | if (weights_[nodeI]== 0) |
| 338 | { |
| 339 | // Include these nodes in distance calculation |
no test coverage detected