coriolis/anabatic/src/AutoSegments.cpp

778 lines
24 KiB
C++
Raw Normal View History

// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2008-2018, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | A n a b a t i c - Routing Toolbox |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./AutoSegments.cpp" |
// +-----------------------------------------------------------------+
#include "hurricane/Error.h"
Apaired segments building for symmetric routing (step 1). * Change: In Hurricane::BaseFlags, store flags in uint64_t instead of unsigned int because we start to need more than 32 different flags in some tools. * New: In ::getString() & ::getRecord() templates, add support for std::array<>. * Change: In CRL::ToolEngine, add support for timer (time & memory measurements) displaced from Katabatic. This way all ToolEngine can use this feature. The _postCreate() method display the memory just after ToolEngine allocation. * Change: In Etesian::EtesianEngine, make use of the ToolEngine builtin timer (remove the local one). Forgot to call the base class _postCreate() and _preDestroy(). * Change: In Anabatic::AnabaticEngine, make use of the ToolEngine builtin timer (remove the local one). * New: In Anabatic, new AutoSegments_Connecteds() collection. This Collection allows a deterministic walkthough *all* the AutoSegments connected either to source or target of one AutoSegment. * New: In Anabatic::AutoContactTerminal::isEndPoint() to check if an AutoContactTerminal is the *only one* anchored on a RoutingPad, thus being a true "end point" and not a kind of feed-through. * New: In Katana::KatanaEngine, added support for symmetric nets. Created new class DataSymmetric to store symmetric information of a net (mainly the paired AutoSegments). Added KatanaEngine::runSymmetricRouter(), for now only build the DataSymmetric informations. More to come... * Change: In Katana::GraphicKatanaEngine::_runTest(), now perform symmetric information building the non-symmetric routing.
2017-03-12 13:34:12 -05:00
#include "hurricane/RoutingPad.h"
#include "anabatic/AutoContactTerminal.h"
#include "anabatic/AutoSegment.h"
namespace {
using namespace Anabatic;
AutoContact* isLocalDogleg ( AutoSegment* current, AutoContact* from, AutoSegment* master )
{
if (not current->isLocal() or not from->isTurn()) return NULL;
AutoContact* to = current->getOppositeAnchor( from );
if (not to->isTurn()) return NULL;
AutoSegment* targetGlobal = to->getPerpandicular( current );
if (not targetGlobal->isGlobal() or (master->getLayer() != targetGlobal->getLayer())) return NULL;
cdebug_log(144,0) << "Global aligned though dogleg:" << targetGlobal << endl;
Interval masterConstraints;
Interval targetConstraints;
master ->getConstraints( masterConstraints );
targetGlobal->getConstraints( targetConstraints );
if (not targetConstraints.intersect(masterConstraints)) return NULL;
return to;
}
} // Anonymous namespace.
namespace Anabatic {
using namespace std;
using Hurricane::tab;
using Hurricane::_TName;
using Hurricane::Error;
using Hurricane::ForEachIterator;
using Hurricane::Hook;
Apaired segments building for symmetric routing (step 1). * Change: In Hurricane::BaseFlags, store flags in uint64_t instead of unsigned int because we start to need more than 32 different flags in some tools. * New: In ::getString() & ::getRecord() templates, add support for std::array<>. * Change: In CRL::ToolEngine, add support for timer (time & memory measurements) displaced from Katabatic. This way all ToolEngine can use this feature. The _postCreate() method display the memory just after ToolEngine allocation. * Change: In Etesian::EtesianEngine, make use of the ToolEngine builtin timer (remove the local one). Forgot to call the base class _postCreate() and _preDestroy(). * Change: In Anabatic::AnabaticEngine, make use of the ToolEngine builtin timer (remove the local one). * New: In Anabatic, new AutoSegments_Connecteds() collection. This Collection allows a deterministic walkthough *all* the AutoSegments connected either to source or target of one AutoSegment. * New: In Anabatic::AutoContactTerminal::isEndPoint() to check if an AutoContactTerminal is the *only one* anchored on a RoutingPad, thus being a true "end point" and not a kind of feed-through. * New: In Katana::KatanaEngine, added support for symmetric nets. Created new class DataSymmetric to store symmetric information of a net (mainly the paired AutoSegments). Added KatanaEngine::runSymmetricRouter(), for now only build the DataSymmetric informations. More to come... * Change: In Katana::GraphicKatanaEngine::_runTest(), now perform symmetric information building the non-symmetric routing.
2017-03-12 13:34:12 -05:00
using Hurricane::RoutingPad;
// -------------------------------------------------------------------
// Class : "Anabatic::AutoSegmentStack".
void AutoSegmentStack::push ( AutoContact* contact, AutoSegment* segment )
{
cdebug_log(144,0) << "Stacking " << contact << " + " << segment << endl;
push_back( make_pair(contact,segment) );
}
// -------------------------------------------------------------------
// Class : "Anabatic::AutoSegments_OnContact".
AutoSegments_OnContact::Locator::Locator ( AutoSegment* master, Contact* contact )
: AutoSegmentHL()
, _master (master)
, _element (NULL)
{
_hook = contact->getBodyHook()->getPreviousMasterHook();
progress();
}
AutoSegmentHL* AutoSegments_OnContact::Locator::getClone () const
{ return new Locator(*this); }
AutoSegment* AutoSegments_OnContact::Locator::getElement () const
{ return _element; }
bool AutoSegments_OnContact::Locator::isValid () const
{ return !_hook; }
void AutoSegments_OnContact::Locator::progress ()
{
cdebug_log(145,0) << "AutoSegments_OnContact::Locator::progress()" << endl;
while (_hook and not _hook->isMaster()) {
_hook = _hook->getNextHook();
_element = NULL;
if ( _hook->isMaster() ) { _hook = NULL; break; }
Segment* segment = dynamic_cast<Segment*>( _hook->getComponent() );
if (segment) _element = Session::lookup( segment );
if (not _element or (_element == _master)) continue;
break;
}
}
string AutoSegments_OnContact::Locator::_getString () const
{
string s = "<" + _TName("AutoSegments_OnContact::Locator")
+ getString(_element)
+ ">";
return s;
}
AutoSegmentHC* AutoSegments_OnContact::getClone () const
{ return new AutoSegments_OnContact(*this); }
AutoSegmentHL* AutoSegments_OnContact::getLocator () const
{ return new Locator(_master,_contact); }
string AutoSegments_OnContact::_getString () const
{
string s = "<" + _TName("AutoSegments_OnContact") + " "
+ getString(_master)
+ ">";
return s;
}
Apaired segments building for symmetric routing (step 1). * Change: In Hurricane::BaseFlags, store flags in uint64_t instead of unsigned int because we start to need more than 32 different flags in some tools. * New: In ::getString() & ::getRecord() templates, add support for std::array<>. * Change: In CRL::ToolEngine, add support for timer (time & memory measurements) displaced from Katabatic. This way all ToolEngine can use this feature. The _postCreate() method display the memory just after ToolEngine allocation. * Change: In Etesian::EtesianEngine, make use of the ToolEngine builtin timer (remove the local one). Forgot to call the base class _postCreate() and _preDestroy(). * Change: In Anabatic::AnabaticEngine, make use of the ToolEngine builtin timer (remove the local one). * New: In Anabatic, new AutoSegments_Connecteds() collection. This Collection allows a deterministic walkthough *all* the AutoSegments connected either to source or target of one AutoSegment. * New: In Anabatic::AutoContactTerminal::isEndPoint() to check if an AutoContactTerminal is the *only one* anchored on a RoutingPad, thus being a true "end point" and not a kind of feed-through. * New: In Katana::KatanaEngine, added support for symmetric nets. Created new class DataSymmetric to store symmetric information of a net (mainly the paired AutoSegments). Added KatanaEngine::runSymmetricRouter(), for now only build the DataSymmetric informations. More to come... * Change: In Katana::GraphicKatanaEngine::_runTest(), now perform symmetric information building the non-symmetric routing.
2017-03-12 13:34:12 -05:00
// -------------------------------------------------------------------
// Class : "Anabatic::AutoSegments_OnRoutingPad".
AutoSegments_OnRoutingPad::Locator::Locator ( RoutingPad* rp, const AutoContactTerminal* contact )
: AutoSegmentHL()
, _elements ({{NULL,NULL,NULL,NULL}})
Apaired segments building for symmetric routing (step 1). * Change: In Hurricane::BaseFlags, store flags in uint64_t instead of unsigned int because we start to need more than 32 different flags in some tools. * New: In ::getString() & ::getRecord() templates, add support for std::array<>. * Change: In CRL::ToolEngine, add support for timer (time & memory measurements) displaced from Katabatic. This way all ToolEngine can use this feature. The _postCreate() method display the memory just after ToolEngine allocation. * Change: In Etesian::EtesianEngine, make use of the ToolEngine builtin timer (remove the local one). Forgot to call the base class _postCreate() and _preDestroy(). * Change: In Anabatic::AnabaticEngine, make use of the ToolEngine builtin timer (remove the local one). * New: In Anabatic, new AutoSegments_Connecteds() collection. This Collection allows a deterministic walkthough *all* the AutoSegments connected either to source or target of one AutoSegment. * New: In Anabatic::AutoContactTerminal::isEndPoint() to check if an AutoContactTerminal is the *only one* anchored on a RoutingPad, thus being a true "end point" and not a kind of feed-through. * New: In Katana::KatanaEngine, added support for symmetric nets. Created new class DataSymmetric to store symmetric information of a net (mainly the paired AutoSegments). Added KatanaEngine::runSymmetricRouter(), for now only build the DataSymmetric informations. More to come... * Change: In Katana::GraphicKatanaEngine::_runTest(), now perform symmetric information building the non-symmetric routing.
2017-03-12 13:34:12 -05:00
, _index (0)
{
if (rp) {
for ( Component* component : rp->getSlaveComponents() ) {
AutoSegment* segment = Session::lookup( dynamic_cast<Segment*>(component) );
if (not segment) continue;
size_t offset = 2;
if (contact and (contact->getSegment() == segment)) offset = 0;
if (segment->isHorizontal()) _elements[offset ] = segment;
else _elements[offset+1] = segment;
}
}
while ( (_index < 4) and not _elements[_index] ) ++_index;
}
AutoSegmentHL* AutoSegments_OnRoutingPad::Locator::getClone () const
{ return new Locator(*this); }
AutoSegment* AutoSegments_OnRoutingPad::Locator::getElement () const
{ return (_index < 4) ? _elements[_index] : NULL; }
bool AutoSegments_OnRoutingPad::Locator::isValid () const
{ return (_index < 4); }
void AutoSegments_OnRoutingPad::Locator::progress ()
{
cdebug_log(145,0) << "AutoSegments_OnRoutingPad::Locator::progress()" << endl;
++_index;
while ( (_index < 4) and not _elements[_index] ) ++_index;
}
string AutoSegments_OnRoutingPad::Locator::_getString () const
{
string s = "<" + _TName("AutoSegments_OnRoutingPad::Locator")
+ getString(_index)
+ ">";
return s;
}
AutoSegments_OnRoutingPad::AutoSegments_OnRoutingPad ( const AutoContact* contact )
: AutoSegmentHC()
, _routingPad(NULL)
, _contact (dynamic_cast<const AutoContactTerminal*>(contact))
{
if (_contact)
_routingPad = dynamic_cast<RoutingPad*>(_contact->getAnchor());
}
AutoSegmentHC* AutoSegments_OnRoutingPad::getClone () const
{ return new AutoSegments_OnRoutingPad(*this); }
AutoSegmentHL* AutoSegments_OnRoutingPad::getLocator () const
{ return new Locator(_routingPad,_contact); }
string AutoSegments_OnRoutingPad::_getString () const
{
string s = "<" + _TName("AutoSegments_OnRoutingPad") + " "
+ getString(_routingPad)
+ ">";
return s;
}
// -------------------------------------------------------------------
// Class : "AutoSegments_Connecteds".
AutoSegments_Connecteds::Locator::Locator ( AutoSegment* segment, Flags flags )
Apaired segments building for symmetric routing (step 1). * Change: In Hurricane::BaseFlags, store flags in uint64_t instead of unsigned int because we start to need more than 32 different flags in some tools. * New: In ::getString() & ::getRecord() templates, add support for std::array<>. * Change: In CRL::ToolEngine, add support for timer (time & memory measurements) displaced from Katabatic. This way all ToolEngine can use this feature. The _postCreate() method display the memory just after ToolEngine allocation. * Change: In Etesian::EtesianEngine, make use of the ToolEngine builtin timer (remove the local one). Forgot to call the base class _postCreate() and _preDestroy(). * Change: In Anabatic::AnabaticEngine, make use of the ToolEngine builtin timer (remove the local one). * New: In Anabatic, new AutoSegments_Connecteds() collection. This Collection allows a deterministic walkthough *all* the AutoSegments connected either to source or target of one AutoSegment. * New: In Anabatic::AutoContactTerminal::isEndPoint() to check if an AutoContactTerminal is the *only one* anchored on a RoutingPad, thus being a true "end point" and not a kind of feed-through. * New: In Katana::KatanaEngine, added support for symmetric nets. Created new class DataSymmetric to store symmetric information of a net (mainly the paired AutoSegments). Added KatanaEngine::runSymmetricRouter(), for now only build the DataSymmetric informations. More to come... * Change: In Katana::GraphicKatanaEngine::_runTest(), now perform symmetric information building the non-symmetric routing.
2017-03-12 13:34:12 -05:00
: AutoSegmentHL()
, _stack ()
{
cdebug_log(145,0) << "AutoSegments_Connecteds::Locator::Locator()" << endl;
if (flags & Flags::Source) {
AutoContact* contact = segment->getAutoSource();
if (contact) _stack.push( contact, segment );
}
if (flags & Flags::Target) {
AutoContact* contact = segment->getAutoTarget();
if (contact) _stack.push( contact, segment );
}
}
AutoSegmentHL* AutoSegments_Connecteds::Locator::getClone () const
{ return new Locator(*this); }
bool AutoSegments_Connecteds::Locator::isValid () const
{ return not _stack.isEmpty(); }
void AutoSegments_Connecteds::Locator::progress ()
{
cdebug_log(145,0) << "AutoSegments_Connecteds::Locator::progress()" << endl;
while (not _stack.isEmpty()) {
AutoContact* sourceContact = _stack.getAutoContact ();
AutoSegment* sourceSegment = _stack.getAutoSegment ();
_stack.pop ();
AutoContactTerminal* sourceTerminal = dynamic_cast<AutoContactTerminal*>( sourceContact );
if (sourceTerminal) {
for ( AutoSegment* currentSegment : sourceTerminal->getRpConnecteds() ) {
cdebug_log(145,0) << "Looking at: " << currentSegment << endl;
if (currentSegment == sourceSegment) continue;
AutoContact* targetContact = currentSegment->getAutoSource();
if (not targetContact->isTerminal()) _stack.push( targetContact, currentSegment );
targetContact = currentSegment->getAutoTarget();
if (not targetContact->isTerminal()) _stack.push( targetContact, currentSegment );
}
} else {
LocatorHelper helper (sourceContact,Flags::WithPerpands);
for ( ; helper.isValid() ; helper.progress() ) {
AutoSegment* currentSegment = helper.getSegment();
cdebug_log(145,0) << "Looking at: " << currentSegment << endl;
if (currentSegment == sourceSegment) continue;
AutoContact* targetContact = currentSegment->getOppositeAnchor( sourceContact );
if (targetContact) _stack.push( targetContact, currentSegment );
}
}
break;
}
}
string AutoSegments_Connecteds::Locator::_getString () const
{
string s = "<" + _TName("AutoSegments_Connecteds::Locator") + ">";
return s;
}
AutoSegmentHC* AutoSegments_Connecteds::getClone () const
{ return new AutoSegments_Connecteds(*this); }
AutoSegmentHL* AutoSegments_Connecteds::getLocator () const
{ return new Locator(_segment,_flags); }
AutoSegment* AutoSegments_Connecteds::Locator::getElement () const
{ return _stack.getAutoSegment(); }
string AutoSegments_Connecteds::_getString () const
{
string s = "<" + _TName("AutoSegments_Connecteds") + " "
+ getString(_segment)
+ ">";
return s;
}
// -------------------------------------------------------------------
// Class : "AutoSegments_Aligneds".
AutoSegments_Aligneds::Locator::Locator ( AutoSegment* segment, Flags flags )
: AutoSegmentHL()
, _flags (flags)
, _master(segment)
, _stack ()
{
if (not _master) return;
if (not _flags.intersect(Flags::Source|Flags::Target))
_flags |= Flags::Source | Flags::Target;
_flags |= (_master->isHorizontal()) ? Flags::Horizontal : Flags::Vertical;
if (_flags & Flags::WithDoglegs) _flags |= Flags::WithPerpands;
cdebug_log(144,0) << "AutoSegments_Aligneds::Locator::Locator() _flags:" << _flags.asString(FlagsFunction) << endl;
if (_flags & Flags::Source) {
AutoContact* contact = segment->getAutoSource();
if (contact) _stack.push( contact, segment );
}
if (_flags & Flags::Target) {
AutoContact* contact = segment->getAutoTarget();
if (contact) _stack.push( contact, segment );
}
Anabatic transient commit 18. Port of Kite (Katana), Yeah, Baby! Yeah! * Bug: In Hurricane, in StaticObservable::getObserver(), if the slot pointer is NULL, do not try to access the owner. Returns NULL, so the caller can be aware of the situation... * Change: In Hurricane, in BreakpointWidget & ExceptionWidget some cosmetic changes (fonts and window sizes). * Bug: In Anabatic, In AutoHorizontal::getConstraints(), take into account the constraints from the source AutoContact, as it holds the constraints transmitted by the RoutingPads and sets up by propageConstraintsFromRp(). It is likely to be a bug affecting the original Katabatic as well. * Change: In Anabatic, in RawGCellsUnder(), check that the segment is not completly oustside the cell abutment box and truncate the coordinates to the part that is inside. Use the "shrink" if we reach the east/north border. * Change: In Anabatic, in Configuration, no more decorator because we will use a true derived relationship. Katana *derives* from *Anabatic* and do not *decorate* it, so the Configuration can do the same. It also implies that we directly create a Katana engine, not an Anabatic one. * Change: In Anabatic, in Session, do not allow the opening of the Session in a standalone fashion (with a static method). Instead it must be opened using the relevant method of the Anabatic/Katana engine. This ensure we are opening the right Session type. * Change: In Anabatic, in AutoSegment_Aligneds() collection the seed segment is not part of the collection by default, but will be included if the Flags::WithSelf is set. * Change: In Configuration, all the flags value are now defined in two steps. Declared in the header and initialized in the module. This is to prevent the fact that on some cases, in relation with the Python "extern C" part modules, we need a true allocated variable. It was causing weird linking problems. A side effect is that they can no longer be used as entry is switches, have to replace them by if/else. * New: In Anabatic, new GCell::getNeighborAt() utility function. * Bug: In Anabatic, in GCell::doGrid(), tag all the GCells of the grid with the grid type... Back annote all the edges capacity (north & east) with the reserved local capacity. * New: Complete portage of Kite over Anabatic. The new engine is christened "Katana" for Kite-Analogic. When it's capabilities and performances will be on a part with Kite, it is to completly replace it (and take back the "Kite" name). Preliminary tests seems to show that, contrary to intuition (because built on a more complex/slower grid), it is even slightly faster than Kite 8-).
2016-08-15 09:30:13 -05:00
if (not (_flags & Flags::WithSelf)) progress();
}
AutoSegmentHL* AutoSegments_Aligneds::Locator::getClone () const
{ return new Locator(*this); }
bool AutoSegments_Aligneds::Locator::isValid () const
{ return not _stack.isEmpty(); }
void AutoSegments_Aligneds::Locator::progress ()
{
cdebug_log(144,0) << "AutoSegments_Aligneds::Locator::progress()" << endl;
while (not _stack.isEmpty()) {
AutoContact* sourceContact = _stack.getAutoContact ();
AutoSegment* sourceSegment = _stack.getAutoSegment ();
_stack.pop ();
cdebug_log(144,1) << "Iterate over: " << sourceContact << endl;
LocatorHelper helper (sourceContact, _flags);
for ( ; helper.isValid() ; helper.progress() ) {
AutoSegment* currentSegment = helper.getSegment();
cdebug_log(144,0) << "| " << currentSegment << endl;
if (currentSegment == sourceSegment) continue;
if (AutoSegment::areAligneds(currentSegment,_master)) {
if ( (not (_flags & Flags::NoCheckLayer))
and AutoSegment::areAlignedsAndDiffLayer(currentSegment,_master)) {
cerr << Error( "Aligned segments not in same layer (aligneds locator)\n"
" %s\n"
" %s."
,getString(_master).c_str()
,getString(currentSegment).c_str() ) << endl;
continue;
}
AutoContact* targetContact = currentSegment->getOppositeAnchor( sourceContact );
if (targetContact) _stack.push( targetContact, currentSegment );
} else {
if (_flags & Flags::WithDoglegs) {
AutoContact* targetContact = isLocalDogleg( currentSegment, sourceContact, _master );
if (targetContact) {
cdebug_log(144,0) << "Stacking dogleg global. " << endl;
_stack.push( targetContact, currentSegment );
continue;
}
}
}
}
cdebug_tabw(144,-1);
if (_stack.getAutoSegment() == _master) continue;
if (not AutoSegment::areAligneds(_stack.getAutoSegment(),_master)) continue;
break;
}
}
string AutoSegments_Aligneds::Locator::_getString () const
{
string s = "<" + _TName("AutoSegments_Aligneds::Locator") + ">";
return s;
}
AutoSegmentHC* AutoSegments_Aligneds::getClone () const
{ return new AutoSegments_Aligneds(*this); }
AutoSegmentHL* AutoSegments_Aligneds::getLocator () const
{ return new Locator(_segment,_flags); }
AutoSegment* AutoSegments_Aligneds::Locator::getElement () const
{ return _stack.getAutoSegment(); }
string AutoSegments_Aligneds::_getString () const
{
string s = "<" + _TName("AutoSegments_Aligneds") + " "
+ getString(_segment)
+ ">";
return s;
}
// -------------------------------------------------------------------
// Class : "AutoSegments_Perpandiculars".
AutoSegments_Perpandiculars::Locator::Locator ( AutoSegment* master, Flags flags )
: AutoSegmentHL()
//, _flags (Flags::WithPerpands|Flags::WithDoglegs)
, _flags (Flags::WithPerpands|flags)
, _master (master)
, _stack ()
, _perpandiculars()
{
cdebug_log(144,0) << "AutoSegments_Perpandiculars::Locator::Locator(): _flags:" << _flags.asString(FlagsFunction) << endl;
cdebug_log(144,0) << " " << _master << endl;
if (not _master) return;
if (_master->isHorizontal()) _flags |= Flags::Horizontal;
else _flags |= Flags::Vertical;
AutoContact* contact = _master->getAutoSource();
if ( contact ) _stack.push( contact, _master );
contact = _master->getAutoTarget();
if ( contact ) _stack.push( contact, _master );
progress();
}
AutoSegment* AutoSegments_Perpandiculars::Locator::getElement () const
{
if (_perpandiculars.empty()) return NULL;
return _perpandiculars.back();
}
void AutoSegments_Perpandiculars::Locator::progress ()
{
cdebug_log(144,1) << "AutoSegments_Perpandiculars::Locator::progress()" << endl;
if (not _perpandiculars.empty()) _perpandiculars.pop_back();
Katana manage wide wires, and they can also be symmetric. * New: In Anabatic::AutoContact and the derived classes, manages wide wires. The contact self dimension itself according to the segments it is connected to. Special case for the AutoContactTerminal which also read the size of the component it is anchored upon. New refresh method "updateSize()" and flag CntInvalidatedWidth. to compute the size. In AutoContactTerminal, compute the constraint box according to the width of the segment. * New: In Anabatic::AutoSegment, flags are now implemented as "static const" attributes of the class. The flags are stored into a uint64_t as they are more than 32. Added new flag "SegWide" and associated predicates. * Change: In GCellTopology::_doHChannel() and GCellTopology::_doVChannel(), uses the simpler overload of AutoSegment::create() in order to detect the wire width automatically. * New: In Katana::Manipulator, split insertToTrack() and forceToTrack() into a one-track method and a segment level method that iterate over the track span of the segment. * New: In Katana::SegmentFsm, for each cost in the table, now allow access to a specific track. So the base functions have now two parameters: "icost" and "itrack" (has a cost can have multiple tracks in the case of wide segments). * Change: In Katana::TrackElement, remove the index of the element inside it's track, as for a wide segment it will not be meaningful for the non-base track. This means that we have to use the Track::find() method each time instead. Remove the wide flag, as it is a duplicate of the one in AutoSegment. Added a getTrackCount() method to tell the number of track the segment is inserted into. Needed in the Track destroy step to delete a segment only when the last track that refers it is destroyed. Added getSymmetricAxis() to correct the computation of the symmetric base track in case of wide segment as the base track is not centered but the the leftmost one. * Change: In Track::insert() insert wide segments in their whole track span. * Change: In TrackCost, create an array of costs according to the segment track span. * Change: In TrackSegment::create(), now activate the factory and create wide segments. * Bug: In Katana::AutoSegments_Perpandicular, correct the debug indentation problem (ever shifting to the right).
2017-07-28 08:30:22 -05:00
if (not _perpandiculars.empty()) { cdebug_tabw(144,-1); return; }
while ( not _stack.isEmpty() ) {
AutoContact* sourceContact = _stack.getAutoContact();
AutoSegment* sourceSegment = _stack.getAutoSegment();
_stack.pop();
cdebug_log(144,0) << "Iterate over: " << sourceContact << endl;
LocatorHelper helper (sourceContact, _flags);
for ( ; helper.isValid() ; helper.progress() ) {
AutoSegment* currentSegment = helper.getSegment();
if (currentSegment == sourceSegment) continue;
cdebug_log(144,0) << "| " << currentSegment << endl;
if (AutoSegment::areAligneds(currentSegment,_master)) {
AutoContact* targetContact = currentSegment->getOppositeAnchor( sourceContact );
if (targetContact) {
if (_master->getLayer() != currentSegment->getLayer()) {
continue;
}
cdebug_log(144,0) << "Stacking target. " << endl;
_stack.push( targetContact, currentSegment );
// if ( (_master->isHorizontal() and sourceContact->isHTee())
// or (_master->isVertical () and sourceContact->isVTee()) ) {
// if (AutoSegment::areAlignedsAndDiffLayer(currentSegment,_master)) {
// cerr << Error("Aligned segments not in same layer (perpandicular locator)\n"
// " %s\n"
// " %s."
// ,getString(_master).c_str()
// ,getString(currentSegment).c_str()) << endl;
// continue;
// }
// cdebug_log(144,0) << "Stacking target. " << endl;
// _stack.push( targetContact, currentSegment );
// }
} else {
cdebug_log(144,0) << "No opposite anchor to: " << sourceContact << endl;
}
} else {
if ( (_flags & Flags::WithDoglegs) and currentSegment->isLocal() and sourceContact->isTurn() ) {
AutoContact* targetContact = currentSegment->getOppositeAnchor( sourceContact );
if (targetContact->isTurn()) {
AutoSegment* targetGlobal = targetContact->getPerpandicular( currentSegment );
if (targetGlobal->isGlobal() and (_master->getLayer() == targetGlobal->getLayer())) {
cdebug_log(144,0) << "Global aligned though dogleg:" << targetGlobal << endl;
Interval masterConstraints;
Interval targetConstraints;
_master ->getConstraints( masterConstraints );
targetGlobal->getConstraints( targetConstraints );
if (targetConstraints.intersect(masterConstraints)) {
cdebug_log(144,0) << "Stacking dogleg global. " << endl;
_stack.push( targetContact, currentSegment );
continue;
}
}
}
}
_perpandiculars.push_back( currentSegment );
}
}
if (_stack.isEmpty()) break;
if (_stack.getAutoSegment() == _master) continue;
if (not _perpandiculars.empty()) break;
}
cdebug_tabw(144,-1);
}
AutoSegmentHL* AutoSegments_Perpandiculars::Locator::getClone () const
{ return new Locator(*this); }
bool AutoSegments_Perpandiculars::Locator::isValid () const
{ return not _perpandiculars.empty(); }
AutoSegmentHC* AutoSegments_Perpandiculars::getClone () const
{ return new AutoSegments_Perpandiculars(*this); }
AutoSegmentHL* AutoSegments_Perpandiculars::getLocator () const
{ return new Locator(_master,_flags); }
string AutoSegments_Perpandiculars::Locator::_getString () const
{
string s = "<" + _TName("AutoSegments_Perpandiculars::Locator") + ">";
return s;
}
string AutoSegments_Perpandiculars::_getString () const
{
string s = "<" + _TName("AutoSegments_Perpandiculars") + " "
+ getString(_master)
+ ">";
return s;
}
// -------------------------------------------------------------------
// Class : "AutoSegments_AnchorOnGCell".
AutoSegments_AnchorOnGCell::Locator::Locator ( GCell* fcell, Flags flags )
: AutoSegmentHL()
, _flags (flags)
, _itContact (fcell->getContacts().begin())
, _itEnd (fcell->getContacts().end())
, _hookLocator(NULL)
, _element (NULL)
{ progress(); }
AutoSegments_AnchorOnGCell::Locator::~Locator ()
{ if (_hookLocator) delete _hookLocator; }
AutoSegment* AutoSegments_AnchorOnGCell::Locator::getElement () const
{ return _element; }
AutoSegmentHL* AutoSegments_AnchorOnGCell::Locator::getClone () const
{ return new Locator(*this); }
bool AutoSegments_AnchorOnGCell::Locator::isValid () const
{ return _element != NULL; }
void AutoSegments_AnchorOnGCell::Locator::progress ()
{
cdebug_log(145,1) << "AutoSegments_AnchorOnGCell::Locator::progress()" << endl;
while ( true ) {
if (_hookLocator == NULL) {
if (_itContact == _itEnd) {
cdebug_log(145,0) << "No more AutoContacts" << endl;
cdebug_tabw(145,-1);
return;
}
cdebug_log(145,0) << *_itContact << endl;
_hookLocator = (*_itContact)->getBodyHook()->getSlaveHooks().getLocator();
_itContact++;
} else {
_hookLocator->progress();
}
while ( _hookLocator->isValid() ) {
cdebug_log(145,0) << _hookLocator->getElement() << endl;
Hook* hook = dynamic_cast<Segment::SourceHook*>(_hookLocator->getElement());
if (hook) {
if ( ((_flags & Flags::Source) and (dynamic_cast<Segment::SourceHook*>(hook)))
or ((_flags & Flags::Target) and (dynamic_cast<Segment::TargetHook*>(hook))) ) {
_element = Session::lookup( static_cast<Segment*>(hook->getComponent()) );
if (_element->isHorizontal()) {
if (_flags & Flags::Horizontal) { cdebug_tabw(145,-1); return; }
} else
if (_flags & Flags::Vertical) { cdebug_tabw(145,-1); return; }
}
}
_hookLocator->progress();
}
_hookLocator = NULL;
_element = NULL;
}
cdebug_tabw(145,-1);
}
string AutoSegments_AnchorOnGCell::Locator::_getString () const
{
string s = "<" + _TName("AutoSegments_AnchorOnGCell::Locator") + ">";
return s;
}
AutoSegmentHC* AutoSegments_AnchorOnGCell::getClone () const
{ return new AutoSegments_AnchorOnGCell(*this); }
AutoSegmentHL* AutoSegments_AnchorOnGCell::getLocator () const
{ return new Locator(_fcell,_flags); }
string AutoSegments_AnchorOnGCell::_getString () const
{
string s = "<" + _TName("AutoSegments_AnchorOnGCell") + " "
+ getString(_fcell)
+ ">";
return s;
}
// -------------------------------------------------------------------
// Class : "Anabatic::AutoSegments_CachedOnContact".
AutoSegments_CachedOnContact::Locator::Locator ( AutoContact* sourceContact, Flags direction )
: AutoSegmentHL()
, _helper(new LocatorHelper(sourceContact,direction))
{ }
AutoSegments_CachedOnContact::Locator::~Locator ()
{ delete _helper; }
AutoSegment* AutoSegments_CachedOnContact::Locator::getElement () const
{ return _helper->getSegment(); }
AutoSegmentHL* AutoSegments_CachedOnContact::Locator::getClone () const
{ return new Locator(*this); }
bool AutoSegments_CachedOnContact::Locator::isValid () const
{ return _helper->isValid(); }
void AutoSegments_CachedOnContact::Locator::progress ()
{
cdebug_log(145,0) << "AutoSegments_CachedOnContact::Locator::progress()" << endl;
_helper->progress();
}
AutoSegmentHL* AutoSegments_CachedOnContact::getLocator () const
{ return new Locator(_sourceContact,_direction); }
AutoSegmentHC* AutoSegments_CachedOnContact::getClone () const
{ return new AutoSegments_CachedOnContact(*this); }
string AutoSegments_CachedOnContact::Locator::_getString () const
{
string s = "<" + _TName("AutoSegments_CachedOnContact::Locator") + ">";
return s;
}
string AutoSegments_CachedOnContact::_getString () const
{
string s = "<" + _TName("AutoSegments_CachedOnContact") + " "
+ getString(_sourceContact)
+ ">";
return s;
}
// -------------------------------------------------------------------
// Class : "AutoSegments_IsAccountable".
AutoSegmentHF* AutoSegments_IsAccountable::getClone () const
{ return new AutoSegments_IsAccountable(); }
bool AutoSegments_IsAccountable::accept ( AutoSegment* segment ) const
{ return segment->isCanonical(); }
string AutoSegments_IsAccountable::_getString () const
{ return "<AutoSegments_IsAccountable>"; }
// -------------------------------------------------------------------
// Class : "AutoSegments_InDirection".
AutoSegmentHF* AutoSegments_InDirection::getClone () const
{ return new AutoSegments_InDirection(_direction); }
bool AutoSegments_InDirection::accept ( AutoSegment* segment ) const
{
return ( segment->isHorizontal() and (_direction & Flags::Horizontal) )
or ( segment->isVertical () and (_direction & Flags::Vertical ) );
}
string AutoSegments_InDirection::_getString () const
{ return "<AutoSegments_InDirection>"; }
} // Anabatic namespace.