MIRA
Rect.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
47 #ifndef _MIRA_RECT_H_
48 #define _MIRA_RECT_H_
49 
50 #include <geometry/Line.h>
51 #include <geometry/Size.h>
52 
53 namespace mira
54 {
55 
57 
68 template<typename T, int D, typename Derived>
69 class RectBase
70 {
71 public:
74  typedef boost::geometry::model::box<PointType> BoxType;
75 
76 public:
79 
82  {
83  for(int d=0; d<D; ++d) {
84  minCorner[d] = 0;
85  maxCorner[d] = -1;
86  }
87  }
88 
90  RectBase(T x, T y, T z, T width, T height, T depth) :
91  minCorner(x, y, z), maxCorner(x+width, y+height, z+depth) {}
92 
94  RectBase(T x, T y, T width, T height) :
95  minCorner(x, y), maxCorner(x+width, y+height) {}
96 
98  explicit RectBase(const PointType& pos, T width, T height) :
99  minCorner(pos), maxCorner(pos.x()+width, pos.y()+height) {}
100 
102  explicit RectBase(const PointType& pos, T width, T height, T depth) :
103  minCorner(pos), maxCorner(pos.x()+width, pos.y()+height, pos.z()+depth) {}
104 
107  explicit RectBase(const PointType& pos, const SizeType& s) :
108  minCorner(pos), maxCorner(pos+s) {}
109 
111  explicit RectBase(const BoxType& box) :
112  minCorner(box.min_corner()), maxCorner(box.max_corner()) {}
113 
121  explicit RectBase(const PointType& p1, const PointType& p2,
122  bool makeValid)
123  {
124  for(int d=0; d<D; ++d)
125  {
126  if(makeValid && (p1[d]>p2[d])) {
127  minCorner[d]=p2[d];
128  maxCorner[d]=p1[d];
129  } else {
130  minCorner[d]=p1[d];
131  maxCorner[d]=p2[d];
132  }
133  }
134  }
135 
137 
138 public:
140  template<typename Reflector>
141  void reflect(Reflector& reflector)
142  {
143  reflector.property("MinCorner", minCorner, "The minimum corner");
144  reflector.property("MaxCorner", maxCorner, "The maximum corner");
145  }
146 
147 public:
150 
152  operator BoxType() const {
153  return BoxType(minCorner, maxCorner);
154  }
155 
157 
158 public:
160  SizeType size() const {
161  return SizeType(maxCorner-minCorner);
162  }
163 
164 public:
167 
168  template <typename OtherDerived>
169  bool operator==(const RectBase<T,D, OtherDerived>& other) const {
170  return minCorner == other.minCorner && maxCorner == other.maxCorner;
171  }
172 
173  template <typename OtherDerived>
174  bool operator!=(const RectBase<T,D, OtherDerived>& other) const {
175  return !this->operator==(other);
176  }
177 
179 
180 public:
183 
185  template <typename OtherGeometry>
186  bool contains(const OtherGeometry& otherGeometry) const {
187  return boost::geometry::within(otherGeometry, *this);
188  }
189 
191  template <typename OtherGeometry>
192  bool intersects(const OtherGeometry& otherGeometry) const {
193  return boost::geometry::intersects(otherGeometry, *this);
194  }
195 
197  template <typename OtherGeometry>
198  bool disjoint(const OtherGeometry& otherGeometry) const {
199  return boost::geometry::disjoint(otherGeometry, *this);
200  }
201 
203 
204 public:
207 
213  bool isValid() const {
214  for(int d=0; d<D; ++d)
215  if(maxCorner[d]<minCorner[d])
216  return false;
217  return true;
218  }
219 
224  static Derived invalid() {
225  return Derived();
226  }
227 
233  Derived normalized() const
234  {
235  Derived r;
236  for(int d=0; d<D; ++d)
237  {
238  if(maxCorner[d]<minCorner[d]) {
239  r.maxCorner[d] = minCorner[d];
240  r.minCorner[d] = maxCorner[d];
241  } else {
242  r.maxCorner[d] = maxCorner[d];
243  r.minCorner[d] = minCorner[d];
244  }
245  }
246  return r;
247  }
248 
253  bool isNull() const {
254  for(int d=0; d<D; ++d)
255  if(maxCorner[d]!=minCorner[d])
256  return false;
257  return true;
258  }
259 
264  static Derived null() {
265  Derived r;
267  r.maxCorner = Eigen::Matrix<T,D,1>::Zero(D,1);
268  return r;
269  }
270 
274  static Derived zero() {
275  return null();
276  }
278 
279 public:
282 
292  Derived operator|(const Derived& other) const
293  {
294  if(!this->isValid())
295  return other;
296  if(!other.isValid())
297  return *((Derived*)this); // we are of type Derived
298 
299  Derived r;
300  for(int d=0; d<D; ++d) {
301  r.minCorner[d] = std::min(minCorner[d], other.minCorner[d]);
302  r.maxCorner[d] = std::max(maxCorner[d], other.maxCorner[d]);
303  }
304  return r;
305  }
306 
315  const Derived& operator|=(const Derived& other)
316  {
317  if(!isValid()) {
318  *this = other;
319  } else if(other.isValid()) {
320  for(int d=0; d<D; ++d) {
321  if(other.minCorner[d]<minCorner[d])
322  minCorner[d] = other.minCorner[d];
323  if(other.maxCorner[d]>maxCorner[d])
324  maxCorner[d] = other.maxCorner[d];
325  }
326  }
327  return *((Derived*)this); // we are of type Derived
328  }
329 
350  const Derived& operator|=(const PointType& p)
351  {
352  if(!isValid()) {
353  minCorner = p;
354  maxCorner = p;
355  } else {
356  for(int d=0; d<D; ++d) {
357  if(p[d]<minCorner[d])
358  minCorner[d] = p[d];
359  if(p[d]>maxCorner[d])
360  maxCorner[d] = p[d];
361  }
362  }
363  return *((Derived*)this); // we are of type Derived
364  }
365 
377  Derived operator&(const Derived& other) const
378  {
379  if(!isValid())
380  return invalid();
381  if(!other.isValid())
382  return invalid();
383 
384  Derived r;
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]);
388  }
389  return r;
390  }
391 
396  const Derived& operator&=(const Derived& other)
397  {
398  if(!isValid())
399  return *((Derived*)this);
400 
401  if(!other.isValid()) {
402  *this = other;
403  } else {
404  for(int d=0; d<D; ++d) {
405  minCorner[d] = std::max(minCorner[d], other.minCorner[d]);
406  maxCorner[d] = std::min(maxCorner[d], other.maxCorner[d]);
407  }
408  }
409  return *((Derived*)this);
410  }
412 
414  template<typename U, typename OtherDerived>
415  static Derived convertFrom(const RectBase<U,D, OtherDerived>& other) {
416  return Derived(PointType(other.minCorner.template cast<T>()),
417  PointType(other.maxCorner.template cast<T>()));
418  }
419 
423  const Derived& operator+=(const PointType& displacement)
424  {
425  minCorner+=displacement;
426  maxCorner+=displacement;
427  return *((Derived*)this);
428  }
429 
433  Derived operator+(const PointType& displacement) const
434  {
435  return Derived((PointType)(minCorner+displacement), (PointType)(maxCorner+displacement));
436  }
437 
438 public:
441 };
442 
444 
450 template<typename T, int D>
451 class Rect : public RectBase<T,D, Rect<T,D> >
452 {
453 public:
455  typedef typename Base::PointType PointType;
456  typedef typename Base::SizeType SizeType;
457  typedef typename Base::BoxType BoxType;
458 
459 public:
461  Rect() {}
462 
464  Rect(const PointType& p1, const PointType& p2,
465  bool makeValid = true) :
466  Base(p1, p2, makeValid) {}
467 };
468 
470 
476 template<typename T>
477 class Rect<T,2> : public RectBase<T,2, Rect<T,2> >
478 {
479 public:
481  typedef typename Base::PointType PointType;
482  typedef typename Base::SizeType SizeType;
483  typedef typename Base::BoxType BoxType;
484 
485 public:
488 
490  Rect() {}
491 
499  Rect(T x, T y, T width, T height) :
500  Base(x, y, width, height) {}
501 
508  Rect(const PointType& pos, T width, T height) :
509  Base(pos, width, height) {}
510 
516  Rect(const PointType& pos, const SizeType& s) :
517  Base(pos, s) {}
518 
520  explicit Rect(const BoxType& box) :
521  Base(box) {}
522 
524  explicit Rect(const cv::Rect_<T>& rect) :
525  Base(rect.x, rect.y, rect.width, rect.height) {}
526 
532  Rect(const PointType& p1, const PointType& p2,
533  bool makeValid = true) :
534  Base(p1, p2, makeValid) {}
535 
537 
538 public:
541 
543  operator cv::Rect_<T>() const
544  {
545  return cv::Rect_<T>(Base::minCorner, Base::size());
546  }
547 
549 
550 public:
553 
555  T& x0() { return this->minCorner[0]; }
557  T x0() const { return this->minCorner[0]; }
558 
560  T& y0() { return this->minCorner[1]; }
562  T y0() const { return this->minCorner[1]; }
563 
565  T& x1() { return this->maxCorner[0]; }
567  T x1() const { return this->maxCorner[0]; }
568 
570  T& y1() { return this->maxCorner[1]; }
572  T y1() const { return this->maxCorner[1]; }
573 
575  T width() const { return this->maxCorner[0] - this->minCorner[0]; }
577  T height() const { return this->maxCorner[1] - this->minCorner[1]; }
578 
580 
588  std::list<Rect<T,2>> operator-(const Rect<T,2>& other) const
589  {
590  if(!this->isValid())
591  return std::list<Rect<T,2>>();
592 
593  if(!other.isValid())
594  return std::list<Rect<T,2>>( {*this} );
595 
596 // if (this->disjoint(other)) // unfortunately, "touching" (intersections of width or
597  // height = 0) is considered intersecting by the boost
598  // geometry base (particularly irritating with T = int)
599  Rect<T,2> inter = *this & other;
600  if ((inter.width() <= 0) || (inter.height() <= 0))
601  return std::list<Rect<T,2>>( {*this} );
602 
603  if (other.contains(*this))
604  return std::list<Rect<T,2>>();
605 
606  std::list<Rect<T,2>> result;
607 
608  PointType tl(this->x0(), this->y1()); // this top left
609  PointType br(this->x1(), this->y0()); // this bottom right
610  const PointType& bl = this->minCorner; // this bottom left
611  const PointType& tr = this->maxCorner; // this top right
612 
613  PointType otl(other.x0(), other.y1()); // other top left
614  PointType obr(other.x1(), other.y0()); // other bottom right
615  const PointType& obl = other.minCorner; // other bottom left
616  const PointType& otr = other.maxCorner; // other top right
617 
618  Rect<T,2> rtl = Rect<T,2>(tl, otr) & *this;
619  Rect<T,2> rbl = Rect<T,2>(bl, otl) & *this;
620  Rect<T,2> rbr = Rect<T,2>(br, obl) & *this;
621  Rect<T,2> rtr = Rect<T,2>(tr, obr) & *this;
622 
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);
627 
628  return result;
629  }
630 };
631 
633 
639 template<typename T>
640 class Rect<T,3> : public RectBase<T,3, Rect<T,3> >
641 {
642 public:
644  typedef typename Base::PointType PointType;
645  typedef typename Base::SizeType SizeType;
646  typedef typename Base::BoxType BoxType;
647 
648 public:
651 
652  Rect() {}
653 
662  Rect(T x, T y, T z, T width, T height, T depth) :
663  Base(x, y, z, width, height, depth) {}
664 
671  Rect(const PointType& pos, T width, T height, T depth) :
672  Base(pos, width, height, depth) {}
673 
678  Rect(const PointType& pos, const SizeType& s) :
679  Base(pos, s) {}
680 
682  explicit Rect(const BoxType& box) :
683  Base(box) {}
684 
688  Rect(const PointType& p1, const PointType& p2,
689  bool makeValid = true) :
690  Base(p1, p2, makeValid) {}
691 
693 
694 public:
697 
699  T& x0() { return this->minCorner[0]; }
701  T x0() const { return this->minCorner[0]; }
702 
704  T& y0() { return this->minCorner[1]; }
706  T y0() const { return this->minCorner[1]; }
707 
709  T& z0() { return this->minCorner[2]; }
711  T z0() const { return this->minCorner[2]; }
712 
714  T& x1() { return this->maxCorner[0]; }
716  T x1() const { return this->maxCorner[0]; }
717 
719  T& y1() { return this->maxCorner[1]; }
721  T y1() const { return this->maxCorner[1]; }
722 
724  T& z1() { return this->maxCorner[2]; }
726  T z1() const { return this->maxCorner[2]; }
727 
729  T width() const { return this->maxCorner[0] - this->minCorner[0]; }
731  T height() const { return this->maxCorner[1] - this->minCorner[1]; }
733  T depth() const { return this->maxCorner[2] - this->minCorner[2]; }
735 };
736 
738 
741 
744 
747 
750 
753 
756 
758 }
759 
761 // BOOST specialization on Rect to accept them as geometry entity
762 namespace boost { namespace geometry { namespace traits {
763 
765 
766 template <typename T, int D, typename Derived>
767 struct tag<mira::RectBase<T,D, Derived> > { typedef box_tag type; };
768 
769 template <typename T, int D, typename Derived>
770 struct point_type<mira::RectBase<T,D, Derived> > { typedef mira::Point<T,D> type; };
771 
772 template <typename T, int D, std::size_t Dimension, typename Derived>
773 struct indexed_access<mira::RectBase<T,D, Derived>, min_corner, Dimension>
774 {
775  typedef typename geometry::coordinate_type<mira::Point<T,D> >::type coordinate_type;
776  static inline coordinate_type get(mira::RectBase<T,D,Derived> const& b) {
777  return geometry::get<Dimension>(b.minCorner);
778  }
779  static inline void set(mira::RectBase<T,D,Derived>& b, coordinate_type const& value) {
780  geometry::set<Dimension>(b.minCorner, value);
781  }
782 };
783 
784 template <typename T, int D, std::size_t Dimension, typename Derived>
785 struct indexed_access<mira::RectBase<T,D, Derived>, max_corner, Dimension>
786 {
787  typedef typename geometry::coordinate_type<mira::Point<T,D>>::type coordinate_type;
788  static inline coordinate_type get(mira::RectBase<T,D, Derived> const& b) {
789  return geometry::get<Dimension>(b.maxCorner);
790  }
791  static inline void set(mira::RectBase<T,D, Derived>& b, coordinate_type const& value) {
792  geometry::set<Dimension>(b.maxCorner, value);
793  }
794 };
795 
796 template <typename T, int D>
797 struct tag<mira::Rect<T,D> > : public tag<mira::RectBase<T,D, mira::Rect<T,D>>> {};
798 
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>>> {};
801 
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> {};
805 
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> {};
809 
811 
812 }}}
814 
816 
817 #endif
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&#39;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