a2dRouteData Class Reference

Class for rerouting wires. More...

#include <wire.h>

Inheritance diagram for a2dRouteData:

Inheritance graph
[legend]
Collaboration diagram for a2dRouteData:

Collaboration graph
[legend]

List of all members.

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.
RoutePointGetRoutePoint (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 a2dObjectClone (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
a2dCanvasObjectm_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 )
RoutePointm_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...


Detailed Description

Class for rerouting wires.

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.


Member Enumeration Documentation

directions for RoutePoint

Enumerator:
dir_start  start point
dir_min  min usual direction value
dir_max  max usual direction value
dir_count  number of usual direction values
dir_invxor  result of dir1^dir2 for two opposing directions

Definition at line 113 of file wire.h.


Constructor & Destructor Documentation

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.

Definition at line 174 of file wire.cpp.


Member Function Documentation

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.

Parameters:
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
Returns:
true if wire was changed

Definition at line 372 of file wire.cpp.

void a2dRouteData::AddOccupationRect ( const a2dBoundingBox bbox,
short  incr 
) [protected]

add a bounding box to the occupied area

All grid points within the rectangle are incremented by incr in the vertical and horizontal occupation buffers.

Definition at line 888 of file wire.cpp.

void a2dRouteData::AddOccupationPolyline ( const a2dVertexList points,
const a2dAffineMatrix trns,
short  incr 
) [protected]

add a polyline to the occupation area

All vertical and horizontal lines are set into the vertical and horizontal occupation areas as being occupied. That is the grid points where those lines pass, are incremented by incr.

Definition at line 923 of file wire.cpp.

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.

Definition at line 1005 of file wire.cpp.

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:

  • if is on the orginal wire +1
  • not on original wire +3
  • corner compared to current point direction +10
  • crossing occupied area +10 (in case of diagonal lines?)
This is a large function, but it is inlined for speed

Definition at line 306 of file wire.cpp.

a2dBoundingBox a2dRouteData::CalculateRoutingBbox ( a2dCanvasObject object  )  [protected]

Calculates the routing relevant bounding box of an object.

This includes one level of childs, but no pins Pins are not included because their size may change during routing and this might lead to pre-final / final inconsistencies.

Definition at line 1063 of file wire.cpp.

virtual a2dObject* a2dRouteData::Clone ( CloneOptions  options  )  const [inline, protected, virtual]

File for debug dumps.

for wxStaticCast Required by a2dObject

Implements a2dObject.

Definition at line 383 of file wire.h.


The documentation for this class was generated from the following files:
a2dRouteData Class Reference -- Tue Aug 31 18:33:46 2010 -- 31 Aug 2010 -- 1.5.5 -- wxArt2D -- . -- Main Page Reference Documentation