21 Extent3() { tx1_ = tx2_ = ty1_ = ty2_ = tz1_ = tz2_ = initVal<T>(); }
27 :tx1_(
x1), tx2_(
x2), ty1_(
y1), ty2_(
y2), tz1_(
z1), tz2_(
z2) { }
30 :tx1_(v111.x()), tx2_(v222.x()), ty1_(v111.y()), ty2_(v222.y()), tz1_(v111.z()), tz2_(v222.z()) { }
32 Extent3(
const Extent3<T> &r) : tx1_(r.tx1_), tx2_(r.tx2_), ty1_(r.ty1_), ty2_(r.ty2_), tz1_(r.tz1_), tz2_(r.tz2_) { }
41 const T &
x1()
const {
return tx1_; }
43 const T &
x2()
const {
return tx2_; }
45 const T &
y1()
const {
return ty1_; }
47 const T &
y2()
const {
return ty2_; }
49 const T &
z1()
const {
return tz1_; }
51 const T &
z2()
const {
return tz2_; }
71 T
width()
const {
return (tx2_-tx1_); }
73 T
height()
const {
return (ty2_-ty1_); }
75 T
depth()
const {
return (tz2_-tz1_); }
86 if (y) {
if (z)
return c222();
else return c221(); }
87 else {
if (z)
return c212();
else return c211(); }
89 if (y) {
if (z)
return c122();
else return c121(); }
90 else {
if (z)
return c112();
else return c111(); }
120 bool isEmpty()
const {
return ( (tx1_>=tx2_) || (ty1_>=ty2_) || (tz1_>=tz2_) ); }
125 return( (tx1_==c.tx1_)&&(tx2_==c.tx2_)&&(ty1_==c.ty1_)&&(ty2_==c.ty2_)&&(tz1_==c.tz1_)&&(tz2_==c.tz2_) );
135 if ( (v.
x()>=tx1_) && (v.
x()<=tx2_) && (v.
y()>=ty1_) && (v.
y()<=ty2_) && (v.
z()>=tz1_) && (v.
z()<=tz2_) )
return true;
140 if ( (c.
x1()>=tx1_) && (c.
x2()<=tx2_) && (c.
y1()>=ty1_) && (c.
y2()<=ty2_) && (c.
z1()>=tz1_) && (c.
z2()<=tz2_) )
return true;
145 if ( (v.
x()>=tx1_-tol) && (v.
x()<=tx2_+tol) && (v.
y()>=ty1_-tol) && (v.
y()<=ty2_+tol) && (v.
z()>=tz1_-tol) && (v.
z()<=tz2_+tol) )
return true;
150 if ( (c.
x1()>=tx1_-tol) && (c.
x2()<=tx2_+tol) && (c.
y1()>=ty1_-tol) && (c.
y2()<=ty2_+tol) && (c.
z1()>=tz1_-tol) && (c.
z2()<=tz2_+tol) )
return true;
155 if ((c.tx2_<tx1_) || (c.tx1_>tx2_) ||
156 (c.ty2_<ty1_) || (c.ty1_>ty2_) ||
157 (c.tz2_<tz1_) || (c.tz1_>tz2_))
return false;
162 if ((c.tx2_<tx1_-tol) || (c.tx1_>tx2_+tol) ||
163 (c.ty2_<ty1_-tol) || (c.ty1_>ty2_+tol) ||
164 (c.tz2_<tz1_-tol) || (c.tz1_>tz2_+tol))
return false;
195 void width(
const T &t) { tx2_ = tx1_ + t; }
197 void height(
const T &t) { ty2_ = ty1_ + t; }
199 void depth(
const T &t) { tz2_ = tz1_ + t; }
239 Extent3<T> out(std::max<T>(tx1_,r.tx1_),std::min<T>(tx2_,r.tx2_),
240 std::max<T>(ty1_,r.ty1_),std::min<T>(ty2_,r.ty2_),
241 std::max<T>(tz1_,r.tz1_),std::min<T>(tz2_,r.tz2_));
246 tx1_ = std::min<T>(tx1_,r.tx1_);
247 ty1_ = std::min<T>(ty1_,r.ty1_);
248 tz1_ = std::min<T>(tz1_,r.tz1_);
249 tx2_ = std::max<T>(tx2_,r.tx2_);
250 ty2_ = std::max<T>(ty2_,r.ty2_);
251 tz2_ = std::max<T>(tz2_,r.tz2_);
256 tx1_ = std::min<T>(tx1_,v.
x());
257 ty1_ = std::min<T>(ty1_,v.
y());
258 tz1_ = std::min<T>(tz1_,v.
z());
259 tx2_ = std::max<T>(tx2_,v.
x());
260 ty2_ = std::max<T>(ty2_,v.
y());
261 tz2_ = std::max<T>(tz2_,v.
z());
287 const Extent3<T> &
expand(
const T &tol) { tx1_ -= tol; tx2_ += tol; ty1_ -= tol; ty2_ += tol; tz1_ -= tol; tz2_ += tol;
return *
this; }
320 T pBound(
const T &min,
const T &v,
const T &max)
const {
return std::min(std::max(v,min),max); }
Vector3< T > upperBound() const
Returns the upper bounding corner of the extent, maximum value of x,y, and z.
Definition: extent3.h:114
T depth() const
Returns the size of the extent in the z-direction.
Definition: extent3.h:75
T height() const
Returns the size of the extent in the y-direction.
Definition: extent3.h:73
const T & x2() const
Returns the upper bound of the extent in the x-direction.
Definition: extent3.h:43
const T & y1() const
Returns the lower y-bound.
Definition: extent2.h:36
Vector3< T > c112() const
Returns one of the eith corners that characterize the extent.
Definition: extent3.h:104
bool operator>(const Extent3< T > &c) const
Comparison operator, based on volume.
Definition: extent3.h:132
const Extent3< T > & expand(const T &tol)
Definition: extent3.h:287
void lowerBound(const Vector3< T > &v)
Sets the lower bound of the exetnt, keeping the upper bound constant. Synonym to c111().
Definition: extent3.h:217
bool tolIsIn(const Extent3< T > &c, const T &tol) const
Returns true if the Extent3 c falls completely inside (inclusive) the extent with an added tolerance ...
Definition: extent3.h:149
const Extent3< T > & operator-=(const Vector3< T > &v)
Subtracts v from all extent boundaries, effectively translating it.
Definition: extent3.h:230
const Extent3< T > & expandToInclude(const Vector3< T > &v)
Enlarges the extent to contain v.
Definition: extent3.h:255
void upperBound(const Vector3< T > &v)
Sets the upper bound of the exetnt, keeping the lower bound constant. Synonym to c222().
Definition: extent3.h:219
void c112(const Vector3< T > &v)
Sets one of the eight characteristic corners of the extent, keeping the other three extents constant.
Definition: extent3.h:209
void c221(const Vector3< T > &v)
Sets one of the eight characteristic corners of the extent, keeping the other three extents constant.
Definition: extent3.h:207
T volume() const
Returns the volume of the extent ( width() * height() * depth() ).
Definition: extent3.h:79
const T & dof2(UInt u) const
Returns the upper bound of degree-of-freedom dof.
Definition: extent3.h:62
void c111(const Vector3< T > &v)
Sets one of the eight characteristic corners of the extent, keeping the other three extents constant.
Definition: extent3.h:201
T width() const
Returns the size of the extent in the x-direction.
Definition: extent3.h:71
Extent3< Float > FExtent3
Definition: extent3.h:332
const Extent3< T > & expandToInclude(const T &x, const T &y, const T &z)
Definition: extent3.h:265
Vector3< T > centroid() const
Returns the geometric center of the extent as a Vector3.
Definition: extent3.h:77
Vector3< T > lowerBound() const
Returns the lower bounding corner of the extent, minimum value of x,y, and z.
Definition: extent3.h:112
Extent3< T > operator-(const Vector3< T > &v) const
Returns the extent created ty translating this one -v units.
Definition: extent3.h:236
Vector3< T > corner(UInt x, UInt y, UInt z) const
Definition: extent3.h:84
T & rdof1(UInt u)
Reference access to lower bound of degree-of-freedom dof.
Definition: extent3.h:176
bool isEmpty() const
Returns true if the region is "inside out" in any of its three coordinates.
Definition: extent3.h:120
Vector3< T > size() const
Returns the size of the extent as a Vector3(width(),height(),depth()).
Definition: extent3.h:116
Extent3< T > biggerBy(const T &fact) const
Definition: extent3.h:294
debug checked shorthand for std::numeric_limits<T>::
Definition: limit.h:25
unsigned int UInt
unsigned 32 bit
Definition: basedef.h:31
T & ry1()
Reference access to the minimum y extent.
Definition: extent3.h:171
Vector3< T > c211() const
Returns one of the eith corners that characterize the extent.
Definition: extent3.h:100
T & rz1()
Reference access to the minimum z extent.
Definition: extent3.h:173
const T & y1() const
Returns the lower bound of the extent in the y-direction.
Definition: extent3.h:45
Extent3< T > expandedToInclude(const T &x, const T &y, const T &z) const
Definition: extent3.h:281
Extent3< T > intersectedWith(const Extent3< T > &r) const
Returns the extent formed by the intersections of the two extents. May end up empty.
Definition: extent3.h:238
Vector3< T > c222() const
Returns one of the eith corners that characterize the extent.
Definition: extent3.h:110
void width(const T &t)
Sets the width of the extent by moving the maximum x extent, keeping the minimum constant.
Definition: extent3.h:195
Extent3(const Vector3< T > &v111, const Vector3< T > &v222)
Explicit constructor, by providing the lower-bound and upper-bound as two Vector3.
Definition: extent3.h:29
bool tolIntersects(const Extent3< T > &c, const T &tol) const
Returns true if the Extent3 C intersects (inclusive) this extent in any way with an added tolerance f...
Definition: extent3.h:161
const Extent3< T > & expandToInclude(const Extent3< T > &r)
Enlarges the extent to include both its original extent and r.
Definition: extent3.h:245
void c222(const Vector3< T > &v)
Sets one of the eight characteristic corners of the extent, keeping the other three extents constant.
Definition: extent3.h:215
bool operator<(const Extent3< T > &c) const
Comparison operator, based on volume.
Definition: extent3.h:130
Vector3< T > c121() const
Returns one of the eith corners that characterize the extent.
Definition: extent3.h:98
const Extent3< T > & operator+=(const Vector3< T > &v)
Adds v to all extent boundaries, effectively translating it.
Definition: extent3.h:228
Extent3< UInt > UExtent3
Definition: extent3.h:334
const T & z() const
The z-component of the vector.
Definition: vect.h:186
void c212(const Vector3< T > &v)
Sets one of the eight characteristic corners of the extent, keeping the other three extents constant.
Definition: extent3.h:213
T & rdof2(UInt u)
Reference access to lower bound of degree-of-freedom dof.
Definition: extent3.h:185
Extent3< Double > DExtent3
Definition: extent3.h:331
T & rx1()
Reference access to the minimum x extent.
Definition: extent3.h:169
bool tolIsEmpty(const double &tol=limits< double >::epsilon() *100) const
Returns true if the region is "inside out" with a tolerance in any of its three coordinates.
Definition: extent3.h:122
const T & x1() const
Returns the lower bound of the extent in the x-direction.
Definition: extent3.h:41
void height(const T &t)
Sets the height of the extent by moving the maximum y extent, keeping the minimum constant.
Definition: extent3.h:197
Extent3(const Extent3< T > &r)
Copy constructor.
Definition: extent3.h:32
const T & y2() const
Returns the upper y-bound.
Definition: extent2.h:38
void c121(const Vector3< T > &v)
Sets one of the eight characteristic corners of the extent, keeping the other three extents constant.
Definition: extent3.h:203
Extent3< T > expandedToInclude(const Vector3< T > &v) const
Returns an extent large enough to contain this one and the point v.
Definition: extent3.h:275
Vector3< T > c111() const
Returns one of the eith corners that characterize the extent.
Definition: extent3.h:96
Extent3(const Extent2< T > &r)
Explicit contructor, from a Extent2. The z extent is set to (0,1).
Definition: extent3.h:34
Vector3< T > bound(const Vector3< T > &v) const
Definition: extent3.h:224
T & ry2()
Reference access to the maximum y extent.
Definition: extent3.h:172
Extent3()
Default constructor, no data initialization.
Definition: extent3.h:23
void depth(const T &t)
Sets the depth of the extent by moving the maximum z extent, keeping the minimum constant.
Definition: extent3.h:199
T & rx2()
Reference access to the maximum x extent.
Definition: extent3.h:170
2D cartesian region in space.
Definition: extent2.h:12
3D vector utility class.
Definition: vect.h:161
bool operator!=(const Extent3< T > &r) const
Comparison operator.
Definition: extent3.h:128
Vector3< T > c122() const
Returns one of the eith corners that characterize the extent.
Definition: extent3.h:106
bool isIn(const Vector3< T > &v) const
Returns true if Vector3 v is "inside" the extent, inclusive.
Definition: extent3.h:134
T diagonal() const
Returns the diagonal length of the extent, or the distance from the lower bound corner to the upper b...
Definition: extent3.h:81
const T & z1() const
Returns the lower bound of the extent in the y-direction.
Definition: extent3.h:49
void size(const Vector3< T > &v)
Specifies the size of the extent by moving the upper bound, keeping the lower bound constant.
Definition: extent3.h:221
bool operator==(const Extent3< T > &c) const
Comparison operator.
Definition: extent3.h:124
Extent3< T > expanded(const T &tol) const
Definition: extent3.h:291
static constexpr Extent3< T > nothing()
Returns an Extent3 with maximum negative size. Useful for calculating bounds.
Definition: extent3.h:36
Extent3< T > center(const Vector3< T > &v) const
Returns a Extent2 centered about point v.
Definition: extent3.h:313
const T & x2() const
Returns the upper x-bound.
Definition: extent2.h:34
Vector3< T > c212() const
Returns one of the eith corners that characterize the extent.
Definition: extent3.h:108
const Extent3< T > & toExtent3(const Extent3< T > &t)
Returns a Extent3.
Definition: extent3.h:337
bool isIn(const Extent3< T > &c) const
Returns true if the Extent3 c falls completely inside (inclusive) the extent.
Definition: extent3.h:139
bool tolIsIn(const Vector3< T > &v, const T &tol) const
Returns true if Vector3 v is "inside" the extent, inclusive with an added tolerance factor.
Definition: extent3.h:144
void c122(const Vector3< T > &v)
Sets one of the eight characteristic corners of the extent, keeping the other three extents constant.
Definition: extent3.h:211
Extent3< Int > IExtent3
Definition: extent3.h:333
const Extent3< T > & center(const Vector3< T > &v)
Centers this Extent2 about point v.
Definition: extent3.h:302
const T & x1() const
Returns the lower x-bound.
Definition: extent2.h:32
A Class representing a cartesian extent in 3D.
Definition: extent3.h:16
Vector3< T > c221() const
Returns one of the eith corners that characterize the extent.
Definition: extent3.h:102
void c211(const Vector3< T > &v)
Sets one of the eight characteristic corners of the extent, keeping the other three extents constant.
Definition: extent3.h:205
const T & y() const
The y-component of the vector.
Definition: vect.h:184
const T & x() const
The x-component of the vector.
Definition: vect.h:182
const T & z2() const
Returns the upper bound of the extent in the y-direction.
Definition: extent3.h:51
Extent3< T > operator+(const Vector3< T > &v) const
Returns the extent created ty translating this one v units.
Definition: extent3.h:234
const T & y2() const
Returns the upper bound of the extent in the y-direction.
Definition: extent3.h:47
T & rz2()
Definition: extent3.h:174
Extent3< T > expandedToInclude(const Extent3< T > &r) const
Returns an extent large enough to contain this one and r.
Definition: extent3.h:269
const T & dof1(UInt u) const
Returns the lower bound of degree-of-freedom dof.
Definition: extent3.h:53
bool intersects(const Extent3< T > &c) const
Returns true if the Extent3 C intersects (inclusive) this extent in any way.
Definition: extent3.h:154