rect.h revision 6c3e745a94ef6b25a4ef9f018d350a7535aa45af
/**
* \file
* \brief D2<Interval> specialization to Rect
*/
/*
* Copyright 2007 Michael Sloan <mgsloan@gmail.com>
*
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, output to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*
*/
/* Authors of original rect class:
* Lauris Kaplinski <lauris@kaplinski.com>
* Nathan Hurst <njh@mail.csse.monash.edu.au>
* bulia byak <buliabyak@users.sf.net>
* MenTaLguY <mental@rydia.net>
*/
#ifndef _2GEOM_RECT
#define _2GEOM_RECT
/** D2<Interval> specialization to Rect */
/**
* %Rect class.
* The Rect class is actually a specialisation of D2<Interval>.
*
*/
template<>
Interval f[2];
/** Best not to use this constructor, do not rely on what it initializes the object to.
*The default constructor creates a rect of default intervals.
*/
f[X] = a;
f[Y] = b;
}
f[X] = Interval(a[X], b[X]);
f[Y] = Interval(a[Y], b[Y]);
}
/** Returns the four corners of the rectangle in positive order
* (clockwise if +Y is up, anticlockwise if +Y is down) */
switch(i % 4) {
}
}
//We should probably remove these - they're coord sys gnostic
/** Returns a vector from min to max. */
/**
* \brief Compute the area of this rectangle.
*
* Note that a zero area rectangle is not empty - just as the interval [0,0] contains one point, the rectangle [0,0] x [0,0] contains 1 point and no area.
* \retval For a valid return value, the rect must be tested for emptyness first.
*/
// inline bool isEmpty() const {
// return f[X].isEmpty() || f[Y].isEmpty();
// }
inline bool intersects(Rect const &r) const {
return f[X].intersects(r[X]) && f[Y].intersects(r[Y]);
}
}
}
}
}
}
}
};
}
for(unsigned i = 1; i < r.size(); i++)
return ret;
}
inline
{
{
}
{
}
{
}
{
}
}
/**
* Returns the smallest distance between p and rect.
*/
inline
{
}
/**
* The OptRect class can represent and empty Rect and non-empty Rects.
* If OptRect is not empty, it means that both X and Y intervals are not empty.
*
*/
/**
* Creates an empty OptRect when one of the argument intervals is empty.
*/
}
// else, stay empty.
}
/**
* Check whether this OptRect is empty or not.
*/
/**
* If \c this is empty, copy argument \c b. Otherwise, union with it (and do nothing when \c b is empty)
*/
if (b) {
if (*this) { // check that we are not empty
} else {
*this = b;
}
}
}
};
/**
* Returns the smallest rectangle that encloses both rectangles.
* An empty argument is assumed to be an empty rectangle
*/
if (!a) {
return b;
} else if (!b) {
return a;
} else {
return unify(*a, *b);
}
}
}
if (b) {
unionWith(*b);
}
}
} // end namespace Geom
#endif //_2GEOM_RECT
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :