Describes a rectangle with integer boundaries. More...
#include <Box.h>
Public Types | |
typedef iterator | const_iterator |
Public Member Functions | |
iterator | begin () const |
iterator | end () const |
Box (int x, int y, int r, int t) | |
Box (const Box &b) | |
int | x () const |
void | x (int v) |
int | y () const |
void | y (int v) |
int | r () const |
void | r (int v) |
int | t () const |
void | t (int v) |
int | w () const |
void | w (int v) |
int | h () const |
void | h (int v) |
float | center_x () const |
float | center_y () const |
void | set (int x, int y, int r, int t) |
void | set (const Box &b) |
bool | is_constant () const |
void | clear () |
void | move (int dx, int dy) |
void | pad (int dx, int dy, int dr, int dt) |
void | pad (int dx, int dy) |
void | pad (int d) |
int | clampx (int x) const |
int | clampy (int y) const |
void | merge (const Box &) |
void | merge (int x, int y) |
void | merge (int x, int y, int r, int t) |
void | expand (int amount) |
void | expand (int widthAmount, int heightAmount) |
void | scale (float scaleAmount) |
void | intersect (const Box &) |
void | intersect (int x, int y, int r, int t) |
bool | intersects (const Box &other) const |
bool | intersects (int x, int y, int r, int t) const |
bool | contains (const Box &other) const |
int64_t | area () const |
Describes a rectangle with integer boundaries.
This class is used as a base for everything in DD::Image that describes a rectangle of pixels. It contains 4 integers storing the left, bottom, right, and top edges of the box.
Boxes must have a size of at least 1 in both dimensions. This is so they always contain at least one pixel. This pixel is used to provide a value when locations are indexed outside the box. If you set a box to a size less than one then the result is unpredictable.
In DD::Image integer coordinates are considered to be at the corners of the pixels, not in their centers. When addressing a pixel by integers the pixel to the upper-right of the integer coordinate is chosen. This is why the right and top edge appear to indicate a pixel outside the box. In fact all 4 edges are treated the same and they represent the positions around the outside edge of the pixels.
|
inline |
Location of left edge
Referenced by DD::Image::Iop::_copyState(), DD::Image::IllumShader::_request(), DD::Image::NukeWrapper::_request(), DD::Image::Render::_request(), DD::Image::RenderScene::_request(), DD::Image::Read::_validate(), DD::Image::Transform::_validate(), DD::Image::UpRez::_validate(), DD::Image::DrawIop::_validate(), DD::Image::Format::append(), DD::Image::Interest::at(), DD::Image::RowCacheTile::at(), DD::Image::Black::Black(), contains(), DD::Image::ImagePlane::copyIntersectionFrom(), DD::Image::DeepPlane::covers(), DD::Image::DeepOp::deepEngine(), DD::Image::Iop::doFetchPlane(), DD::Image::Transform::draw_handle(), DD::Image::Read::engine(), DD::Image::Iop::fetchPlane(), DD::Image::CameraOp::fromFormat(), DD::Image::Iop::get(), DD::Image::DeepInPlaceOutputPlane::getPixel(), DD::Image::ImagePlane::getRow(), DD::Image::ViewerContext::getScreenBoundingBox(), DD::Image::PlanarIop::getStripeBox(), DD::Image::gl_drawTextTopLeftOrthogonal(), DD::Image::GLProject(), DD::Image::Interest::Interest(), intersect(), intersects(), DD::Image::ImagePlaneDescriptor::intersects(), merge(), DD::Image::Transform::motionBlurSample(), DD::Image::operator!=(), DD::Image::operator<<(), DD::Image::operator==(), DD::Image::DrawIop::pixel_engine(), DD::Image::ViewerCache::read_from_cache(), DD::Image::Iop::request(), DD::Image::Scene::request(), DD::Image::Transform::sample(), slr::SlrShadingContext::sample(), DD::Image::VertexContext::sample(), scale(), DD::Image::ProxyContext::setProxyscale(), DD::Image::DeepInPlaceOutputPlane::setSampleCount(), DD::Image::ToBuffer::to_buffer(), DD::Image::ProxyContext::to_proxy(), DD::Image::ProxyContext::to_proxy_rel(), DD::Image::CameraOp::toFormat(), DD::Image::Transform::updateConcat(), DD::Image::Scene::validate(), DD::Image::ViewerContext::viewAreaFromScreenToRender(), and DD::Image::ViewFrustum::ViewFrustum().
|
inline |
Set left edge
|
inline |
Location of bottom edge
Referenced by DD::Image::Iop::_copyState(), DD::Image::IllumShader::_request(), DD::Image::NukeWrapper::_request(), DD::Image::Render::_request(), DD::Image::RenderScene::_request(), DD::Image::Read::_validate(), DD::Image::Transform::_validate(), DD::Image::UpRez::_validate(), DD::Image::DrawIop::_validate(), DD::Image::Format::append(), DD::Image::Interest::at(), DD::Image::RowCacheTile::at(), DD::Image::Black::Black(), contains(), DD::Image::ImagePlane::copyIntersectionFrom(), DD::Image::DeepPlane::covers(), DD::Image::DeepOp::deepEngine(), DD::Image::Iop::doFetchPlane(), DD::Image::PlanarIop::doFetchPlane(), DD::Image::Interest::done(), DD::Image::Transform::draw_handle(), DD::Image::PlanarIop::expandToFullTiles(), DD::Image::Iop::fetchPlane(), DD::Image::CameraOp::fromFormat(), DD::Image::Iop::get(), DD::Image::DeepInPlaceOutputPlane::getPixel(), DD::Image::ImagePlane::getRow(), DD::Image::ViewerContext::getScreenBoundingBox(), DD::Image::GLProject(), DD::Image::Interest::Interest(), intersect(), intersects(), DD::Image::ImagePlaneDescriptor::intersects(), DD::Image::Interest::is_zero(), DD::Image::GeneralTile::load_range(), merge(), DD::Image::Transform::motionBlurSample(), DD::Image::operator!=(), DD::Image::operator<<(), DD::Image::operator==(), DD::Image::DrawIop::pixel_engine(), DD::Image::ViewerCache::read_from_cache(), DD::Image::Iop::request(), DD::Image::Scene::request(), DD::Image::Transform::sample(), DD::Image::VertexContext::sample(), scale(), DD::Image::ProxyContext::setProxyscale(), DD::Image::DeepInPlaceOutputPlane::setSampleCount(), DD::Image::ToBuffer::to_buffer(), DD::Image::ProxyContext::to_proxy(), DD::Image::ProxyContext::to_proxy_rel(), DD::Image::CameraOp::toFormat(), DD::Image::Transform::updateConcat(), DD::Image::Scene::validate(), DD::Image::ViewerContext::viewAreaFromScreenToRender(), and DD::Image::ViewFrustum::ViewFrustum().
|
inline |
Set bottom edge
|
inline |
Location of right edge
Referenced by DD::Image::Iop::_copyState(), DD::Image::IllumShader::_request(), DD::Image::NukeWrapper::_request(), DD::Image::RenderScene::_request(), DD::Image::Read::_validate(), DD::Image::UpRez::_validate(), DD::Image::DrawIop::_validate(), DD::Image::Format::append(), contains(), DD::Image::ImagePlane::copyIntersectionFrom(), DD::Image::DeepPlane::covers(), DD::Image::DeepOp::deepEngine(), DD::Image::Iop::doFetchPlane(), DD::Image::Transform::draw_handle(), DD::Image::Read::engine(), DD::Image::Iop::fetchPlane(), DD::Image::CameraOp::fromFormat(), DD::Image::Iop::get(), DD::Image::DeepInPlaceOutputPlane::getPixel(), DD::Image::ImagePlane::getRow(), DD::Image::ViewerContext::getScreenBoundingBox(), DD::Image::Interest::Interest(), intersect(), intersects(), DD::Image::ImagePlaneDescriptor::intersects(), merge(), DD::Image::Transform::motionBlurSample(), DD::Image::operator!=(), DD::Image::operator<<(), DD::Image::operator==(), DD::Image::DrawIop::pixel_engine(), DD::Image::ViewerCache::read_from_cache(), DD::Image::Iop::request(), DD::Image::Scene::request(), DD::Image::Transform::sample(), scale(), DD::Image::DeepInPlaceOutputPlane::setSampleCount(), DD::Image::ProxyContext::to_proxy(), DD::Image::ProxyContext::to_proxy_rel(), DD::Image::CameraOp::toFormat(), DD::Image::Transform::updateConcat(), DD::Image::ViewerContext::viewAreaFromScreenToRender(), and DD::Image::ViewFrustum::ViewFrustum().
|
inline |
Set right edge
|
inline |
Location of top edge
Referenced by DD::Image::Iop::_copyState(), DD::Image::IllumShader::_request(), DD::Image::NukeWrapper::_request(), DD::Image::RenderScene::_request(), DD::Image::Read::_validate(), DD::Image::UpRez::_validate(), DD::Image::DrawIop::_validate(), DD::Image::Format::append(), contains(), DD::Image::ImagePlane::copyIntersectionFrom(), DD::Image::DeepPlane::covers(), DD::Image::DeepOp::deepEngine(), DD::Image::Iop::doFetchPlane(), DD::Image::PlanarIop::doFetchPlane(), DD::Image::Transform::draw_handle(), DD::Image::PlanarIop::expandToFullTiles(), DD::Image::Iop::fetchPlane(), DD::Image::CameraOp::fromFormat(), DD::Image::Iop::get(), DD::Image::DeepInPlaceOutputPlane::getPixel(), DD::Image::ImagePlane::getRow(), DD::Image::ViewerContext::getScreenBoundingBox(), DD::Image::gl_drawTextTopLeftOrthogonal(), DD::Image::Interest::Interest(), intersect(), intersects(), DD::Image::ImagePlaneDescriptor::intersects(), DD::Image::GeneralTile::load_range(), merge(), DD::Image::Transform::motionBlurSample(), DD::Image::operator!=(), DD::Image::operator<<(), DD::Image::operator==(), DD::Image::DrawIop::pixel_engine(), DD::Image::ViewerCache::read_from_cache(), DD::Image::Iop::request(), DD::Image::Scene::request(), DD::Image::Transform::sample(), scale(), DD::Image::ProxyContext::setProxyscale(), DD::Image::DeepInPlaceOutputPlane::setSampleCount(), DD::Image::ProxyContext::to_proxy(), DD::Image::ProxyContext::to_proxy_rel(), DD::Image::CameraOp::toFormat(), DD::Image::Transform::updateConcat(), DD::Image::ViewerContext::viewAreaFromScreenToRender(), and DD::Image::ViewFrustum::ViewFrustum().
|
inline |
Set top edge
|
inline |
Referenced by DD::Image::Render::_request(), DD::Image::Read::_validate(), DD::Image::RenderScene::_validate(), DD::Image::Transform::_validate(), DD::Image::DrawIop::_validate(), DD::Image::DeepOp::deepEngine(), DD::Image::Iop::doFetchPlane(), DD::Image::CameraOp::fromFormat(), DD::Image::GenericImagePlane::GenericImagePlane(), DD::Image::gl_drawTextTopLeftOrthogonal(), DD::Image::GLProject(), DD::Image::Iop::merge_info(), DD::Image::Iop::request(), slr::SlrShadingContext::sample(), DD::Image::VertexContext::sample(), DD::Image::ProxyContext::setProxyscale(), DD::Image::GenericImagePlane::SetStrides(), DD::Image::ToBuffer::to_buffer(), DD::Image::CameraOp::toFormat(), and DD::Image::Scene::validate().
|
inline |
Set width by moving right edge
|
inline |
Referenced by DD::Image::Render::_request(), DD::Image::Read::_validate(), DD::Image::RenderScene::_validate(), DD::Image::Transform::_validate(), DD::Image::DrawIop::_validate(), DD::Image::DeepOp::deepEngine(), DD::Image::Iop::doFetchPlane(), DD::Image::GenericImagePlane::GenericImagePlane(), DD::Image::gl_drawTextTopLeftOrthogonal(), DD::Image::GLProject(), DD::Image::Iop::request(), slr::SlrShadingContext::sample(), DD::Image::VertexContext::sample(), DD::Image::GenericImagePlane::SetStrides(), DD::Image::Reader::stripeHeight(), DD::Image::ToBuffer::to_buffer(), and DD::Image::Scene::validate().
|
inline |
Set height by moving top edge
|
inline |
center in x
|
inline |
center in y
|
inline |
Set all four sides at once.
Referenced by DD::Image::Read::_validate(), DD::Image::Render::_validate(), DD::Image::RenderScene::_validate(), DD::Image::Transform::_validate(), DD::Image::DrawIop::_validate(), DD::Image::Black::Black(), DD::Image::Iop::clear_info(), DD::Image::Iop::copy_info(), DD::Image::Transform::degenerate(), DD::Image::Iop::Iop(), DD::Image::Box3::project(), DD::Image::Reader::Reader(), DD::Image::Iop::request(), DD::Image::Reader::set_info(), DD::Image::Transform::setclip(), DD::Image::Transform::updateConcat(), and DD::Image::Scene::validate().
|
inline |
Set all four sides at once.
|
inline |
True if box is 1x1 in both directions.
|
inline |
Set to is_constant()
Referenced by DD::Image::Render::_validate(), DD::Image::ViewerCache::BoxPresent(), DD::Image::Scene::Scene(), and DD::Image::Scene::validate().
|
inline |
Move all the sides and thus the entire box by the given deltas
Referenced by DD::Image::Transform::_validate().
|
inline |
Move x(), y(), r(), t() by the given deltas, except if a dimension is 1 it does not move those edges, because the color is constant in that direction. This is used to pad out an input image with the spill that a filter will create. Notice that dx and dy are negative to make the box bigger.
Referenced by DD::Image::Render::_validate(), and DD::Image::Transform::_validate().
|
inline |
|
inline |
|
inline |
Return x restricted to pointing at a pixel in the box.
Referenced by DD::Image::GeneralTile::at(), DD::Image::Interest::at(), DD::Image::BufferIopTile::at(), DD::Image::Iop::at(), and DD::Image::RowCacheTile::at().
|
inline |
Return y restricted to pointing at a pixel in the box.
Referenced by DD::Image::GeneralTile::at(), DD::Image::Interest::at(), DD::Image::BufferIopTile::at(), DD::Image::Iop::at(), DD::Image::RowCacheTile::at(), and DD::Image::Interest::is_zero().
void DD::Image::Box::merge | ( | const Box & | v | ) |
Change this box to be the union of itself and the passed box.
This is for bounding boxes where it is assumed the edge pixels extend out to infinity. 1-wide or 1-tall boxes cause the other's dimensions to be used unchanged because these indicate an infinite area of constant color and thus their position is irrelevant. If both boxes are 1 wide or 1 tall then the passed box's position is used.
The output is never an "empty" box which is now illegal for bounding boxes. If both boxes are <= 0 wide or tall then the passed box's postition is used and the right/top edge are set to x/y plus one.
References merge().
Referenced by DD::Image::NukeWrapper::_validate(), DD::Image::Render::_validate(), DD::Image::RenderScene::_validate(), DD::Image::Transform::_validate(), DD::Image::DrawIop::_validate(), DD::Image::DeepPlane::covers(), DD::Image::DeepOp::deepRequest(), DD::Image::PlanarI::getOutputBox(), merge(), DD::Image::Iop::merge_info(), and DD::Image::Scene::validate().
void DD::Image::Box::merge | ( | int | x, |
int | y | ||
) |
void DD::Image::Box::merge | ( | int | x, |
int | y, | ||
int | r, | ||
int | t | ||
) |
void DD::Image::Box::expand | ( | int | amount | ) |
Expand the bbox by the given amount in all directions around the centre. Negative values will shrink the bbox.
void DD::Image::Box::expand | ( | int | widthAmount, |
int | heightAmount | ||
) |
Expand the bbox by the given amount for both dimensions around the centre. Negative values will shrink the bbox.
void DD::Image::Box::scale | ( | float | scaleAmount | ) |
void DD::Image::Box::intersect | ( | const Box & | v | ) |
Change this box to be the intersection of itself and the passed box.
DD::Image replicates pixels from the nearest edge of the bounding box when selecting coordinates outside it. This affects how boxes intersect, because a box with zero dimensions is not allowed. If the boxes don't intersect the result will still have 1 pixel in it. The resulting location of this box could be anywhere, but this function places it inside the edge of the passed box v.
References intersect().
Referenced by DD::Image::NukeWrapper::_validate(), DD::Image::Render::_validate(), DD::Image::Write::_validate(), DD::Image::DrawIop::_validate(), DD::Image::Interest::Interest(), intersect(), DD::Image::GeneralTile::load_range(), and DD::Image::BufferIopTile::makeTile().
void DD::Image::Box::intersect | ( | int | x, |
int | y, | ||
int | r, | ||
int | t | ||
) |
bool DD::Image::Box::intersects | ( | const Box & | other | ) | const |
Check if this box intersects the other box
References intersects(), r(), t(), x(), and y().
Referenced by intersects().
bool DD::Image::Box::intersects | ( | int | x, |
int | y, | ||
int | r, | ||
int | t | ||
) | const |
©2024 The Foundry Visionmongers, Ltd. All Rights Reserved. |