BSIRect.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 #include <Bentley/Bentley.h>
13 
15 
24 struct BSIRect
25 {
28 
30  void Init (int xOrg, int yOrg, int xHigh, int yHigh)
31  {
32  origin.x = xOrg;
33  origin.y = yOrg;
34  corner.x = xHigh;
35  corner.y = yHigh;
36  }
37 
39  void Init (Point2d const* low, Point2d const* high)
40  {
41  origin = *low;
42  corner = *high;
43  }
44 
46  int Left () const {return origin.x;}
48  int Top () const {return origin.y;}
50  int Right () const {return corner.x;}
52  int Bottom () const {return corner.y;}
53 
55  int Width () const {return (corner.x - origin.x) + 1;}
57  int Height () const {return (corner.y - origin.y) + 1;}
59  int Area () const {return Width() * Height();}
61  double Aspect () const {return ((double) Width() / (double) Height());}
62 
64  GEOMDLLIMPEXP void Limit (BSIRect const* other);
65 
67  GEOMDLLIMPEXP void Inset (int deltaX, int deltaY);
68 
70  GEOMDLLIMPEXP void Expand (int delta);
71 
73  GEOMDLLIMPEXP void Offset (int dx, int dy);
74 
76  GEOMDLLIMPEXP void Union (BSIRect const* other);
77 
79  GEOMDLLIMPEXP bool IsEqual (BSIRect const* other) const;
80 
82  GEOMDLLIMPEXP bool PointInside (Point2d const&) const;
83 
85  GEOMDLLIMPEXP bool Overlap (BSIRect* overlap, BSIRect const* other) const;
86 
88  GEOMDLLIMPEXP bool IsContained (BSIRect const* container) const;
89 };
90 
92 
93 DEFINE_GEOM_STRUCT1 (BSIRect)
94 
int Bottom() const
Reuturn the corner y coordinate. (Called "Bottom" because screen rectangles advance downward...
Definition: BSIRect.h:52
int Width() const
Return corner.x - origin.x + 1, i.e. pixel width with start end considered inclusive.
Definition: BSIRect.h:55
int Area() const
Return Width() * Height ()
Definition: BSIRect.h:59
Integer x,y rectangle coordinates.
Definition: BSIRect.h:24
int Left() const
Return the origin x coordinate.
Definition: BSIRect.h:46
#define DEFINE_GEOM_STRUCT1(_StructName_)
Definition: msgeomstructs_typedefs.h:40
#define END_BENTLEY_GEOMETRY_NAMESPACE
Definition: Bentley.r.h:30
An integer 2d point, useful for screen pixel references, but not for real geometry: Point...
Offset constraint.
Point2d origin
The rectangle origin.
Definition: BSIRect.h:26
int Top() const
Return the origin y coordinate. (Called "Top" name because screen rectangles start at top left and ad...
Definition: BSIRect.h:48
int Right() const
Return the corner x coordinate.
Definition: BSIRect.h:50
double Aspect() const
Return Width () / Height ()
Definition: BSIRect.h:61
int Height() const
Return corner.y - origin.y + 1, i.e. pixel height with start end considered inclusive.
Definition: BSIRect.h:57
void Init(Point2d const *low, Point2d const *high)
Initialize by direct copy to points. This does NOT enforce ordering.
Definition: BSIRect.h:39
Defines typedefs and constants that can be used across other namespaces. All Bentley-authored C++ sou...
#define BEGIN_BENTLEY_GEOMETRY_NAMESPACE
Definition: Bentley.r.h:29
Point2d corner
The rectangle corner.
Definition: BSIRect.h:27
void Init(int xOrg, int yOrg, int xHigh, int yHigh)
Initialize by direct copy to points. This does NOT enforce ordering.
Definition: BSIRect.h:30
An integer 2d point, useful for screen pixel references, but not for real geometry.
Definition: Point.h:20

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.