Updated code for cell size calculation
This commit is contained in:
parent
b0acbda6e3
commit
199833d603
@ -36,6 +36,7 @@
|
||||
#include "latex-output/latex-output.h"
|
||||
#include "widgets/conv-settings-dialog.h"
|
||||
#include "cairo-output/cairo-output.h"
|
||||
#include "trigonometric/cell-trigonometrics.h"
|
||||
|
||||
/**
|
||||
* @brief User data supplied to callback function of the open button
|
||||
@ -217,6 +218,7 @@ static void on_convert_clicked(gpointer button, gpointer user)
|
||||
GtkFileFilter *filter;
|
||||
gint res;
|
||||
char *file_name;
|
||||
union bounding_box *cell_box;
|
||||
|
||||
/* Get selected cell */
|
||||
selection = gtk_tree_view_get_selection(data->tree_view);
|
||||
@ -231,6 +233,9 @@ static void on_convert_clicked(gpointer button, gpointer user)
|
||||
/* Get layers that are rendered */
|
||||
layer_list = export_rendered_layer_info();
|
||||
|
||||
/* Calculate cell size in DB units */
|
||||
|
||||
/* Show settings dialog */
|
||||
settings = renderer_settings_dialog_new(GTK_WINDOW(data->main_window));
|
||||
renderer_settings_dialog_set_settings(settings, &sett);
|
||||
res = gtk_dialog_run(GTK_DIALOG(settings));
|
||||
|
@ -157,4 +157,9 @@ void bounding_box_update_point(union bounding_box *destination, conv_generic_to_
|
||||
destination->vectors.upper_right.y = MAX(destination->vectors.upper_right.y, point.y);
|
||||
}
|
||||
|
||||
void bounding_box_apply_transform(double scale, double rotation, union bounding_box *box)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -48,6 +48,7 @@ void bounding_box_calculate_polygon(GList *vertices, conv_generic_to_vector_2d_t
|
||||
void bounding_box_update_box(union bounding_box *destination, union bounding_box *update);
|
||||
void bounding_box_prepare_empty(union bounding_box *box);
|
||||
void bounding_box_update_point(union bounding_box *destination, conv_generic_to_vector_2d_t conv_func, void *pt);
|
||||
void bounding_box_apply_transform(double scale, double rotation, union bounding_box *box);
|
||||
|
||||
#endif /* _BOUNDING_BOX_H_ */
|
||||
|
||||
|
104
trigonometric/cell-trigonometrics.c
Normal file
104
trigonometric/cell-trigonometrics.c
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* GDSII-Converter
|
||||
* Copyright (C) 2018 Mario Hüttel <mario.huettel@gmx.net>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cell-trigonometrics.c
|
||||
* @brief Calculation of gds_cell trigonometrics
|
||||
* @author Mario Hüttel <mario.huettel@gmx.net>
|
||||
*/
|
||||
|
||||
#include "cell-trigonometrics.h"
|
||||
|
||||
/**
|
||||
* @addtogroup trigonometric
|
||||
* @{
|
||||
*/
|
||||
|
||||
static void convert_gds_point_to_2d_vector(struct gds_point *pt, struct vector_2d *vector)
|
||||
{
|
||||
vector->x = pt->x;
|
||||
vector->y = pt->y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief update_box_with_gfx
|
||||
* @param box
|
||||
* @param gfx_list
|
||||
*/
|
||||
static void update_box_with_gfx(union bounding_box *box, struct gds_graphics *gfx)
|
||||
{
|
||||
union bounding_box current_box;
|
||||
|
||||
bounding_box_prepare_empty(¤t_box);
|
||||
|
||||
switch (gfx->gfx_type) {
|
||||
case GRAPHIC_BOX:
|
||||
case GRAPHIC_POLYGON:
|
||||
bounding_box_calculate_polygon(gfx->vertices,
|
||||
(conv_generic_to_vector_2d_t)&convert_gds_point_to_2d_vector,
|
||||
¤t_box);
|
||||
break;
|
||||
case GRAPHIC_PATH:
|
||||
/*
|
||||
* This is not implemented correctly.
|
||||
* Please be aware if paths are the oputpost elements of your cell.
|
||||
* You might end up with a completely wrong calculated cell size.
|
||||
*/
|
||||
/* Okay.. You're right. It is not implemented at all. ;P */
|
||||
break;
|
||||
default:
|
||||
/* Unknown graphics object. */
|
||||
/* Print error? Nah.. */
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update box with results */
|
||||
bounding_box_update_box(box, ¤t_box);
|
||||
}
|
||||
|
||||
void calculate_cell_bounding_box(union bounding_box *box, struct gds_cell *cell)
|
||||
{
|
||||
GList *gfx_list;
|
||||
struct gds_graphics *gfx;
|
||||
GList *sub_cell_list;
|
||||
struct gds_cell_instance *sub_cell;
|
||||
union bounding_box temp_box;
|
||||
|
||||
if (!box || !cell)
|
||||
return;
|
||||
|
||||
/* Update box with graphic elements */
|
||||
for (gfx_list = cell->graphic_objs; gfx_list != NULL; gfx_list = gfx_list->next) {
|
||||
gfx = (struct gds_graphics *)gfx_list->data;
|
||||
update_box_with_gfx(box, gfx);
|
||||
}
|
||||
|
||||
/* 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) {
|
||||
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);
|
||||
|
||||
/* TODO: Apply transformations! */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
47
trigonometric/cell-trigonometrics.h
Normal file
47
trigonometric/cell-trigonometrics.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* GDSII-Converter
|
||||
* Copyright (C) 2018 Mario Hüttel <mario.huettel@gmx.net>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cell-trigonometrics.h
|
||||
* @brief Calculation of gds_cell trigonometrics
|
||||
* @author Mario Hüttel <mario.huettel@gmx.net>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup trigonometric
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _CELL_TRIGONOMETRICS_H_
|
||||
#define _CELL_TRIGONOMETRICS_H_
|
||||
|
||||
#include "bounding-box.h"
|
||||
#include "../gds-parser/gds-types.h"
|
||||
|
||||
/**
|
||||
* @brief calculate_cell_bounding_box Calculate bounding box of gds cell
|
||||
* @param box Resulting boundig box. Will be uüdated and not overwritten
|
||||
* @param cell toplevel cell
|
||||
* @warning Path handling not yet implemented correctly
|
||||
*/
|
||||
void calculate_cell_bounding_box(union bounding_box *box, struct gds_cell *cell);
|
||||
|
||||
#endif /* _CELL_TRIGONOMETRICS_H_ */
|
||||
|
||||
/** @} */
|
Loading…
Reference in New Issue
Block a user