68 template<
typename T,
int D,
typename Derived>
74 typedef boost::geometry::model::box<PointType>
BoxType;
83 for(
int d=0; d<D; ++d) {
90 RectBase(T x, T y, T z, T width, T height, T depth) :
124 for(
int d=0; d<D; ++d)
126 if(makeValid && (p1[d]>p2[d])) {
140 template<
typename Reflector>
143 reflector.property(
"MinCorner",
minCorner,
"The minimum corner");
144 reflector.property(
"MaxCorner",
maxCorner,
"The maximum corner");
168 template <
typename OtherDerived>
173 template <
typename OtherDerived>
185 template <
typename OtherGeometry>
186 bool contains(
const OtherGeometry& otherGeometry)
const {
187 return boost::geometry::within(otherGeometry, *
this);
191 template <
typename OtherGeometry>
193 return boost::geometry::intersects(otherGeometry, *
this);
197 template <
typename OtherGeometry>
198 bool disjoint(
const OtherGeometry& otherGeometry)
const {
199 return boost::geometry::disjoint(otherGeometry, *
this);
214 for(
int d=0; d<D; ++d)
236 for(
int d=0; d<D; ++d)
254 for(
int d=0; d<D; ++d)
297 return *((Derived*)
this);
300 for(
int d=0; d<D; ++d) {
302 r.maxCorner[d] = std::max(
maxCorner[d], other.maxCorner[d]);
319 }
else if(other.isValid()) {
320 for(
int d=0; d<D; ++d) {
327 return *((Derived*)
this);
356 for(
int d=0; d<D; ++d) {
363 return *((Derived*)
this);
385 for(
int d=0; d<D; ++d) {
386 r.minCorner[d] = std::max(
minCorner[d], other.minCorner[d]);
387 r.maxCorner[d] = std::min(
maxCorner[d], other.maxCorner[d]);
399 return *((Derived*)
this);
401 if(!other.isValid()) {
404 for(
int d=0; d<D; ++d) {
409 return *((Derived*)
this);
414 template<
typename U,
typename OtherDerived>
427 return *((Derived*)
this);
450 template<
typename T,
int D>
465 bool makeValid =
true) :
466 Base(p1, p2, makeValid) {}
499 Rect(T x, T y, T width, T height) :
500 Base(x, y, width, height) {}
509 Base(pos, width, height) {}
524 explicit Rect(
const cv::Rect_<T>& rect) :
525 Base(rect.x, rect.y, rect.width, rect.height) {}
533 bool makeValid =
true) :
534 Base(p1, p2, makeValid) {}
543 operator cv::Rect_<T>()
const 591 return std::list<Rect<T,2>>();
601 return std::list<Rect<T,2>>( {*
this} );
606 std::list<Rect<T,2>> result;
613 PointType otl(other.
x0(), other.
y1());
623 if ((rtl.
width() > 0) && (rtl.
height() > 0)) result.push_back(rtl);
624 if ((rbl.width() > 0) && (rbl.height() > 0)) result.push_back(rbl);
625 if ((rbr.width() > 0) && (rbr.height() > 0)) result.push_back(rbr);
626 if ((rtr.width() > 0) && (rtr.height() > 0)) result.push_back(rtr);
662 Rect(T x, T y, T z, T width, T height, T depth) :
663 Base(x, y, z, width, height, depth) {}
672 Base(pos, width, height, depth) {}
689 bool makeValid =
true) :
690 Base(p1, p2, makeValid) {}
762 namespace boost {
namespace geometry {
namespace traits {
766 template <
typename T,
int D,
typename Derived>
767 struct tag<
mira::RectBase<T,D, Derived> > {
typedef box_tag
type; };
769 template <
typename T,
int D,
typename Derived>
772 template <
typename T,
int D, std::
size_t Dimension,
typename Derived>
773 struct indexed_access<
mira::RectBase<T,D, Derived>, min_corner, Dimension>
775 typedef typename geometry::coordinate_type<mira::Point<T,D> >
::type coordinate_type;
777 return geometry::get<Dimension>(b.minCorner);
780 geometry::set<Dimension>(b.minCorner, value);
784 template <
typename T,
int D, std::
size_t Dimension,
typename Derived>
785 struct indexed_access<
mira::RectBase<T,D, Derived>, max_corner, Dimension>
787 typedef typename geometry::coordinate_type<mira::Point<T,D>>
::type coordinate_type;
789 return geometry::get<Dimension>(b.maxCorner);
792 geometry::set<Dimension>(b.maxCorner, value);
796 template <
typename T,
int D>
797 struct tag<
mira::Rect<T,D> > :
public tag<mira::RectBase<T,D, mira::Rect<T,D>>> {};
799 template <
typename T,
int D>
800 struct point_type<
mira::Rect<T,D> > :
public point_type<mira::RectBase<T,D,mira::Rect<T,D>>> {};
802 template <
typename T,
int D, std::
size_t Dimension>
803 struct indexed_access<
mira::Rect<T,D>, min_corner, Dimension> :
804 public indexed_access<mira::RectBase<T,D,mira::Rect<T,D>>, min_corner, Dimension> {};
806 template <
typename T,
int D, std::
size_t Dimension>
807 struct indexed_access<
mira::Rect<T,D>, max_corner, Dimension> :
808 public indexed_access<mira::RectBase<T,D,mira::Rect<T,D>>, max_corner, Dimension> {};
Rect class for defining rectangles.
Definition: Rect.h:451
Rect< int, 3 > Box3i
A 3D box with integer precision.
Definition: Rect.h:749
Derived operator|(const Derived &other) const
Returns the bounding rectangle of this rectangle and the given rectangle.
Definition: Rect.h:292
T & y0()
Returns the y-coordinate of the lower corner.
Definition: Rect.h:704
T y0() const
Returns the y-coordinate of the lower corner.
Definition: Rect.h:706
A class for a n-dimensional line.
Rect< int, 2 > Rect2i
A 2D rect with integer precision.
Definition: Rect.h:740
Definition: SyncTimedRead.h:62
static Derived zero()
Same as null().
Definition: Rect.h:274
RectBase(const BoxType &box)
Creating an n-dimensional object from boost::model::box.
Definition: Rect.h:111
Derived operator &(const Derived &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: Rect.h:377
RectBase< T, D, Rect< T, D > > Base
Definition: Rect.h:454
const Derived & operator &=(const Derived &other)
Intersects the rectangle with the given rectangle.
Definition: Rect.h:396
T depth() const
Returns the depth.
Definition: Rect.h:733
General point class template.
Definition: Point.h:133
RectBase< T, 3, Rect< T, 3 > > Base
Definition: Rect.h:643
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Base::PointType PointType
Definition: Rect.h:455
RectBase(const PointType &pos, T width, T height)
A constructor for the 2D case.
Definition: Rect.h:98
T & y1()
Returns the y-coordinate of the upper corner.
Definition: Rect.h:719
Rect(const PointType &pos, T width, T height, T depth)
a constructor to create a 3D rect
Definition: Rect.h:671
Rect< float, 3 > Box3f
A 3D box with floating point precision.
Definition: Rect.h:752
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:213
T & y0()
Returns the y-coordinate of the lower corner.
Definition: Rect.h:560
Derived normalized() const
Returns the normalized Rect, where the maxCorner and minCorner components are swapped if necessary to...
Definition: Rect.h:233
RectBase(const PointType &p1, const PointType &p2, bool makeValid)
Create an n-dimensional object from specifying two corners.
Definition: Rect.h:121
T & z0()
Returns the z-coordinate of the lower corner.
Definition: Rect.h:709
Rect< float, 2 > Rect2f
A 2D rect with floating point precision.
Definition: Rect.h:743
PointType minCorner
Definition: Rect.h:439
T width() const
Returns the width.
Definition: Rect.h:729
boost::geometry::model::box< PointType > BoxType
Definition: Rect.h:74
Rect(const PointType &pos, T width, T height)
A constructor to create a 2D rect.
Definition: Rect.h:508
Point< T, D > PointType
Definition: Rect.h:72
Rect(const PointType &pos, const SizeType &s)
A constructor to create a 2D rect.
Definition: Rect.h:516
Base::PointType PointType
Definition: Rect.h:481
T & y1()
Returns the y-coordinate of the upper corner.
Definition: Rect.h:570
Rect(const cv::Rect_< T > &rect)
copy constructor from OpenCV rect
Definition: Rect.h:524
T & x1()
Returns the x-coordinate of the upper corner.
Definition: Rect.h:565
RectBase< T, 2, Rect< T, 2 > > Base
Definition: Rect.h:480
Rect()
the default constructor
Definition: Rect.h:652
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:423
Rect(const PointType &p1, const PointType &p2, bool makeValid=true)
a constructor to create a 3D rect
Definition: Rect.h:688
RectBase(T x, T y, T width, T height)
A constructor for the 2D case.
Definition: Rect.h:94
T x0() const
Returns the x-coordinate of the lower corner.
Definition: Rect.h:557
T width() const
Returns the width.
Definition: Rect.h:575
bool isNull() const
Returns true, if all extends (i.e.
Definition: Rect.h:253
Rect(const BoxType &box)
copy constructor from boost::BoxType
Definition: Rect.h:682
T x1() const
Returns the x-coordinate of the upper corner.
Definition: Rect.h:716
T z1() const
Returns the z-coordinate of the upper corner.
Definition: Rect.h:726
static Derived invalid()
Returns an invalid rect with negative extends.
Definition: Rect.h:224
Rect< double, 2 > Rect2d
A 2D rect with 64 bit floating point precision.
Definition: Rect.h:746
Base::SizeType SizeType
Definition: Rect.h:645
Size< T, D > SizeType
Definition: Rect.h:73
T y1() const
Returns the y-coordinate of the upper corner.
Definition: Rect.h:572
RectBase(const PointType &pos, T width, T height, T depth)
A constructor for the 3D case.
Definition: Rect.h:102
Base::PointType PointType
Definition: Rect.h:644
PointType maxCorner
Definition: Rect.h:440
Rect(const PointType &pos, const SizeType &s)
a constructor to create a 3D rect
Definition: Rect.h:678
Base::BoxType BoxType
Definition: Rect.h:483
Base::BoxType BoxType
Definition: Rect.h:457
This class provides templatized multidimensional sizes for multidimensional geometric objects...
T & x1()
Returns the x-coordinate of the upper corner.
Definition: Rect.h:714
Rect()
The default constructor.
Definition: Rect.h:490
T height() const
Returns the height.
Definition: Rect.h:731
T & x0()
Returns the x-coordinate of the lower corner.
Definition: Rect.h:555
Rect(const PointType &p1, const PointType &p2, bool makeValid=true)
A constructor to create a 2D rect.
Definition: Rect.h:532
Rect(const PointType &p1, const PointType &p2, bool makeValid=true)
A constructor to initialize from 2 points.
Definition: Rect.h:464
static Derived null()
Returns a null-Rect which extends are null (minCorner and maxCorner) are set to 0.
Definition: Rect.h:264
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:107
T & z1()
Returns the z-coordinate of the upper corner.
Definition: Rect.h:724
T x0() const
Returns the x-coordinate of the lower corner.
Definition: Rect.h:701
Base::SizeType SizeType
Definition: Rect.h:482
bool operator==(const RectBase< T, D, OtherDerived > &other) const
Definition: Rect.h:169
void reflect(Reflector &reflector)
the method to serialize this object
Definition: Rect.h:141
Rect(const BoxType &box)
copy constructor from boost::BoxType
Definition: Rect.h:520
RectBase()
The default constructor, creates an invalid rect with negative extends.
Definition: Rect.h:81
T y1() const
Returns the y-coordinate of the upper corner.
Definition: Rect.h:721
T x1() const
Returns the x-coordinate of the upper corner.
Definition: Rect.h:567
Base::BoxType BoxType
Definition: Rect.h:646
T y0() const
Returns the y-coordinate of the lower corner.
Definition: Rect.h:562
bool disjoint(const OtherGeometry &otherGeometry) const
this method checks for non-intersections with other geometry
Definition: Rect.h:198
Rect(T x, T y, T width, T height)
A constructor to create a 2D rect.
Definition: Rect.h:499
Size class for defining sizes with different data types.
Definition: Size.h:67
Rect< double, 3 > Box3d
A 3D box with 64 bit floating point precision.
Definition: Rect.h:755
Base::SizeType SizeType
Definition: Rect.h:456
static Derived convertFrom(const RectBase< U, D, OtherDerived > &other)
Converts from a Rect of a different type.
Definition: Rect.h:415
T height() const
Returns the height.
Definition: Rect.h:577
Rect(T x, T y, T z, T width, T height, T depth)
a constructor to create a 3D rect
Definition: Rect.h:662
SizeType size() const
return the size of the multidimensional rect
Definition: Rect.h:160
bool contains(const OtherGeometry &otherGeometry) const
this method checks if a given geometry is enclosed by this box
Definition: Rect.h:186
RectBase(T x, T y, T z, T width, T height, T depth)
A constructor for the 3D case.
Definition: Rect.h:90
The base class for rectangles.
Definition: Rect.h:69
T z0() const
Returns the z-coordinate of the lower corner.
Definition: Rect.h:711
bool intersects(const OtherGeometry &otherGeometry) const
this method checks for intersections with other geometry
Definition: Rect.h:192
bool operator!=(const RectBase< T, D, OtherDerived > &other) const
Definition: Rect.h:174
T & x0()
Returns the x-coordinate of the lower corner.
Definition: Rect.h:699
const Derived & operator|=(const PointType &p)
Unites this rectangle with the given point.
Definition: Rect.h:350
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:588
Rect()
The default constructor.
Definition: Rect.h:461
const Derived & operator|=(const Derived &other)
Unites this rectangle with the given rectangle.
Definition: Rect.h:315
Specialization for 2D.
Definition: Rect.h:477
Derived operator+(const PointType &displacement) const
Returns a rect that is moved by the specified displacement.
Definition: Rect.h:433