12#include "Kanoop/kanoopcommon.h"
26 _direction(
Geo::NoDirection),
27 _forceDirection(
Geo::NoDirection),
28 _initialDirectionForced(false),
29 _firstSegmentLength(0),
31 _routingMargin(DefaultRoutingMargin),
32 _consolidateEmptyRectangles(true),
33 _routeAroundMargins(true),
34 _verticalConstraint(-1),
44 PathRouter(
const Point& origin,
const Point& destination,
const QRectF &canvas,
const QList<Rectangle> &obstacles = QList<Rectangle>());
62 void setObstacles(
const QList<Rectangle>& value) { _obstacles = value; }
170 bool cycleOnPass1(
const Point& a,
const Point& b);
171 bool cycleFindDirectShot(
const Point& a,
const Point& b);
172 bool cycleChooseDirection(
const Point& a,
const Point& b);
173 bool cycleSimpleLShot(
const Point &a,
const Point &b);
174 bool cycleFindWayOffObstacle(
const Point& a,
const Point& b);
175 bool cycleFindNextPoint(
const Point& a,
const Point& b);
177 bool rectangleCrossesObstacle(
const Rectangle &rectangle,
const QList<Rectangle> &ignoreObstacles = QList<Rectangle>())
const;
178 bool linesCrossObstacle(
const Line::List &lines)
const;
179 bool lineCrossesObstacle(
const Line &line)
const;
180 bool lineCrossesObstacle(
const Line &line,
Rectangle &firstObstacle,
Point &intersection)
const;
182 bool lineCrossesObstacle(
const Line &line,
const QList<Rectangle> &ignoreObstacles,
Rectangle &firstObstacle,
Point &intersection)
const;
183 bool pointLiesWithinObstacle(
const Point &point,
Rectangle &result);
184 bool pointLiesOnObstacleEdge(
const Point &point,
Rectangle &result);
186 bool lineLiesOnObstacleEdge(
const Line &line,
Rectangle &foundObstacle,
Line& foundEdge);
187 bool lineLiesNearObstacleEdge(
const Line &line,
double margin,
Rectangle &foundObstacle,
Line& foundEdge);
188 void replaceLines(
int index,
int count,
const Line::List &newLines);
191 static QList<Geo::Direction> chooseDirections(
const Point& a,
const Point& b);
194 static Geo::Direction nonExcludedDirection(QList<Geo::Direction> choices, QList<Geo::Direction> exclude);
204 Line findPathOffObstacleInDirections(
const Point& origin,
const Rectangle &obstacle,
const QList<Geo::Direction>& directions)
const;
205 bool pointLiesOnAppropriateObtstacleCorner(
const Point& origin,
const Rectangle &obstacle,
const QList<Geo::Direction>& directions)
const;
207 void removeZeroLengthLines(
Line::List& lines)
const;
208 void mergeTinySegments(
Line::List& lines)
const;
209 bool lineCrossesVerticalConstraint(
const Line& line);
210 static int countAdjacentLines(
const Line::List& lines);
213 void appendPathLine(
const Line& line);
214 void dumpPathLines(
const QString &label)
const;
216 void logText(
const char* file,
int line,
int level,
const QString& text)
const;
219 Point _destinationPoint;
221 QList<Rectangle> _obstacles;
224 bool _initialDirectionForced;
225 double _firstSegmentLength;
228 bool _consolidateEmptyRectangles;
229 bool _routeAroundMargins;
230 double _verticalConstraint;
239 static const int DefaultRoutingMargin = 10;
A list of Line objects with spatial query helpers.
Represents a 2D line segment between two Point endpoints.
Orthogonal path-routing algorithm that navigates around rectangular obstacles.
Point originPoint() const
Return the origin point.
void setRouteAroundMargins(bool value)
Enable or disable routing around obstacle margins.
void setRoutingMargin(int value)
Set the routing margin applied around each obstacle.
bool routeAroundMargins() const
Return whether the router routes around obstacle margins.
void setInitialDirection(Geo::Direction direction)
Force the direction of the first routed segment.
bool consolidateEmptyRectangles() const
Return whether empty (non-obstacle) rectangles are consolidated before routing.
Line::List calcluatePath()
Compute the routed path from origin to destination avoiding all obstacles.
PathRouter(const Point &origin, const Point &destination, const QRectF &canvas, const QList< Rectangle > &obstacles=QList< Rectangle >())
Construct a PathRouter with full configuration.
void appendObstacle(const Rectangle &value)
Append a single obstacle rectangle to the routing obstacle set.
int routingMargin() const
Return the routing margin applied around each obstacle.
int debugLevel() const
Return the debug verbosity level.
int verticalConstraint() const
Return the vertical constraint (maximum Y coordinate the path may reach).
void setObstacles(const QList< Rectangle > &value)
Replace the entire obstacle set.
void setVerticalConstraint(int value)
Set the vertical constraint (maximum Y the path may reach).
static void mergeAdjacentLines(Line::List &lines)
Merge adjacent collinear line segments in-place.
void setFirstSegmentLength(double value)
Set the length of the first segment before obstacle avoidance begins.
void setConsolidateEmptyRectangles(bool value)
Enable or disable consolidation of empty rectangles before routing.
void setOriginPoint(const Point &value)
Set the origin point.
Point destinationPoint() const
Return the destination point.
PathRouter()
Default constructor — creates an unconfigured router with default margin settings.
void setDebugLevel(int value)
Set the debug verbosity level.
void setDestinationPoint(const Point &value)
Set the destination point.
A 2D floating-point point extending QPointF with movement and spatial query methods.
A 2D rectangle extending QRectF with edge, corner, and geometric query helpers.
Geographic type enumerations and string-conversion helpers for Qt geometry types.
Direction
Cardinal directions, aliased to the corresponding Side values.
@ NoDirection
No direction.