DD::Image::Box Class Reference

Describes a rectangle with integer boundaries. More...

Inherited by DD::Image::Format, DD::Image::Info2D, and DD::Image::Interest.

List of all members.

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
int area () const

Detailed Description

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.


Member Function Documentation

int DD::Image::Box::x ( ) const [inline]
void DD::Image::Box::x ( int  v) [inline]

Set left edge

int DD::Image::Box::y ( ) const [inline]

Location of bottom edge

Referenced by DD::Image::Iop::_copyState(), DD::Image::RenderScene::_request(), DD::Image::Render::_request(), DD::Image::IllumShader::_request(), DD::Image::UpRez::_validate(), DD::Image::Transform::_validate(), DD::Image::Read::_validate(), DD::Image::DrawIop::_validate(), DD::Image::Format::append(), DD::Image::Interest::at(), DD::Image::Black::Black(), DD::Image::ImagePlane::copyIntersectionFrom(), DD::Image::DeepPlane::covers(), DD::Image::DeepOp::deepEngine(), DD::Image::PlanarIop::doFetchPlane(), DD::Image::Iop::doFetchPlane(), DD::Image::Interest::done(), DD::Image::Transform::draw_handle(), DD::Image::PlanarIop::expandToFullTiles(), DD::Image::Iop::fetchPlane(), DD::Image::CameraOp::from_format(), DD::Image::GeneralTile::GeneralTile(), DD::Image::Iop::get(), DD::Image::ImagePlane::getRow(), DD::Image::ViewerContext::getScreenBoundingBox(), DD::Image::GLProject(), DD::Image::Interest::Interest(), DD::Image::ImagePlaneDescriptor::intersects(), intersects(), DD::Image::Transform::motionBlurSample(), DD::Image::DrawIop::pixel_engine(), DD::Image::ViewerCache::read_from_cache(), DD::Image::Scene::request(), DD::Image::Iop::request(), DD::Image::VertexContext::sample(), DD::Image::Transform::sample(), DD::Image::ProxyContext::setProxyscale(), DD::Image::ToBuffer::to_buffer(), DD::Image::CameraOp::to_format(), DD::Image::ProxyContext::to_proxy(), DD::Image::ProxyContext::to_proxy_rel(), DD::Image::Transform::updateConcat(), DD::Image::Scene::validate(), DD::Image::ViewerContext::viewAreaFromScreenToRender(), and DD::Image::ViewFrustum::ViewFrustum().

void DD::Image::Box::y ( int  v) [inline]

Set bottom edge

void DD::Image::Box::r ( int  v) [inline]

Set right edge

void DD::Image::Box::t ( int  v) [inline]

Set top edge

void DD::Image::Box::w ( int  v) [inline]

Set width by moving right edge

void DD::Image::Box::h ( int  v) [inline]

Set height by moving top edge

float DD::Image::Box::center_x ( ) const [inline]

center in x

float DD::Image::Box::center_y ( ) const [inline]

center in y

void DD::Image::Box::set ( const Box b) [inline]

Set all four sides at once.

bool DD::Image::Box::is_constant ( ) const [inline]

True if box is 1x1 in both directions.

void DD::Image::Box::move ( int  dx,
int  dy 
) [inline]

Move all the sides and thus the entire box by the given deltas

Referenced by DD::Image::Transform::_validate().

void DD::Image::Box::pad ( int  dx,
int  dy,
int  dr,
int  dt 
) [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::Transform::_validate(), and DD::Image::Render::_validate().

void DD::Image::Box::pad ( int  dx,
int  dy 
) [inline]

Same as pad(-dx,-dy,dx,dy), add the same amount on all sides.

References pad().

Referenced by pad().

void DD::Image::Box::pad ( int  d) [inline]

Same as pad(-d,-d,d,d), add the same amount on all sides.

References pad().

Referenced by pad().

int DD::Image::Box::clampx ( int  x) const [inline]

Return x restricted to pointing at a pixel in the box.

Referenced by DD::Image::RowCacheTile::at(), DD::Image::Iop::at(), DD::Image::Interest::at(), and DD::Image::GeneralTile::at().

int DD::Image::Box::clampy ( int  y) const [inline]
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.

Referenced by DD::Image::Transform::_validate(), DD::Image::RenderScene::_validate(), DD::Image::Render::_validate(), DD::Image::NukeWrapper::_validate(), DD::Image::DrawIop::_validate(), DD::Image::DeepPlane::covers(), DD::Image::DeepOp::deepRequest(), DD::Image::PlanarI::getOutputBox(), DD::Image::DeepInfo::merge(), DD::Image::Iop::merge_info(), and DD::Image::Scene::validate().

void DD::Image::Box::merge ( int  x,
int  y 
)

Similar to merge(x,y,x+1,y+1) but it always expands the box, even if it describes a constant. This allows you to build a box out of a bunch of pixels that you plan to index.

void DD::Image::Box::merge ( int  x,
int  y,
int  r,
int  t 
)

Same as merge(Box(x,y,r,t))

References MAX(), and MIN().

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)

Scale the bbox by the ratio for both dimensions around the centre. 1.0 is the current size.

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.

Referenced by DD::Image::Write::_validate(), DD::Image::Render::_validate(), DD::Image::NukeWrapper::_validate(), DD::Image::DrawIop::_validate(), and DD::Image::Interest::is_zero().

void DD::Image::Box::intersect ( int  x,
int  y,
int  r,
int  t 
)

Same as intersect(Box(x,y,r,t))

bool DD::Image::Box::intersects ( const Box other) const

Check if this box intersects the other box

References r(), t(), x(), and y().

bool DD::Image::Box::intersects ( int  x,
int  y,
int  r,
int  t 
) const

Same as intersects(Box(x,y,r,t))