GDS-Render v1.2.1
Geometric Helper Functions

Data Structures

union  bounding_box
 Union describing a bounding box. More...
 
struct  vector_2d
 

Macros

#define MIN(a, b)   (((a) < (b)) ? (a) : (b))
 Return smaller number. More...
 
#define MAX(a, b)   (((a) > (b)) ? (a) : (b))
 Return bigger number. More...
 
#define ABS_DBL(a)   ((a) < 0 ? -(a) : (a))
 
#define ABS_DBL(a)   ((a) < 0.0 ? -(a) : (a))
 
#define DEG2RAD(a)   ((a)*M_PI/180.0)
 

Typedefs

typedef void(* conv_generic_to_vector_2d_t) (void *, struct vector_2d *)
 

Functions

void bounding_box_calculate_from_polygon (GList *vertices, conv_generic_to_vector_2d_t conv_func, union bounding_box *box)
 Calculate bounding box of polygon. More...
 
void bounding_box_update_with_box (union bounding_box *destination, union bounding_box *update)
 Update an exisitng bounding box with another one. More...
 
void bounding_box_prepare_empty (union bounding_box *box)
 Prepare an empty bounding box. More...
 
static void calculate_path_miter_points (struct vector_2d *a, struct vector_2d *b, struct vector_2d *c, struct vector_2d *m1, struct vector_2d *m2, double width)
 Calculate path miter points for a pathwith a width and the anchors a b c. More...
 
void bounding_box_update_with_path (GList *vertices, double thickness, conv_generic_to_vector_2d_t conv_func, union bounding_box *box)
 Calculate the bounding box of a path and update the given bounding box. More...
 
void bounding_box_update_with_point (union bounding_box *destination, conv_generic_to_vector_2d_t conv_func, void *pt)
 Update bounding box with a point. More...
 
void bounding_box_get_all_points (struct vector_2d *points, union bounding_box *box)
 Return all four corner points of a bounding box. More...
 
void bounding_box_apply_transform (double scale, double rotation_deg, bool flip_at_x, union bounding_box *box)
 Apply transformations onto bounding box. More...
 
static void convert_gds_point_to_2d_vector (struct gds_point *pt, struct vector_2d *vector)
 
static void update_box_with_gfx (union bounding_box *box, struct gds_graphics *gfx)
 Update the given bounding box with the bounding box of a graphics element. More...
 
void calculate_cell_bounding_box (union bounding_box *box, struct gds_cell *cell)
 Calculate bounding box of a gds cell. More...
 
double vector_2d_scalar_multipy (struct vector_2d *a, struct vector_2d *b)
 
void vector_2d_normalize (struct vector_2d *vec)
 
void vector_2d_rotate (struct vector_2d *vec, double angle)
 
struct vector_2dvector_2d_copy (struct vector_2d *opt_res, struct vector_2d *vec)
 
struct vector_2dvector_2d_alloc (void)
 
void vector_2d_free (struct vector_2d *vec)
 
void vector_2d_scale (struct vector_2d *vec, double scale)
 
double vector_2d_abs (struct vector_2d *vec)
 
double vector_2d_calculate_angle_between (struct vector_2d *a, struct vector_2d *b)
 
void vector_2d_subtract (struct vector_2d *res, struct vector_2d *a, struct vector_2d *b)
 
void vector_2d_add (struct vector_2d *res, struct vector_2d *a, struct vector_2d *b)
 

Detailed Description

The geometric helper function are used to calculate bounding boxes

Warning
Code is incomplete. Please double check for functionality!

Macro Definition Documentation

◆ ABS_DBL [1/2]

#define ABS_DBL (   a)    ((a) < 0 ? -(a) : (a))

Definition at line 38 of file bounding-box.c.

◆ ABS_DBL [2/2]

#define ABS_DBL (   a)    ((a) < 0.0 ? -(a) : (a))

Definition at line 36 of file vector-operations.c.

◆ DEG2RAD

#define DEG2RAD (   a)    ((a)*M_PI/180.0)

Definition at line 42 of file vector-operations.h.

