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 #pragma once
21 #include "hurricane/Point.h"
22 
23 namespace Hurricane {
24 
25 // ****************************************************************************************************
26 // Box declaration
27 // ****************************************************************************************************
28 
29 class Box {
30 // ******
31 
32 // Attributes
33 // **********
34 
35  private: DbU::Unit _xMin;
36  private: DbU::Unit _yMin;
37  private: DbU::Unit _xMax;
38  private: DbU::Unit _yMax;
39 
40 // constructors
41 // ************
42 
43  public: Box();
44 
45  public: Box(const DbU::Unit& x, const DbU::Unit& y);
46  public: Box(const Point& point);
47  public: Box(const DbU::Unit& x1, const DbU::Unit& y1, const DbU::Unit& x2, const DbU::Unit& y2);
48  public: Box(const Point& point1, const Point& point2);
49 
50  public: Box(const Box& box);
51 
52 // Operators
53 // *********
54 
55  public: Box& operator=(const Box& box);
56 
57  public: bool operator==(const Box& box) const;
58  public: bool operator!=(const Box& box) const;
59 
60 // Accessors
61 // *********
62 
63  public: const DbU::Unit& getXMin() const {return _xMin;};
64  public: const DbU::Unit& getYMin() const {return _yMin;};
65  public: const DbU::Unit& getXMax() const {return _xMax;};
66  public: const DbU::Unit& getYMax() const {return _yMax;};
67 
68  public: DbU::Unit getXCenter() const {return ((_xMin + _xMax) / 2);};
69  public: DbU::Unit getYCenter() const {return ((_yMin + _yMax) / 2);};
70  public: Point getCenter() const {return Point(getXCenter(), getYCenter());};
71  public: Point getCornerBL() const { return Point(_xMin,_yMin); }
72  public: Point getCornerTL() const { return Point(_xMin,_yMax); }
73  public: Point getCornerTR() const { return Point(_xMax,_yMax); }
74  public: Point getCornerBR() const { return Point(_xMax,_yMin); }
75 
76  public: DbU::Unit getWidth() const {return (_xMax - _xMin);};
77  public: DbU::Unit getHalfWidth() const {return (getWidth() / 2);};
78  public: DbU::Unit getHeight() const {return (_yMax - _yMin);};
79  public: DbU::Unit getHalfHeight() const {return (getHeight() / 2);};
80 
81  public: Box getUnion(const Box& box) const;
82 
83  public: Box getIntersection(const Box& box) const;
84  public: DbU::Unit manhattanDistance(const Point& pt) const;
85  public: DbU::Unit manhattanDistance(const Box& box) const;
86 
87 // Predicates
88 // **********
89 
90  public: bool isEmpty() const;
91  public: bool isFlat() const;
92  public: bool isPonctual() const;
93 
94  public: bool contains(const DbU::Unit& x, const DbU::Unit& y) const;
95  public: bool contains(const Point& point) const;
96  public: bool contains(const Box& box) const;
97 
98  public: bool intersect(const Box& box) const;
99 
100  public: bool isConstrainedBy(const Box& box) const;
101 
102 // Updators
103 // ********
104 
105  public: Box& makeEmpty();
106 
107  public: Box& inflate(const DbU::Unit& d);
108  public: Box& inflate(const DbU::Unit& dx, const DbU::Unit& dy);
109  public: Box& inflate(const DbU::Unit& dxMin, const DbU::Unit& dyMin, const DbU::Unit& dxMax, const DbU::Unit& dyMax);
110  public: Box getInflated(const DbU::Unit& d) const;
111  public: Box& shrinkByFactor(double factor); // 0 <= factor <= 1
112 
113  public: Box& merge(const DbU::Unit& x, const DbU::Unit& y);
114  public: Box& merge(const Point& point);
115  public: Box& merge(const DbU::Unit& x1, const DbU::Unit& y1, const DbU::Unit& x2, const DbU::Unit& y2);
116  public: Box& merge(const Box& box);
117 
118  public: Box& translate(const DbU::Unit& dx, const DbU::Unit& dy);
119  public: Box& translate(const Point& p);
120 
121 // Others
122 // ******
123 
124 
125  public: string _getTypeName() const { return _TName("Box"); };
126  public: string _getString() const;
127  public: Record* _getRecord() const;
128  public: void toJson(JsonWriter*) const;
129 
130 };
131 
132 
133 class JsonBox : public JsonObject {
134 // ********************************
135 
136  public: static void initialize();
137  public: JsonBox(unsigned long);
138  public: virtual string getTypeName() const;
139  public: virtual JsonBox* clone(unsigned long) const;
140  public: virtual void toData(JsonStack&);
141 };
142 
143 
144 } // End of Hurricane namespace.
145 
146 
147 INSPECTOR_PR_SUPPORT(Hurricane::Box);
148 
149 
150 // ****************************************************************************************************
151 // Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
152 // ****************************************************************************************************
Box description (API)
Definition: Box.h:29
Box & operator=(const Box &box)
const DbU::Unit & getYMax() const
Definition: Box.h:66
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:64
DbU::Unit getHalfHeight() const
Definition: Box.h:79
Box getIntersection(const Box &box) const
DbU::Unit getYCenter() const
Definition: Box.h:69
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:65
DbU::Unit getHeight() const
Definition: Box.h:78
DbU::Unit getHalfWidth() const
Definition: Box.h:77
Box & inflate(const DbU::Unit &d)
DbU::Unit getXCenter() const
Definition: Box.h:68
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:70
bool contains(const Box &box) const
const DbU::Unit & getXMin() const
Definition: Box.h:63
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:76
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:30
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