// -*- C++ -*- // // This file is part of the Coriolis Software. // Copyright (c) UPMC 2008-2016, All Rights Reserved // // +-----------------------------------------------------------------+ // | C O R I O L I S | // | K a t a b a t i c - Routing Toolbox | // | | // | Author : Jean-Paul CHAPUT | // | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Module : "./GCellGrid.cpp" | // +-----------------------------------------------------------------+ #include "hurricane/Error.h" #include "hurricane/Cell.h" #include "knik/KnikEngine.h" #include "katabatic/Session.h" #include "katabatic/GCellGrid.h" #include "katabatic/KatabaticEngine.h" namespace Katabatic { using namespace std; using Hurricane::tab; using Hurricane::Error; using Hurricane::ForEachIterator; using Knik::KnikEngine; const char* missingKnikEngine = "%s :\n\n" " Hey, Banana! You forgot to run the Knik global router on %s.\n"; // ------------------------------------------------------------------- // Class : "Katabatic::GCellGrid". GCellGrid::GCellGrid ( KatabaticEngine* ktbt ) : Grid (ktbt->getCell()->getAbutmentBox()) , _katabatic (ktbt) , _densityMode (MaxDensity) , _hEdgeCapacity(ktbt->getConfiguration()->getHEdgeCapacity()) , _vEdgeCapacity(ktbt->getConfiguration()->getVEdgeCapacity()) { } void GCellGrid::_postCreate () { KnikEngine* knik; knik = KnikEngine::get ( getCell() ); if ( !knik ) throw Error ( missingKnikEngine, "GCellGrid::_postCreate()", getString(getCell()).c_str() ); vector knikGraduations; knik->getHorizontalCutLines ( knikGraduations ); for ( size_t i=0 ; igetVerticalCutLines ( knikGraduations ); for ( size_t i=0 ; i_postCreate (); return grid; } GCellGrid::~GCellGrid () { } void GCellGrid::_preDestroy () { cdebug.log(145,1) << "GCellGrid::_preDestroy()" << endl; vector::iterator it = _gcells.begin(); vector::iterator end = _gcells.end (); for ( ; it != end ; it++ ) (*it)->destroy (); cdebug.tabw(145,-1); } Cell* GCellGrid::getCell () const { return _katabatic->getCell(); } Interval GCellGrid::getUSide ( unsigned int direction ) const { Interval side; switch ( direction ) { default: cerr << Error( "GCellGrid::getUSide(): Unknown direction flag \"%i\"" , direction ) << endl; case KbHorizontal: side = Interval(_boundingBox.getXMin(),_boundingBox.getXMax()); break; case KbVertical: side = Interval(_boundingBox.getYMin(),_boundingBox.getYMax()); break; } return side; } void GCellGrid::updateContacts ( unsigned int flags ) { if (flags & KbOpenSession) Session::open( _katabatic ); forEach ( GCell*, gcell, getGCells() ) gcell->updateContacts(); if (flags & KbOpenSession) Session::close(); } size_t GCellGrid::updateDensity () { size_t saturateds = 0; forEach ( GCell*, gcell, getGCells() ) { saturateds += gcell->updateDensity (); } return saturateds; } size_t GCellGrid::checkDensity () const { size_t saturateds = 0; forEach ( GCell*, gcell, const_cast(this)->getGCells() ) { saturateds += gcell->checkDensity (); } return saturateds; } bool GCellGrid::checkEdgeOverflow ( size_t hreserved, size_t vreserved) const { bool overload = false; forEach ( GCell*, gcell, const_cast(this)->getGCells() ) { overload = gcell->checkEdgeSaturation(hreserved,vreserved) or overload; } return overload; } string GCellGrid::_getTypeName () const { return _TName("GCellGrid"); } string GCellGrid::_getString () const { return "<" + _getTypeName() + " " + getString(getRows()) + "x" + getString(getColumns()) + ">"; } void GCellGrid::_xmlWrite ( ostream& o ) { updateDensity (); o << "getName() << "\">" << endl; o << "" << endl; o << "" << endl; unsigned int row = 0; forEach ( GCell*, gcell, getGCells() ) { if ( gcell->getRow() > row ) { o << endl; o << "" << endl; row = gcell->getRow(); } o << " "; gcell->_xmlWrite ( o ); o << endl; } o << "" << endl; } Record* GCellGrid::_getRecord () const { Record* record = Grid::_getRecord (); record->add ( getSlot ( "_katabatic", _katabatic ) ); return record; } } // End of Katabatic namespace.