More comprehensive warning for offgrid shapes in GdsStream::xyToComponent().

This commit is contained in:
Jean-Paul Chaput 2021-05-22 14:57:25 +02:00
parent 90300eb651
commit 4b2c120478
2 changed files with 21 additions and 3 deletions

View File

@ -678,6 +678,7 @@ namespace {
GdsStream& GdsStream::operator<< ( Points points ) GdsStream& GdsStream::operator<< ( Points points )
{ {
//cerr << "GdsStream::operator<<(Points&) " << points.getSize() << endl;
GdsRecord record ( GdsRecord::XY ); GdsRecord record ( GdsRecord::XY );
Point first = points.getFirst(); Point first = points.getFirst();
for ( Point p : points ) { for ( Point p : points ) {
@ -703,6 +704,7 @@ namespace {
GdsStream& GdsStream::operator<< ( const vector<Point>& points ) GdsStream& GdsStream::operator<< ( const vector<Point>& points )
{ {
//cerr << "GdsStream::operator<<(vector<Points>&) " << points.size() << endl;
GdsRecord record ( GdsRecord::XY ); GdsRecord record ( GdsRecord::XY );
for ( Point p : points ) { for ( Point p : points ) {
record.push( (int32_t)toGdsDbu(p.getX()) ); record.push( (int32_t)toGdsDbu(p.getX()) );

View File

@ -1331,15 +1331,31 @@ namespace {
vector<Point> points; vector<Point> points;
vector<int32_t> coordinates = _record.getInt32s(); vector<int32_t> coordinates = _record.getInt32s();
vector<size_t> offgrids;
for ( size_t i=0 ; i<coordinates.size() ; i += 2 ) { for ( size_t i=0 ; i<coordinates.size() ; i += 2 ) {
points.push_back( Point( coordinates[i ]*_scale points.push_back( Point( coordinates[i ]*_scale
, coordinates[i+1]*_scale ) ); , coordinates[i+1]*_scale ) );
if ( (points.back().getX() % oneGrid) or (points.back().getX() % oneGrid) ) { if ( (points.back().getX() % oneGrid) or (points.back().getX() % oneGrid) ) {
cerr << Error( "GdsStream::xyToComponent(): Offgrid %s (foundry grid: %s)." offgrids.push_back( i );
, getString(points.back()).c_str()
, DbU::getValueString(oneGrid).c_str() ) << endl;
} }
} }
if (not offgrids.empty()) {
size_t offgrid = 0;
ostringstream m;
for ( size_t i=0 ; i<points.size() ; ++i ) {
if (i) m << "\n";
m << " | " << points[i];
if ((offgrid < offgrids.size()) and (i == offgrid)) {
m << " offgrid";
++offgrid;
}
}
cerr << Error( "GdsStream::xyToComponent(): Offgrid points on layer \"%s\" (foundry grid: %s).\n"
"%s"
, getString(layer->getName()).c_str()
, DbU::getValueString(oneGrid).c_str()
, m.str().c_str() ) << endl;
}
_stream >> _record; _stream >> _record;