◆ MAX

#define MAX (   a,
 
)    (((a) > (b)) ? (a) : (b))

Return bigger number.

Definition at line 37 of file bounding-box.c.

◆ MIN

#define MIN (   a,
 
)    (((a) < (b)) ? (a) : (b))

Return smaller number.

Definition at line 36 of file bounding-box.c.

Typedef Documentation

◆ conv_generic_to_vector_2d_t

typedef void(* conv_generic_to_vector_2d_t) (void *, struct vector_2d *)

Definition at line 76 of file bounding-box.h.

Function Documentation

◆ bounding_box_apply_transform()

void bounding_box_apply_transform ( double  scale,
double  rotation_deg,
bool  flip_at_x,
union bounding_box box 
)

Apply transformations onto bounding box.

All corner points \( \vec{P_i} \) of the bounding box are transformed to output points \( \vec{P_o} \) by:

\( \vec{P_o} = s \cdot \begin{pmatrix}\cos\left(\phi\right) & -\sin\left(\phi\right)\\ \sin\left(\phi\right) & \cos\left(\phi\right)\end{pmatrix} \cdot \begin{pmatrix} 1 & 0 \\ 0 & -1^{m} \end{pmatrix} \cdot \vec{P_i} \), with:

  • \(s\): Scale
  • \(m\): 1, if flipped_at_x is True, else 0
  • \(\phi\): Rotation angle in radians. The conversion degrees => radians is done internally

The result is the bounding box generated around all output points

Parameters
scaleScaling factor
rotation_degRotation of bounding box around the origin in degrees (counterclockwise)
flip_at_xFlip the boundig box on the x axis before rotating.
boxBounding box the operations should be applied to.
Note
Keep in mind, that this bounding box is actually the bounding box of the rotated boundig box and not the object itself. It might be too big.

Definition at line 207 of file bounding-box.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bounding_box_calculate_from_polygon()

void bounding_box_calculate_from_polygon ( GList *  vertices,
conv_generic_to_vector_2d_t  conv_func,
union bounding_box box 
)

Calculate bounding box of polygon.

Parameters
verticesList of vertices that describe the polygon
conv_funcConversion function to convert vertices to vector_2d structs.
boxBox to write to. This box is not updated! All previous data is discarded

Definition at line 40 of file bounding-box.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bounding_box_get_all_points()

void bounding_box_get_all_points ( struct vector_2d points,
union bounding_box box 
)

Return all four corner points of a bounding box.

Parameters
[out]pointsArray of 4 vector_2d structs that has to be allocated by the caller
boxBounding box

Definition at line 192 of file bounding-box.c.

Here is the caller graph for this function:

◆ bounding_box_prepare_empty()

void bounding_box_prepare_empty ( union bounding_box box)

Prepare an empty bounding box.

Updating this specially prepared box, results in a bounding box that is the same size as the update

Parameters
boxBox to preapre

Definition at line 86 of file bounding-box.c.

Here is the caller graph for this function:

◆ bounding_box_update_with_box()

void bounding_box_update_with_box ( union bounding_box destination,
union bounding_box update 
)

Update an exisitng bounding box with another one.

Parameters
destinationTarget box to update
updateBox to update the target with

Definition at line 71 of file bounding-box.c.

Here is the caller graph for this function:

◆ bounding_box_update_with_path()

void bounding_box_update_with_path ( GList *  vertices,
double  thickness,
conv_generic_to_vector_2d_t  conv_func,
union bounding_box box 
)

Calculate the bounding box of a path and update the given bounding box.

Parameters
verticesVertices the path is made up of
thicknessThisckness of the path
conv_funcConversion function for vertices to vector_2d structs
boxBounding box to write results in.
Warning
This function is not yet implemented correctly. Miter points of paths are not taken into account. If a path is the outmost object of your cell and it is not parallel to one of the coordinate axes, the calculated bounding box size might be off. In other cases it should be reasonable close to the real bounding box.

Definition at line 148 of file bounding-box.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bounding_box_update_with_point()

