Notation used in Ruby API documentation

**Module**: db

**Description**: A box class with floating-point coordinates

- Public constructors
- Public methods
- Public static methods and constants
- Deprecated methods (protected, public, static, non-static and constructors)
- Detailed description

This object represents a box (a rectangular shape).

The definition of the attributes is: p1 is the lower left point, p2 the upper right one. If a box is constructed from two points (or four coordinates), the coordinates are sorted accordingly.

A box can be empty. An empty box represents no area (not even a point). Empty boxes behave neutral with respect to most operations. Empty boxes return true on empty?.

A box can be a point or a single line. In this case, the area is zero but the box still can overlap other boxes for example and it is not empty.

See The Database API for more details about the database objects.

new DBox ptr | new | (const Box box) | Creates a floating-point coordinate box from an integer coordinate box |

new DBox ptr | new | Creates an empty (invalid) box | |

new DBox ptr | new | (double w) | Creates a square with the given dimensions centered around the origin |

new DBox ptr | new | (double w, double h) | Creates a rectangle with given width and height, centered around the origin |

new DBox ptr | new | (double left, double bottom, double right, double top) | Creates a box with four coordinates |

new DBox ptr | new | (const DPoint lower_left, const DPoint upper_right) | Creates a box from two points |

[const] | bool | != | (const DBox box) | Returns true if this box is not equal to the other box |

[const] | DBox | & | (const DBox box) | Returns the intersection of this box with another box |

[const] | DBox | * | (const DBox box) | Returns the convolution product from this box with another box |

[const] | DBox | * | (double scale_factor) | Returns the scaled box |

[const] | DBox | + | (const DPoint point) | Joins box with a point |

[const] | DBox | + | (const DBox box) | Joins two boxes |

[const] | DBox | - | (const DBox box) | Subtraction of boxes |

[const] | bool | < | (const DBox box) | Returns true if this box is 'less' than another box |

[const] | bool | == | (const DBox box) | Returns true if this box is equal to the other box |

[const] | DBox ptr | _const_cast | Returns a non-const reference to self. | |

void | _create | Ensures the C++ object is created | ||

void | _destroy | Explicitly destroys the object | ||

[const] | bool | _destroyed? | Returns a value indicating whether the object was already destroyed | |

[const] | bool | _is_const_object? | Returns a value indicating whether the reference is a const reference | |

void | _manage | Marks the object as managed by the script side. | ||

void | _unmanage | Marks the object as no longer owned by the script side. | ||

[const] | double | area | Computes the box area | |

void | assign | (const DBox other) | Assigns another object to self | |

[const] | DBox | bbox | Returns the bounding box | |

[const] | double | bottom | Gets the bottom coordinate of the box | |

void | bottom= | (double c) | Sets the bottom coordinate of the box | |

[const] | DPoint | center | Gets the center of the box | |

[const] | bool | contains? | (double x, double y) | Returns true if the box contains the given point |

[const] | bool | contains? | (const DPoint point) | Returns true if the box contains the given point |

[const] | new DBox ptr | dup | Creates a copy of self | |

[const] | bool | empty? | Returns a value indicating whether the box is empty | |

DBox | enlarge | (double dx, double dy) | Enlarges the box by a certain amount. | |

DBox | enlarge | (double d) | Enlarges the box by a certain amount on all sides. | |

DBox | enlarge | (const DVector enlargement) | Enlarges the box by a certain amount. | |

[const] | DBox | enlarged | (double dx, double dy) | Enlarges the box by a certain amount. |

[const] | DBox | enlarged | (double d) | Enlarges the box by a certain amount on all sides. |

[const] | DBox | enlarged | (const DVector enlargement) | Returns the enlarged box. |

[const] | unsigned long | hash | Computes a hash value | |

[const] | double | height | Gets the height of the box | |

[const] | bool | inside? | (const DBox box) | Tests if this box is inside the argument box |

[const] | bool | is_point? | Returns true, if the box is a single point | |

[const] | double | left | Gets the left coordinate of the box | |

void | left= | (double c) | Sets the left coordinate of the box | |

DBox | move | (double dx, double dy) | Moves the box by a certain distance | |

DBox | move | (const DVector distance) | Moves the box by a certain distance | |

[const] | DBox | moved | (double dx, double dy) | Moves the box by a certain distance |

[const] | DBox | moved | (const DVector distance) | Returns the box moved by a certain distance |

[const] | bool | overlaps? | (const DBox box) | Tests if this box overlaps the argument box |

[const] | DPoint | p1 | Gets the lower left point of the box | |

void | p1= | (const DPoint p) | Sets the lower left point of the box | |

[const] | DPoint | p2 | Gets the upper right point of the box | |

