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


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