Limbo
3.5.4
Toggle main menu visibility
Loading...
Searching...
No Matches
test
parsers
gdsii
test_writer.cpp
Go to the documentation of this file.
1
7
8
#include <vector>
9
#include <
limbo/parsers/gdsii/stream/GdsWriter.h
>
10
15
int
main
(
int
argc,
char
*argv[] )
16
{
17
18
int
19
x[5],
20
y[5];
21
22
if
(argc < 2)
23
{
24
printf(
"need a output file name\n"
);
25
return
1;
26
}
27
// start the gds library with HEADER, BGNLIB, LIBNAME, and UNITS
28
29
GdsParser::GdsWriter
gw (argv[1]);
30
// two different wrappers
31
//gw.gds_create_lib( "dogs", 0.001 /* um per bit */ );
32
gw.
create_lib
(
"dogs"
, 0.001, 1.0e-9);
33
34
// create a cell called "hotdogs"
35
36
gw.
gds_write_bgnstr
( );
37
gw.
gds_write_strname
(
"hotdogs"
);
38
40
//-----------------------------------------------------------------------------
41
// create a polygon 1
42
43
gw.
gds_write_boundary
( );
// write just the token
44
gw.
gds_write_layer
( 10001 );
// layer 0, for example
45
gw.
gds_write_datatype
( 0 );
// datatype 1, for example
46
47
x[0] = 0; y[0] = 0;
// signed four-byte integers
48
x[1] = 0; y[1] = 500;
49
x[2] = 1000; y[2] = 500;
// in this example 1 integer unit = 1 nm
50
x[3] = 1000; y[3] = 0;
51
x[4] = 0; y[4] = 0;
// required repetition of first point (yup, that's stupid)
52
53
gw.
gds_write_xy
( x, y, 5 );
// polygon, four vertices, first vertex repeated => 5 points
54
gw.
gds_write_endel
( );
// end of element
55
//-----------------------------------------------------------------------------
56
// create a polygon 2
57
// use high-level interfaces
58
59
std::vector<int> vx(4);
60
std::vector<int> vy(4);
61
vx[0] = 0; vy[0] = 0;
// signed four-byte integers
62
vx[1] = 0; vy[1] = 500;
63
vx[2] = 1000; vy[2] = 500;
// in this example 1 integer unit = 1 nm
64
vx[3] = 1000; vy[3] = 0;
65
66
gw.
write_boundary
(10002, 0, vx, vy,
false
);
67
//-----------------------------------------------------------------------------
68
// create a polygon 3
69
// for rectangles
70
// use high-level interfaces
71
72
for
(
int
i = 0; i < 1; ++i)
73
gw.
write_box
(10003, 0, 10, 10, 20, 20);
74
75
//-----------------------------------------------------------------------------
76
// create some text, reflected about the x axis
77
78
gw.
gds_write_text
( );
79
gw.
gds_write_layer
( 1 );
80
gw.
gds_write_texttype
( 0 );
81
gw.
gds_write_presentation
( 0, 1, 1 );
// font, hp, vp
82
gw.
gds_write_width
( 500 );
83
gw.
gds_write_strans
( 1, 0, 0 );
// reflect, abs_angle, abs_mag
84
x[0] = 2000;
85
y[0] = 2000;
86
gw.
gds_write_xy
( x, y, 1 );
87
gw.
gds_write_string
(
"reflected"
);
88
gw.
gds_write_endel
( );
89
90
//-----------------------------------------------------------------------------
91
// create some text, using the helper function instead.
92
// arguments: file-descriptor, string, x, y, layer, size
93
// where x, y, and size are in database units (nanometers, usually)
94
95
gw.
gds_create_text
(
"not reflected"
, 2000, 1500, 2, 500 );
96
97
//-----------------------------------------------------------------------------
98
// create a path
99
100
gw.
gds_write_path
( );
101
gw.
gds_write_layer
( 3 );
// layer 3
102
gw.
gds_write_datatype
( 4 );
// datatype 4
103
gw.
gds_write_pathtype
( 2 );
// extended square ends
104
gw.
gds_write_width
( 200 );
// 200 nm wide
105
x[0] = 2000; y[0] = 3000;
106
x[1] = 2000; y[1] = 4000;
107
x[2] = 2500; y[2] = 3500;
108
gw.
gds_write_xy
( x, y, 3 );
109
gw.
gds_write_endel
( );
110
111
//-----------------------------------------------------------------------------
112
// create a box, which is stupid
113
114
gw.
gds_write_box
( );
// write just the token
115
gw.
gds_write_layer
( 6 );
// layer 6, for example
116
gw.
gds_write_boxtype
( 12 );
// boxtype 12, for example same as datatype
117
118
x[0] = 3000; y[0] = 0;
// signed four-byte integers
119
x[1] = 3000; y[1] = 500;
120
x[2] = 4000; y[2] = 500;
// in this example 1 integer unit = 1 nm
121
x[3] = 4000; y[3] = 0;
122
x[4] = 3000; y[4] = 0;
// required repetition of first point (yup, that's stupid)
123
124
gw.
gds_write_xy
( x, y, 5 );
// polygon, four vertices, first vertex repeated => 5 points
125
gw.
gds_write_endel
( );
// end of element
126
127
128
// end the structure (the cell hotdogs)
129
130
gw.
gds_write_endstr
( );
131
132
//-----------------------------------------------------------------------------
133
// Create a new cell, which will contain an instance of the previous cell
134
135
gw.
gds_write_bgnstr
( );
// new cell (structure)
136
gw.
gds_write_strname
(
"sausage"
);
// called "sausage"
137
gw.
gds_write_sref
( );
// contains an instance of...
138
gw.
gds_write_sname
(
"hotdogs"
);
// the cell hotdogs
139
gw.
gds_write_mag
( 5.0 );
// which will be 5 times larger
140
gw.
gds_write_angle
( 15.4 );
// and tilted at some weird angle
141
x[0] = 2000;
142
y[0] = -2000;
143
gw.
gds_write_xy
( x, y, 1 );
// at these coordinates (database units)
144
gw.
gds_write_endel
( );
// end of element
145
gw.
gds_write_endstr
( );
// end of structure (cell)
146
147
//-----------------------------------------------------------------------------
148
// Create a new cell "meatball" containing an array of the cell "sausage"
149
150
gw.
gds_write_bgnstr
( );
// new cell
151
gw.
gds_write_strname
(
"meatball"
);
// called "meatball"
152
gw.
gds_write_aref
( );
// containing an array of...
153
gw.
gds_write_sname
(
"sausage"
);
// the cell "sausage"
154
gw.
gds_write_colrow
( 2, 5 );
// 2 columns, 5 rows
155
156
x[0] = 5000; y[0] = 5000;
// array anchor point
157
158
x[1] = 85000; y[1] = 5000;
// displacement from anchor plus ncols*pitch
159
// which makes the column pitch 40 um
160
x[2] = 5000; y[2] = 205000;
// displacement from anchor plus nrows*pitch
161
// which makes the row pitch 40 um
162
gw.
gds_write_xy
( x, y, 3 );
// See how you could have a diagonal matrix?
163
// That would be so goofy!
164
gw.
gds_write_endel
( );
// end of element
165
gw.
gds_write_endstr
( );
// end of structure (cell) "meatball"
166
167
// end of library
168
169
gw.
gds_write_endlib
( );
170
171
printf(
"\nDone. Look at %s\n\n"
, argv[1] );
172
173
return
0;
174
}
GdsWriter.h
write GDSII file
GdsParser::GdsWriter
Definition
GdsWriter.h:91
GdsParser::GdsWriter::gds_create_text
void gds_create_text(const char *str, int x, int y, int layer, int size)
wrapper to create text
GdsParser::GdsWriter::gds_write_layer
void gds_write_layer(short int layer)
write LAYER
GdsParser::GdsWriter::gds_write_angle
void gds_write_angle(double angle)
write ANGLE
GdsParser::GdsWriter::gds_write_texttype
void gds_write_texttype(short int dt)
write TEXTTYPE
GdsParser::GdsWriter::gds_write_strans
void gds_write_strans(BOOL reflect, BOOL abs_angle, BOOL abs_mag)
write STRANS
GdsParser::GdsWriter::gds_write_width
void gds_write_width(int width)
write WIDTH
GdsParser::GdsWriter::gds_write_bgnstr
void gds_write_bgnstr()
write BGNSTR
GdsParser::GdsWriter::gds_write_colrow
void gds_write_colrow(int ncols, int nrows)
write COLROW
GdsParser::GdsWriter::gds_write_endlib
void gds_write_endlib()
write ENDLIB
GdsParser::GdsWriter::gds_write_sname
void gds_write_sname(const char *s)
write SNAME
GdsParser::GdsWriter::gds_write_strname
void gds_write_strname(const char *name)
write STRNAME
GdsParser::GdsWriter::gds_write_box
void gds_write_box()
write BOX
GdsParser::GdsWriter::gds_write_datatype
void gds_write_datatype(short int dt)
write DATATYPE
GdsParser::GdsWriter::gds_write_string
void gds_write_string(const char *s)
write STRING
GdsParser::GdsWriter::create_lib
void create_lib(const char *libname, double dbu_uu, double dbu_m)
create GDSII library
GdsParser::GdsWriter::gds_write_endstr
void gds_write_endstr()
write ENDSTR
GdsParser::GdsWriter::write_box
void write_box(int layer, int datatype, int xl, int yl, int xh, int yh)
write a box object
GdsParser::GdsWriter::gds_write_text
void gds_write_text()
write TEXT
GdsParser::GdsWriter::write_boundary
void write_boundary(int layer, int datatype, std::vector< int > const &vx, std::vector< int > const &vy, bool has_last=true)
write a boundary object
GdsParser::GdsWriter::gds_write_boxtype
void gds_write_boxtype(short int dt)
write BOXTYPE
GdsParser::GdsWriter::gds_write_aref
void gds_write_aref()
write AREF
GdsParser::GdsWriter::gds_write_sref
void gds_write_sref()
write SREF
GdsParser::GdsWriter::gds_write_path
void gds_write_path()
write PATH
GdsParser::GdsWriter::gds_write_endel
void gds_write_endel()
write ENDEL
GdsParser::GdsWriter::gds_write_pathtype
void gds_write_pathtype(short int pt)
write PATHTYPE
GdsParser::GdsWriter::gds_write_presentation
void gds_write_presentation(int font, int vp, int hp)
write PRESENTATION
GdsParser::GdsWriter::gds_write_xy
void gds_write_xy(const int *x, const int *y, int n, bool has_last=true)
write XY
GdsParser::GdsWriter::gds_write_boundary
void gds_write_boundary()
write BOUNDARY
GdsParser::GdsWriter::gds_write_mag
void gds_write_mag(double mag)
write MAG
main
int main()
Definition
test_ChromaticNumber.cpp:78
Generated on
for Limbo by
1.17.0