GME  13
AutoRouterEdge.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include "AutoRouterPort.h"
00004 
00005 class CAutoRouterBox;
00006 class CAutoRouterPort;
00007 class CAutoRouterPath;
00008 class CAutoRouterGraph;
00009 
00010 
00011 // --------------------------- SArEdge
00012 
00013 class CAutoRouterEdgeList;
00014 
00015 class CAutoRouterEdge
00016 {
00017 public:
00018         CAutoRouterEdge();
00019         virtual ~CAutoRouterEdge();
00020 
00021         CObject* GetOwner(void) const;
00022         void    SetOwner(CObject* owner);
00023         CPoint  GetStartPointPrev(void) const;
00024         bool    IsStartPointPrevNull(void) const;
00025         void    SetStartPointPrev(CPoint* point);
00026         CPoint  GetStartPoint(void) const;
00027         bool    IsSameStartPointByPointer(const CPoint* point) const;
00028         bool    IsStartPointNull(void) const;
00029         void    SetStartPoint(CPoint* point);
00030         void    SetStartPointX(int x);
00031         void    SetStartPointY(int y);
00032         CPoint  GetEndPoint(void) const;
00033         bool    IsEndPointNull(void) const;
00034         void    SetEndPoint(CPoint* point);
00035         void    SetStartAndEndPoint(CPoint* startPoint, CPoint* endPoint);
00036         void    SetEndPointX(int x);
00037         void    SetEndPointY(int y);
00038         CPoint  GetEndPointNext(void) const;
00039         bool    IsEndPointNextNull(void) const;
00040         void    SetEndPointNext(CPoint* point);
00041 
00042         float   GetPositionY(void) const;
00043         void    SetPositionY(float y);
00044         void    AddToPositionY(float dy);
00045         int             GetPositionX1(void) const;
00046         void    SetPositionX1(int x1);
00047         int             GetPositionX2(void) const;
00048         void    SetPositionX2(int x2);
00049         bool    GetBracketClosing(void) const;
00050         void    SetBracketClosing(bool b);
00051         bool    GetBracketOpening(void) const;
00052         void    SetBracketOpening(bool b);
00053 
00054         CAutoRouterEdge* GetOrderNext(void);
00055         void    SetOrderNext(CAutoRouterEdge* ordernext);
00056         CAutoRouterEdge* GetOrderPrev(void);
00057         void    SetOrderPrev(CAutoRouterEdge* orderprev);
00058 
00059         long    GetSectionX1(void);
00060         void    SetSectionX1(long x1);
00061         long    GetSectionX2(void);
00062         void    SetSectionX2(long x2);
00063         CAutoRouterEdge* GetSectionNext(void);
00064         CAutoRouterEdge** GetSectionNextPtr(void);
00065         void    SetSectionNext(CAutoRouterEdge* sectionnext);
00066         CAutoRouterEdge* GetSectionDown(void);
00067         CAutoRouterEdge** GetSectionDownPtr(void);
00068         void    SetSectionDown(CAutoRouterEdge* sectiondown);
00069 
00070         bool    GetEdgeFixed(void);
00071         void    SetEdgeFixed(bool ef);
00072         bool    GetEdgeCustomFixed(void);
00073         void    SetEdgeCustomFixed(bool ecf);
00074         bool    GetEdgeCanpassed(void);
00075         void    SetEdgeCanpassed(bool ecp);
00076         RoutingDirection        GetDirection(void);
00077         void    SetDirection(RoutingDirection dir);
00078         void    RecalculateDirection(void);
00079 
00080         CAutoRouterEdge* GetBlockPrev(void);
00081         void    SetBlockPrev(CAutoRouterEdge* bp);
00082         CAutoRouterEdge* GetBlockNext(void);
00083         void    SetBlockNext(CAutoRouterEdge* bn);
00084         CAutoRouterEdge* GetBlockTrace(void);
00085         void    SetBlockTrace(CAutoRouterEdge* bt);
00086 
00087         CAutoRouterEdge* GetClosestPrev(void);
00088         void    SetClosestPrev(CAutoRouterEdge* cp);
00089         CAutoRouterEdge* GetClosestNext(void);
00090         void    SetClosestNext(CAutoRouterEdge* cn);
00091 
00092 private:
00093         CObject* owner;
00094         CPoint* startpoint_prev;
00095         CPoint* startpoint;
00096         CPoint* endpoint;
00097         CPoint* endpoint_next;
00098 
00099         float position_y;
00100         long position_x1;
00101         long position_x2;
00102         bool bracket_closing;
00103         bool bracket_opening;
00104 
00105         CAutoRouterEdge* order_next;
00106         CAutoRouterEdge* order_prev;
00107 
00108         long section_x1;
00109         long section_x2;
00110         CAutoRouterEdge* section_next;
00111         CAutoRouterEdge* section_down;
00112 
00113         bool edge_fixed;
00114         bool edge_customFixed;
00115         bool edge_canpassed;
00116         RoutingDirection edge_direction;
00117 
00118         CAutoRouterEdge* block_prev;
00119         CAutoRouterEdge* block_next;
00120         CAutoRouterEdge* block_trace;
00121 
00122         CAutoRouterEdge* closest_prev;
00123         CAutoRouterEdge* closest_next;
00124 };
00125 
00126 class CAutoRouterEdgeList
00127 {
00128 public:
00129         CAutoRouterEdgeList(bool ishorizontal);
00130         virtual ~CAutoRouterEdgeList();
00131 
00132         void SetOwner(CAutoRouterGraph* owner);
00133 
00134 private:
00135         CAutoRouterGraph* owner;
00136 
00137 // --- Edges
00138 
00139 public:
00140         bool AddEdges(CAutoRouterPath* path);
00141         void AddEdges(CAutoRouterPort* port);
00142         void AddEdges(CAutoRouterBox* box);
00143         void AddEdges(CAutoRouterGraph* graph);
00144         void DeleteEdges(CObject* object);
00145         void DeleteAllEdges();
00146 
00147         bool IsEmpty() const;
00148 
00149 private:
00150         bool ishorizontal;
00151 
00152 public:
00153         CAutoRouterEdge* GetEdge(CAutoRouterPath* path, const CPoint& startpoint, const CPoint& endpoint) const;
00154         CAutoRouterEdge* GetEdgeByPointer(const CPoint* startpoint, const CPoint* endpoint) const;
00155         CAutoRouterEdge* GetEdgeAt(const CPoint& point, int nearness = 0) const;
00156 
00157 #ifdef _DEBUG
00158 public:
00159         void AssertValidPathEdges(CAutoRouterPath* path, CPointListPath& points) const;
00160         void DumpEdges(const CString& headMsg);
00161 #endif _DEBUG
00162 
00163 // --- Position
00164 
00165 private:
00166         long Position_GetRealY(const CAutoRouterEdge* edge) const;
00167         void Position_SetRealY(CAutoRouterEdge* edge, long y) const;
00168         void Position_GetRealX(const CAutoRouterEdge* edge, long& x1, long& x2) const;
00169         void Position_GetRealO(const CAutoRouterEdge* edge, long& o1, long& o2) const;
00170 
00171         void Position_LoadY(CAutoRouterEdge* edge) const;
00172         void Position_LoadB(CAutoRouterEdge* edge) const;
00173         void PositionAll_StoreY() const;
00174 
00175         void PositionAll_LoadX() const;
00176 
00177 #ifdef _DEBUG
00178 private:
00179         void AssertValidPositions() const;
00180 #endif
00181 
00182 // --- Order
00183 
00184 private:
00185         void Init_Order();
00186         void Check_Order();
00187 
00188 public:
00189         void InsertBefore(CAutoRouterEdge* edge, CAutoRouterEdge* before);
00190         void InsertAfter(CAutoRouterEdge* edge, CAutoRouterEdge* after);
00191         void InsertLast(CAutoRouterEdge* edge);
00192         void Insert(CAutoRouterEdge* edge);
00193         void Remove(CAutoRouterEdge* edge);
00194         void Delete(CAutoRouterEdge* edge);
00195 
00196 private:
00197         CAutoRouterEdge* SlideButNotPassEdges(CAutoRouterEdge* edge, float y);
00198 
00199         CAutoRouterEdge* order_first;
00200         CAutoRouterEdge* order_last;
00201 
00202 #ifdef _DEBUG
00203 private:
00204         void AssertValidOrder() const;
00205 #endif
00206 
00207 // --- Section
00208 
00209 private:
00210         void Init_Section();
00211         void Check_Section();
00212 
00213         void Section_Reset();
00214         void Section_BeginScan(CAutoRouterEdge* blocker);
00215         bool Section_HasBlockedEdge();
00216         CAutoRouterEdge* Section_GetBlockedEdge();
00217         bool Section_IsImmediate();
00218 
00219         CAutoRouterEdge* section_first;
00220         CAutoRouterEdge* section_blocker;
00221         CAutoRouterEdge** section_ptr2blocked;
00222 
00223 #ifdef _DEBUG
00224         void Section_AssertLevel(CAutoRouterEdge* level, long x1, long x2) const;
00225         void AssertValidSection() const;
00226         void AssertSectionReady() const;
00227 #endif
00228 
00229 // --- Bracket
00230 
00231         bool Bracket_IsClosing(const CAutoRouterEdge* edge) const;
00232         bool Bracket_IsOpening(const CAutoRouterEdge* edge) const;
00233         bool Bracket_IsSmallGap(const CAutoRouterEdge* blocked, const CAutoRouterEdge* blocker) const;
00234 
00235         bool Bracket_ShouldBeSwitched(const CAutoRouterEdge* edge, const CAutoRouterEdge* next) const;
00236 
00237 // --- Block
00238 
00239 public:
00240         bool Block_PushBackward(CAutoRouterEdge* blocked, CAutoRouterEdge* blocker);
00241         bool Block_PushForward(CAutoRouterEdge* blocked, CAutoRouterEdge* blocker);
00242         bool Block_ScanForward();
00243         bool Block_ScanBackward();
00244 
00245         bool Block_SwitchWrongs();
00246 };