Limbo 3.5.4
Loading...
Searching...
No Matches
GdsObjects.h
Go to the documentation of this file.
1
7
8#ifndef LIMBO_PARSERS_GDSII_GDSDB_GDSOBJECTS_H
9#define LIMBO_PARSERS_GDSII_GDSDB_GDSOBJECTS_H
10
11#include <boost/geometry.hpp>
12// use adapted boost.polygon in boost.geometry, which is compatible to rtree
13#include <boost/geometry/geometries/adapted/boost_polygon.hpp>
14#include <boost/geometry/geometries/geometries.hpp>
16
18namespace GdsParser
19{
21namespace GdsDB
22{
23
24// some shortcuts for namespace
25namespace gtl = boost::polygon;
26namespace bg = boost::geometry;
27
28// forward declaration
29class GdsCell;
30class GdsDB;
31
37{
38 public:
40 typedef int coordinate_type;
44 typedef gtl::point_data<coordinate_type> point_type;
46 typedef gtl::point_data<double> float_point_type;
48 typedef gtl::interval_data<coordinate_type> interval_type;
50 typedef gtl::rectangle_data<coordinate_type> rectangle_type;
52 typedef gtl::polygon_data<coordinate_type> polygon_type;
54 typedef gtl::polygon_90_set_data<coordinate_type> polygon_set_type;
56
61 GdsObject(GdsObject const& rhs);
69 virtual ~GdsObject();
70};
71
75class GdsShape : public GdsObject
76{
77 public:
80
85 GdsShape(GdsShape const& rhs);
91
92 // accessors
94 int layer() const {return m_layer;}
96 void setLayer(int l) {m_layer = l;}
97
99 int datatype() const {return m_datatype;}
101 void setDatatype(int d) {m_datatype = d;}
102 protected:
105};
106
126class GdsRectangle : public GdsShape, public gtl::rectangle_data<int>
127{
128 public:
132 typedef gtl::rectangle_data<int> base_ext_type;
133
144};
145
175class GdsPolygon : public GdsShape, public gtl::polygon_data<GdsShape::coordinate_type>
176{
177 public:
181 typedef gtl::polygon_data<GdsShape::coordinate_type> base_ext_type;
183 typedef base_type::coordinate_type coordinate_type;
184 typedef base_type::point_type point_type;
186
191 GdsPolygon(GdsPolygon const& rhs);
197};
198
232class GdsPath : public GdsShape, public bg::model::linestring<GdsShape::point_type>
233{
234 public:
238 typedef bg::model::linestring<GdsShape::point_type> base_ext_type;
239
244 GdsPath(GdsPath const& rhs);
250
251 // accessors
253 int pathtype() const {return m_pathtype;}
255 void setPathtype(int p) {m_pathtype = p;}
256
258 coordinate_type width() const {return m_width;}
261
266
271
275 template <typename Iterator>
276 void set(Iterator first, Iterator last) {this->assign(first, last);}
277
281 protected:
286};
287
320class GdsText : public GdsShape
321{
322 public:
325
330 GdsText(GdsText const& rhs);
336
337 // accessors
339 int texttype() const {return m_texttype;}
341 void setTexttype(int t) {m_texttype = t;}
342
344 std::string const& text() const {return m_text;}
346 void setText(std::string const& t) {m_text = t;}
347
349 int width() const {return m_width;}
351 void setWidth(int w) {m_width = w;}
352
354 point_type const& position() const {return m_position;}
356 void setPosition(point_type const& p) {m_position = p;}
357
359 int presentation() const {return m_presentation;}
362
364 double angle() const {return m_angle;}
366 void setAngle(double a) {m_angle = a;}
367
369 double magnification() const {return m_magnification;}
371 void setMagnification(double m) {m_magnification = m;}
372
374 int strans() const {return m_strans;}
376 void setStrans(int s) {m_strans = s;}
377 protected:
379 std::string m_text;
383 double m_angle;
386};
387
406{
407 public:
410
421
422 // accessors
424 std::string const& refCell() const {return m_refCell;}
426 void setRefCell(std::string const& r) {m_refCell = r;}
427
429 point_type const& position() const {return m_position;}
431 void setPosition(point_type const& p) {m_position = p;}
432
434 double angle() const {return m_angle;}
436 void setAngle(double a) {m_angle = a;}
437
439 double magnification() const {return m_magnification;}
441 void setMagnification(double m) {m_magnification = m;}
442
444 int strans() const {return m_strans;}
446 void setStrans(int s) {m_strans = s;}
447
453 GdsCell extractCellRef(GdsDB const& gdsDB, GdsCell const& srcCell) const;
454 protected:
455 std::string m_refCell;
457 double m_angle;
460};
461
486{
487 public:
490
501
502 // accessors
504 std::string const& refCell() const {return m_refCell;}
506 void setRefCell(std::string const& r) {m_refCell = r;}
507
509 int columns() const {return m_columns;}
511 void setColumns(int c) {m_columns = c;}
512
514 int rows() const {return m_rows;}
516 void setRows(int r) {m_rows = r;}
517
520 coordinate_type spacing(unsigned int idx) const {return m_spacing[idx];}
523 void setSpacing(unsigned int idx, coordinate_type s) {m_spacing[idx] = s;}
524
526 std::vector<point_type> const& positions() const {return m_vPosition;}
528 std::vector<point_type>& positions() {return m_vPosition;}
529
531 double angle() const {return m_angle;}
533 void setAngle(double a) {m_angle = a;}
534
536 double magnification() const {return m_magnification;}
538 void setMagnification(double m) {m_magnification = m;}
539
541 int strans() const {return m_strans;}
543 void setStrans(int s) {m_strans = s;}
544 protected:
545 std::string m_refCell;
547 int m_rows;
549 std::vector<point_type> m_vPosition;
550 double m_angle;
553};
554
567class GdsCell : public GdsObject
568{
569 public:
573 typedef std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject*> object_entry_type;
574
579 GdsCell(GdsCell const& rhs);
585
589 void addPolygon(int layer, int datatype, std::vector<point_type> const& vPoint);
597 void addPath(int layer, int datatype, int pathtype, int width, int bgnextn, int endextn, std::vector<point_type> const& vPoint);
608 void addText(int layer, int datatype, int texttype, std::string const& str, point_type const& position, int width, int presentation, double angle, double magnification, int strans);
614 void addCellReference(std::string const& sname, point_type const& position, double angle, double magnification, int strans);
623 void addCellArray(std::string const& sname, int columns, int rows, int spacing[2], std::vector<point_type> const& vPosition, double angle, double magnification, int strans);
624
625 // accessors
627 std::string const& name() const {return m_name;}
629 void setName(std::string const& n) {m_name = n;}
630
632 std::vector<std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject*> > const& objects() const {return m_vObject;}
634 std::vector<std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject*> >& objects() {return m_vObject;}
635 protected:
638 void copy(GdsCell const& rhs);
640 void destroy();
641
642 std::string m_name;
643 std::vector<object_entry_type> m_vObject;
644};
645
660class GdsDB : public GdsObject
661{
662 public:
665
670 GdsDB(GdsDB const& rhs);
673 GdsDB& operator=(GdsDB const& rhs);
676
679 GdsCell& addCell(std::string const& name = "");
682 GdsCell& addCell(GdsCell const& cell);
683
684 // accessors
686 std::string const& header() const {return m_header;}
688 void setHeader(std::string const& h) {m_header = h;}
690 void setHeader(int h);
691
693 std::string const& libname() const {return m_libname;}
695 void setLibname(std::string const& n) {m_libname = n;}
696
698 double unit() const {return m_unit;}
700 void setUnit(double u) {m_unit = u;}
701
703 double precision() const {return m_precision;}
705 void setPrecision(double p) {m_precision = p;}
706
708 std::vector<GdsCell> const& cells() const {return m_vCell;}
710 std::vector<GdsCell>& cells() {return m_vCell;}
711
716 GdsCell const* getCell(std::string const& cellName) const;
721 GdsCell* getCell(std::string const& cellName);
722
725 GdsCell extractCell(std::string const& cellName) const;
726 protected:
727 std::string m_header;
728 std::string m_libname;
729 double m_unit;
730 double m_precision;
731 std::vector<GdsCell> m_vCell;
732 std::map<std::string, unsigned int> m_mCellName2Idx;
733};
734
735} // namespace GdsDB
736} // namespace GdsParser
737
738
740namespace boost { namespace geometry { namespace traits {
741
744
746template <>
747struct tag<GdsParser::GdsDB::GdsRectangle > : public tag<GdsParser::GdsDB::GdsRectangle::base_ext_type>
748{
749};
750
751template <>
752struct point_type<GdsParser::GdsDB::GdsRectangle >
753{
757};
758
759
762
764template <>
765struct tag<GdsParser::GdsDB::GdsPolygon > : public tag<GdsParser::GdsDB::GdsPolygon::base_ext_type>
766{
767};
768
769template <>
770struct point_type<GdsParser::GdsDB::GdsPolygon >
771{
775};
776
777
778}}} // namespace boost // namespace geometry // namespace traits
779
781namespace boost { namespace polygon {
782
784template <>
785struct geometry_concept<GdsParser::GdsDB::GdsRectangle>
786{
788 typedef rectangle_concept type;
790};
791
793template <>
794struct geometry_concept<GdsParser::GdsDB::GdsPolygon>
795{
797 typedef polygon_concept type;
799};
800
801}} // namespace boost // namespace polygon
802
803#endif
read GDSII file
GdsCellArray(GdsCellArray const &rhs)
std::vector< point_type > & positions()
Definition GdsObjects.h:528
GdsCellArray()
default constructor
GdsObject base_type
base type
Definition GdsObjects.h:489
void setRefCell(std::string const &r)
Definition GdsObjects.h:506
double m_magnification
magnification
Definition GdsObjects.h:551
std::vector< point_type > m_vPosition
array of positions
Definition GdsObjects.h:549
std::string const & refCell() const
Definition GdsObjects.h:504
std::string m_refCell
reference cell
Definition GdsObjects.h:545
std::vector< point_type > const & positions() const
Definition GdsObjects.h:526
int m_columns
number of columns
Definition GdsObjects.h:546
void setSpacing(unsigned int idx, coordinate_type s)
Definition GdsObjects.h:523
coordinate_type spacing(unsigned int idx) const
Definition GdsObjects.h:520
GdsCellArray & operator=(GdsCellArray const &rhs)
coordinate_type m_spacing[2]
spacing of x and y
Definition GdsObjects.h:548
void addPath(int layer, int datatype, int pathtype, int width, int bgnextn, int endextn, std::vector< point_type > const &vPoint)
void addText(int layer, int datatype, int texttype, std::string const &str, point_type const &position, int width, int presentation, double angle, double magnification, int strans)
std::vector< object_entry_type > m_vObject
gdsii objects with types
Definition GdsObjects.h:643
GdsObject base_type
base type
Definition GdsObjects.h:571
std::vector< std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > > & objects()
Definition GdsObjects.h:634
std::vector< std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > > const & objects() const
Definition GdsObjects.h:632
void setName(std::string const &n)
Definition GdsObjects.h:629
std::string const & name() const
Definition GdsObjects.h:627
void addCellReference(std::string const &sname, point_type const &position, double angle, double magnification, int strans)
GdsCell()
default constructor
void destroy()
destroy objects in m_vObject
GdsCell & operator=(GdsCell const &rhs)
void copy(GdsCell const &rhs)
void addPolygon(int layer, int datatype, std::vector< point_type > const &vPoint)
GdsCell(GdsCell const &rhs)
std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > object_entry_type
use pair of GDSII record and GDSII object to describe each object entry
Definition GdsObjects.h:573
void addCellArray(std::string const &sname, int columns, int rows, int spacing[2], std::vector< point_type > const &vPosition, double angle, double magnification, int strans)
std::string m_name
cell name
Definition GdsObjects.h:642
void setPosition(point_type const &p)
Definition GdsObjects.h:431
GdsCellReference(GdsCellReference const &rhs)
std::string const & refCell() const
Definition GdsObjects.h:424
double m_magnification
magnification
Definition GdsObjects.h:458
std::string m_refCell
string to reference cell
Definition GdsObjects.h:455
GdsCellReference()
default constructor
point_type const & position() const
Definition GdsObjects.h:429
GdsCellReference & operator=(GdsCellReference const &rhs)
void setRefCell(std::string const &r)
Definition GdsObjects.h:426
GdsCell extractCellRef(GdsDB const &gdsDB, GdsCell const &srcCell) const
double m_precision
precision
Definition GdsObjects.h:730
GdsCell & addCell(std::string const &name="")
add a cell and return the reference to the new cell
GdsCell * getCell(std::string const &cellName)
given cell name and return the pointer to the cell, return NULL if not found
GdsDB(GdsDB const &rhs)
void setUnit(double u)
Definition GdsObjects.h:700
std::vector< GdsCell > m_vCell
cell array
Definition GdsObjects.h:731
std::string m_header
header
Definition GdsObjects.h:727
GdsCell const * getCell(std::string const &cellName) const
given cell name and return the pointer to the cell, return NULL if not found
std::string const & libname() const
Definition GdsObjects.h:693
std::vector< GdsCell > & cells()
Definition GdsObjects.h:710
GdsObject base_type
base type
Definition GdsObjects.h:664
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
std::string const & header() const
Definition GdsObjects.h:686
std::string m_libname
name of library
Definition GdsObjects.h:728
void setPrecision(double p)
Definition GdsObjects.h:705
std::map< std::string, unsigned int > m_mCellName2Idx
map from cell name to index
Definition GdsObjects.h:732
GdsDB & operator=(GdsDB const &rhs)
void setLibname(std::string const &n)
Definition GdsObjects.h:695
std::vector< GdsCell > const & cells() const
Definition GdsObjects.h:708
void setHeader(std::string const &h)
Definition GdsObjects.h:688
GdsCell & addCell(GdsCell const &cell)
add a cell
int coordinate_type
coordinate types
Definition GdsObjects.h:40
GdsObject & operator=(GdsObject const &rhs)
assignment
gtl::interval_data< coordinate_type > interval_type
interval type
Definition GdsObjects.h:48
gtl::point_data< double > float_point_type
float point type to avoid numerical issue
Definition GdsObjects.h:46
gtl::polygon_90_set_data< coordinate_type > polygon_set_type
polygon set type
Definition GdsObjects.h:54
GdsObject(GdsObject const &rhs)
copy constructor
virtual ~GdsObject()
destructor
gtl::point_data< coordinate_type > point_type
Definition GdsObjects.h:44
gtl::polygon_data< coordinate_type > polygon_type
polygon type
Definition GdsObjects.h:52
GdsObject()
default constructor
gtl::rectangle_data< coordinate_type > rectangle_type
rectangle type
Definition GdsObjects.h:50
coordinate_type bgnExtn() const
Definition GdsObjects.h:263
void set(Iterator first, Iterator last)
set path
Definition GdsObjects.h:276
GdsShape base_type
base type
Definition GdsObjects.h:236
GdsPath(GdsPath const &rhs)
coordinate_type m_endextn
end point extension
Definition GdsObjects.h:285
coordinate_type width() const
Definition GdsObjects.h:258
void setWidth(coordinate_type w)
Definition GdsObjects.h:260
GdsPath()
default constructor
bg::model::linestring< GdsShape::point_type > base_ext_type
use a linestring to describe path
Definition GdsObjects.h:238
coordinate_type m_bgnextn
begin point extension
Definition GdsObjects.h:284
coordinate_type endExtn() const
Definition GdsObjects.h:268
GdsPolygon toPolygon() const
convert from path to polygon description
coordinate_type m_width
path width
Definition GdsObjects.h:283
void setBgnExtn(coordinate_type e)
Definition GdsObjects.h:265
GdsPath & operator=(GdsPath const &rhs)
void setEndExtn(coordinate_type e)
Definition GdsObjects.h:270
GdsPolygon(GdsPolygon const &rhs)
GdsPolygon & operator=(GdsPolygon const &rhs)
GdsPolygon()
default constructor
GdsShape base_type
base type
Definition GdsObjects.h:179
gtl::polygon_data< GdsShape::coordinate_type > base_ext_type
use polygon_data as polygon type
Definition GdsObjects.h:181
GdsRectangle(GdsRectangle const &rhs)
GdsRectangle & operator=(GdsRectangle const &rhs)
GdsRectangle()
default constructor
GdsShape base_type
base type
Definition GdsObjects.h:130
gtl::rectangle_data< int > base_ext_type
rectangle type
Definition GdsObjects.h:132
GdsShape & operator=(GdsShape const &rhs)
GdsObject base_type
base type
Definition GdsObjects.h:79
GdsShape()
default constructor
GdsShape(GdsShape const &rhs)
double magnification() const
Definition GdsObjects.h:369
GdsText(GdsText const &rhs)
GdsText()
default constructor
void setMagnification(double m)
Definition GdsObjects.h:371
void setText(std::string const &t)
Definition GdsObjects.h:346
int m_presentation
presentation
Definition GdsObjects.h:382
point_type const & position() const
Definition GdsObjects.h:354
void setPosition(point_type const &p)
Definition GdsObjects.h:356
GdsShape base_type
base type
Definition GdsObjects.h:324
std::string const & text() const
Definition GdsObjects.h:344
GdsText & operator=(GdsText const &rhs)
std::string m_text
text string
Definition GdsObjects.h:379
void setAngle(double a)
Definition GdsObjects.h:366
double m_magnification
magnification
Definition GdsObjects.h:384
point_type m_position
position
Definition GdsObjects.h:380
namespace for Limbo.GdsParser.GdsDB
Definition GdsIO.h:23
namespace for Limbo.GdsParser
Definition GdsIO.h:20
Boost.Geometry.
Definition GdsObjects.h:740