From be59d787a1517fd345faaa8639a611699112e5e5 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Tue, 17 Jan 2023 20:14:38 -0500 Subject: [PATCH] Modified the "gds subcell polygon" command option to split into three types: "none", "temporary", and "keep" (instead of "true" or "false"). "none" now reverts back to the original behavior, because it was found that saving polygons in subcells prevents them from participating in boolean operations. The "keep" option is the original option (polygons kept in subcells), and "temporary" is the one recently introduced (which puts polygons in subcells and then flattens them). This restores the original method while retaining the recently implemented method. However, a proper solution needs to be found that deals with the problem of boolean operators. --- VERSION | 2 +- calma/CalmaRdcl.c | 3 ++- calma/CalmaRdpt.c | 14 ++++++++------ calma/CalmaRead.c | 5 ++--- calma/calma.h | 11 ++++++++++- commands/CmdCD.c | 37 ++++++++++++++++++++++++++++++------- 6 files changed, 53 insertions(+), 19 deletions(-) diff --git a/VERSION b/VERSION index 3adebf79..a8daa452 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.362 +8.3.363 diff --git a/calma/CalmaRdcl.c b/calma/CalmaRdcl.c index ab004e5a..6405f857 100644 --- a/calma/CalmaRdcl.c +++ b/calma/CalmaRdcl.c @@ -606,7 +606,8 @@ calmaParseStructure(filename) */ DBEraseLabelsByContent(cifReadCellDef, NULL, -1, ""); - if ((!CalmaSubcellPolygons) && (locPolygonCount < CalmaPolygonCount)) + if ((CalmaSubcellPolygons == CALMA_POLYGON_TEMP) && + (locPolygonCount < CalmaPolygonCount)) DBCellEnum(cifReadCellDef, calmaFlattenPolygonFunc, (ClientData)cifReadCellDef); DBAdjustLabelsNew(cifReadCellDef, &TiPlaneRect, diff --git a/calma/CalmaRdpt.c b/calma/CalmaRdpt.c index 5da55a66..b24d18de 100644 --- a/calma/CalmaRdpt.c +++ b/calma/CalmaRdpt.c @@ -247,13 +247,13 @@ calmaElementBoundary() /* so we need to set it again. */ 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. */ + /* Save non-Manhattan polygons in their own subcells. */ + /* NOTE: CALMA_POLYGON_TEMP and CALMA_POLYGON_KEEP read in polygons much + * faster, but that interferes with boolean processing. This method + * needs to be reworked. + */ - if (calmaNonManhattan > 0) + if ((CalmaSubcellPolygons != CALMA_POLYGON_NONE) && (calmaNonManhattan > 0)) { /* Place the polygon in its own subcell */ char newname[] = "polygonXXXXX"; @@ -281,6 +281,8 @@ calmaElementBoundary() } } + /* Convert the polygon to rectangles. */ + rp = CIFPolyToRects(pathheadp, plane, CIFPaintTable, (PaintUndoInfo *)NULL); CIFFreePath(pathheadp); diff --git a/calma/CalmaRead.c b/calma/CalmaRead.c index 2def12ce..cf95cbf2 100644 --- a/calma/CalmaRead.c +++ b/calma/CalmaRead.c @@ -55,9 +55,8 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ /* Globals for Calma reading */ FILETYPE calmaInputFile = NULL; /* Read from this stream */ FILE *calmaErrorFile = NULL; /* Write error output here */ -bool CalmaSubcellPolygons = FALSE; /* Put non-Manhattan polygons - * in their own subcells. - */ +unsigned char CalmaSubcellPolygons = CALMA_POLYGON_NONE; + /* Read non-Manhattan polygons as-is */ int CalmaPolygonCount; bool CalmaSubcellPaths = FALSE; /* Put paths in their own subcells. */ int CalmaPathCount; diff --git a/calma/calma.h b/calma/calma.h index 9abc433e..b9e8ef78 100644 --- a/calma/calma.h +++ b/calma/calma.h @@ -25,7 +25,7 @@ #include "utils/magic.h" /* Externally visible variables */ -extern bool CalmaSubcellPolygons; +extern unsigned char CalmaSubcellPolygons; extern bool CalmaSubcellPaths; extern bool CalmaDoLabels; extern bool CalmaDoLibrary; @@ -49,6 +49,15 @@ extern bool CalmaPostOrder; extern bool CalmaAllowUndefined; extern bool CalmaAllowAbstract; +/* Definitions used by the return value for CalmaSubcellPolygons */ +/* CALMA_POLYGON_NONE: Process polygons immediately */ +/* CALMA_POLYGON_TEMP: Create temporary polygon subcells */ +/* CALMA_POLYGON_KEEP: Keep polygons in subcells */ + +#define CALMA_POLYGON_NONE 0 +#define CALMA_POLYGON_TEMP 1 +#define CALMA_POLYGON_KEEP 2 + /* Externally-visible procedures: */ extern bool CalmaWrite(); extern void CalmaReadFile(); diff --git a/commands/CmdCD.c b/commands/CmdCD.c index 2681eff0..f1f05d38 100644 --- a/commands/CmdCD.c +++ b/commands/CmdCD.c @@ -143,6 +143,7 @@ CmdCalma(w, cmd) static char *cmdCalmaYesNo[] = { "no", "false", "off", "0", "yes", "true", "on", "1", 0 }; static char *cmdCalmaAllowDisallow[] = {"disallow", "0", "allow", "1", 0}; + static char *cmdCalmaPolygonType[] = {"none", "temporary", "keep", 0}; static char *cmdCalmaWarnOptions[] = { "default", "none", "align", "limit", "redirect", "help", 0 }; static char *cmdCalmaOption[] = @@ -672,22 +673,44 @@ CmdCalma(w, cmd) if (cmd->tx_argc == 3) { #ifdef MAGIC_WRAPPER - Tcl_SetObjResult(magicinterp, Tcl_NewBooleanObj(CalmaSubcellPolygons)); + switch (CalmaSubcellPolygons) + { + case CALMA_POLYGON_NONE: + Tcl_SetObjResult(magicinterp, Tcl_NewStringObj("none", 0)); + break; + case CALMA_POLYGON_TEMP: + Tcl_SetObjResult(magicinterp, Tcl_NewStringObj("temporary", 0)); + break; + case CALMA_POLYGON_KEEP: + Tcl_SetObjResult(magicinterp, Tcl_NewStringObj("keep", 0)); + break; + } #else - if (CalmaSubcellPolygons) - TxPrintf("Non-manhattan polygons placed in subcells.\n"); - else + if (CalmaSubcellPolygons == CALMA_POLYGON_NONE) TxPrintf("Non-manhattan polygons read as-is.\n"); + else if (CalmaSubcellPolygons == CALMA_POLYGON_TEMP) + TxPrintf("Non-manhattan polygons placed in temporary subcells.\n"); + else + TxPrintf("Non-manhattan polygons placed in subcells.\n"); #endif return; } else if (cmd->tx_argc != 4) goto wrongNumArgs; - option = Lookup(cmd->tx_argv[3], cmdCalmaYesNo); + option = Lookup(cmd->tx_argv[3], cmdCalmaPolygonType); if (option < 0) - goto wrongNumArgs; - CalmaSubcellPolygons = (option < 4) ? FALSE : TRUE; + { + option = Lookup(cmd->tx_argv[3], cmdCalmaYesNo); + if (option < 0) + goto wrongNumArgs; + else if (option < 4) + CalmaSubcellPolygons = (unsigned char)CALMA_POLYGON_NONE; + else + CalmaSubcellPolygons = (unsigned char)CALMA_POLYGON_KEEP; + } + else + CalmaSubcellPolygons = (unsigned char)option; return; case CALMA_NO_DUP: