6 * $Date: 2012-07-06 15:04:28 +0200 (Fr, 06. Jul 2012) $
7 ***************************************************************/
10 * \brief Declaration of class Rectangle.
12 * \author Stefan Hachul
15 * This file is part of the Open Graph Drawing Framework (OGDF).
19 * See README.txt in the root directory of the OGDF installation for details.
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License
24 * Version 2 or 3 as published by the Free Software Foundation;
25 * see the file LICENSE.txt included in the packaging of this file
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public
36 * License along with this program; if not, write to the Free
37 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
38 * Boston, MA 02110-1301, USA.
40 * \see http://www.gnu.org/copyleft/gpl.html
41 ***************************************************************/
47 #ifndef OGDF_RECTANGLE_H
48 #define OGDF_RECTANGLE_H
50 #include <ogdf/basic/geometry.h>
57 //Helping data structure for packing rectangles; The width, height and the position
58 //of the down left corner of the tight surroundig rectangle is represented for each
59 //connected component of the graph.
61 //Outputstream for Rectangle.
62 friend ostream
&operator<< (ostream
& output
, const Rectangle
& A
)
64 output
<<"width: "<< A
.width
<<" height: "<<A
.height
<<" old dlc_position: "
65 <<A
.old_down_left_corner_position
<<" new dlc_position: "
66 <<A
.new_down_left_corner_position
<<" coponenet_index: "<<A
.component_index
;
67 if(A
.tipped_over
== true)
68 output
<<" is tipped_over";
72 //Inputstream for Rectangle.
73 friend istream
&operator>> (istream
& input
, Rectangle
& A
)
81 Rectangle() //constructor
83 old_down_left_corner_position
.m_x
= 0;
84 old_down_left_corner_position
.m_y
= 0;
85 new_down_left_corner_position
.m_x
= 0;
86 new_down_left_corner_position
.m_y
= 0;
93 ~Rectangle() { } //destructor
95 void set_rectangle (double w
, double h
, double old_dlc_x_pos
,double
96 old_dlc_y_pos
,int comp_index
)
100 old_down_left_corner_position
.m_x
= old_dlc_x_pos
;
101 old_down_left_corner_position
.m_y
= old_dlc_y_pos
;
102 component_index
= comp_index
;
106 void set_old_dlc_position(DPoint dlc_pos
){old_down_left_corner_position
= dlc_pos
;}
107 void set_new_dlc_position(DPoint dlc_pos
){new_down_left_corner_position
= dlc_pos
;}
108 void set_width(double w
) {width
= w
;}
109 void set_height(double h
) {height
= h
;}
110 void set_component_index (int comp_index
) {component_index
= comp_index
;}
113 if(tipped_over
== false)
119 DPoint
get_old_dlc_position() const { return old_down_left_corner_position
; }
120 DPoint
get_new_dlc_position() const { return new_down_left_corner_position
; }
121 double get_width() const {return width
;}
122 double get_height() const {return height
;}
123 int get_component_index() const {return component_index
;}
124 bool is_tipped_over() const {return tipped_over
;}
127 DPoint old_down_left_corner_position
;//down left corner of the tight surround. rect.
128 DPoint new_down_left_corner_position
;//new calculated down left corner of ...
129 double width
; //width of the surround. rect.
130 double height
; //height of the surround. rect.
131 int component_index
; //the index of the related connected component
132 bool tipped_over
; //indicates if this rectangle has been tipped over in the
138 //Needed for sorting algorithms in ogdf/List and ogdf/Array.
139 class RectangleComparerHeight
142 RectangleComparerHeight() { }
143 ~RectangleComparerHeight() { }
145 bool less(const Rectangle
& A
,const Rectangle
& B
) const
147 if(A
.get_height() > B
.get_height() )
153 bool leq(const Rectangle
& A
,const Rectangle
& B
) const
155 if(A
.get_height() >= B
.get_height() )
161 bool equal(const Rectangle
& A
,const Rectangle
& B
) const
163 if(A
.get_height() == B
.get_height() )
171 class RectangleComparerWidth
174 RectangleComparerWidth() { }
175 ~RectangleComparerWidth() { }
177 bool less(const Rectangle
& A
,const Rectangle
& B
) const
179 if(A
.get_width() > B
.get_width() )
185 bool leq(const Rectangle
& A
,const Rectangle
& B
) const
187 if(A
.get_width() >= B
.get_width() )
193 bool equal(const Rectangle
& A
,const Rectangle
& B
) const
195 if(A
.get_width() == B
.get_width() )