void bounding_box_update_with_point ( union bounding_box destination,
conv_generic_to_vector_2d_t  conv_func,
void *  pt 
)

Update bounding box with a point.

Parameters
destinationBounding box to update
conv_funcConversion function to convert pt to a vector_2d. May be NULL
ptPoint to update bounding box with

Definition at line 174 of file bounding-box.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_cell_bounding_box()

void calculate_cell_bounding_box ( union bounding_box box,
struct gds_cell cell 
)

Calculate bounding box of a gds cell.

This function updates a given bounding box with the dimensions of a gds_cell. Please note that the handling of path miter points is not complete yet. If a path object is the outmost object of your cell at any edge, the resulting bounding box might be the wrong size. The devistion from the real size is guaranteed to be within the width of the path object.

Parameters
boxResulting boundig box. Will be updated and not overwritten
cellToplevel cell
Warning
Handling of Path graphic objects not yet implemented correctly.

Definition at line 80 of file cell-geometrics.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_path_miter_points()

static void calculate_path_miter_points ( struct vector_2d a,
struct vector_2d b,
struct vector_2d c,
struct vector_2d m1,
struct vector_2d m2,
double  width 
)
static

Calculate path miter points for a pathwith a width and the anchors a b c.

Parameters
[in]a
[in]b
[in]c
[out]m1
[out]m2
[in]width
Returns
Miter points in m1 and m2
Note
This function is currently unused (and untested). Ignore any compiler warning regarding this function.

Definition at line 105 of file bounding-box.c.

Here is the call graph for this function:

◆ convert_gds_point_to_2d_vector()

static void convert_gds_point_to_2d_vector ( struct gds_point pt,
struct vector_2d vector 
)
static

Definition at line 35 of file cell-geometrics.c.

Here is the caller graph for this function:

◆ update_box_with_gfx()

static void update_box_with_gfx ( union bounding_box box,
struct gds_graphics gfx 
)
static

Update the given bounding box with the bounding box of a graphics element.

Parameters
boxbox to update
gfxGraphics element

Definition at line 46 of file cell-geometrics.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_2d_abs()

double vector_2d_abs ( struct vector_2d vec)

Definition at line 114 of file vector-operations.c.

Here is the caller graph for this function:

◆ vector_2d_add()

void vector_2d_add ( struct vector_2d res,
struct vector_2d a,
struct vector_2d b 
)

Definition at line 142 of file vector-operations.c.

Here is the caller graph for this function:

◆ vector_2d_alloc()

struct vector_2d * vector_2d_alloc ( void  )

Definition at line 94 of file vector-operations.c.

Here is the caller graph for this function:

◆ vector_2d_calculate_angle_between()

double vector_2d_calculate_angle_between ( struct vector_2d a,
struct vector_2d b 
)

Definition at line 123 of file vector-operations.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_2d_copy()

struct vector_2d * vector_2d_copy ( struct vector_2d opt_res,
struct vector_2d vec 
)

Definition at line 75 of file vector-operations.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_2d_free()

void vector_2d_free ( struct vector_2d vec)

Definition at line 99 of file vector-operations.c.

◆ vector_2d_normalize()

void vector_2d_normalize ( struct vector_2d vec)

Definition at line 46 of file vector-operations.c.

Here is the caller graph for this function:

◆ vector_2d_rotate()

void vector_2d_rotate ( struct vector_2d vec,
double  angle 
)

Definition at line 57 of file vector-operations.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_2d_scalar_multipy()

double vector_2d_scalar_multipy ( struct vector_2d a,
struct vector_2d b 
)

Definition at line 38 of file vector-operations.c.

Here is the caller graph for this function:

◆ vector_2d_scale()

void vector_2d_scale ( struct vector_2d vec,
double  scale 
)

Definition at line 105 of file vector-operations.c.

Here is the caller graph for this function:

◆ vector_2d_subtract()

void vector_2d_subtract ( struct vector_2d res,
struct vector_2d a,
struct vector_2d b 
)

Definition at line 134 of file vector-operations.c.

Here is the caller graph for this function: