<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>HippoDraw Class Library</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> <link rel="shortcut icon" href="hippoApp.ico"> </head><body> <!-- Generated by Doxygen 1.6.2 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_dd37c879693a21e1d65a2840272c12ab.html">graphics</a> </div> </div> <div class="contents"> <h1>Rectangle.cxx</h1><a href="Rectangle_8cxx.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00014"></a>00014 <span class="preprocessor">#ifdef _MSC_VER</span> <a name="l00015"></a>00015 <span class="preprocessor"></span><span class="comment">// Include max() and min() missing from MicroSoft Visual C++.</span> <a name="l00016"></a>00016 <span class="preprocessor">#include "msdevstudio/MSconfig.h"</span> <a name="l00017"></a>00017 <span class="preprocessor">#endif //_MSC_VER</span> <a name="l00018"></a>00018 <span class="preprocessor"></span> <a name="l00019"></a>00019 <span class="preprocessor">#include "<a class="code" href="Rectangle_8h.html" title="hippodrw::Rect class interface">Rectangle.h</a>"</span> <a name="l00020"></a>00020 <a name="l00021"></a>00021 <span class="preprocessor">#ifdef _MSC_VER</span> <a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#define isnan _isnan</span> <a name="l00023"></a>00023 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00024"></a>00024 <span class="preprocessor"></span> <a name="l00025"></a>00025 <span class="comment">//To have isnan.</span> <a name="l00026"></a>00026 <span class="preprocessor">#ifdef __APPLE__</span> <a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#define _GLIBCPP_USE_C99 1</span> <a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00029"></a>00029 <span class="preprocessor"></span> <a name="l00030"></a>00030 <span class="preprocessor">#include <algorithm></span> <a name="l00031"></a>00031 <span class="preprocessor">#include <functional></span> <a name="l00032"></a>00032 <span class="preprocessor">#include <iostream></span> <a name="l00033"></a>00033 <a name="l00034"></a>00034 <span class="preprocessor">#include <cmath></span> <a name="l00035"></a>00035 <span class="preprocessor">#include <cfloat></span> <a name="l00036"></a>00036 <a name="l00037"></a>00037 <span class="preprocessor">#ifdef __APPLE__</span> <a name="l00038"></a>00038 <span class="preprocessor"></span><span class="keyword">using</span> std::isnan; <a name="l00039"></a>00039 <span class="preprocessor">#endif</span> <a name="l00040"></a>00040 <span class="preprocessor"></span> <a name="l00041"></a>00041 <span class="keyword">using</span> std::bind2nd; <a name="l00042"></a>00042 <span class="keyword">using</span> std::greater; <a name="l00043"></a>00043 <span class="keyword">using</span> std::less; <a name="l00044"></a>00044 <span class="keyword">using</span> std::max; <a name="l00045"></a>00045 <span class="keyword">using</span> std::min; <a name="l00046"></a>00046 <span class="keyword">using</span> std::replace_if; <a name="l00047"></a>00047 <span class="keyword">using</span> std::vector; <a name="l00048"></a>00048 <a name="l00049"></a>00049 <span class="keyword">using namespace </span>hippodraw; <a name="l00050"></a>00050 <a name="l00051"></a><a class="code" href="classhippodraw_1_1Rect.html#ae436fd0322c99157c5443a3385961e22">00051</a> Rect::Rect() <a name="l00052"></a>00052 : m_origin(), m_size() <a name="l00053"></a>00053 { <a name="l00054"></a>00054 } <a name="l00055"></a>00055 <a name="l00056"></a>00056 <a class="code" href="classhippodraw_1_1Rect.html#ae436fd0322c99157c5443a3385961e22" title="Default constructor.">Rect::</a> <a name="l00057"></a><a class="code" href="classhippodraw_1_1Rect.html#ac6c4908a8afc650d0c882ff162a425bc">00057</a> <a class="code" href="classhippodraw_1_1Rect.html#ae436fd0322c99157c5443a3385961e22" title="Default constructor.">Rect</a>( <span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y, <span class="keywordtype">double</span> width, <span class="keywordtype">double</span> height ) <a name="l00058"></a>00058 : m_origin(), m_size() <a name="l00059"></a>00059 { <a name="l00060"></a>00060 <a class="code" href="classhippodraw_1_1Rect.html#a4e35ed485a6c714ac8b2707bb152af60" title="Set the parameters of 2D Rectangle.">setRect</a>( x, y, width, height ); <a name="l00061"></a>00061 } <a name="l00062"></a>00062 <a name="l00063"></a><a class="code" href="classhippodraw_1_1Rect.html#a511806409f2e21bfddc220640f69249b">00063</a> <a class="code" href="classhippodraw_1_1Rect.html#ae436fd0322c99157c5443a3385961e22" title="Default constructor.">Rect::Rect</a>( <span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y, <span class="keywordtype">double</span> z, <a name="l00064"></a>00064 <span class="keywordtype">double</span> width, <span class="keywordtype">double</span> height, <span class="keywordtype">double</span> depth ) <a name="l00065"></a>00065 : m_origin(), m_size() <a name="l00066"></a>00066 { <a name="l00067"></a>00067 <a class="code" href="classhippodraw_1_1Rect.html#a4e35ed485a6c714ac8b2707bb152af60" title="Set the parameters of 2D Rectangle.">setRect</a>( x, y, z, width, height, depth ); <a name="l00068"></a>00068 } <a name="l00069"></a>00069 <a name="l00070"></a><a class="code" href="classhippodraw_1_1Rect.html#a4e35ed485a6c714ac8b2707bb152af60">00070</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1Rect.html#a4e35ed485a6c714ac8b2707bb152af60" title="Set the parameters of 2D Rectangle.">Rect::setRect</a>( <span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y, <span class="keywordtype">double</span> width, <span class="keywordtype">double</span> height ) <a name="l00071"></a>00071 { <a name="l00072"></a>00072 <a class="code" href="classhippodraw_1_1Rect.html#aeff5670a4ac7d3b61978676f40a1c088" title="The origin of the Rectangle.">m_origin</a>.<a class="code" href="classhippodraw_1_1Point.html#aae20a5a02597edd1813cf2d76b679926">setPoint</a>( x, y ); <a name="l00073"></a>00073 <a class="code" href="classhippodraw_1_1Rect.html#ab671eca0216b5844e8ef60b4b4184487" title="The size of the Rectangle.">m_size</a>.<a class="code" href="classhippodraw_1_1Size.html#aca25d49481f9bf5fc8f7df4c086c4ce7">setSize</a>( width, height ); <a name="l00074"></a>00074 } <a name="l00075"></a>00075 <a name="l00076"></a><a class="code" href="classhippodraw_1_1Rect.html#a04856ef24101641b8f504f8bda90513f">00076</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1Rect.html#a4e35ed485a6c714ac8b2707bb152af60" title="Set the parameters of 2D Rectangle.">Rect::setRect</a>( <span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y, <span class="keywordtype">double</span> z, <a name="l00077"></a>00077 <span class="keywordtype">double</span> width, <span class="keywordtype">double</span> height, <span class="keywordtype">double</span> depth ) <a name="l00078"></a>00078 { <a name="l00079"></a>00079 <a class="code" href="classhippodraw_1_1Rect.html#aeff5670a4ac7d3b61978676f40a1c088" title="The origin of the Rectangle.">m_origin</a>.<a class="code" href="classhippodraw_1_1Point.html#aae20a5a02597edd1813cf2d76b679926">setPoint</a>( x, y, z ); <a name="l00080"></a>00080 <a class="code" href="classhippodraw_1_1Rect.html#ab671eca0216b5844e8ef60b4b4184487" title="The size of the Rectangle.">m_size</a>.<a class="code" href="classhippodraw_1_1Size.html#aca25d49481f9bf5fc8f7df4c086c4ce7">setSize</a>( width, height, depth ); <a name="l00081"></a>00081 } <a name="l00082"></a>00082 <a name="l00083"></a><a class="code" href="classhippodraw_1_1Rect.html#a0a54aee40f16bb73d33931f333f208be">00083</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1Rect.html#a0a54aee40f16bb73d33931f333f208be" title="Moves the Rectangle by specified amount.">Rect::moveBy</a> ( <span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y ) <a name="l00084"></a>00084 { <a name="l00085"></a>00085 <a class="code" href="classhippodraw_1_1Rect.html#aeff5670a4ac7d3b61978676f40a1c088" title="The origin of the Rectangle.">m_origin</a>.<a class="code" href="classhippodraw_1_1Point.html#a0a54aee40f16bb73d33931f333f208be" title="Moves the point by specified amount.">moveBy</a> ( x, y ); <a name="l00086"></a>00086 } <a name="l00087"></a>00087 <a name="l00088"></a><a class="code" href="classhippodraw_1_1Rect.html#a3113241c60766acdbd6528357bee855c">00088</a> <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Point.html" title="Class representing a two or three dimension point.">Point</a> & <a class="code" href="classhippodraw_1_1Rect.html#a3113241c60766acdbd6528357bee855c" title="Returns the origin.">Rect::getOrigin</a>()<span class="keyword"> const</span> <a name="l00089"></a>00089 <span class="keyword"></span>{ <a name="l00090"></a>00090 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1Rect.html#aeff5670a4ac7d3b61978676f40a1c088" title="The origin of the Rectangle.">m_origin</a>; <a name="l00091"></a>00091 } <a name="l00092"></a>00092 <a name="l00093"></a><a class="code" href="classhippodraw_1_1Rect.html#a5ed1187d992a910f5ad71e25a3056da1">00093</a> <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Size.html" title="Class representing a two or three dimension size.">Size</a> & <a class="code" href="classhippodraw_1_1Rect.html#a5ed1187d992a910f5ad71e25a3056da1" title="Returns the size.">Rect::getSize</a>()<span class="keyword"> const</span> <a name="l00094"></a>00094 <span class="keyword"></span>{ <a name="l00095"></a>00095 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1Rect.html#ab671eca0216b5844e8ef60b4b4184487" title="The size of the Rectangle.">m_size</a>; <a name="l00096"></a>00096 } <a name="l00097"></a>00097 <a name="l00098"></a><a class="code" href="classhippodraw_1_1Rect.html#aa8d2d377de54332ea8f5c6191ddea692">00098</a> <span class="keywordtype">double</span> <a class="code" href="classhippodraw_1_1Rect.html#aa8d2d377de54332ea8f5c6191ddea692" title="A shortcut to get origin.Z.">Rect::getZ</a>()<span class="keyword"> const</span> <a name="l00099"></a>00099 <span class="keyword"></span>{ <a name="l00100"></a>00100 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1Rect.html#a3113241c60766acdbd6528357bee855c" title="Returns the origin.">getOrigin</a>().<a class="code" href="classhippodraw_1_1Point.html#aa8d2d377de54332ea8f5c6191ddea692" title="The following function returns the Z coordinate.">getZ</a>(); <a name="l00101"></a>00101 } <a name="l00102"></a>00102 <a name="l00103"></a><a class="code" href="classhippodraw_1_1Rect.html#a5c7441d63ee9d9d76d552f188cc7a14c">00103</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1Rect.html#a5c7441d63ee9d9d76d552f188cc7a14c" title="Sets the Z dimension.">Rect::setZ</a> ( <span class="keywordtype">double</span> z ) <a name="l00104"></a>00104 { <a name="l00105"></a>00105 <a class="code" href="classhippodraw_1_1Rect.html#aeff5670a4ac7d3b61978676f40a1c088" title="The origin of the Rectangle.">m_origin</a>.<a class="code" href="classhippodraw_1_1Point.html#a5c7441d63ee9d9d76d552f188cc7a14c" title="Sets the Z component of the Rectangle.">setZ</a> ( z ); <a name="l00106"></a>00106 } <a name="l00107"></a>00107 <a name="l00108"></a><a class="code" href="classhippodraw_1_1Rect.html#a5410fe8e5b318eb82d84dcccf3634d8b">00108</a> <span class="keywordtype">double</span> <a class="code" href="classhippodraw_1_1Rect.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="A shortcut to get size.width.">Rect::getWidth</a>()<span class="keyword"> const</span> <a name="l00109"></a>00109 <span class="keyword"></span>{ <a name="l00110"></a>00110 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1Rect.html#ab671eca0216b5844e8ef60b4b4184487" title="The size of the Rectangle.">m_size</a>.<a class="code" href="classhippodraw_1_1Size.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="The following function returns the width.">getWidth</a>(); <a name="l00111"></a>00111 } <a name="l00112"></a>00112 <a name="l00113"></a><a class="code" href="classhippodraw_1_1Rect.html#ab22b7a83bfd69953e9421f6941bc9304">00113</a> <span class="keywordtype">double</span> <a class="code" href="classhippodraw_1_1Rect.html#ab22b7a83bfd69953e9421f6941bc9304" title="A shortcut to get size.height.">Rect::getHeight</a>()<span class="keyword"> const</span> <a name="l00114"></a>00114 <span class="keyword"></span>{ <a name="l00115"></a>00115 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1Rect.html#ab671eca0216b5844e8ef60b4b4184487" title="The size of the Rectangle.">m_size</a>.<a class="code" href="classhippodraw_1_1Size.html#ab22b7a83bfd69953e9421f6941bc9304" title="The following function returns the height.">getHeight</a>(); <a name="l00116"></a>00116 } <a name="l00117"></a>00117 <a name="l00118"></a><a class="code" href="classhippodraw_1_1Rect.html#a1adc74eef892f7566f7588640487a5bb">00118</a> <span class="keywordtype">double</span> <a class="code" href="classhippodraw_1_1Rect.html#a1adc74eef892f7566f7588640487a5bb" title="A shortcut to get size.depth.">Rect::getDepth</a>()<span class="keyword"> const</span> <a name="l00119"></a>00119 <span class="keyword"></span>{ <a name="l00120"></a>00120 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1Rect.html#a5ed1187d992a910f5ad71e25a3056da1" title="Returns the size.">getSize</a>().<a class="code" href="classhippodraw_1_1Size.html#a1adc74eef892f7566f7588640487a5bb" title="The following function returns the depth.">getDepth</a>(); <a name="l00121"></a>00121 } <a name="l00122"></a>00122 <a name="l00123"></a>00123 <a name="l00124"></a><a class="code" href="classhippodraw_1_1Rect.html#a770777aa902687e8420ac2a611c3bff8">00124</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1Rect.html#a770777aa902687e8420ac2a611c3bff8" title="Sets the depth of the rectangle.">Rect::setDepth</a> ( <span class="keywordtype">double</span> d ) <a name="l00125"></a>00125 { <a name="l00126"></a>00126 <a class="code" href="classhippodraw_1_1Rect.html#ab671eca0216b5844e8ef60b4b4184487" title="The size of the Rectangle.">m_size</a>.<a class="code" href="classhippodraw_1_1Size.html#a770777aa902687e8420ac2a611c3bff8" title="Sets the depth dimenision of the size.">setDepth</a> ( d ); <a name="l00127"></a>00127 } <a name="l00128"></a>00128 <a name="l00136"></a><a class="code" href="classhippodraw_1_1Rect.html#a1562bb253fac5b114dfa4250f2baf67e">00136</a> <span class="keywordtype">bool</span> <a class="code" href="classhippodraw_1_1Rect.html#a1562bb253fac5b114dfa4250f2baf67e" title="Checks the value against the depth to see if it is in bounds.">Rect::isInDepth</a> ( <span class="keywordtype">double</span> z1 )<span class="keyword"> const</span> <a name="l00137"></a>00137 <span class="keyword"></span>{ <a name="l00138"></a>00138 <span class="keywordtype">bool</span> yes = <span class="keyword">false</span>; <a name="l00139"></a>00139 <span class="keywordtype">double</span> z_lo = <a class="code" href="classhippodraw_1_1Rect.html#aeff5670a4ac7d3b61978676f40a1c088" title="The origin of the Rectangle.">m_origin</a>.<a class="code" href="classhippodraw_1_1Point.html#aa8d2d377de54332ea8f5c6191ddea692" title="The following function returns the Z coordinate.">getZ</a> (); <a name="l00140"></a>00140 <a name="l00141"></a>00141 <span class="keywordflow">if</span> ( z1 >= z_lo && <a name="l00142"></a>00142 ( z1 ) <= z_lo + 1.00001*<a class="code" href="classhippodraw_1_1Rect.html#ab671eca0216b5844e8ef60b4b4184487" title="The size of the Rectangle.">m_size</a>.<a class="code" href="classhippodraw_1_1Size.html#a1adc74eef892f7566f7588640487a5bb" title="The following function returns the depth.">getDepth</a>() ) yes = <span class="keyword">true</span>; <a name="l00143"></a>00143 <a name="l00144"></a>00144 <span class="keywordflow">return</span> yes; <a name="l00145"></a>00145 } <a name="l00146"></a>00146 <a name="l00149"></a><a class="code" href="classhippodraw_1_1Rect.html#a113e4881dc561d2a7233568b478551df">00149</a> <span class="keywordtype">bool</span> <a class="code" href="classhippodraw_1_1Rect.html#a113e4881dc561d2a7233568b478551df" title="Checks the coordinates to see if they are inside or on the boundary of the rectangle...">Rect::isInBounds</a> ( <span class="keywordtype">double</span> x1, <span class="keywordtype">double</span> y1 )<span class="keyword"> const</span> <a name="l00150"></a>00150 <span class="keyword"></span>{ <a name="l00151"></a>00151 <span class="keywordflow">if</span> ( isnan ( x1 ) || isnan ( y1 ) ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00152"></a>00152 <a name="l00153"></a>00153 <span class="keywordtype">double</span> x_lo = <a class="code" href="classhippodraw_1_1Rect.html#af71e522ec6aa935c2618819b54f20e02" title="A shortcut to get origin.X.">getX</a> (); <a name="l00154"></a>00154 <span class="keywordtype">double</span> y_lo = <a class="code" href="classhippodraw_1_1Rect.html#acd84440598b1da2a23c326ce371db4e4" title="A shortcut to get origin.Y.">getY</a> (); <a name="l00155"></a>00155 <a name="l00156"></a>00156 <span class="keywordtype">double</span> x_hi = x_lo + <a class="code" href="classhippodraw_1_1Rect.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="A shortcut to get size.width.">getWidth</a>(); <a name="l00157"></a>00157 <span class="keywordtype">double</span> y_hi = y_lo + <a class="code" href="classhippodraw_1_1Rect.html#ab22b7a83bfd69953e9421f6941bc9304" title="A shortcut to get size.height.">getHeight</a>(); <a name="l00158"></a>00158 <a name="l00159"></a>00159 <span class="keywordflow">if</span>( x1 < x_lo || x1 > x_hi || <a name="l00160"></a>00160 y1 < y_lo || y1 > y_hi ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00161"></a>00161 <a name="l00162"></a>00162 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00163"></a>00163 } <a name="l00164"></a>00164 <a name="l00165"></a><a class="code" href="classhippodraw_1_1Rect.html#a90e2c4a5ae5c96b8b656f8c6ea482692">00165</a> <span class="keywordtype">bool</span> <a class="code" href="classhippodraw_1_1Rect.html#a113e4881dc561d2a7233568b478551df" title="Checks the coordinates to see if they are inside or on the boundary of the rectangle...">Rect::isInBounds</a> ( <span class="keywordtype">double</span> x1, <span class="keywordtype">double</span> y1, <span class="keywordtype">double</span> z1 )<span class="keyword"> const</span> <a name="l00166"></a>00166 <span class="keyword"></span>{ <a name="l00167"></a>00167 <span class="keywordtype">double</span> x_lo = <a class="code" href="classhippodraw_1_1Rect.html#af71e522ec6aa935c2618819b54f20e02" title="A shortcut to get origin.X.">getX</a> (); <a name="l00168"></a>00168 <span class="keywordtype">double</span> y_lo = <a class="code" href="classhippodraw_1_1Rect.html#acd84440598b1da2a23c326ce371db4e4" title="A shortcut to get origin.Y.">getY</a> (); <a name="l00169"></a>00169 <span class="keywordtype">double</span> z_lo = <a class="code" href="classhippodraw_1_1Rect.html#aa8d2d377de54332ea8f5c6191ddea692" title="A shortcut to get origin.Z.">getZ</a> (); <a name="l00170"></a>00170 <a name="l00171"></a>00171 <span class="keywordtype">double</span> x_hi = x_lo + <a class="code" href="classhippodraw_1_1Rect.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="A shortcut to get size.width.">getWidth</a>(); <a name="l00172"></a>00172 <span class="keywordtype">double</span> y_hi = y_lo + <a class="code" href="classhippodraw_1_1Rect.html#ab22b7a83bfd69953e9421f6941bc9304" title="A shortcut to get size.height.">getHeight</a>(); <a name="l00173"></a>00173 <span class="keywordtype">double</span> z_hi = z_lo + <a class="code" href="classhippodraw_1_1Rect.html#a1adc74eef892f7566f7588640487a5bb" title="A shortcut to get size.depth.">getDepth</a>(); <a name="l00174"></a>00174 <a name="l00175"></a>00175 <span class="keywordflow">if</span>( x1 < x_lo || x1 > x_hi || <a name="l00176"></a>00176 y1 < y_lo || y1 > y_hi || <a name="l00177"></a>00177 z1 < z_lo || z1 > z_hi ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00178"></a>00178 <a name="l00179"></a>00179 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00180"></a>00180 } <a name="l00181"></a>00181 <a name="l00182"></a>00182 <span class="comment">/* Note: the if statements were measured faster than the use of max()</span> <a name="l00183"></a>00183 <span class="comment"> and min(). </span> <a name="l00184"></a>00184 <span class="comment">*/</span> <a name="l00185"></a><a class="code" href="classhippodraw_1_1Rect.html#a4d3aa2a3a88746ce6270b68812faca3c">00185</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1Rect.html#a4d3aa2a3a88746ce6270b68812faca3c" title="Changes the coordinates so that they are inside or on the boundary of the rectangle...">Rect::makeInBounds</a> ( <span class="keywordtype">double</span> & x1, <span class="keywordtype">double</span> & y1 )<span class="keyword"> const</span> <a name="l00186"></a>00186 <span class="keyword"></span>{ <a name="l00187"></a>00187 <span class="keywordtype">double</span> x_lo = <a class="code" href="classhippodraw_1_1Rect.html#aeff5670a4ac7d3b61978676f40a1c088" title="The origin of the Rectangle.">m_origin</a>.<a class="code" href="classhippodraw_1_1Point.html#af71e522ec6aa935c2618819b54f20e02" title="The following function returns the X coordinate.">getX</a> (); <a name="l00188"></a>00188 <span class="keywordtype">double</span> y_lo = <a class="code" href="classhippodraw_1_1Rect.html#aeff5670a4ac7d3b61978676f40a1c088" title="The origin of the Rectangle.">m_origin</a>.<a class="code" href="classhippodraw_1_1Point.html#acd84440598b1da2a23c326ce371db4e4" title="The following function returns the Y coordinate.">getY</a> (); <a name="l00189"></a>00189 <a name="l00190"></a>00190 <span class="keywordtype">double</span> x_hi = x_lo + <a class="code" href="classhippodraw_1_1Rect.html#ab671eca0216b5844e8ef60b4b4184487" title="The size of the Rectangle.">m_size</a>.<a class="code" href="classhippodraw_1_1Size.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="The following function returns the width.">getWidth</a>(); <a name="l00191"></a>00191 <span class="keywordtype">double</span> y_hi = y_lo + <a class="code" href="classhippodraw_1_1Rect.html#ab671eca0216b5844e8ef60b4b4184487" title="The size of the Rectangle.">m_size</a>.<a class="code" href="classhippodraw_1_1Size.html#ab22b7a83bfd69953e9421f6941bc9304" title="The following function returns the height.">getHeight</a>(); <a name="l00192"></a>00192 <a name="l00193"></a>00193 <span class="keywordflow">if</span> ( x1 < x_lo ) { <a name="l00194"></a>00194 x1 = x_lo; <a name="l00195"></a>00195 } <a name="l00196"></a>00196 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( x1 > x_hi ) { <a name="l00197"></a>00197 x1 = x_hi; <a name="l00198"></a>00198 } <a name="l00199"></a>00199 <span class="keywordflow">if</span> ( y1 < y_lo ) { <a name="l00200"></a>00200 y1 = y_lo; <a name="l00201"></a>00201 } <a name="l00202"></a>00202 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( y1 > y_hi ) { <a name="l00203"></a>00203 y1 = y_hi; <a name="l00204"></a>00204 } <a name="l00205"></a>00205 } <a name="l00206"></a>00206 <a name="l00207"></a>00207 <span class="keywordtype">void</span> <a name="l00208"></a>00208 <a class="code" href="classhippodraw_1_1Rect.html#a4d3aa2a3a88746ce6270b68812faca3c" title="Changes the coordinates so that they are inside or on the boundary of the rectangle...">Rect::</a> <a name="l00209"></a><a class="code" href="classhippodraw_1_1Rect.html#a55906f4280bdfe781fda3dced9813d4c">00209</a> <a class="code" href="classhippodraw_1_1Rect.html#a4d3aa2a3a88746ce6270b68812faca3c" title="Changes the coordinates so that they are inside or on the boundary of the rectangle...">makeInBounds</a> ( <span class="keywordtype">double</span> & x1, <span class="keywordtype">double</span> & y1, <span class="keywordtype">double</span> & z1 )<span class="keyword"> const</span> <a name="l00210"></a>00210 <span class="keyword"></span>{ <a name="l00211"></a>00211 <span class="keywordtype">double</span> x_lo = <a class="code" href="classhippodraw_1_1Rect.html#aeff5670a4ac7d3b61978676f40a1c088" title="The origin of the Rectangle.">m_origin</a>.<a class="code" href="classhippodraw_1_1Point.html#af71e522ec6aa935c2618819b54f20e02" title="The following function returns the X coordinate.">getX</a> (); <a name="l00212"></a>00212 <span class="keywordtype">double</span> y_lo = <a class="code" href="classhippodraw_1_1Rect.html#aeff5670a4ac7d3b61978676f40a1c088" title="The origin of the Rectangle.">m_origin</a>.<a class="code" href="classhippodraw_1_1Point.html#acd84440598b1da2a23c326ce371db4e4" title="The following function returns the Y coordinate.">getY</a> (); <a name="l00213"></a>00213 <span class="keywordtype">double</span> z_lo = <a class="code" href="classhippodraw_1_1Rect.html#aeff5670a4ac7d3b61978676f40a1c088" title="The origin of the Rectangle.">m_origin</a>.<a class="code" href="classhippodraw_1_1Point.html#aa8d2d377de54332ea8f5c6191ddea692" title="The following function returns the Z coordinate.">getZ</a> (); <a name="l00214"></a>00214 <a name="l00215"></a>00215 <span class="keywordtype">double</span> x_hi = x_lo + <a class="code" href="classhippodraw_1_1Rect.html#ab671eca0216b5844e8ef60b4b4184487" title="The size of the Rectangle.">m_size</a>.<a class="code" href="classhippodraw_1_1Size.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="The following function returns the width.">getWidth</a>(); <a name="l00216"></a>00216 <span class="keywordtype">double</span> y_hi = y_lo + <a class="code" href="classhippodraw_1_1Rect.html#ab671eca0216b5844e8ef60b4b4184487" title="The size of the Rectangle.">m_size</a>.<a class="code" href="classhippodraw_1_1Size.html#ab22b7a83bfd69953e9421f6941bc9304" title="The following function returns the height.">getHeight</a>(); <a name="l00217"></a>00217 <span class="keywordtype">double</span> z_hi = z_lo + <a class="code" href="classhippodraw_1_1Rect.html#ab671eca0216b5844e8ef60b4b4184487" title="The size of the Rectangle.">m_size</a>.<a class="code" href="classhippodraw_1_1Size.html#a1adc74eef892f7566f7588640487a5bb" title="The following function returns the depth.">getDepth</a>(); <a name="l00218"></a>00218 <a name="l00219"></a>00219 x1 = max ( x1, x_lo ); <a name="l00220"></a>00220 x1 = min ( x1, x_hi ); <a name="l00221"></a>00221 <a name="l00222"></a>00222 y1 = max ( y1, y_lo ); <a name="l00223"></a>00223 y1 = min ( y1, y_hi ); <a name="l00224"></a>00224 <a name="l00225"></a>00225 z1 = max ( z1, z_lo ); <a name="l00226"></a>00226 z1 = min ( z1, z_hi ); <a name="l00227"></a>00227 } <a name="l00228"></a>00228 <a name="l00229"></a>00229 <span class="keywordtype">void</span> <a name="l00230"></a>00230 <a class="code" href="classhippodraw_1_1Rect.html#a4d3aa2a3a88746ce6270b68812faca3c" title="Changes the coordinates so that they are inside or on the boundary of the rectangle...">Rect::</a> <a name="l00231"></a><a class="code" href="classhippodraw_1_1Rect.html#a23053195db1c6380262a6d1241544747">00231</a> <a class="code" href="classhippodraw_1_1Rect.html#a4d3aa2a3a88746ce6270b68812faca3c" title="Changes the coordinates so that they are inside or on the boundary of the rectangle...">makeInBounds</a> ( std::vector< double > & x, <a name="l00232"></a>00232 std::vector< double > & y )<span class="keyword"> const</span> <a name="l00233"></a>00233 <span class="keyword"></span>{ <a name="l00234"></a>00234 <span class="keywordtype">double</span> lo = <a class="code" href="classhippodraw_1_1Rect.html#af71e522ec6aa935c2618819b54f20e02" title="A shortcut to get origin.X.">getX</a> (); <a name="l00235"></a>00235 <span class="keywordtype">double</span> hi = lo + <a class="code" href="classhippodraw_1_1Rect.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="A shortcut to get size.width.">getWidth</a> (); <a name="l00236"></a>00236 <a name="l00237"></a>00237 replace_if ( x.begin (), x.end (), <a name="l00238"></a>00238 bind2nd ( less< double > (), lo ), lo ); <a name="l00239"></a>00239 <a name="l00240"></a>00240 replace_if ( x.begin (), x.end (), <a name="l00241"></a>00241 bind2nd ( greater< double > (), hi ), hi ); <a name="l00242"></a>00242 <a name="l00243"></a>00243 lo = <a class="code" href="classhippodraw_1_1Rect.html#acd84440598b1da2a23c326ce371db4e4" title="A shortcut to get origin.Y.">getY</a> (); <a name="l00244"></a>00244 hi = lo + <a class="code" href="classhippodraw_1_1Rect.html#ab22b7a83bfd69953e9421f6941bc9304" title="A shortcut to get size.height.">getHeight</a> (); <a name="l00245"></a>00245 <a name="l00246"></a>00246 replace_if ( y.begin (), y.end (), <a name="l00247"></a>00247 bind2nd ( less< double > (), lo ), lo ); <a name="l00248"></a>00248 <a name="l00249"></a>00249 replace_if ( y.begin (), y.end (), <a name="l00250"></a>00250 bind2nd ( greater< double > (), hi ), hi ); <a name="l00251"></a>00251 <a name="l00252"></a>00252 } <a name="l00253"></a>00253 <a name="l00254"></a>00254 <span class="keywordtype">void</span> <a name="l00255"></a>00255 <a class="code" href="classhippodraw_1_1Rect.html#a4d3aa2a3a88746ce6270b68812faca3c" title="Changes the coordinates so that they are inside or on the boundary of the rectangle...">Rect::</a> <a name="l00256"></a><a class="code" href="classhippodraw_1_1Rect.html#a0fba561bac16553f4b9f537301a2b11b">00256</a> <a class="code" href="classhippodraw_1_1Rect.html#a4d3aa2a3a88746ce6270b68812faca3c" title="Changes the coordinates so that they are inside or on the boundary of the rectangle...">makeInBounds</a> ( std::vector< double > & x, <a name="l00257"></a>00257 std::vector< double > & y, <a name="l00258"></a>00258 std::vector< double > & z )<span class="keyword"> const</span> <a name="l00259"></a>00259 <span class="keyword"></span>{ <a name="l00260"></a>00260 <span class="keywordtype">double</span> lo = <a class="code" href="classhippodraw_1_1Rect.html#af71e522ec6aa935c2618819b54f20e02" title="A shortcut to get origin.X.">getX</a> (); <a name="l00261"></a>00261 <span class="keywordtype">double</span> hi = lo + <a class="code" href="classhippodraw_1_1Rect.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="A shortcut to get size.width.">getWidth</a> (); <a name="l00262"></a>00262 <a name="l00263"></a>00263 replace_if ( x.begin (), x.end (), <a name="l00264"></a>00264 bind2nd ( less< double > (), lo ), lo ); <a name="l00265"></a>00265 <a name="l00266"></a>00266 replace_if ( x.begin (), x.end (), <a name="l00267"></a>00267 bind2nd ( greater< double > (), hi ), hi ); <a name="l00268"></a>00268 <a name="l00269"></a>00269 lo = <a class="code" href="classhippodraw_1_1Rect.html#acd84440598b1da2a23c326ce371db4e4" title="A shortcut to get origin.Y.">getY</a> (); <a name="l00270"></a>00270 hi = lo + <a class="code" href="classhippodraw_1_1Rect.html#ab22b7a83bfd69953e9421f6941bc9304" title="A shortcut to get size.height.">getHeight</a> (); <a name="l00271"></a>00271 <a name="l00272"></a>00272 replace_if ( y.begin (), y.end (), <a name="l00273"></a>00273 bind2nd ( less< double > (), lo ), lo ); <a name="l00274"></a>00274 <a name="l00275"></a>00275 replace_if ( y.begin (), y.end (), <a name="l00276"></a>00276 bind2nd ( greater< double > (), hi ), hi ); <a name="l00277"></a>00277 <a name="l00278"></a>00278 lo = <a class="code" href="classhippodraw_1_1Rect.html#aa8d2d377de54332ea8f5c6191ddea692" title="A shortcut to get origin.Z.">getZ</a> (); <a name="l00279"></a>00279 hi = lo + <a class="code" href="classhippodraw_1_1Rect.html#a1adc74eef892f7566f7588640487a5bb" title="A shortcut to get size.depth.">getDepth</a> (); <a name="l00280"></a>00280 <a name="l00281"></a>00281 replace_if ( z.begin (), z.end (), <a name="l00282"></a>00282 bind2nd ( less< double > (), lo ), lo ); <a name="l00283"></a>00283 <a name="l00284"></a>00284 replace_if ( z.begin (), z.end (), <a name="l00285"></a>00285 bind2nd ( greater< double > (), hi ), hi ); <a name="l00286"></a>00286 <a name="l00287"></a>00287 } </pre></div></div> <hr size="1"><address style="align: right;"><small> Generated for HippoDraw Class Library by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0> </a> </small></address> </body> </html>