Discovered that reading in polygons as subcells and then flattening

can be much, much faster than reading in polygons directly into a
cell from GDS.  Modified the handling of polygons so that they are
*always* read into subcells.  If the "polygon subcell flatten true"
option is not enabled, then the subcells are flattened at the end
of reading the cell, and the polygon cells are deleted.  This method
avoids most of the cases in which "polygon subcell flatten true"
has ever needed to be set.
This commit is contained in:
Tim Edwards 2022-12-13 21:58:30 -05:00
parent 53682af668
commit 13a1bfcc2e
2 changed files with 51 additions and 1 deletions

View File

@ -56,6 +56,7 @@ bool CalmaRewound = FALSE;
TileTypeBitMask *CalmaMaskHints = NULL;
extern HashTable calmaDefInitHash;
extern int CalmaPolygonCount;
/* forward declarations */
int calmaElementSref();
@ -274,6 +275,45 @@ calmaExact()
return parray;
}
/*
* ----------------------------------------------------------------------------
*
* calmaFlattenPolygonFunc --
*
* Polygons have been dropped into subcells by default for
* efficiency in reading. If the "subcell polygons" option
* has not been selected, then flatten these cells into the
* layout and delete the cells. This seems inefficient but
* in fact can be much faster than reading the polygons
* directly into the cell from GDS.
*
* ----------------------------------------------------------------------------
*/
int
calmaFlattenPolygonFunc(use, parent)
CellUse *use;
CellDef *parent;
{
int i;
CellUse dummy;
SearchContext scx;
if (use->cu_def == NULL || use->cu_def->cd_name == NULL) return 0;
if (strncmp(use->cu_def->cd_name, "polygon", 7)) return 0;
dummy.cu_transform = GeoIdentityTransform;
dummy.cu_id = NULL;
dummy.cu_def = parent;
scx.scx_use = use;
scx.scx_area = use->cu_bbox;
scx.scx_trans = GeoIdentityTransform;
DBCellCopyAllPaint(&scx, &DBAllButSpaceAndDRCBits, 0, &dummy);
DBDeleteCellNoModify(use);
DBCellDeleteDef(use->cu_def);
return 0; /* Keep the search going */
}
/*
@ -547,6 +587,12 @@ calmaParseStructure(filename)
CIFPaintCurrent(FILE_CALMA);
}
if ((!CalmaSubcellPolygons) && (CalmaPolygonCount > 0))
{
DBCellEnum(cifReadCellDef, calmaFlattenPolygonFunc, (ClientData)cifReadCellDef);
CalmaPolygonCount = 0;
}
DBAdjustLabelsNew(cifReadCellDef, &TiPlaneRect,
(cifCurReadStyle->crs_flags & CRF_NO_RECONNECT_LABELS) ? 1 : 0);
DBReComputeBbox(cifReadCellDef);

View File

@ -248,8 +248,12 @@ calmaElementBoundary()
if (ciftype >= 0) plane = cifCurReadPlanes[ciftype];
/* Convert the polygon to rectangles. */
/* NOTE: This was previously contingent on CalmaSubcellPolygons. */
/* However, in practice it has been found to be much faster to read */
/* polygons into subcells and then flatten into the layout instead */
/* of reading polygons directly into the layout. I am unsure why. */
if (CalmaSubcellPolygons && (calmaNonManhattan > 0))
if (calmaNonManhattan > 0)
{
/* Place the polygon in its own subcell */
char newname[] = "polygonXXXXX";