Hurricane VLSI Database


Polygon.h
1// -*- C++ -*-
2//
3// Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
4//
5// This file is part of Hurricane.
6//
7// Hurricane is free software: you can redistribute it and/or modify
8// it under the terms of the GNU Lesser General Public License as
9// published by the Free Software Foundation, either version 3 of the
10// License, or (at your option) any later version.
11//
12// Hurricane is distributed in the hope that it will be useful, but
13// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
14// TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU
15// General Public License for more details.
16//
17// You should have received a copy of the Lesser GNU General Public
18// License along with Hurricane. If not, see
19// <http://www.gnu.org/licenses/>.
20//
21// +-----------------------------------------------------------------+
22// | H U R R I C A N E |
23// | V L S I B a c k e n d D a t a - B a s e |
24// | |
25// | Author : Jean-Paul Chaput |
26// | E-mail : Jean-Paul.Chaput@lip6.fr |
27// | =============================================================== |
28// | C++ Header : "./hurricane/Polygon.h" |
29// +-----------------------------------------------------------------+
30
31
32#ifndef HURRICANE_POLYGON_H
33#define HURRICANE_POLYGON_H
34
35#include "hurricane/Component.h"
36#include "hurricane/Polygons.h"
37
38
39namespace Hurricane {
40
41 class Layer;
42
43
44 class Polygon : public Component {
45 public:
47 public:
48 static const uint32_t Above = (1<<0);
49 static const uint32_t YSteps = (1<<1);
50 static const uint32_t XSteps = (1<<2);
51 static const uint32_t XIncrease = (1<<3);
52 static const uint32_t YIncrease = (1<<4);
53 static const uint32_t Horizontal = (1<<5);
54 static const uint32_t Vertical = (1<<6);
55
56 public:
57 class Edge {
58 public:
59 Edge ( Point origin, Point extremity, uint32_t flags );
60 inline size_t getSize () const;
61 Point getPoint ( size_t i ) const;
62 inline bool isPositiveSlope () const;
63 inline bool isYIncrease () const;
64 inline bool isXIncrease () const;
65 inline bool isHV () const;
66 inline bool isXSteps () const;
67 inline bool isYSteps () const;
68 void translate ( DbU::Unit dx, DbU::Unit dy );
69 string _getTypeName () const;
70 string _getString () const;
71 Record* _getRecord () const;
72 private:
73 uint32_t _flags;
74 DbU::Unit _xyOrigin;
75 vector<DbU::Unit> _steps;
76 };
77
78 public:
79 class Points_Manhattan : public PointHC {
80 public:
81 class Locator : public PointHL {
82 public:
83 Locator ( const Polygon* );
84 inline Locator ( const Locator& );
85 virtual Point getElement () const;
86 virtual PointHL* getClone () const;
87 virtual bool isValid () const;
88 virtual void progress ();
89 virtual string _getString () const;
90 protected:
91 const Polygon* _polygon;
92 size_t _iEdge;
93 size_t _iPoint;
94 };
95 public:
96 inline Points_Manhattan ( const Polygon* );
97 inline Points_Manhattan ( const Points_Manhattan& );
98 virtual PointHC* getClone () const;
99 virtual PointHL* getLocator () const;
100 virtual string _getString () const;
101 protected:
102 const Polygon* _polygon;
103 };
104
105 public:
106 static Polygon* create ( Net*, const Layer*, const std::vector<Point>& );
107 static float getSlope ( const Point&, const Point& );
108 public:
109 virtual bool isNonRectangle () const;
110 virtual bool isManhattanized () const;
111 virtual DbU::Unit getX () const;
112 virtual DbU::Unit getY () const;
113 inline const vector<Point>& getPoints () const;
114 inline const vector<Edge*>& getEdges () const;
115 virtual size_t getPointsSize () const;
116 virtual Point getPoint ( size_t ) const;
117 virtual Box getBoundingBox () const;
118 virtual Box getBoundingBox ( const BasicLayer* ) const;
119 void getSubPolygons ( vector< vector<Point> >& ) const;
120 virtual const Layer* getLayer () const;
121 void setLayer ( const Layer* layer );
122 virtual void translate ( const DbU::Unit& dx, const DbU::Unit& dy );
123 void setPoints ( const vector<Point>& );
124 static float getSign ( const vector<Point>&, size_t );
125 float getSlope ( size_t i ) const;
126 void manhattanize ();
127 virtual Points getMContour () const;
128 virtual void _toJson ( JsonWriter* ) const;
129 static JsonObject* getJsonObject ( unsigned long flags );
130 virtual string _getTypeName () const;
131 virtual string _getString () const;
132 virtual Record* _getRecord () const;
133 protected:
134 Polygon ( Net*, const Layer*, const std::vector<Point>& );
135 ~Polygon ();
136 private:
137 const Layer* _layer;
138 std::vector<Point> _points;
139 std::vector<Edge*> _edges;
140 };
141
142
143 inline const vector<Polygon::Edge*>& Polygon::getEdges () const { return _edges; }
144 inline const vector<Point>& Polygon::getPoints () const { return _points; }
145
146 inline bool Polygon::Edge::isYIncrease () const { return (_flags & Polygon::YIncrease); }
147 inline bool Polygon::Edge::isXIncrease () const { return (_flags & Polygon::XIncrease); }
148 inline bool Polygon::Edge::isPositiveSlope () const { return not ( (_flags & Polygon::XIncrease) xor (_flags & Polygon::YIncrease) ); }
149 inline bool Polygon::Edge::isHV () const { return (_flags & (Polygon::Horizontal|Polygon::Vertical)); }
150 inline bool Polygon::Edge::isXSteps () const { return (_flags & Polygon::XSteps); }
151 inline bool Polygon::Edge::isYSteps () const { return (_flags & Polygon::YSteps); }
152 inline size_t Polygon::Edge::getSize () const { if (isHV() or (_steps.size() < 2)) return 1; return (_steps.size() - 1)*2; }
153
154
155 inline Polygon::Points_Manhattan::Locator::Locator ( const Locator &locator )
156 : PointHL ()
157 , _polygon(locator._polygon)
158 , _iEdge (locator._iEdge)
159 , _iPoint (locator._iPoint)
160 { }
161
162
163 inline Polygon::Points_Manhattan::Points_Manhattan ( const Polygon* polygon )
164 : PointHC ()
165 , _polygon(polygon)
166 { }
167
168
169 inline Polygon::Points_Manhattan::Points_Manhattan ( const Points_Manhattan& other )
170 : PointHC()
171 , _polygon(other._polygon)
172 { }
173
174
175 class JsonPolygon : public JsonComponent {
176 public:
177 static void initialize ();
178 JsonPolygon ( unsigned long flags );
179 virtual string getTypeName () const;
180 virtual JsonPolygon* clone ( unsigned long ) const;
181 virtual void toData ( JsonStack& );
182 };
183
184
185} // Hurricane namespace.
186
187
188INSPECTOR_P_SUPPORT(Hurricane::Polygon::Edge);
189INSPECTOR_P_SUPPORT(Hurricane::Polygon);
190
191#endif // HURRICANE_POLYGON_H
BasicLayer description (API)
Definition BasicLayer.h:42
Box description (API)
Definition Box.h:29
Collection description (API)
Definition Collection.h:39
Component description (API)
Definition Component.h:43
std::int64_t Unit
Definition DbU.h:67
Generic Collection auto-pointer.
Definition Collection.h:235
Horizontal description (API)
Definition Horizontal.h:36
Support for JSON export.
Definition JsonObject.h:83
Layer description (API)
Definition Layer.h:50
Locator description (API)
Definition Locator.h:33
Net description (API)
Definition Net.h:46
Point description (API)
Definition Point.h:30
Polygon description (API)
Definition Polygon.h:44
static Polygon * create(Net *, const Layer *, const std::vector< Point > &)
Component Super
Definition Polygon.h:46
Vertical description (API)
Definition Vertical.h:36
Contains Almost Everything.
Definition BasicLayer.h:39


Generated by doxygen 1.9.7 on Fri Sep 27 2024 Return to top of page
Hurricane VLSI Database Copyright © 2000-2020 Bull S.A. All rights reserved