70 template<
typename T,
int D,
typename Derived>
76 typedef boost::geometry::model::box<PointType>
BoxType;
85 for(
int d=0; d<D; ++d) {
92 RectBase(T x, T y, T z, T width, T height, T depth) :
126 for(
int d=0; d<D; ++d)
128 if(makeValid && (p1[d]>p2[d])) {
142 template<
typename Reflector>
145 reflector.property(
"MinCorner",
minCorner,
"The minimum corner");
146 reflector.property(
"MaxCorner",
maxCorner,
"The maximum corner");
170 template <
typename OtherDerived>
175 template <
typename OtherDerived>
187 template <
typename OtherGeometry>
188 bool contains(
const OtherGeometry& otherGeometry)
const {
189 return boost::geometry::within(otherGeometry, *
this);
193 template <
typename OtherGeometry>
195 return boost::geometry::intersects(otherGeometry, *
this);
199 template <
typename OtherGeometry>
200 bool disjoint(
const OtherGeometry& otherGeometry)
const {
201 return boost::geometry::disjoint(otherGeometry, *
this);
216 for(
int d=0; d<D; ++d)
238 for(
int d=0; d<D; ++d)
256 for(
int d=0; d<D; ++d)
299 return *((Derived*)
this);
302 for(
int d=0; d<D; ++d) {
304 r.maxCorner[d] = std::max(
maxCorner[d], other.maxCorner[d]);
321 }
else if(other.isValid()) {
322 for(
int d=0; d<D; ++d) {
329 return *((Derived*)
this);
358 for(
int d=0; d<D; ++d) {
365 return *((Derived*)
this);
387 for(
int d=0; d<D; ++d) {
388 r.minCorner[d] = std::max(
minCorner[d], other.minCorner[d]);
389 r.maxCorner[d] = std::min(
maxCorner[d], other.maxCorner[d]);
401 return *((Derived*)
this);
403 if(!other.isValid()) {
406 for(
int d=0; d<D; ++d) {
411 return *((Derived*)
this);
416 template<
typename U,
typename OtherDerived>
429 return *((Derived*)
this);
452 template<
typename T,
int D>
467 bool makeValid =
true) :
468 Base(p1, p2, makeValid) {}
501 Rect(T x, T y, T width, T height) :
502 Base(x, y, width, height) {}
511 Base(pos, width, height) {}
526 explicit Rect(
const cv::Rect_<T>& rect) :
527 Base(rect.x, rect.y, rect.width, rect.height) {}
535 bool makeValid =
true) :
536 Base(p1, p2, makeValid) {}
545 operator cv::Rect_<T>()
const 593 return std::list<Rect<T,2>>();
603 return std::list<Rect<T,2>>( {*
this} );
608 std::list<Rect<T,2>> result;
615 PointType otl(other.
x0(), other.
y1());
625 if ((rtl.
width() > 0) && (rtl.
height() > 0)) result.push_back(rtl);
626 if ((rbl.width() > 0) && (rbl.height() > 0)) result.push_back(rbl);
627 if ((rbr.width() > 0) && (rbr.height() > 0)) result.push_back(rbr);
628 if ((rtr.width() > 0) && (rtr.height() > 0)) result.push_back(rtr);
664 Rect(T x, T y, T z, T width, T height, T depth) :
665 Base(x, y, z, width, height, depth) {}
674 Base(pos, width, height, depth) {}
691 bool makeValid =
true) :
692 Base(p1, p2, makeValid) {}
785 namespace boost {
namespace geometry {
namespace traits {
789 template <
typename T,
int D,
typename Derived>
790 struct tag<
mira::RectBase<T,D, Derived> > {
typedef box_tag
type; };
792 template <
typename T,
int D,
typename Derived>
795 template <
typename T,
int D, std::
size_t Dimension,
typename Derived>
796 struct indexed_access<
mira::RectBase<T,D, Derived>, min_corner, Dimension>
798 typedef typename geometry::coordinate_type<mira::Point<T,D> >
::type coordinate_type;
800 return geometry::get<Dimension>(b.minCorner);
803 geometry::set<Dimension>(b.minCorner, value);
807 template <
typename T,
int D, std::
size_t Dimension,
typename Derived>
808 struct indexed_access<
mira::RectBase<T,D, Derived>, max_corner, Dimension>
810 typedef typename geometry::coordinate_type<mira::Point<T,D>>
::type coordinate_type;
812 return geometry::get<Dimension>(b.maxCorner);
815 geometry::set<Dimension>(b.maxCorner, value);
819 template <
typename T,
int D>
820 struct tag<
mira::Rect<T,D> > :
public tag<mira::RectBase<T,D, mira::Rect<T,D>>> {};
822 template <
typename T,
int D>
823 struct point_type<
mira::Rect<T,D> > :
public point_type<mira::RectBase<T,D,mira::Rect<T,D>>> {};
825 template <
typename T,
int D, std::
size_t Dimension>
826 struct indexed_access<
mira::Rect<T,D>, min_corner, Dimension> :
827 public indexed_access<mira::RectBase<T,D,mira::Rect<T,D>>, min_corner, Dimension> {};
829 template <
typename T,
int D, std::
size_t Dimension>
830 struct indexed_access<
mira::Rect<T,D>, max_corner, Dimension> :
831 public indexed_access<mira::RectBase<T,D,mira::Rect<T,D>>, max_corner, Dimension> {};
Rect class for defining rectangles.
Definition: Rect.h:453
Rect< int, 3 > Box3i
A 3D box with integer precision.
Definition: Rect.h:751
Derived operator|(const Derived &other) const
Returns the bounding rectangle of this rectangle and the given rectangle.
Definition: Rect.h:294
T & y0()
Returns the y-coordinate of the lower corner.
Definition: Rect.h:706
T y0() const
Returns the y-coordinate of the lower corner.
Definition: Rect.h:708
A class for a n-dimensional line.
Rect< int, 2 > Rect2i
A 2D rect with integer precision.
Definition: Rect.h:742
Definition: SyncTimedRead.h:62
static Derived zero()
Same as null().
Definition: Rect.h:276
RectBase(const BoxType &box)
Creating an n-dimensional object from boost::model::box.
Definition: Rect.h:113
Derived operator &(const Derived &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: Rect.h:379
RectBase< T, D, Rect< T, D > > Base
Definition: Rect.h:456
const Derived & operator &=(const Derived &other)
Intersects the rectangle with the given rectangle.
Definition: Rect.h:398
T depth() const
Returns the depth.
Definition: Rect.h:735
General point class template.
Definition: Point.h:135
RectBase< T, 3, Rect< T, 3 > > Base
Definition: Rect.h:645
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Base::PointType PointType
Definition: Rect.h:457
RectBase(const PointType &pos, T width, T height)
A constructor for the 2D case.
Definition: Rect.h:100
T & y1()
Returns the y-coordinate of the upper corner.
Definition: Rect.h:721
Rect(const PointType &pos, T width, T height, T depth)
a constructor to create a 3D rect
Definition: Rect.h:673
Rect< float, 3 > Box3f
A 3D box with floating point precision.
Definition: Rect.h:754
bool isValid() const
Returns true if this is a valid Rect where the maxCorner's components are not smaller than the minCor...
Definition: Rect.h:215
T & y0()
Returns the y-coordinate of the lower corner.
Definition: Rect.h:562
Derived normalized() const
Returns the normalized Rect, where the maxCorner and minCorner components are swapped if necessary to...
Definition: Rect.h:235
RectBase(const PointType &p1, const PointType &p2, bool makeValid)
Create an n-dimensional object from specifying two corners.
Definition: Rect.h:123
T & z0()
Returns the z-coordinate of the lower corner.
Definition: Rect.h:711
Rect< float, 2 > Rect2f
A 2D rect with floating point precision.
Definition: Rect.h:745
PointType minCorner
Definition: Rect.h:441
T width() const
Returns the width.
Definition: Rect.h:731
boost::geometry::model::box< PointType > BoxType
Definition: Rect.h:76
Rect(const PointType &pos, T width, T height)
A constructor to create a 2D rect.
Definition: Rect.h:510
Point< T, D > PointType
Definition: Rect.h:74
Rect(const PointType &pos, const SizeType &s)
A constructor to create a 2D rect.
Definition: Rect.h:518
Base::PointType PointType
Definition: Rect.h:483
T & y1()
Returns the y-coordinate of the upper corner.
Definition: Rect.h:572
Rect(const cv::Rect_< T > &rect)
copy constructor from OpenCV rect
Definition: Rect.h:526
T & x1()
Returns the x-coordinate of the upper corner.
Definition: Rect.h:567
RectBase< T, 2, Rect< T, 2 > > Base
Definition: Rect.h:482
Rect()
the default constructor
Definition: Rect.h:654
By default, IsCheapToCopy<T>::value evaluates to true for fundamental types T, false for all other ty...
Definition: IsCheapToCopy.h:63
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
const Derived & operator+=(const PointType &displacement)
Moves the rect (the minCorner and the maxCorner) by the specified displacement.
Definition: Rect.h:425
Rect(const PointType &p1, const PointType &p2, bool makeValid=true)
a constructor to create a 3D rect
Definition: Rect.h:690
RectBase(T x, T y, T width, T height)
A constructor for the 2D case.
Definition: Rect.h:96
T x0() const
Returns the x-coordinate of the lower corner.
Definition: Rect.h:559
T width() const
Returns the width.
Definition: Rect.h:577
bool isNull() const
Returns true, if all extends (i.e.
Definition: Rect.h:255
Rect(const BoxType &box)
copy constructor from boost::BoxType
Definition: Rect.h:684
Type trait to define if a class is cheap to copy.
T x1() const
Returns the x-coordinate of the upper corner.
Definition: Rect.h:718
T z1() const
Returns the z-coordinate of the upper corner.
Definition: Rect.h:728
static Derived invalid()
Returns an invalid rect with negative extends.
Definition: Rect.h:226
Rect< double, 2 > Rect2d
A 2D rect with 64 bit floating point precision.
Definition: Rect.h:748
Base::SizeType SizeType
Definition: Rect.h:647
Size< T, D > SizeType
Definition: Rect.h:75
T y1() const
Returns the y-coordinate of the upper corner.
Definition: Rect.h:574
RectBase(const PointType &pos, T width, T height, T depth)
A constructor for the 3D case.
Definition: Rect.h:104
Base::PointType PointType
Definition: Rect.h:646
PointType maxCorner
Definition: Rect.h:442
Rect(const PointType &pos, const SizeType &s)
a constructor to create a 3D rect
Definition: Rect.h:680
Base::BoxType BoxType
Definition: Rect.h:485
Base::BoxType BoxType
Definition: Rect.h:459
This class provides templatized multidimensional sizes for multidimensional geometric objects...
T & x1()
Returns the x-coordinate of the upper corner.
Definition: Rect.h:716
Rect()
The default constructor.
Definition: Rect.h:492
T height() const
Returns the height.
Definition: Rect.h:733
T & x0()
Returns the x-coordinate of the lower corner.
Definition: Rect.h:557
Rect(const PointType &p1, const PointType &p2, bool makeValid=true)
A constructor to create a 2D rect.
Definition: Rect.h:534
Rect(const PointType &p1, const PointType &p2, bool makeValid=true)
A constructor to initialize from 2 points.
Definition: Rect.h:466
static Derived null()
Returns a null-Rect which extends are null (minCorner and maxCorner) are set to 0.
Definition: Rect.h:266
RectBase(const PointType &pos, const SizeType &s)
a constructor to construct the rect, cube or whatever by defining the lower corner and specifying an ...
Definition: Rect.h:109
T & z1()
Returns the z-coordinate of the upper corner.
Definition: Rect.h:726
T x0() const
Returns the x-coordinate of the lower corner.
Definition: Rect.h:703
Base::SizeType SizeType
Definition: Rect.h:484
bool operator==(const RectBase< T, D, OtherDerived > &other) const
Definition: Rect.h:171
void reflect(Reflector &reflector)
the method to serialize this object
Definition: Rect.h:143
Rect(const BoxType &box)
copy constructor from boost::BoxType
Definition: Rect.h:522
RectBase()
The default constructor, creates an invalid rect with negative extends.
Definition: Rect.h:83
T y1() const
Returns the y-coordinate of the upper corner.
Definition: Rect.h:723
T x1() const
Returns the x-coordinate of the upper corner.
Definition: Rect.h:569
Base::BoxType BoxType
Definition: Rect.h:648
T y0() const
Returns the y-coordinate of the lower corner.
Definition: Rect.h:564
bool disjoint(const OtherGeometry &otherGeometry) const
this method checks for non-intersections with other geometry
Definition: Rect.h:200
Rect(T x, T y, T width, T height)
A constructor to create a 2D rect.
Definition: Rect.h:501
Size class for defining sizes with different data types.
Definition: Size.h:69
Rect< double, 3 > Box3d
A 3D box with 64 bit floating point precision.
Definition: Rect.h:757
Base::SizeType SizeType
Definition: Rect.h:458
static Derived convertFrom(const RectBase< U, D, OtherDerived > &other)
Converts from a Rect of a different type.
Definition: Rect.h:417
T height() const
Returns the height.
Definition: Rect.h:579
Rect(T x, T y, T z, T width, T height, T depth)
a constructor to create a 3D rect
Definition: Rect.h:664
SizeType size() const
return the size of the multidimensional rect
Definition: Rect.h:162
bool contains(const OtherGeometry &otherGeometry) const
this method checks if a given geometry is enclosed by this box
Definition: Rect.h:188
RectBase(T x, T y, T z, T width, T height, T depth)
A constructor for the 3D case.
Definition: Rect.h:92
The base class for rectangles.
Definition: Rect.h:71
T z0() const
Returns the z-coordinate of the lower corner.
Definition: Rect.h:713
bool intersects(const OtherGeometry &otherGeometry) const
this method checks for intersections with other geometry
Definition: Rect.h:194
bool operator!=(const RectBase< T, D, OtherDerived > &other) const
Definition: Rect.h:176
T & x0()
Returns the x-coordinate of the lower corner.
Definition: Rect.h:701
const Derived & operator|=(const PointType &p)
Unites this rectangle with the given point.
Definition: Rect.h:352
std::list< Rect< T, 2 > > operator-(const Rect< T, 2 > &other) const
Intersects the rectangle with the inverse of the given rectangle, i.e.
Definition: Rect.h:590
Rect()
The default constructor.
Definition: Rect.h:463
const Derived & operator|=(const Derived &other)
Unites this rectangle with the given rectangle.
Definition: Rect.h:317
Specialization for 2D.
Definition: Rect.h:479
Derived operator+(const PointType &displacement) const
Returns a rect that is moved by the specified displacement.
Definition: Rect.h:435