Hurricane VLSI Database


Box.h
1 // ****************************************************************************************************
2 // File: ./hurricane/Box.h
3 // Authors: R. Escassut
4 // Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
5 //
6 // This file is part of Hurricane.
7 //
8 // Hurricane is free software: you can redistribute it and/or modify it under the terms of the GNU
9 // Lesser General Public License as 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 WITHOUT ANY WARRANTY; without even
13 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU
14 // General Public License for more details.
15 //
16 // You should have received a copy of the Lesser GNU General Public License along with Hurricane. If
17 // not, see <http://www.gnu.org/licenses/>.
18 // ****************************************************************************************************
19 
20 #ifndef HURRICANE_BOX
21 #define HURRICANE_BOX
22 
23 #include "hurricane/Point.h"
24 
25 namespace Hurricane {
26 
27 // ****************************************************************************************************
28 // Box declaration
29 // ****************************************************************************************************
30 
31 class Box {
32 // ******
33 
34 // Attributes
35 // **********
36 
37  private: DbU::Unit _xMin;
38  private: DbU::Unit _yMin;
39  private: DbU::Unit _xMax;
40  private: DbU::Unit _yMax;
41 
42 // constructors
43 // ************
44 
45  public: Box();
46 
47  public: Box(const DbU::Unit& x, const DbU::Unit& y);
48  public: Box(const Point& point);
49  public: Box(const DbU::Unit& x1, const DbU::Unit& y1, const DbU::Unit& x2, const DbU::Unit& y2);
50  public: Box(const Point& point1, const Point& point2);
51 
52  public: Box(const Box& box);
53 
54 // Operators
55 // *********
56 
57  public: Box& operator=(const Box& box);
58 
59  public: bool operator==(const Box& box) const;
60  public: bool operator!=(const Box& box) const;
61 
62 // Accessors
63 // *********
64 
65  public: const DbU::Unit& getXMin() const {return _xMin;};
66  public: const DbU::Unit& getYMin() const {return _yMin;};
67  public: const DbU::Unit& getXMax() const {return _xMax;};
68  public: const DbU::Unit& getYMax() const {return _yMax;};
69 
70  public: DbU::Unit getXCenter() const {return ((_xMin + _xMax) / 2);};
71  public: DbU::Unit getYCenter() const {return ((_yMin + _yMax) / 2);};
72  public: Point getCenter() const {return Point(getXCenter(), getYCenter());};
73  public: Point getCornerBL() const { return Point(_xMin,_yMin); }
74  public: Point getCornerTL() const { return Point(_xMin,_yMax); }
75  public: Point getCornerTR() const { return Point(_xMax,_yMax); }
76  public: Point getCornerBR() const { return Point(_xMax,_yMin); }
77 
78  public: DbU::Unit getWidth() const {return (_xMax - _xMin);};
79  public: DbU::Unit getHalfWidth() const {return (getWidth() / 2);};
80  public: DbU::Unit getHeight() const {return (_yMax - _yMin);};
81  public: DbU::Unit getHalfHeight() const {return (getHeight() / 2);};
82 
83  public: Box getUnion(const Box& box) const;
84 
85  public: Box getIntersection(const Box& box) const;
86  public: DbU::Unit manhattanDistance(const Point& pt) const;
87  public: DbU::Unit manhattanDistance(const Box& box) const;
88 
89 // Predicates
90 // **********
91 
92  public: bool isEmpty() const;
93  public: bool isFlat() const;
94  public: bool isPonctual() const;
95 
96  public: bool contains(const DbU::Unit& x, const DbU::Unit& y) const;
97  public: bool contains(const Point& point) const;
98  public: bool contains(const Box& box) const;
99 
100  public: bool intersect(const Box& box) const;
101 
102  public: bool isConstrainedBy(const Box& box) const;
103 
104 // Updators
105 // ********
106 
107  public: Box& makeEmpty();
108 
109  public: Box& inflate(const DbU::Unit& d);
110  public: Box& inflate(const DbU::Unit& dx, const DbU::Unit& dy);
111  public: Box& inflate(const DbU::Unit& dxMin, const DbU::Unit& dyMin, const DbU::Unit& dxMax, const DbU::Unit& dyMax);
112  public: Box getInflated(const DbU::Unit& d) const;
113  public: Box& shrinkByFactor(double factor); // 0 <= factor <= 1
114 
115  public: Box& merge(const DbU::Unit& x, const DbU::Unit& y);
116  public: Box& merge(const Point& point);
117  public: Box& merge(const DbU::Unit& x1, const DbU::Unit& y1, const DbU::Unit& x2, const DbU::Unit& y2);
118  public: Box& merge(const Box& box);
119 
120  public: Box& translate(const DbU::Unit& dx, const DbU::Unit& dy);
121 
122 // Others
123 // ******
124 
125 
126  public: string _getTypeName() const { return _TName("Box"); };
127  public: string _getString() const;
128  public: Record* _getRecord() const;
129  public: void toJson(JsonWriter*) const;
130 
131 };
132 
133 
134 class JsonBox : public JsonObject {
135 // ********************************
136 
137  public: static void initialize();
138  public: JsonBox(unsigned long);
139  public: virtual string getTypeName() const;
140  public: virtual JsonBox* clone(unsigned long) const;
141  public: virtual void toData(JsonStack&);
142 };
143 
144 
145 } // End of Hurricane namespace.
146 
147 
148 INSPECTOR_PR_SUPPORT(Hurricane::Box);
149 
150 
151 #endif // HURRICANE_BOX
152 
153 
154 // ****************************************************************************************************
155 // Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
156 // ****************************************************************************************************
Box description (API)
Definition: Box.h:31
Box & operator=(const Box &box)
const DbU::Unit & getYMax() const
Definition: Box.h:68
Box & makeEmpty()
Box & merge(const Box &box)
bool isFlat() const
Box(const DbU::Unit &x1, const DbU::Unit &y1, const DbU::Unit &x2, const DbU::Unit &y2)
bool contains(const Point &point) const
Box getUnion(const Box &box) const
bool operator==(const Box &box) const
Box(const Point &point)
bool isPonctual() const
Box(const Point &point1, const Point &point2)
const DbU::Unit & getYMin() const
Definition: Box.h:66
DbU::Unit getHalfHeight() const
Definition: Box.h:81
Box getIntersection(const Box &box) const
DbU::Unit getYCenter() const
Definition: Box.h:71
Box & inflate(const DbU::Unit &dx, const DbU::Unit &dy)
bool isConstrainedBy(const Box &box) const
bool operator!=(const Box &box) const
const DbU::Unit & getXMax() const
Definition: Box.h:67
DbU::Unit getHeight() const
Definition: Box.h:80
DbU::Unit getHalfWidth() const
Definition: Box.h:79
Box & inflate(const DbU::Unit &d)
DbU::Unit getXCenter() const
Definition: Box.h:70
Box & translate(const DbU::Unit &dx, const DbU::Unit &dy)
Box & merge(const DbU::Unit &x, const DbU::Unit &y)
Point getCenter() const
Definition: Box.h:72
bool contains(const Box &box) const
const DbU::Unit & getXMin() const
Definition: Box.h:65
Box & merge(const DbU::Unit &x1, const DbU::Unit &y1, const DbU::Unit &x2, const DbU::Unit &y2)
bool contains(const DbU::Unit &x, const DbU::Unit &y) const
DbU::Unit getWidth() const
Definition: Box.h:78
bool intersect(const Box &box) const
Box & merge(const Point &point)
Box(const DbU::Unit &x, const DbU::Unit &y)
bool isEmpty() const
Box(const Box &box)
Box & inflate(const DbU::Unit &dxMin, const DbU::Unit &dyMin, const DbU::Unit &dxMax, const DbU::Unit &dyMax)
std::int64_t Unit
Definition: DbU.h:67
Point description (API)
Definition: Point.h:32
The namespace dedicated to Hurricane.
Definition: Generalities.dox:5


Generated by doxygen 1.9.1 on Thu Aug 11 2022 Return to top of page
Hurricane VLSI Database Copyright © 2000-2020 Bull S.A. All rights reserved