Limbo
3.5.4
Toggle main menu visibility
Loading...
Searching...
No Matches
test
parsers
gdsii
test_gdsdb.cpp
Go to the documentation of this file.
1
7
8
#include <iostream>
9
#include <
limbo/parsers/gdsii/gdsdb/GdsIO.h
>
10
#include <
limbo/parsers/gdsii/gdsdb/GdsObjectHelpers.h
>
11
#include <
limbo/preprocessor/Msg.h
>
12
17
int
main
(
int
argc,
char
** argv)
18
{
19
GdsParser::GdsDB::GdsDB
db;
20
if
(argc > 2 && argc <= 4)
21
{
22
// test simple read and write
23
GdsParser::GdsDB::GdsReader
reader (db);
24
limboAssert
(reader(argv[1]));
25
26
for
(std::vector<GdsParser::GdsDB::GdsCell>::const_iterator it = db.
cells
().begin(); it != db.
cells
().end(); ++it)
27
std::cout <<
"cell: "
<< it->name() << std::endl;
28
29
// write
30
GdsParser::GdsDB::GdsWriter
gw (db);
31
gw(argv[2]);
32
33
std::cout <<
"4 arguments to test flatten: input gds, output gds, flat output gds, flat cell name"
<< std::endl;
34
}
35
else
if
(argc > 4)
36
{
37
// test simple read and write
38
GdsParser::GdsDB::GdsReader
reader (db);
39
limboAssert
(reader(argv[1]));
40
41
for
(std::vector<GdsParser::GdsDB::GdsCell>::const_iterator it = db.
cells
().begin(); it != db.
cells
().end(); ++it)
42
std::cout <<
"cell: "
<< it->name() << std::endl;
43
44
#if 0
45
// try removing all text records except for the top cell
46
// iterate through all cells
47
for
(std::vector<GdsParser::GdsDB::GdsCell>::iterator it = db.
cells
().begin(); it != db.
cells
().end(); ++it)
48
{
49
GdsParser::GdsDB::GdsCell
& cell = *it;
50
if
(cell.
name
() != argv[4])
// check the non-top cell
51
{
52
// iterate through all objects
53
for
(std::vector<GdsParser::GdsDB::GdsCell::object_entry_type>::iterator itc = cell.
objects
().begin(), itce = cell.
objects
().end(); itc != itce; )
54
{
55
if
(itc->first == ::GdsParser::GdsRecords::TEXT)
// find TEXT records
56
{
57
std::vector<GdsParser::GdsDB::GdsCell::object_entry_type>::iterator itclast = itce - 1;
58
if
(itc != itclast)
// swap current object with the last object
59
{
60
std::swap(*itc, *itclast);
61
}
62
// delete the last object
63
GdsParser::GdsDB::GdsObjectHelpers
()(itclast->first, itclast->second,
GdsParser::GdsDB::DeleteCellObjectAction
(*itclast));
64
// update the object array in the cell
65
cell.
objects
().pop_back();
66
// update end iterator
67
itce = cell.
objects
().end();
68
}
69
else
70
{
71
++itc;
72
}
73
}
74
}
75
}
76
#endif
77
78
// test flatten
79
GdsParser::GdsDB::GdsCell
flatCell = db.
extractCell
(argv[4]);
80
81
GdsParser::GdsDB::GdsDB
flatDB;
82
flatDB.
setLibname
(db.
libname
());
83
flatDB.
setUnit
(db.
unit
());
84
flatDB.
setPrecision
(db.
precision
());
85
flatDB.
addCell
(flatCell);
86
87
// write flatten cell
88
GdsParser::GdsDB::GdsWriter
flatGw (flatDB);
89
flatGw(argv[3]);
90
}
91
else
std::cout <<
"at least 4 arguments are required: input gds, output gds, flat output gds, flat cell name"
<< std::endl;
92
93
return
0;
94
}
limboAssert
#define limboAssert(condition)
custom assertion without message
Definition
AssertMsg.h:36
GdsIO.h
Wrapper to GDSII read and write with GDSII database GdsParser::GdsDB::GdsDB.
GdsObjectHelpers.h
Various GDSII objects and a top GDSII database.
Msg.h
header to include PrintMsg.h and AssertMsg.h
GdsParser::GdsDB::GdsCell
Definition
GdsObjects.h:568
GdsParser::GdsDB::GdsCell::objects
std::vector< std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > > const & objects() const
Definition
GdsObjects.h:632
GdsParser::GdsDB::GdsCell::name
std::string const & name() const
Definition
GdsObjects.h:627
GdsParser::GdsDB::GdsDB
Definition
GdsObjects.h:661
GdsParser::GdsDB::GdsDB::addCell
GdsCell & addCell(std::string const &name="")
add a cell and return the reference to the new cell
GdsParser::GdsDB::GdsDB::setUnit
void setUnit(double u)
Definition
GdsObjects.h:700
GdsParser::GdsDB::GdsDB::libname
std::string const & libname() const
Definition
GdsObjects.h:693
GdsParser::GdsDB::GdsDB::unit
double unit() const
Definition
GdsObjects.h:698
GdsParser::GdsDB::GdsDB::extractCell
GdsCell extractCell(std::string const &cellName) const
extract a cell into a new cell with flatten hierarchies
GdsParser::GdsDB::GdsDB::precision
double precision() const
Definition
GdsObjects.h:703
GdsParser::GdsDB::GdsDB::setPrecision
void setPrecision(double p)
Definition
GdsObjects.h:705
GdsParser::GdsDB::GdsDB::setLibname
void setLibname(std::string const &n)
Definition
GdsObjects.h:695
GdsParser::GdsDB::GdsDB::cells
std::vector< GdsCell > const & cells() const
Definition
GdsObjects.h:708
GdsParser::GdsDB::GdsReader
read GDSII file with GDSII database GdsParser::GdsDB::GdsDB
Definition
GdsIO.h:27
GdsParser::GdsDB::GdsWriter
write GDSII file with GDSII database GdsParser::GdsDB::GdsDB
Definition
GdsIO.h:121
GdsParser::GdsDB::DeleteCellObjectAction
an action function for delete a cell
Definition
GdsObjectHelpers.h:117
GdsParser::GdsDB::GdsObjectHelpers
a helper to facilitate actions on different GDSII objects.
Definition
GdsObjectHelpers.h:30
main
int main()
Definition
test_ChromaticNumber.cpp:78
Generated on
for Limbo by
1.17.0