From cd9030a24ed8ee44a0c89f6bc63fc10c3332f46f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 5 Mar 2019 19:38:07 +0100 Subject: [PATCH] Create GDS Tree checking functions. Renamed doxygen section of GDS Parser to GDS-Utilities so the cheking function fit into this section --- gds-parser/gds-parser.c | 7 +--- gds-parser/gds-parser.h | 2 +- gds-parser/gds-tree-checker.c | 48 +++++++++++++++++++++++++ gds-parser/gds-tree-checker.h | 55 +++++++++++++++++++++++++++++ gds-parser/gds-types.h | 2 +- trigonometric/cell-trigonometrics.c | 6 ++-- 6 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 gds-parser/gds-tree-checker.c create mode 100644 gds-parser/gds-tree-checker.h diff --git a/gds-parser/gds-parser.c b/gds-parser/gds-parser.c index e6ef61b..8fe475c 100644 --- a/gds-parser/gds-parser.c +++ b/gds-parser/gds-parser.c @@ -17,11 +17,6 @@ * along with GDSII-Converter. If not, see . */ -/* - - */ - - /** * @file gds-parser.c * @brief Implementation of the GDS-Parser @@ -35,7 +30,7 @@ */ /** - * @addtogroup GDS-Parser + * @addtogroup GDS-Utilities * @{ */ diff --git a/gds-parser/gds-parser.h b/gds-parser/gds-parser.h index 1704395..ce745e4 100644 --- a/gds-parser/gds-parser.h +++ b/gds-parser/gds-parser.h @@ -24,7 +24,7 @@ */ /** - * @addtogroup GDS-Parser + * @addtogroup GDS-Utilities * @{ */ diff --git a/gds-parser/gds-tree-checker.c b/gds-parser/gds-tree-checker.c new file mode 100644 index 0000000..7833ec0 --- /dev/null +++ b/gds-parser/gds-tree-checker.c @@ -0,0 +1,48 @@ +/* + * GDSII-Converter + * Copyright (C) 2019 Mario Hüttel + * + * This file is part of GDSII-Converter. + * + * GDSII-Converter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * GDSII-Converter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GDSII-Converter. If not, see . + */ + +/** + * @file gds-tree-checker.c + * @brief Checking functions of a cell tree + * + * This file contains cehcking functions for the GDS cell tree. + * These functions include checks if all child references could be resolved, + * and if the cell tree contains loops. + * + * @author Mario Hüttel + */ + +/** + * @addtogroup GDS-Utilities + * @{ + */ + +#include "gds-tree-checker.h" + +int gds_tree_check_cell_references(struct gds_library *lib) +{ + return 0; +} + +int gds_tree_check_reference_loops(struct gds_library *lib) +{ + return 0; +} + +/** @} */ diff --git a/gds-parser/gds-tree-checker.h b/gds-parser/gds-tree-checker.h new file mode 100644 index 0000000..964b1b9 --- /dev/null +++ b/gds-parser/gds-tree-checker.h @@ -0,0 +1,55 @@ +/* + * GDSII-Converter + * Copyright (C) 2019 Mario Hüttel + * + * This file is part of GDSII-Converter. + * + * GDSII-Converter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * GDSII-Converter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GDSII-Converter. If not, see . + */ + +/** + * @file gds-tree-checker.h + * @brief Checking functions of a cell tree (Header) + * @author Mario Hüttel + */ + +/** + * @addtogroup GDS-Utilities + * @{ + */ + +#ifndef _GDS_TREE_CHECKER_H_ +#define _GDS_TREE_CHECKER_H_ + +#include "gds-types.h" + +/** + * @brief gds_tree_check_cell_references checks if all child cell references can be resolved in the given library + * @param lib The GDS library to check + * @return less than 0 if an error occured during processing; 0 if all child cells could be resolved; + * greater than zero if the processing was successful but not all cell references could be resolved. + * In this case the number of unresolved references is returned + */ +int gds_tree_check_cell_references(struct gds_library *lib); + +/** + * @brief gds_tree_check_reference_loops checks if the given library contains reference loops + * @param lib GDS library + * @return negative if an error occured, zero if there are no reference loops, else a positive number representing the number + * of affected cells + */ +int gds_tree_check_reference_loops(struct gds_library *lib); + +#endif /* _GDS_TREE_CHECKER_H_ */ + +/** @} */ diff --git a/gds-parser/gds-types.h b/gds-parser/gds-types.h index 80e2acc..d6630cb 100644 --- a/gds-parser/gds-types.h +++ b/gds-parser/gds-types.h @@ -24,7 +24,7 @@ */ /** - * @addtogroup GDS-Parser + * @addtogroup GDS-Utilities * @{ */ diff --git a/trigonometric/cell-trigonometrics.c b/trigonometric/cell-trigonometrics.c index 823a531..7f13d44 100644 --- a/trigonometric/cell-trigonometrics.c +++ b/trigonometric/cell-trigonometrics.c @@ -94,14 +94,16 @@ void calculate_cell_bounding_box(union bounding_box *box, struct gds_cell *cell) } /* Update bounding box with boxes of subcells */ - for (sub_cell_list = cell->child_cells; sub_cell_list != NULL; sub_cell_list = sub_cell_list->next) { + for (sub_cell_list = cell->child_cells; sub_cell_list != NULL; + sub_cell_list = sub_cell_list->next) { sub_cell = (struct gds_cell_instance *)sub_cell_list->data; bounding_box_prepare_empty(&temp_box); /* Recursion Woohoo!! This dies if your GDS is faulty and contains a reference loop */ calculate_cell_bounding_box(&temp_box, sub_cell->cell_ref); /* Apply transformations */ - bounding_box_apply_transform(ABS(sub_cell->magnification), sub_cell->angle, sub_cell->flipped, &temp_box); + bounding_box_apply_transform(ABS(sub_cell->magnification), sub_cell->angle, + sub_cell->flipped, &temp_box); /* Move bounding box to origin */ temp_box.vectors.lower_left.x += sub_cell->origin.x;