SILICON
Loading...
Searching...
No Matches
wireRouting.hpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include <functional>
21#include <span>
22#include <vector>
23
24#include <QPointF>
25#include <QRectF>
26
27namespace Avoid {
28class ConnRef;
29class Router;
30} // namespace Avoid
31
32namespace SILICON::core {
33
40void configureOrthogonalRouter(Avoid::Router& router, qreal gridSize);
41
43[[nodiscard]] std::vector<QPointF> extractOrthogonalRoute(Avoid::ConnRef& connector,
44 qreal gridSize);
45
47[[nodiscard]] bool isOrthogonalRoute(std::span<const QPointF> points);
48
50[[nodiscard]] bool orthogonalRouteSelfIntersects(std::span<const QPointF> points);
51
54 std::span<const QPointF> route, std::span<const QRectF> obstacles);
55
57[[nodiscard]] bool pointOnOrthogonalRoute(QPointF point, std::span<const QPointF> route);
58
60[[nodiscard]] bool orthogonalRoutesTouch(std::span<const QPointF> first,
61 std::span<const QPointF> second);
62
64[[nodiscard]] bool orthogonalRoutesShareSegment(std::span<const QPointF> first,
65 std::span<const QPointF> second);
66
68[[nodiscard]] bool orthogonalRoutesIntersect(std::span<const QPointF> first,
69 std::span<const QPointF> second);
70
72[[nodiscard]] std::size_t orthogonalRouteCrossingCount(std::span<const QPointF> first,
73 std::span<const QPointF> second);
74
76[[nodiscard]] std::size_t
78 const std::vector<std::vector<QPointF>>& routes);
79
81[[nodiscard]] std::vector<QPointF>
82canonicalizeOrthogonalRoute(std::vector<QPointF> points);
83
92[[nodiscard]] std::vector<std::vector<QPointF>>
93mergeOrthogonalRoutes(const std::vector<std::vector<QPointF>>& routes,
94 const std::function<bool()>& progress = {});
95
96[[nodiscard]] std::vector<QPointF>
97routeOrthogonalWire(QPointF start, QPointF end, const std::vector<QRectF>& obstacleRects,
98 qreal gridSize);
99
100} // namespace SILICON::core
std::vector< QPointF > canonicalizeOrthogonalRoute(std::vector< QPointF > points)
Removes consecutive duplicates and redundant collinear interior points.
bool orthogonalRouteCrossesObstacleInterior(const std::span< const QPointF > route, const std::span< const QRectF > obstacles)
bool orthogonalRoutesTouch(const std::span< const QPointF > first, const std::span< const QPointF > second)
Returns whether an endpoint of either route lies on the other route.
std::size_t orthogonalRouteCrossingCount(const std::span< const QPointF > first, const std::span< const QPointF > second)
Counts strict, perpendicular interior crossings between two routes.
void configureOrthogonalRouter(Avoid::Router &router, const qreal gridSize)
Applies SILICON's shared orthogonal-routing policy to a libavoid router.
std::size_t orthogonalRouteIncidentArmCount(const QPointF point, const std::vector< std::vector< QPointF > > &routes)
Counts the distinct orthogonal arms incident to point.
std::vector< QPointF > extractOrthogonalRoute(Avoid::ConnRef &connector, const qreal gridSize)
Extracts, grid-snaps, and canonicalizes a libavoid display route.
std::vector< QPointF > routeOrthogonalWire(const QPointF start, const QPointF end, const std::vector< QRectF > &obstacleRects, const qreal gridSize)
bool orthogonalRouteSelfIntersects(const std::span< const QPointF > points)
Detects crossings, touches, or retraced portions within one route.
bool orthogonalRoutesIntersect(const std::span< const QPointF > first, const std::span< const QPointF > second)
Returns true when two routes overlap or form an ambiguous endpoint junction.
bool pointOnOrthogonalRoute(const QPointF point, const std::span< const QPointF > route)
Returns whether point lies on an orthogonal polyline.
bool isOrthogonalRoute(const std::span< const QPointF > points)
Returns whether every consecutive route segment is axis-aligned.
bool orthogonalRoutesShareSegment(const std::span< const QPointF > first, const std::span< const QPointF > second)
Returns true when two orthogonal polylines share a positive-length segment.
std::vector< std::vector< QPointF > > mergeOrthogonalRoutes(const std::vector< std::vector< QPointF > > &routes, const std::function< bool()> &progress)
Unions several routes of one net into maximal terminal-to-junction paths.