16 #include "msdevstudio/MSconfig.h"
27 #define _GLIBCPP_USE_C99 1
46 using std::replace_if;
49 using namespace hippodraw;
52 : m_origin(), m_size()
57 Rect(
double x,
double y,
double width,
double height )
58 : m_origin(), m_size()
64 double width,
double height,
double depth )
65 : m_origin(), m_size()
67 setRect( x, y, z, width, height, depth );
77 double width,
double height,
double depth )
151 if ( isnan ( x1 ) || isnan ( y1 ) )
return false;
153 double x_lo =
getX ();
154 double y_lo =
getY ();
159 if( x1 < x_lo || x1 > x_hi ||
160 y1 < y_lo || y1 > y_hi )
return false;
167 double x_lo =
getX ();
168 double y_lo =
getY ();
169 double z_lo =
getZ ();
175 if( x1 < x_lo || x1 > x_hi ||
176 y1 < y_lo || y1 > y_hi ||
177 z1 < z_lo || z1 > z_hi )
return false;
196 else if ( x1 > x_hi ) {
202 else if ( y1 > y_hi ) {
219 x1 = max ( x1, x_lo );
220 x1 = min ( x1, x_hi );
222 y1 = max ( y1, y_lo );
223 y1 = min ( y1, y_hi );
225 z1 = max ( z1, z_lo );
226 z1 = min ( z1, z_hi );
232 std::vector< double > & y )
const
237 replace_if ( x.begin (), x.end (),
238 bind2nd ( less< double > (), lo ), lo );
240 replace_if ( x.begin (), x.end (),
241 bind2nd ( greater< double > (), hi ), hi );
246 replace_if ( y.begin (), y.end (),
247 bind2nd ( less< double > (), lo ), lo );
249 replace_if ( y.begin (), y.end (),
250 bind2nd ( greater< double > (), hi ), hi );
257 std::vector< double > & y,
258 std::vector< double > & z )
const
263 replace_if ( x.begin (), x.end (),
264 bind2nd ( less< double > (), lo ), lo );
266 replace_if ( x.begin (), x.end (),
267 bind2nd ( greater< double > (), hi ), hi );
272 replace_if ( y.begin (), y.end (),
273 bind2nd ( less< double > (), lo ), lo );
275 replace_if ( y.begin (), y.end (),
276 bind2nd ( greater< double > (), hi ), hi );
281 replace_if ( z.begin (), z.end (),
282 bind2nd ( less< double > (), lo ), lo );
284 replace_if ( z.begin (), z.end (),
285 bind2nd ( greater< double > (), hi ), hi );
void makeInBounds(double &x, double &y) const
Changes the coordinates so that they are inside or on the boundary of the rectangle.
void moveBy(double x, double y)
Moves the point by specified amount.
double getHeight() const
A shortcut to get size.height.
void setZ(double)
Sets the Z dimension.
bool isInDepth(double z1) const
Checks the value against the depth to see if it is in bounds.
double getY() const
The following function returns the Y coordinate.
hippodrw::Rect class interface
Class representing a two or three dimension point.
void setSize(double width, double height)
void setZ(double)
Sets the Z component of the Rectangle.
Rect()
Default constructor.
double getWidth() const
A shortcut to get size.width.
void setRect(double x, double y, double width, double height)
Set the parameters of 2D Rectangle.
void setDepth(double)
Sets the depth dimenision of the size.
void setDepth(double)
Sets the depth of the rectangle.
double getZ() const
A shortcut to get origin.Z.
double getDepth() const
A shortcut to get size.depth.
Size m_size
The size of the Rectangle.
void moveBy(double x, double y)
Moves the Rectangle by specified amount.
Class representing a two or three dimension size.
double getZ() const
The following function returns the Z coordinate.
double getX() const
A shortcut to get origin.X.
double getWidth() const
The following function returns the width.
bool isInBounds(double x1, double y1) const
Checks the coordinates to see if they are inside or on the boundary of the rectangle.
double getHeight() const
The following function returns the height.
void setPoint(double x, double y)
const Size & getSize() const
Returns the size.
double getY() const
A shortcut to get origin.Y.
double getDepth() const
The following function returns the depth.
const Point & getOrigin() const
Returns the origin.
double getX() const
The following function returns the X coordinate.
Point m_origin
The origin of the Rectangle.