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 #pragma once
33 #include "hurricane/Component.h"
34 #include "hurricane/Polygons.h"
35 
36 
37 namespace Hurricane {
38 
39  class Layer;
40 
41 
42  class Polygon : public Component {
43  public:
44  typedef Component Super;
45  public:
46  static const uint32_t Above = (1<<0);
47  static const uint32_t YSteps = (1<<1);
48  static const uint32_t XSteps = (1<<2);
49  static const uint32_t XIncrease = (1<<3);
50  static const uint32_t YIncrease = (1<<4);
51  static const uint32_t Horizontal = (1<<5);
52  static const uint32_t Vertical = (1<<6);
53  static const uint32_t Convex = (1<<7);
54  static const uint32_t Polygon45 = (1<<8);
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  static void normalize ( std::vector<Point>&, uint32_t& flags );
109  public:
110  virtual bool isNonRectangle () const;
111  virtual bool isManhattanized () const;
112  virtual bool isConvex () const;
113  virtual bool isPolygon45 () const;
114  virtual DbU::Unit getX () const;
115  virtual DbU::Unit getY () const;
116  inline const vector<Point>& getPoints () const;
117  inline const vector<Edge*>& getEdges () const;
118  virtual size_t getPointsSize () const;
119  virtual Point getPoint ( size_t ) const;
120  virtual Box getBoundingBox () const;
121  virtual Box getBoundingBox ( const BasicLayer* ) const;
122  void getSubPolygons ( vector< vector<Point> >& ) const;
123  virtual const Layer* getLayer () const;
124  void setLayer ( const Layer* layer );
125  virtual void translate ( const DbU::Unit& dx, const DbU::Unit& dy );
126  void setPoints ( const vector<Point>& );
127  static float getSign ( const vector<Point>&, size_t );
128  static bool isEdge45 ( const vector<Point>&, size_t );
129  float getSlope ( size_t i ) const;
130  void manhattanize ();
131  virtual Points getMContour () const;
132  virtual void _toJson ( JsonWriter* ) const;
133  static JsonObject* getJsonObject ( unsigned long flags );
134  virtual string _getTypeName () const;
135  virtual string _getString () const;
136  virtual Record* _getRecord () const;
137  protected:
138  Polygon ( Net*, const Layer*, const std::vector<Point>& );
139  ~Polygon ();
140  private:
141  uint32_t _flags;
142  const Layer* _layer;
143  std::vector<Point> _points;
144  std::vector<Edge*> _edges;
145  };
146 
147 
148  inline const vector<Polygon::Edge*>& Polygon::getEdges () const { return _edges; }
149  inline const vector<Point>& Polygon::getPoints () const { return _points; }
150 
151  inline bool Polygon::Edge::isYIncrease () const { return (_flags & Polygon::YIncrease); }
152  inline bool Polygon::Edge::isXIncrease () const { return (_flags & Polygon::XIncrease); }
153  inline bool Polygon::Edge::isPositiveSlope () const { return not ( (_flags & Polygon::XIncrease) xor (_flags & Polygon::YIncrease) ); }
154  inline bool Polygon::Edge::isHV () const { return (_flags & (Polygon::Horizontal|Polygon::Vertical)); }
155  inline bool Polygon::Edge::isXSteps () const { return (_flags & Polygon::XSteps); }
156  inline bool Polygon::Edge::isYSteps () const { return (_flags & Polygon::YSteps); }
157  inline size_t Polygon::Edge::getSize () const { if (isHV() or (_steps.size() < 2)) return 1; return (_steps.size() - 1)*2; }
158 
159 
160  inline Polygon::Points_Manhattan::Locator::Locator ( const Locator &locator )
161  : PointHL ()
162  , _polygon(locator._polygon)
163  , _iEdge (locator._iEdge)
164  , _iPoint (locator._iPoint)
165  { }
166 
167 
168  inline Polygon::Points_Manhattan::Points_Manhattan ( const Polygon* polygon )
169  : PointHC ()
170  , _polygon(polygon)
171  { }
172 
173 
174  inline Polygon::Points_Manhattan::Points_Manhattan ( const Points_Manhattan& other )
175  : PointHC()
176  , _polygon(other._polygon)
177  { }
178 
179 
180  class JsonPolygon : public JsonComponent {
181  public:
182  static void initialize ();
183  JsonPolygon ( unsigned long flags );
184  virtual string getTypeName () const;
185  virtual JsonPolygon* clone ( unsigned long ) const;
186  virtual void toData ( JsonStack& );
187  };
188 
189 
190 } // Hurricane namespace.
191 
192 
193 INSPECTOR_P_SUPPORT(Hurricane::Polygon::Edge);
194 INSPECTOR_P_SUPPORT(Hurricane::Polygon);
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:42
static Polygon * create(Net *, const Layer *, const std::vector< Point > &)
Component Super
Definition: Polygon.h:44
Vertical description (API)
Definition: Vertical.h:36
Contains Almost Everything.
Definition: BasicLayer.h:39


Generated by doxygen 1.9.1 on Wed Nov 20 2024 Return to top of page
Hurricane VLSI Database Copyright © 2000-2020 Bull S.A. All rights reserved