42 #ifndef LIBLAS_LASBOUNDS_HPP_INCLUDED
43 #define LIBLAS_LASBOUNDS_HPP_INCLUDED
45 #include <liblas/detail/fwd.hpp>
48 #include <liblas/detail/private_utility.hpp>
51 #include <boost/concept_check.hpp>
72 Range(T mmin=(std::numeric_limits<T>::max)(), T mmax=(std::numeric_limits<T>::min)())
73 : minimum(mmin), maximum(mmax) {}
77 : minimum(other.minimum)
78 , maximum(other.maximum)
105 if (!(detail::compare_distance(minimum, other.
minimum))
106 || !(detail::compare_distance(maximum, other.
maximum)))
126 return minimum <= v && v <= maximum;
131 return detail::compare_distance(minimum, (std::numeric_limits<T>::max)()) && detail::compare_distance(maximum, (std::numeric_limits<T>::min)());
170 return maximum - minimum;
174 template <
typename T>
215 ranges[0].minimum =
minx;
216 ranges[1].minimum =
miny;
217 ranges[2].minimum =
minz;
219 ranges[0].maximum =
maxx;
220 ranges[1].maximum =
maxy;
221 ranges[2].maximum =
maxz;
237 ranges[0].minimum =
minx;
238 ranges[1].minimum =
miny;
240 ranges[0].maximum =
maxx;
241 ranges[1].maximum =
maxy;
253 ranges[0].minimum = min.
GetX();
254 ranges[1].minimum = min.
GetY();
255 ranges[2].minimum = min.
GetZ();
257 ranges[0].maximum = max.
GetX();
258 ranges[1].maximum = max.
GetY();
259 ranges[2].maximum = max.
GetZ();
289 if (ranges.size() <=
index) {
296 return ranges[
index].minimum;
301 if (ranges.size() <= index) {
302 ranges.resize(index + 1);
304 ranges[index].minimum = v;
307 T (
max)(std::size_t
const& index)
const
309 if (ranges.size() <= index) {
316 return ranges[index].maximum;
319 void (
max)(std::size_t
const& index, T v)
321 if (ranges.size() <= index) {
322 ranges.resize(index + 1);
324 ranges[index].maximum = v;
356 T
minx()
const {
if (ranges.size() == 0)
return 0;
return ranges[0].minimum; }
357 T
miny()
const {
if (ranges.size() < 2)
return 0;
return ranges[1].minimum; }
358 T
minz()
const {
if (ranges.size() < 3)
return 0;
return ranges[2].minimum; }
359 T
maxx()
const {
if (ranges.size() == 0)
return 0;
return ranges[0].maximum; }
360 T
maxy()
const {
if (ranges.size() < 2)
return 0;
return ranges[1].maximum; }
361 T
maxz()
const {
if (ranges.size() < 3)
return 0;
return ranges[2].maximum; }
370 return (!
equal(rhs));
384 RangeVec
const&
dims ()
const {
return ranges; }
389 return ranges.size();
395 if (ranges.size() < d) {
403 for (size_type i = 0; i <
dimension(); i++) {
404 if ( ranges[i] != other.ranges[i] )
414 for (size_type i = 0; i <
dimension(); i++) {
415 if ( ranges[i].
overlaps(other.ranges[i]) )
432 for (size_type i = 0; i <
dimension(); i++) {
433 if ( ranges[i].
contains(other.ranges[i]) )
465 if (detail::compare_distance(ranges[2].length(), 0.0))
474 typedef typename std::vector< T >::size_type
size_type;
479 std::ostringstream msg;
480 msg <<
"liblas::Bounds::shift: Delta vector size, " << deltas.size()
481 <<
", is larger than the dimensionality of the bounds, "<<
dimension() <<
".";
482 throw std::runtime_error(msg.str());
484 for (i = 0; i < deltas.size(); ++i){
485 ranges[i].shift(deltas[i]);
492 typedef typename std::vector< T >::size_type
size_type;
497 std::ostringstream msg;
498 msg <<
"liblas::Bounds::scale: Delta vector size, " << deltas.size()
499 <<
", is larger than the dimensionality of the bounds, "<<
dimension() <<
".";
500 throw std::runtime_error(msg.str());
502 for (i = 0; i < deltas.size(); ++i){
503 ranges[i].scale(deltas[i]);
510 RangeVec ds = r.
dims();
511 for (size_type i = 0; i <
dimension(); ++i){
512 ranges[i].clip(ds[i]);
519 RangeVec ds = r.
dims();
520 for (size_type i = 0; i <
dimension(); ++i){
521 ranges[i].grow(ds[i]);
528 ranges[0].grow(p.
GetX());
529 ranges[1].grow(p.
GetY());
530 ranges[2].grow(p.
GetZ());
536 for (size_type i = 0; i <
dimension(); i++) {
537 output = output * ranges[i].length();
545 for (size_type i = 0; i <
dimension(); i++) {
546 if (ranges[i].
empty())
554 for (size_type d = 0; d <
dimension(); ++d)
559 if ( (detail::compare_distance((
min)(d), (std::numeric_limits<T>::max)()) ||
560 detail::compare_distance((
max)(d), -(std::numeric_limits<T>::max)()) ))
562 std::ostringstream msg;
563 msg <<
"liblas::Bounds::verify: Minimum point at dimension " << d
564 <<
"is greater than maximum point. Neither point is infinity.";
565 throw std::runtime_error(msg.str());
596 #endif // ndef LIBLAS_LASBOUNDS_HPP_INCLUDED
void scale(T v)
Definition: bounds.hpp:140
std::vector< Range< T > > RangeVec
Definition: bounds.hpp:182
void scale(std::vector< T > deltas)
Scale each dimension by a vector of deltas.
Definition: bounds.hpp:490
Bounds(RangeVec const &rngs)
Definition: bounds.hpp:200
bool contains(Bounds const &other) const
Does this Bounds contain other?
Definition: bounds.hpp:430
#define LAS_DLL
Definition: export.hpp:58
bool contains(T v) const
Definition: bounds.hpp:124
bool operator!=(Range const &rhs) const
Definition: bounds.hpp:97
Range(Range const &other)
Definition: bounds.hpp:76
T minimum
Definition: bounds.hpp:67
void grow(Range const &r)
Definition: bounds.hpp:162
bool contains(Point const &point) const
Does this Bounds this point other?
Definition: bounds.hpp:442
std::vector< Range< double > >::size_type size_type
Definition: bounds.hpp:180
T miny() const
Definition: bounds.hpp:357
bool operator==(Bounds< T > const &rhs) const
Definition: bounds.hpp:363
bool equal(Range const &other) const
Definition: bounds.hpp:102
bool empty() const
Definition: bounds.hpp:543
Definition: bounds.hpp:175
Bounds(T minx, T miny, T minz, T maxx, T maxy, T maxz)
Definition: bounds.hpp:206
void grow(T v)
Definition: bounds.hpp:154
T maxy() const
Definition: bounds.hpp:360
void grow(Bounds const &r)
Grow to the union of two liblas::Bounds.
Definition: bounds.hpp:517
size_type dimension() const
The number of dimensions of the Bounds.
Definition: bounds.hpp:387
Range & operator=(Range< T > const &rhs)
Definition: bounds.hpp:82
bool intersects(Bounds const &other) const
Does this Bounds intersect other?
Definition: bounds.hpp:411
bool operator!=(Bounds< T > const &rhs) const
Definition: bounds.hpp:368
T value_type
Definition: bounds.hpp:179
Range(T mmin=(std::numeric_limits< T >::max)(), T mmax=(std::numeric_limits< T >::min)())
Definition: bounds.hpp:72
Definition: bounds.hpp:64
T value_type
Definition: bounds.hpp:70
Bounds(T minx, T miny, T maxx, T maxy)
Definition: bounds.hpp:229
void clip(Range const &r)
Definition: bounds.hpp:146
void grow(Point const &p)
Expand the liblas::Bounds to include this point.
Definition: bounds.hpp:526
bool operator==(Range< T > const &rhs) const
Definition: bounds.hpp:92
T maxz() const
Definition: bounds.hpp:361
bool empty(void) const
Definition: bounds.hpp:129
Bounds(Bounds const &other)
Definition: bounds.hpp:194
bool contains(Range const &r) const
Definition: bounds.hpp:119
void shift(T v)
Definition: bounds.hpp:134
void shift(std::vector< T > deltas)
Shift each dimension by a vector of detlas.
Definition: bounds.hpp:472
void clip(Bounds const &r)
Clip this Bounds to the extent of r.
Definition: bounds.hpp:508
T minz() const
Definition: bounds.hpp:358
void dimension(size_type d)
Resize the dimensionality of the Bounds to d.
Definition: bounds.hpp:393
Namespace grouping all elements of libLAS public interface.
Definition: bounds.hpp:60
T volume() const
Definition: bounds.hpp:533
T() max(std::size_t const &index) const
Definition: bounds.hpp:307
T() min(std::size_t const &index) const
Definition: bounds.hpp:287
Point data record composed with X, Y, Z coordinates and attributes.
Definition: point.hpp:68
Bounds(const Point &min, const Point &max)
Definition: bounds.hpp:249
void verify()
Definition: bounds.hpp:552
Bounds< T > & operator=(Bounds< T > const &rhs)
Definition: bounds.hpp:374
T minx() const
Definition: bounds.hpp:356
T length() const
Definition: bounds.hpp:168
bool overlaps(Bounds const &other) const
Synonym for intersects for now.
Definition: bounds.hpp:424
bool equal(Bounds< T > const &other) const
Is this Bounds equal to other?
Definition: bounds.hpp:401
RangeVec const & dims() const
The vector of Range for the Bounds.
Definition: bounds.hpp:384
bool overlaps(Range const &r) const
Definition: bounds.hpp:114
Definition: schema.hpp:80
T maxx() const
Definition: bounds.hpp:359
T maximum
Definition: bounds.hpp:68