void | p2= | (const DPoint p) | Sets the upper right point of the box | |

[const] | double | perimeter | Returns the perimeter of the box | |

[const] | double | right | Gets the right coordinate of the box | |

void | right= | (double c) | Sets the right coordinate of the box | |

[const] | Box | to_itype | (double dbu = 1) | Converts the box to an integer coordinate box |

[const] | string | to_s | (double dbu = 0) | Returns a string representing this box |

[const] | double | top | Gets the top coordinate of the box | |

void | top= | (double c) | Sets the top coordinate of the box | |

[const] | bool | touches? | (const DBox box) | Tests if this box touches the argument box |

[const] | Box | transformed | (const VCplxTrans t) | Transforms the box with the given complex transformation |

[const] | DBox | transformed | (const DTrans t) | Returns the box transformed with the given simple transformation |

[const] | DBox | transformed | (const DCplxTrans t) | Returns the box transformed with the given complex transformation |

[const] | double | width | Gets the width of the box |

new DBox ptr | from_s | (string s) | Creates a box object from a string | |

DBox | world | Gets the 'world' box |

void | create | Use of this method is deprecated. Use _create instead | ||

void | destroy | Use of this method is deprecated. Use _destroy instead | ||

[const] | bool | destroyed? | Use of this method is deprecated. Use _destroyed? instead | |

[static] | new DBox ptr | from_ibox | (const Box box) | Use of this method is deprecated. Use new instead |

[const] | bool | is_const_object? | Use of this method is deprecated. Use _is_const_object? instead |

## != |
Returns true, if this box and the given box are not equal | ||||

## & |
The intersection of two boxes is the largest box common to both boxes. The intersection may be empty if both boxes to not touch. If the boxes do not overlap but touch the result may be a single line or point with an area of zero. Overwrites this box with the result. | ||||

## * |
The * operator convolves the firstbox with the one given as the second argument. The box resulting from "convolution" is the outer boundary of the union set formed by placing the second box at every point of the first. In other words, the returned box of (p1,p2)*(q1,q2) is (p1+q1,p2+q2).
| ||||

The * operator scales the box with the given factor and returns the result. This method has been introduced in version 0.22.
| |||||

## + |
The + operator joins a point with the box. The resulting box will enclose both the original box and the point. | ||||

The + operator joins the first box with the one given as the second argument. Joining constructs a box that encloses both boxes given. Empty boxes are neutral: they do not change another box when joining. Overwrites this box with the result. | |||||

## - |
The - operator subtracts the argument box from self. This will return the bounding box of the are covered by self, but not by argument box. Subtracting a box from itself will render an empty box. Subtracting another box from self will modify the first box only if the argument box covers one side entirely. This feature has been introduced in version 0.29. | ||||

## < |
Returns true, if this box is 'less' with respect to first and second point (in this order) | ||||

## == |
Returns true, if this box and the given box are equal | ||||

## _const_cast |
Basically, this method allows turning a const object reference to a non-const one. This method is provided as last resort to remove the constness from an object. Usually there is a good reason for a const object reference, so using this method may have undesired side effects. This method has been introduced in version 0.29.6. | ||||

## _create |
Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created. | ||||

## _destroy |
Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing. | ||||

## _destroyed? |
This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself. | ||||

## _is_const_object? |
This method returns true, if self is a const reference. In that case, only const methods may be called on self. | ||||

## _manage |
After calling this method on an object, the script side will be responsible for the management of the object. This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. If necessary, the script side may delete the object if the script's reference is no longer required. Usually it's not required to call this method. It has been introduced in version 0.24. | ||||

## _unmanage |
Calling this method will make this object no longer owned by the script's memory management. Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. Technically speaking, this method will turn the script's reference into a weak reference. After the script engine decides to delete the reference, the object itself will still exist. If the object is not managed otherwise, memory leaks will occur. Usually it's not required to call this method. It has been introduced in version 0.24. | ||||

## area |
Returns the box area or 0 if the box is empty | ||||

## assign |
| ||||

## bbox |
This method is provided for consistency of the shape API is returns the box itself. This method has been introduced in version 0.27. | ||||

## bottom |
| ||||

## bottom= |
| ||||

## center |
| ||||

## contains? |
Tests whether a point (x, y) is inside the box. It also returns true if the point is exactly on the box contour. | ||||

Tests whether a point is inside the box. It also returns true if the point is exactly on the box contour. | |||||

## create |
Use of this method is deprecated. Use _create instead Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created. | ||||

## destroy |
Use of this method is deprecated. Use _destroy instead Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing. | ||||

## destroyed? |
Use of this method is deprecated. Use _destroyed? instead This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself. | ||||

## dup |
| ||||

