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  private:
46  static FastRTTI _fastRTTI;
47  public:
48  static inline const FastRTTI& fastRTTI ();
49  virtual const FastRTTI& vfastRTTI () const;
50  public:
51  static const uint32_t Above = (1<<0);
52  static const uint32_t YSteps = (1<<1);
53  static const uint32_t XSteps = (1<<2);
54  static const uint32_t XIncrease = (1<<3);
55  static const uint32_t YIncrease = (1<<4);
56  static const uint32_t Horizontal = (1<<5);
57  static const uint32_t Vertical = (1<<6);
58  static const uint32_t Convex = (1<<7);
59  static const uint32_t Polygon45 = (1<<8);
60 
61  public:
62  class Edge {
63  public:
64  Edge ( Point origin, Point extremity, uint32_t flags );
65  inline size_t getSize () const;
66  Point getPoint ( size_t i ) const;
67  inline bool isPositiveSlope () const;
68  inline bool isYIncrease () const;
69  inline bool isXIncrease () const;
70  inline bool isHV () const;
71  inline bool isXSteps () const;
72  inline bool isYSteps () const;
73  void translate ( DbU::Unit dx, DbU::Unit dy );
74  string _getTypeName () const;
75  string _getString () const;
76  Record* _getRecord () const;
77  private:
78  uint32_t _flags;
79  DbU::Unit _xyOrigin;
80  vector<DbU::Unit> _steps;
81  };
82 
83  public:
84  class Points_Manhattan : public PointHC {
85  public:
86  class Locator : public PointHL {
87  public:
88  Locator ( const Polygon* );
89  inline Locator ( const Locator& );
90  virtual Point getElement () const;
91  virtual PointHL* getClone () const;
92  virtual bool isValid () const;
93  virtual void progress ();
94  virtual string _getString () const;
95  protected:
96  const Polygon* _polygon;
97  size_t _iEdge;
98  size_t _iPoint;
99  };
100  public:
101  inline Points_Manhattan ( const Polygon* );
102  inline Points_Manhattan ( const Points_Manhattan& );
103  virtual PointHC* getClone () const;
104  virtual PointHL* getLocator () const;
105  virtual string _getString () const;
106  protected:
107  const Polygon* _polygon;
108  };
109 
110  public:
111  static Polygon* create ( Net*, const Layer*, const std::vector<Point>& );
112  static float getSlope ( const Point&, const Point& );
113  static void normalize ( std::vector<Point>&, uint32_t& flags );
114  public:
115  virtual bool isNonRectangle () const;
116  virtual bool isManhattanized () const;
117  virtual bool isConvex () const;
118  virtual bool isPolygon45 () const;
119  virtual DbU::Unit getX () const;
120  virtual DbU::Unit getY () const;
121  inline const vector<Point>& getPoints () const;
122  inline const vector<Edge*>& getEdges () const;
123  virtual size_t getPointsSize () const;
124  virtual Point getPoint ( size_t ) const;
125  virtual Box getBoundingBox () const;
126  virtual Box getBoundingBox ( const BasicLayer* ) const;
127  void getSubPolygons ( vector< vector<Point> >& ) const;
128  virtual const Layer* getLayer () const;
129  void setLayer ( const Layer* layer );
130  virtual void translate ( const DbU::Unit& dx, const DbU::Unit& dy );
131  void setPoints ( const vector<Point>& );
132  static float getSign ( const vector<Point>&, size_t );
133  static bool isEdge45 ( const vector<Point>&, size_t );
134  float getSlope ( size_t i ) const;
135  void manhattanize ();
136  virtual Points getMContour () const;
137  virtual void _toJson ( JsonWriter* ) const;
138  static JsonObject* getJsonObject ( unsigned long flags );
139  virtual string _getTypeName () const;
140  virtual string _getString () const;
141  virtual Record* _getRecord () const;
142  protected:
143  Polygon ( Net*, const Layer*, const std::vector<Point>& );
144  ~Polygon ();
145  private:
146  uint32_t _flags;
147  const Layer* _layer;
148  std::vector<Point> _points;
149  std::vector<Edge*> _edges;
150  };
151 
152 
153  inline const FastRTTI& Polygon::fastRTTI () { return _fastRTTI; }
154 
155  inline const vector<Polygon::Edge*>& Polygon::getEdges () const { return _edges; }
156  inline const vector<Point>& Polygon::getPoints () const { return _points; }
157 
158  inline bool Polygon::Edge::isYIncrease () const { return (_flags & Polygon::YIncrease); }
159  inline bool Polygon::Edge::isXIncrease () const { return (_flags & Polygon::XIncrease); }
160  inline bool Polygon::Edge::isPositiveSlope () const { return not ( (_flags & Polygon::XIncrease) xor (_flags & Polygon::YIncrease) ); }
161  inline bool Polygon::Edge::isHV () const { return (_flags & (Polygon::Horizontal|Polygon::Vertical)); }
162  inline bool Polygon::Edge::isXSteps () const { return (_flags & Polygon::XSteps); }
163  inline bool Polygon::Edge::isYSteps () const { return (_flags & Polygon::YSteps); }
164  inline size_t Polygon::Edge::getSize () const { if (isHV() or (_steps.size() < 2)) return 1; return (_steps.size() - 1)*2; }
165 
166 
167  inline Polygon::Points_Manhattan::Locator::Locator ( const Locator &locator )
168  : PointHL ()
169  , _polygon(locator._polygon)
170  , _iEdge (locator._iEdge)
171  , _iPoint (locator._iPoint)
172  { }
173 
174 
175  inline Polygon::Points_Manhattan::Points_Manhattan ( const Polygon* polygon )
176  : PointHC ()
177  , _polygon(polygon)
178  { }
179 
180 
181  inline Polygon::Points_Manhattan::Points_Manhattan ( const Points_Manhattan& other )
182  : PointHC()
183  , _polygon(other._polygon)
184  { }
185 
186 
187  class JsonPolygon : public JsonComponent {
188  public:
189  static void initialize ();
190  JsonPolygon ( unsigned long flags );
191  virtual string getTypeName () const;
192  virtual JsonPolygon* clone ( unsigned long ) const;
193  virtual void toData ( JsonStack& );
194  };
195 
196 
197 } // Hurricane namespace.
198 
199 
200 INSPECTOR_P_SUPPORT(Hurricane::Polygon::Edge);
201 INSPECTOR_P_SUPPORT(Hurricane::Polygon);
BasicLayer description (API)
Definition: BasicLayer.h:42
Box description (API)
Definition: Box.h:30
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:120
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 Sun Dec 14 2025 Return to top of page
Hurricane VLSI Database Copyright © 2000-2020 Bull S.A. All rights reserved