Limbo 3.5.4
Loading...
Searching...
No Matches
test_gdsdb.cpp
Go to the documentation of this file.
1
7
8#include <iostream>
12
17int main(int argc, char** argv)
18{
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
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
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}
#define limboAssert(condition)
custom assertion without message
Definition AssertMsg.h:36
Wrapper to GDSII read and write with GDSII database GdsParser::GdsDB::GdsDB.
Various GDSII objects and a top GDSII database.
header to include PrintMsg.h and AssertMsg.h
std::vector< std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > > const & objects() const
Definition GdsObjects.h:632
std::string const & name() const
Definition GdsObjects.h:627
GdsCell & addCell(std::string const &name="")
add a cell and return the reference to the new cell
void setUnit(double u)
Definition GdsObjects.h:700
std::string const & libname() const
Definition GdsObjects.h:693
double unit() const
Definition GdsObjects.h:698
GdsCell extractCell(std::string const &cellName) const
extract a cell into a new cell with flatten hierarchies
double precision() const
Definition GdsObjects.h:703
void setPrecision(double p)
Definition GdsObjects.h:705
void setLibname(std::string const &n)
Definition GdsObjects.h:695
std::vector< GdsCell > const & cells() const
Definition GdsObjects.h:708
read GDSII file with GDSII database GdsParser::GdsDB::GdsDB
Definition GdsIO.h:27
write GDSII file with GDSII database GdsParser::GdsDB::GdsDB
Definition GdsIO.h:121
an action function for delete a cell
a helper to facilitate actions on different GDSII objects.
int main()