From 0f4de608a2fcc7c925da5f01f01dd8091dc01414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sat, 2 Jun 2018 02:19:36 +0200 Subject: [PATCH] Enabled parser to detect path-types, fix indentation --- gds-parser/gds-parser.c | 20 ++++++++++-- gds-parser/gds-types.h | 63 +++++++++++++++++++------------------ latex-output/latex-output.c | 4 +-- 3 files changed, 52 insertions(+), 35 deletions(-) diff --git a/gds-parser/gds-parser.c b/gds-parser/gds-parser.c index c5a72ae..a51e6e7 100644 --- a/gds-parser/gds-parser.c +++ b/gds-parser/gds-parser.c @@ -59,6 +59,7 @@ enum record { BOX = 0x2D00, LAYER = 0x0D02, WIDTH = 0x0F03, + PATHTYPE = 0x2102 }; static int name_cell_ref(struct gds_cell_instance *cell_inst, @@ -189,7 +190,8 @@ static GList *append_graphics(GList *curr_list, enum graphics_type type, gfx->layer = 0; gfx->vertices = NULL; gfx->width_absolute = 0; - gfx->type = type; + gfx->gfx_type = type; + gfx->path_render_type = PATH_FLUSH; } else return NULL; @@ -561,7 +563,7 @@ int parse_gds_from_file(const char *filename, GList **library_list) case ENDEL: if (current_graphics != NULL) { - printf("\tLeaving %s\n", (current_graphics->type == GRAPHIC_POLYGON ? "boundary" : "path")); + printf("\tLeaving %s\n", (current_graphics->gfx_type == GRAPHIC_POLYGON ? "boundary" : "path")); current_graphics = NULL; } if (current_s_reference != NULL) { @@ -587,6 +589,8 @@ int parse_gds_from_file(const char *filename, GList **library_list) break; case WIDTH: break; + case PATHTYPE: + break; default: //GDS_WARN("Record: %04x, len: %u", (unsigned int)rec_type, (unsigned int)rec_data_length); break; @@ -693,6 +697,18 @@ int parse_gds_from_file(const char *filename, GList **library_list) printf("\t\tAngle defined: %lf\n", current_s_reference->angle); } break; + case PATHTYPE: + if (current_graphics == NULL) { + GDS_WARN("Path type defined outside of path. Ignoring"); + break; + } + if (current_graphics->gfx_type == GRAPHIC_PATH) { + current_graphics->path_render_type = (int)gds_convert_signed_int16(workbuff); + printf("\t\tPathtype: %d\n", current_graphics->path_render_type); + } else { + GDS_WARN("Path type defined inside non-path graphics object. Ignoring"); + } + break; } diff --git a/gds-parser/gds-types.h b/gds-parser/gds-types.h index 9bb9753..6ec8e4e 100644 --- a/gds-parser/gds-types.h +++ b/gds-parser/gds-types.h @@ -7,54 +7,55 @@ #define CELL_NAME_MAX (100) enum graphics_type {GRAPHIC_PATH = 0, GRAPHIC_POLYGON = 1}; +enum path_type {PATH_FLUSH = 0, PATH_ROUNDED = 1, PATH_SQUARED = 2}; struct gds_time_field { - uint16_t year; - uint16_t month; - uint16_t day; - uint16_t hour; - uint16_t minute; - uint16_t second; + uint16_t year; + uint16_t month; + uint16_t day; + uint16_t hour; + uint16_t minute; + uint16_t second; }; struct gds_point { - int x; - int y; + int x; + int y; }; struct gds_graphics { - enum graphics_type type; - GList *vertices; - unsigned int path_width; - int width_absolute; - int16_t layer; - uint16_t datatype; + enum graphics_type gfx_type; + GList *vertices; + enum path_type path_render_type; + int width_absolute; + int16_t layer; + uint16_t datatype; }; struct gds_cell_instance { - char ref_name[CELL_NAME_MAX]; - struct gds_cell *cell_ref; - struct gds_point origin; - int flipped; - double angle; - double magnification; + char ref_name[CELL_NAME_MAX]; + struct gds_cell *cell_ref; + struct gds_point origin; + int flipped; + double angle; + double magnification; }; struct gds_cell { - char name[CELL_NAME_MAX]; - struct gds_time_field mod_time; - struct gds_time_field access_time; - GList *child_cells; - GList *graphic_objs; + char name[CELL_NAME_MAX]; + struct gds_time_field mod_time; + struct gds_time_field access_time; + GList *child_cells; + GList *graphic_objs; }; struct gds_library { - char name[CELL_NAME_MAX]; - struct gds_time_field mod_time; - struct gds_time_field access_time; - double unit_to_meters; - GList *cells; - GList *cell_names; + char name[CELL_NAME_MAX]; + struct gds_time_field mod_time; + struct gds_time_field access_time; + double unit_to_meters; + GList *cells; + GList *cell_names; }; #endif /* __GDS_TYPES_H__ */ diff --git a/latex-output/latex-output.c b/latex-output/latex-output.c index 0b0b63a..618d4ff 100644 --- a/latex-output/latex-output.c +++ b/latex-output/latex-output.c @@ -95,7 +95,7 @@ static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GSt if (write_layer_env(tex_file, &color, (int)gfx->layer, linfo, buffer) == TRUE) { /* Layer is defined => create graphics */ - if (gfx->type == GRAPHIC_POLYGON) { + if (gfx->gfx_type == GRAPHIC_POLYGON) { g_string_printf(buffer, "\\draw[line width=0.00001 pt, draw={c%d}, fill={c%d}, fill opacity={%lf}] ", gfx->layer, gfx->layer, color.alpha); WRITEOUT_BUFFER(buffer); @@ -107,7 +107,7 @@ static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GSt } g_string_printf(buffer, "cycle;\n"); WRITEOUT_BUFFER(buffer); - } else if(gfx->type == GRAPHIC_PATH) { + } else if(gfx->gfx_type == GRAPHIC_PATH) { g_string_printf(buffer, "\\draw[line width=%lf pt, draw={c%d}, opacity={%lf}] ", gfx->width_absolute/1000.0, gfx->layer, gfx->layer, color.alpha); WRITEOUT_BUFFER(buffer);