OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Private Attributes | Friends | List of all members
ossimVrect Class Reference

#include <ossimVrect.h>

Public Member Functions

 ossimVrect ()
 
 ossimVrect (const ossimDpt &ul, const ossimDpt &lr)
 
 ossimVrect (double ul_corner_x, double ul_corner_y, double lr_corner_x, double lr_corner_y)
 
 ossimVrect (const ossimVrect &rect)
 
 ~ossimVrect ()
 
const ossimVrectoperator= (const ossimVrect &rect)
 
bool operator!= (const ossimVrect &rect) const
 
bool operator== (const ossimVrect &rect) const
 
const ossimDptul () const
 
const ossimDptur () const
 
const ossimDptlr () const
 
const ossimDptll () const
 
ossim_float64 height () const
 
ossim_float64 width () const
 
ossimDpt midPoint () const
 
void print (std::ostream &os) const
 
ossimVrect combine (const ossimVrect &rect) const
 
ossimVrect clipToRect (const ossimVrect &rect) const
 

Private Attributes

ossimDpt theUlCorner
 
ossimDpt theLlCorner
 
ossimDpt theLrCorner
 
ossimDpt theUrCorner
 

Friends

std::ostream & operator<< (std::ostream &os, const ossimVrect &rect)
 

Detailed Description

Definition at line 25 of file ossimVrect.h.

Constructor & Destructor Documentation

◆ ossimVrect() [1/4]

ossimVrect::ossimVrect ( )
inline

Definition at line 28 of file ossimVrect.h.

Referenced by clipToRect(), and combine().

29  :theUlCorner(0.0, 0.0),
30  theLlCorner(0.0, 0.0),
31  theLrCorner(0.0, 0.0),
32  theUrCorner(0.0, 0.0)
33  {}
ossimDpt theLrCorner
Definition: ossimVrect.h:92
ossimDpt theUlCorner
Definition: ossimVrect.h:90
ossimDpt theLlCorner
Definition: ossimVrect.h:91
ossimDpt theUrCorner
Definition: ossimVrect.h:93

◆ ossimVrect() [2/4]

ossimVrect::ossimVrect ( const ossimDpt ul,
const ossimDpt lr 
)
inline

Definition at line 34 of file ossimVrect.h.

36  :theUlCorner(ul),
37  theLlCorner(ul.x, lr.y),
38  theLrCorner(lr),
39  theUrCorner(lr.x, ul.y)
40  {}
ossimDpt theLrCorner
Definition: ossimVrect.h:92
ossimDpt theUlCorner
Definition: ossimVrect.h:90
double y
Definition: ossimDpt.h:165
const ossimDpt & ul() const
Definition: ossimVrect.h:65
const ossimDpt & lr() const
Definition: ossimVrect.h:67
ossimDpt theLlCorner
Definition: ossimVrect.h:91
double x
Definition: ossimDpt.h:164
ossimDpt theUrCorner
Definition: ossimVrect.h:93

◆ ossimVrect() [3/4]

ossimVrect::ossimVrect ( double  ul_corner_x,
double  ul_corner_y,
double  lr_corner_x,
double  lr_corner_y 
)
inline

Definition at line 41 of file ossimVrect.h.

45  :
46  theUlCorner(ul_corner_x, ul_corner_y),
47  theLlCorner(ul_corner_x, lr_corner_y),
48  theLrCorner(lr_corner_x, lr_corner_y),
49  theUrCorner(lr_corner_x, ul_corner_y)
50  {}
ossimDpt theLrCorner
Definition: ossimVrect.h:92
ossimDpt theUlCorner
Definition: ossimVrect.h:90
ossimDpt theLlCorner
Definition: ossimVrect.h:91
ossimDpt theUrCorner
Definition: ossimVrect.h:93

◆ ossimVrect() [4/4]

ossimVrect::ossimVrect ( const ossimVrect rect)
inline

Definition at line 51 of file ossimVrect.h.

52  :
53  theUlCorner(rect.ul()),
54  theLlCorner(rect.ll()),
55  theLrCorner(rect.lr()),
56  theUrCorner(rect.ur())
57  {}
ossimDpt theLrCorner
Definition: ossimVrect.h:92
ossimDpt theUlCorner
Definition: ossimVrect.h:90
const ossimDpt & ur() const
Definition: ossimVrect.h:66
const ossimDpt & ul() const
Definition: ossimVrect.h:65
const ossimDpt & ll() const
Definition: ossimVrect.h:68
const ossimDpt & lr() const
Definition: ossimVrect.h:67
ossimDpt theLlCorner
Definition: ossimVrect.h:91
ossimDpt theUrCorner
Definition: ossimVrect.h:93

◆ ~ossimVrect()

ossimVrect::~ossimVrect ( )

Definition at line 39 of file ossimVrect.cpp.

40 {
41 }

Member Function Documentation

◆ clipToRect()

ossimVrect ossimVrect::clipToRect ( const ossimVrect rect) const
inline

