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();
287 T (min)(std::size_t
const&
index)
const 289 if (ranges.size() <=
index) {
296 return ranges[
index].minimum;
299 void (min)(std::size_t
const&
index, T v)
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]) )
426 return intersects(other);
432 for (size_type i = 0; i < dimension(); i++) {
433 if ( !ranges[i].contains(other.ranges[i]) )
455 if (!ranges[0].contains(point.
GetX()))
457 if (!ranges[1].contains(point.
GetY()))
461 if (!ranges[2].contains(point.
GetZ()))
463 if (detail::compare_distance(ranges[2].length(), 0.0))
472 typedef typename std::vector< T >::size_type size_type;
475 if( dimension() <= deltas.size())
477 std::ostringstream msg;
478 msg <<
"liblas::Bounds::shift: Delta vector size, " << deltas.size()
479 <<
", is larger than the dimensionality of the bounds, "<< dimension() <<
".";
480 throw std::runtime_error(msg.str());
482 for (i = 0; i < deltas.size(); ++i){
483 ranges[i].shift(deltas[i]);
490 typedef typename std::vector< T >::size_type size_type;
493 if( dimension() <= deltas.size())
495 std::ostringstream msg;
496 msg <<
"liblas::Bounds::scale: Delta vector size, " << deltas.size()
497 <<
", is larger than the dimensionality of the bounds, "<< dimension() <<
".";
498 throw std::runtime_error(msg.str());
500 for (i = 0; i < deltas.size(); ++i){
501 ranges[i].scale(deltas[i]);
508 RangeVec ds = r.
dims();
509 for (size_type i = 0; i < dimension(); ++i){
510 ranges[i].clip(ds[i]);
517 RangeVec ds = r.
dims();
518 for (size_type i = 0; i < dimension(); ++i){
519 ranges[i].grow(ds[i]);
526 ranges[0].grow(p.
GetX());
527 ranges[1].grow(p.
GetY());
528 ranges[2].grow(p.
GetZ());
534 for (size_type i = 0; i < dimension(); i++) {
535 output = output * ranges[i].length();
543 for (size_type i = 0; i < dimension(); i++) {
544 if (ranges[i].empty())
552 for (size_type d = 0; d < dimension(); ++d)
554 if ((min)(d) > (max)(d) )
557 if ( (detail::compare_distance((min)(d), (std::numeric_limits<T>::max)()) ||
558 detail::compare_distance((max)(d), -(std::numeric_limits<T>::max)()) ))
560 std::ostringstream msg;
561 msg <<
"liblas::Bounds::verify: Minimum point at dimension " << d
562 <<
"is greater than maximum point. Neither point is infinity.";
563 throw std::runtime_error(msg.str());
594 #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:488
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:440
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:541
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:515
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:524
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:470
void clip(Bounds const &r)
Clip this Bounds to the extent of r.
Definition: bounds.hpp:506
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:531
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:550
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<T> 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