DGtal  1.4.2
Rect.h
1 /* -*- mode: c++ -*- */
9 /*
10  * \@copyright This File is part of the Board library which is
11  * licensed under the terms of the GNU Lesser General Public Licence.
12  * See the LICENCE file for further details.
13  */
14 #ifndef _BOARD_RECT_H_
15 #define _BOARD_RECT_H_
16 
17 #include <iostream>
18 #include "Board/Point.h"
19 
20 namespace LibBoard {
21 
26 struct Rect {
27 
28  double left;
29  double top;
30  double width;
31  double height;
42  Rect( double leftX = 0.0f, double topY = 0.0f, double rectWidth = 0.0f, double rectHeight = 0.0f )
43  :left( leftX ), top( topY ), width( rectWidth ), height( rectHeight ) { }
44 
45  Point topLeft() { return Point( left, top ); }
46  Point topRight() { return Point( left + width, top ); }
47  Point bottomLeft() { return Point( left, top - height ); }
48  Point bottomRight() { return Point( left + width, top - height ); }
49 };
50 
59 Rect operator||( const Rect & rectA, const Rect & rectB );
60 
69 Rect operator&&( const Rect & rectA, const Rect & rectB );
70 
71 
72 } // mamespace BoardLib
73 
82 std::ostream & operator<<( std::ostream & out, const LibBoard::Rect & rect );
83 
84 #endif // _RECT_H_
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
Rect operator&&(const Rect &rectA, const Rect &rectB)
Definition: Rect.cpp:37
Rect operator||(const Rect &rectA, const Rect &rectB)
Definition: Rect.cpp:20
Struct representing a 2D point.
Definition: Point.h:27
Struct representing a rectangle on the plane.
Definition: Rect.h:26
Point bottomLeft()
Definition: Rect.h:47
Point bottomRight()
Definition: Rect.h:48
Rect(double leftX=0.0f, double topY=0.0f, double rectWidth=0.0f, double rectHeight=0.0f)
Definition: Rect.h:42
Point topRight()
Definition: Rect.h:46
double height
Definition: Rect.h:31
Point topLeft()
Definition: Rect.h:45
double width
Definition: Rect.h:30
double left
Definition: Rect.h:28
double top
Definition: Rect.h:29
MyPointD Point
Definition: testClone2.cpp:383