From 127b2bc9a1faaca5e7a90689b8d05f0eb0249823 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Mon, 22 Jan 2024 15:25:46 +0100 Subject: [PATCH] In GdsParser, force boundary to be on grid, do it by shrinking. --- crlcore/src/ccore/gds/GdsDriver.cpp | 36 ++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/crlcore/src/ccore/gds/GdsDriver.cpp b/crlcore/src/ccore/gds/GdsDriver.cpp index b410d56fe..84a6b596a 100644 --- a/crlcore/src/ccore/gds/GdsDriver.cpp +++ b/crlcore/src/ccore/gds/GdsDriver.cpp @@ -103,52 +103,66 @@ namespace { bool isOnGrid ( Component* component, const Box& bb ) { - bool error = false; - DbU::Unit oneGrid = DbU::fromGrid( 1.0 ); - if (bb.getXMin() % oneGrid) { + bool error = false; + if (bb.getXMin() % DbU::oneGrid) { error = true; cerr << Error( "isOnGrid(): On %s of %s,\n" " X-Min %s is not on grid (%s)" , getString(component).c_str() , getString(component->getCell()).c_str() , DbU::getValueString(bb.getXMin()).c_str() - , DbU::getValueString(oneGrid).c_str() + , DbU::getValueString(DbU::oneGrid).c_str() ) << endl; } - if (bb.getXMax() % oneGrid) { + if (bb.getXMax() % DbU::oneGrid) { error = true; cerr << Error( "isOnGrid(): On %s of %s,\n" " X-Max %s is not on grid (%s)" , getString(component).c_str() , getString(component->getCell()).c_str() , DbU::getValueString(bb.getXMax()).c_str() - , DbU::getValueString(oneGrid).c_str() + , DbU::getValueString(DbU::oneGrid).c_str() ) << endl; } - if (bb.getYMin() % oneGrid) { + if (bb.getYMin() % DbU::oneGrid) { error = true; cerr << Error( "isOnGrid(): On %s of %s,\n" " Y-Min %s is not on grid (%s)" , getString(component).c_str() , getString(component->getCell()).c_str() , DbU::getValueString(bb.getYMin()).c_str() - , DbU::getValueString(oneGrid).c_str() + , DbU::getValueString(DbU::oneGrid).c_str() ) << endl; } - if (bb.getYMax() % oneGrid) { + if (bb.getYMax() % DbU::oneGrid) { error = true; cerr << Error( "isOnGrid(): On %s of %s,\n" " Y-Max %s is not on grid (%s)" , getString(component).c_str() , getString(component->getCell()).c_str() , DbU::getValueString(bb.getYMax()).c_str() - , DbU::getValueString(oneGrid).c_str() + , DbU::getValueString(DbU::oneGrid).c_str() ) << endl; } return error; } + Box& putOnGrid ( Box& bb ) + { + DbU::Unit xMinShrink = bb.getXMin() % DbU::oneGrid; + DbU::Unit yMinShrink = bb.getYMin() % DbU::oneGrid; + DbU::Unit xMaxShrink = bb.getXMax() % DbU::oneGrid; + DbU::Unit yMaxShrink = bb.getYMax() % DbU::oneGrid; + + if (xMinShrink) xMinShrink -= DbU::oneGrid; + if (yMinShrink) yMinShrink -= DbU::oneGrid; + + bb.inflate( xMinShrink, yMinShrink, -xMaxShrink, -yMaxShrink ); + return bb; + } + + bool isOnGrid ( Component* component, const vector& points ) { bool error = false; @@ -832,12 +846,12 @@ namespace { Box bb = component->getBoundingBox(layer); if ((bb.getWidth() == 0) or (bb.getHeight() == 0)) continue; + isOnGrid( component, bb ); (*this) << BOUNDARY; (*this) << LAYER(layer->getGds2Layer()); (*this) << DATATYPE(layer->getGds2Datatype()); (*this) << bb; (*this) << ENDEL; - isOnGrid( component, bb ); const BasicLayer* exportLayer = layer; if (NetExternalComponents::isExternal(component)) {