## empty? |
An empty box may be created with the default constructor for example. Such a box is neutral when combining it with other boxes and renders empty boxes if used in box intersections and false in geometrical relationship tests. | ||||

## enlarge |
This is a convenience method which takes two values instead of a Vector object. This method has been introduced in version 0.23. | ||||

This is a convenience method which takes one values instead of two values. It will apply the given enlargement in both directions. This method has been introduced in version 0.28. | |||||

Enlarges the box by x and y value specified in the vector passed. Positive values with grow the box, negative ones will shrink the box. The result may be an empty box if the box disappears. The amount specifies the grow or shrink per edge. The width and height will change by twice the amount. Does not check for coordinate overflows. | |||||

## enlarged |
This is a convenience method which takes two values instead of a Vector object. This method has been introduced in version 0.23. | ||||

This is a convenience method which takes one values instead of two values. It will apply the given enlargement in both directions. This method has been introduced in version 0.28. | |||||

Enlarges the box by x and y value specified in the vector passed. Positive values with grow the box, negative ones will shrink the box. The result may be an empty box if the box disappears. The amount specifies the grow or shrink per edge. The width and height will change by twice the amount. Does not modify this box. Does not check for coordinate overflows. | |||||

## from_ibox |
Use of this method is deprecated. Use new instead This constructor has been introduced in version 0.25 and replaces the previous static method 'from_ibox'.
| ||||

## from_s |
Creates the object from a string representation (as returned by to_s) This method has been added in version 0.23. | ||||

## hash |
Returns a hash value for the given box. This method enables boxes as hash keys. This method has been introduced in version 0.25.
| ||||

## height |
| ||||

## inside? |
Returns true, if this box is inside the given box, i.e. the box intersection renders this box | ||||

## is_const_object? |
Use of this method is deprecated. Use _is_const_object? instead This method returns true, if self is a const reference. In that case, only const methods may be called on self. | ||||

## is_point? |
| ||||

## left |
| ||||

## left= |
| ||||

## move |
This is a convenience method which takes two values instead of a Point object. This method has been introduced in version 0.23. | ||||

Moves the box by a given offset and returns the moved box. Does not check for coordinate overflows. | |||||

## moved |
This is a convenience method which takes two values instead of a Point object. This method has been introduced in version 0.23. | ||||

Moves the box by a given offset and returns the moved box. Does not modify this box. Does not check for coordinate overflows. | |||||

## new |
This constructor has been introduced in version 0.25 and replaces the previous static method 'from_ibox'.
| ||||

Empty boxes don't modify a box when joined with it. The intersection between an empty and any other box is also an empty box. The width, height, p1 and p2 attributes of an empty box are undefined. Use empty? to get a value indicating whether the box is empty.
| |||||

Note that for integer-unit boxes, the dimension has to be an even number to avoid rounding. This convenience constructor has been introduced in version 0.28.
| |||||

Note that for integer-unit boxes, the dimensions have to be an even number to avoid rounding. This convenience constructor has been introduced in version 0.28.
| |||||

Four coordinates are given to create a new box. If the coordinates are not provided in the correct order (i.e. right < left), these are swapped.
| |||||

Two points are given to create a new box. If the coordinates are not provided in the correct order (i.e. right < left), these are swapped.
| |||||

## overlaps? |
Returns true, if the intersection box of this box with the argument box exists and has a non-vanishing area | ||||

## p1 |
| ||||

## p1= |
| ||||

## p2 |
| ||||

## p2= |
| ||||

## perimeter |
This method is equivalent to 2*(width+height). For empty boxes, this method returns 0. This method has been introduced in version 0.23. | ||||

## right |
| ||||

## right= |
| ||||

## to_itype |
The database unit can be specified to translate the floating-point coordinate box in micron units to an integer-coordinate box in database units. The boxes coordinates will be divided by the database unit. This method has been introduced in version 0.25. | ||||

## to_s |
This string can be turned into a box again by using from_s . If a DBU is given, the output units will be micrometers. The DBU argument has been added in version 0.27.6.
| ||||

## top |
| ||||

## top= |
| ||||

## touches? |
Two boxes touch if they overlap or their boundaries share at least one common point. Touching is equivalent to a non-empty intersection ('!(b1 & b2).empty?'). | ||||

## transformed |
This method has been introduced in version 0.25. | ||||

| |||||

| |||||

## width |
| ||||

## world |
The world box is the biggest box that can be represented. So it is basically 'all'. The world box behaves neutral on intersections for example. In other operations such as displacement or transformations, the world box may render unexpected results because of coordinate overflow. The world box can be used - for comparison ('==', '!=', '<')
- in union and intersection ('+' and '&')
- in relations (contains?, overlaps?, touches?)
- as 'all' argument in region queries
This method has been introduced in version 0.28. |