Definition at line 126 of file ossimVrect.h.

References d_MAX, lr(), min, ossimVrect(), ul(), ossimDpt::x, and ossimDpt::y.

127 {
128  ossim_float64 ulx, uly, lrx, lry;
129 
130  // XXX not replaced with std::max or ossim::max since the test is backward
131  // here and will give a different answer in the case of nan.
132  #define d_MAX(a,b) (((a)>(b)) ? a : b)
133 
134  ulx = d_MAX(rect.ul().x,ul().x);
135  uly = d_MAX(rect.ul().y,ul().y);
136 
137  #undef d_MAX
138 
139  lrx = std::min(rect.lr().x,lr().x);
140  lry = std::min(rect.lr().y,lr().y);
141 
142  if( lrx <= ulx || lry <= uly )
143  return ossimVrect(ossimDpt(0,0),ossimDpt(0,0));
144  else
145  return ossimVrect(ulx,uly,lrx,lry);
146 }
double y
Definition: ossimDpt.h:165
#define d_MAX(a, b)
double ossim_float64
const ossimDpt & ul() const
Definition: ossimVrect.h:65
const ossimDpt & lr() const
Definition: ossimVrect.h:67
double x
Definition: ossimDpt.h:164
#define min(a, b)
Definition: auxiliary.h:75

◆ combine()

ossimVrect ossimVrect::combine ( const ossimVrect rect) const
inline

Definition at line 154 of file ossimVrect.h.

References lr(), ossimVrect(), ul(), ossimDpt::x, and ossimDpt::y.

155 {
156  ossimDpt ulCombine;
157  ossimDpt lrCombine;
158 
159  ulCombine.x = ((ul().x <= rect.ul().x)?ul().x:rect.ul().x);
160  ulCombine.y = ((ul().y >= rect.ul().y)?ul().y:rect.ul().y);
161  lrCombine.x = ((lr().x >= rect.lr().x)?lr().x:rect.lr().x);
162  lrCombine.y = ((lr().y <= rect.lr().y)?lr().y:rect.lr().y);
163 
164  return ossimVrect(ulCombine, lrCombine);
165 }
double y
Definition: ossimDpt.h:165
const ossimDpt & ul() const
Definition: ossimVrect.h:65
const ossimDpt & lr() const
Definition: ossimVrect.h:67
double x
Definition: ossimDpt.h:164

◆ height()

ossim_float64 ossimVrect::height ( ) const
inline

Returns the height of a rectangle.

Definition at line 72 of file ossimVrect.h.

73  { return fabs(theLlCorner.y - theUlCorner.y) + 1.0; }
ossimDpt theUlCorner
Definition: ossimVrect.h:90
double y
Definition: ossimDpt.h:165
ossimDpt theLlCorner
Definition: ossimVrect.h:91

◆ ll()

const ossimDpt& ossimVrect::ll ( ) const
inline

Definition at line 68 of file ossimVrect.h.

Referenced by midPoint(), operator!=(), operator=(), and operator==().

68 { return theLlCorner; }
ossimDpt theLlCorner
Definition: ossimVrect.h:91

◆ lr()

const ossimDpt& ossimVrect::lr ( ) const
inline

Definition at line 67 of file ossimVrect.h.

Referenced by clipToRect(), combine(), midPoint(), operator!=(), operator=(), and operator==().

67 { return theLrCorner; }
ossimDpt theLrCorner
Definition: ossimVrect.h:92

◆ midPoint()

ossimDpt ossimVrect::midPoint ( ) const
inline

Definition at line 148 of file ossimVrect.h.

References ll(), lr(), ul(), ur(), x, and y.

149 {
150  return ossimDpt( (ul().x + ur().x + ll().x + lr().x)*.25,
151  (ul().y + ur().y + ll().y + lr().y)*.25);
152 }
ossim_uint32 x
const ossimDpt & ur() const
Definition: ossimVrect.h:66
ossim_uint32 y
const ossimDpt & ul() const
Definition: ossimVrect.h:65
const ossimDpt & ll() const
Definition: ossimVrect.h:68
const ossimDpt & lr() const
Definition: ossimVrect.h:67

◆ operator!=()

bool ossimVrect::operator!= ( const ossimVrect rect) const
inline

Definition at line 109 of file ossimVrect.h.

References ll(), lr(), theLlCorner, theLrCorner, theUlCorner, theUrCorner, ul(), and ur().

110 {
111  return ( (theUlCorner != rect.ul()) ||
112  (theUrCorner != rect.ur()) ||
113  (theLrCorner != rect.lr()) ||
114  (theLlCorner != rect.ll()) );
115 }
ossimDpt theLrCorner
Definition: ossimVrect.h:92
ossimDpt theUlCorner
Definition: ossimVrect.h:90
const ossimDpt & ur() const
Definition: ossimVrect.h:66
const ossimDpt & ul() const
Definition: ossimVrect.h:65
const ossimDpt & ll() const
Definition: ossimVrect.h:68
const ossimDpt & lr() const
Definition: ossimVrect.h:67
ossimDpt theLlCorner
Definition: ossimVrect.h:91
ossimDpt theUrCorner
Definition: ossimVrect.h:93

