osgEarth 2.1.1
|
Public Member Functions | |
Bounds () | |
Bounds (double xmin, double ymin, double xmax, double ymax) | |
double | width () const |
double | height () const |
double | depth () const |
bool | contains (double x, double y) const |
bool | contains (const Bounds &rhs) const |
Bounds | unionWith (const Bounds &rhs) const |
Bounds | intersectionWith (const Bounds &rhs) const |
void | expandBy (double x, double y) |
void | expandBy (double x, double y, double z) |
void | expandBy (const Bounds &rhs) |
osg::Vec2d | center2d () const |
double | radius2d () const |
std::string | toString () const |
bool | isValid () const |
bool | isEmpty () const |
void | transform (const SpatialReference *fromSRS, const SpatialReference *toSRS) |
An "anonymous" bounding extent (i.e., no geo reference information)
Bounds::Bounds | ( | ) |
Definition at line 41 of file GeoData.cpp.
:
osg::BoundingBoxImpl<osg::Vec3d>( DBL_MAX, DBL_MAX, DBL_MAX, -DBL_MAX, -DBL_MAX, -DBL_MAX )
{
//nop
}
Bounds::Bounds | ( | double | xmin, |
double | ymin, | ||
double | xmax, | ||
double | ymax | ||
) |
Definition at line 47 of file GeoData.cpp.
:
osg::BoundingBoxImpl<osg::Vec3d>( xmin, ymin, -DBL_MAX, xmax, ymax, DBL_MAX )
{
//nop
}
osg::Vec2d Bounds::center2d | ( | ) | const |
Definition at line 149 of file GeoData.cpp.
{
osg::Vec3d c = center();
return osg::Vec2d( c.x(), c.y() );
}
bool Bounds::contains | ( | double | x, |
double | y | ||
) | const |
Definition at line 60 of file GeoData.cpp.
{ return isValid() && x >= xMin() && x <= xMax() && y >= yMin() && y <= yMax(); }
bool Bounds::contains | ( | const Bounds & | rhs | ) | const |
Definition at line 68 of file GeoData.cpp.
{ return isValid() && rhs.isValid() && xMin() <= rhs.xMin() && xMax() >= rhs.xMax() && yMin() <= rhs.yMin() && yMax() >= rhs.yMax(); }
double Bounds::depth | ( | ) | const |
Definition at line 144 of file GeoData.cpp.
{
return zMax()-zMin();
}
void Bounds::expandBy | ( | double | x, |
double | y | ||
) |
Definition at line 77 of file GeoData.cpp.
{ osg::BoundingBoxImpl<osg::Vec3d>::expandBy( x, y, 0 ); }
void Bounds::expandBy | ( | double | x, |
double | y, | ||
double | z | ||
) |
Definition at line 83 of file GeoData.cpp.
{ osg::BoundingBoxImpl<osg::Vec3d>::expandBy( x, y, z ); }
void Bounds::expandBy | ( | const Bounds & | rhs | ) |
Definition at line 89 of file GeoData.cpp.
{ osg::BoundingBoxImpl<osg::Vec3d>::expandBy( rhs ); }
double Bounds::height | ( | ) | const |
Definition at line 139 of file GeoData.cpp.
{
return yMax()-yMin();
}
Definition at line 113 of file GeoData.cpp.
{ if ( valid() && !rhs.valid() ) return *this; if ( !valid() && rhs.valid() ) return rhs; if ( this->contains(rhs) ) return rhs; if ( rhs.contains(*this) ) return *this; if ( !intersects(rhs) ) return Bounds(); double xmin, xmax, ymin, ymax; xmin = ( xMin() > rhs.xMin() && xMin() < rhs.xMax() ) ? xMin() : rhs.xMin(); xmax = ( xMax() > rhs.xMin() && xMax() < rhs.xMax() ) ? xMax() : rhs.xMax(); ymin = ( yMin() > rhs.yMin() && yMin() < rhs.yMax() ) ? yMin() : rhs.yMin(); ymax = ( yMax() > rhs.yMin() && yMax() < rhs.yMax() ) ? yMax() : rhs.yMax(); return Bounds(xmin, ymin, xmax, ymax); }
bool osgEarth::Bounds::isEmpty | ( | ) | const [inline] |
bool Bounds::isValid | ( | ) | const |
Definition at line 54 of file GeoData.cpp.
{
return xMin() <= xMax() && yMin() <= yMax();
}
double Bounds::radius2d | ( | ) | const |
Definition at line 155 of file GeoData.cpp.
{ return (center2d() - osg::Vec2d(xMin(),yMin())).length(); }
std::string Bounds::toString | ( | ) | const |
Definition at line 160 of file GeoData.cpp.
{ std::stringstream buf; buf << "(" << xMin() << "," << yMin() << " => " << xMax() << "," << yMax() << ")"; std::string result = buf.str(); return result; }
void Bounds::transform | ( | const SpatialReference * | fromSRS, |
const SpatialReference * | toSRS | ||
) |
Definition at line 168 of file GeoData.cpp.
{ from->transformExtent( to, _min.x(), _min.y(), _max.x(), _max.y() ); }
Definition at line 95 of file GeoData.cpp.
{ if ( valid() && !rhs.valid() ) return *this; if ( !valid() && rhs.valid() ) return rhs; Bounds u; if ( intersects(rhs) ) { u.xMin() = xMin() >= rhs.xMin() && xMin() <= rhs.xMax() ? xMin() : rhs.xMin(); u.xMax() = xMax() >= rhs.xMin() && xMax() <= rhs.xMax() ? xMax() : rhs.xMax(); u.yMin() = yMin() >= rhs.yMin() && yMin() <= rhs.yMax() ? yMin() : rhs.yMin(); u.yMax() = yMax() >= rhs.yMin() && yMax() <= rhs.yMax() ? yMax() : rhs.yMax(); u.zMin() = zMin() >= rhs.zMin() && zMin() <= rhs.zMax() ? zMin() : rhs.zMin(); u.zMax() = zMax() >= rhs.zMin() && zMax() <= rhs.zMax() ? zMax() : rhs.zMax(); } return u; }
double Bounds::width | ( | ) | const |
Definition at line 134 of file GeoData.cpp.
{
return xMax()-xMin();
}