#include <wire.h>


Public Types | |
| enum | RoutePointFlag { flag_original = 0x01, flag_targetwire = 0x02, flag_targetpin = 0x04, flag_targetapprox = 0x08, flag_reachable = 0x10, flag_final = 0x20 } |
| flags for RoutePoint | |
| enum | RoutePointDirection { dir_xminus = 0, dir_xplus = 1, dir_yminus = 2, dir_yplus = 3, dir_start = 4, dir_min = 0, dir_max = 3, dir_count = 4, dir_invxor = 1 } |
| directions for RoutePoint More... | |
Public Member Functions | |
| a2dRouteData (a2dCanvasObject *showobject, bool final) | |
| Standard constructor takes the show object under which is routed. | |
| ~a2dRouteData () | |
| Destructor. | |
| bool | RerouteWire (a2dWirePolylineL *wire, a2dPin *dispin, a2dPin *startpin, bool startisbegin, bool final) |
| Reroute a wire. | |
Static Public Member Functions | |
| static void | SetRaster (double raster) |
| the size of the raster | |
Protected Member Functions | |
| unsigned short & | GetVerticalOccupation (int x, int y) |
| Get an element of the vertical occupation array. | |
| unsigned short & | GetHorizontalOccupation (int x, int y) |
| Get an element of the horizontal occupation array. | |
| bool | IsVerticalOccupied (int x, int y) |
| Is an element of the vertical occupation array. | |
| bool | IsHorizontalOccupied (int x, int y) |
| Is an element of the horizontal occupation array. | |
| RoutePoint & | GetRoutePoint (int x, int y, int dir) |
| Get an element of the route point array. | |
| void | AddOccupationRect (const a2dBoundingBox &bbox, short incr) |
| add a bounding box to the occupied area | |
| void | AddOccupationPolyline (const a2dVertexList *points, const a2dAffineMatrix &trns, short incr) |
| add a polyline to the occupation area | |
| void | SetFlagRect (const a2dBoundingBox &bbox, RoutePointFlag flag) |
| Set a RoutePoint flag in a rectangle. | |
| void | SetFlagPolyline (const a2dVertexList *points, const a2dAffineMatrix &trns, RoutePointFlag flag) |
| Set a RoutePoint flag along a polyline. | |
| void | SetFlagRoutePointAllDirs (int x, int y, RoutePointFlag flag) |
| Set a flag in the route points for all directions. | |
| void | AddBorderPoint (BorderQueue *queue, RoutePoint *current, int nextx, int nexty, int dir, int prevdir) |
| Add a new point on the route. | |
| a2dBoundingBox | CalculateRoutingBbox (a2dCanvasObject *object) |
| Calculates the routing relevant bounding box of an object. | |
| void | DumpOccupation (FILE *file) |
| Dump the occupation arrays. | |
| void | DumpCost () |
| void | DumpVertexList (a2dVertexList *list) |
| virtual a2dObject * | Clone (CloneOptions options) const |
| File for debug dumps. | |
| virtual void | DoSave (wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite) |
| Save settings. | |
| virtual void | DoLoad (wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts) |
| Load settings. | |
Protected Attributes | |
| bool | m_ok |
| if true, the raster is initialized | |
| a2dCanvasObject * | m_showobject |
| the show object given in the constructor | |
| int | m_width |
| width of the routing raster array | |
| int | m_widthp1 |
| width of the routing raster array + 1 | |
| int | m_height |
| height of the routing raster array | |
| int | m_heightp1 |
| height of the routing raster array + 1 | |
| double | m_rasterinv |
| the inverse size of the raster | |
| int | m_rasterminx |
| the limits of the raster area | |
| int | m_rastermaxx |
| int | m_rasterminy |
| int | m_rastermaxy |
| double | m_rasterborder |
| an extra border in the raster area around the bounding box | |
| unsigned short * | m_verticaloccupation |
| occupation counts for vertical edges ( a 2d array ) | |
| unsigned short * | m_horizontaloccupation |
| occupation counts for horizontal edges ( a 2d array ) | |
| RoutePoint * | m_routepoints |
| Routing points. | |
Static Protected Attributes | |
| static double | m_raster = 4 |
| the size of the raster | |
Classes | |
| struct | BorderPoint |
| An entry in the border queue. More... | |
| class | BorderQueue |
| This is a priority queue for border points. More... | |
| struct | RoutePoint |
| the data structure holding the per point information More... | |
This class implements a usual Lee router. The one special thing is, that there are penalties for corners. This makes routing a bit complicated, because the lowest cost to reach one point might not be the best for succeeding from this point, as the following example shows:
0-1 0- 3 | | 1-14 16 | | 2-15 19 | | 3-16 22 | | 29 25
The numbers are cost. 0 is the routing start point. The points with cost 1..3 are lying on the original line and have a low cost for this reason. The destination is the point with a cost of 29/25. The important point is, that the target can be reached via the right path with higher intermediate cost with lower final cost.
To get true least cost routing, the cost is stored for every raster point for the four incomming directions.
Definition at line 57 of file wire.h.
directions for RoutePoint
| a2dRouteData::a2dRouteData | ( | a2dCanvasObject * | showobject, | |
| bool | final | |||
| ) |
Standard constructor takes the show object under which is routed.
The boundingbox of the child objects in showobject is taken as the area in which to route a wire. This with a certain margin added, in order to route around the outer objects too. Temporary tool objects are skipped from this boundingbox. The boundingbox is divided into a rectangular grid, each grid of size m_raster. The grid points are points where a routed wire can be routed onto. Buffers are allocated to maintain information on the grid points, e.g. which grid points are occupied by objects, and therefore a wire can not be routed there. a2dWirePolylineL objects marked with property PROPID_rerouteadded, indicates a wire to be rerouted, and will not be added to the occupation area. Only polylines are currently added accurate to the occuption area. Meaning the right grid points are disabled for routing. For the other objects currently the boundingbox is used.
| bool a2dRouteData::RerouteWire | ( | a2dWirePolylineL * | wire, | |
| a2dPin * | dispin, | |||
| a2dPin * | startpin, | |||
| bool | startisbegin, | |||
| bool | final | |||
| ) |
Reroute a wire.
Reroute the given wire, between a start and end pin. The start or end pin is used as a start for producing a border wave, which sets route points to a cost to reach that route point. At the same time the wave itself is expanded at the point with the best cost first. If that point is already reached through another part of the border wave, that point is removed from the wave, else based on the current border point a new point a new border point is created, followed by removing the current best border point. In the end the target pin or wire will be reached and the border wave will be empty. While the border wave is working itself like this through the routing points, the best route is via pointer in the route points.
| wire | on input this is the wire in its original (edited but unadjusted) state | |
| dispin | the pin that became disconnected | |
| startpin | the pin where routing starts | |
| startisbegin | the pin where routing starts is the begin point of the wire | |
| final | last route to destination |
| void a2dRouteData::AddOccupationRect | ( | const a2dBoundingBox & | bbox, | |
| short | incr | |||
| ) | [protected] |
| void a2dRouteData::AddOccupationPolyline | ( | const a2dVertexList * | points, | |
| const a2dAffineMatrix & | trns, | |||
| short | incr | |||
| ) | [protected] |
| void a2dRouteData::SetFlagPolyline | ( | const a2dVertexList * | points, | |
| const a2dAffineMatrix & | trns, | |||
| RoutePointFlag | flag | |||
| ) | [protected] |
Set a RoutePoint flag along a polyline.
Vertical and horizontal segments result in a set in the routepoints which the cover. That is for all directions in a routepoint.
| void a2dRouteData::AddBorderPoint | ( | BorderQueue * | queue, | |
| RoutePoint * | current, | |||
| int | nextx, | |||
| int | nexty, | |||
| int | dir, | |||
| int | prevdir | |||
| ) | [inline, protected] |
Add a new point on the route.
Based on the point where we are and a next point and direction, a new border point is added (unless already reached). The cost for the new point is calculated based on:
| a2dBoundingBox a2dRouteData::CalculateRoutingBbox | ( | a2dCanvasObject * | object | ) | [protected] |
| virtual a2dObject* a2dRouteData::Clone | ( | CloneOptions | options | ) | const [inline, protected, virtual] |