◆ operator=()

const ossimVrect & ossimVrect::operator= ( const ossimVrect rect)
inline

Definition at line 96 of file ossimVrect.h.

References ll(), lr(), theLlCorner, theLrCorner, theUlCorner, theUrCorner, ul(), and ur().

97 {
98  if (this != &rect)
99  {
100  theUlCorner = rect.ul();
101  theUrCorner = rect.ur();
102  theLrCorner = rect.lr();
103  theLlCorner = rect.ll();
104  }
105 
106  return *this;
107 }
ossimDpt theLrCorner
Definition: ossimVrect.h:92
ossimDpt theUlCorner
Definition: ossimVrect.h:90
const ossimDpt & ur() const
Definition: ossimVrect.h:66
const ossimDpt & ul() const
Definition: ossimVrect.h:65
const ossimDpt & ll() const
Definition: ossimVrect.h:68
const ossimDpt & lr() const
Definition: ossimVrect.h:67
ossimDpt theLlCorner
Definition: ossimVrect.h:91
ossimDpt theUrCorner
Definition: ossimVrect.h:93

◆ operator==()

bool ossimVrect::operator== ( const ossimVrect rect) const
inline

Definition at line 117 of file ossimVrect.h.

References ll(), lr(), theLlCorner, theLrCorner, theUlCorner, theUrCorner, ul(), and ur().

118 {
119  return ( (theUlCorner == rect.ul()) &&
120  (theUrCorner == rect.ur()) &&
121  (theLrCorner == rect.lr()) &&
122  (theLlCorner == rect.ll()) );
123 }
ossimDpt theLrCorner
Definition: ossimVrect.h:92
ossimDpt theUlCorner
Definition: ossimVrect.h:90
const ossimDpt & ur() const
Definition: ossimVrect.h:66
const ossimDpt & ul() const
Definition: ossimVrect.h:65
const ossimDpt & ll() const
Definition: ossimVrect.h:68
const ossimDpt & lr() const
Definition: ossimVrect.h:67
ossimDpt theLlCorner
Definition: ossimVrect.h:91
ossimDpt theUrCorner
Definition: ossimVrect.h:93

◆ print()

void ossimVrect::print ( std::ostream &  os) const

Definition at line 24 of file ossimVrect.cpp.

References theLrCorner, and theUlCorner.

Referenced by operator<<().

25 {
26  os << theUlCorner << theLrCorner;
27 }
ossimDpt theLrCorner
Definition: ossimVrect.h:92
ossimDpt theUlCorner
Definition: ossimVrect.h:90

◆ ul()

const ossimDpt& ossimVrect::ul ( ) const
inline

Definition at line 65 of file ossimVrect.h.

Referenced by clipToRect(), combine(), midPoint(), operator!=(), operator=(), and operator==().

65 { return theUlCorner; }
ossimDpt theUlCorner
Definition: ossimVrect.h:90

◆ ur()

const ossimDpt& ossimVrect::ur ( ) const
inline

Definition at line 66 of file ossimVrect.h.

Referenced by midPoint(), operator!=(), operator=(), and operator==().

66 { return theUrCorner; }
ossimDpt theUrCorner
Definition: ossimVrect.h:93

◆ width()

ossim_float64 ossimVrect::width ( ) const
inline

Returns the width of a rectangle.

Definition at line 78 of file ossimVrect.h.

79  { return fabs(theLrCorner.x - theLlCorner.x) + 1.0; }
ossimDpt theLrCorner
Definition: ossimVrect.h:92
ossimDpt theLlCorner
Definition: ossimVrect.h:91
double x
Definition: ossimDpt.h:164

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const ossimVrect rect 
)
friend

Definition at line 32 of file ossimVrect.cpp.

33 {
34  rect.print(os);
35 
36  return os;
37 }
void print(std::ostream &os) const
Definition: ossimVrect.cpp:24

Member Data Documentation

◆ theLlCorner

ossimDpt ossimVrect::theLlCorner
private

Definition at line 91 of file ossimVrect.h.

Referenced by operator!=(), operator=(), and operator==().

◆ theLrCorner

ossimDpt ossimVrect::theLrCorner
private

Definition at line 92 of file ossimVrect.h.

Referenced by operator!=(), operator=(), operator==(), and print().

◆ theUlCorner

ossimDpt ossimVrect::theUlCorner
private

Definition at line 90 of file ossimVrect.h.

Referenced by operator!=(), operator=(), operator==(), and print().

◆ theUrCorner

ossimDpt ossimVrect::theUrCorner
private

Definition at line 93 of file ossimVrect.h.

Referenced by operator!=(), operator=(), and operator==().


The documentation for this class was generated from the following files: