NAME

Rivl_Region, Rivl_RegionClear, Rivl_RegionClipBox, Rivl_RegionContained, Rivl_RegionCopy, Rivl_RegionCopyFromBox, Rivl_RegionCreate, Rivl_RegionCreateFromBox, Rivl_RegionCreateFromRegion, Rivl_RegionDestroy, Rivl_RegionEmpty, Rivl_RegionGetBoxes, Rivl_RegionIntersect, Rivl_RegionIntersectWithBox, Rivl_RegionOffset, Rivl_RegionPad, Rivl_RegionScale, Rivl_RegionSetInf, Rivl_RegionSubtract, Rivl_RegionSubtractBox, Rivl_RegionUnion, Rivl_RegionUnionWithBox, Rivl_RegionArea - procedures to manage geometric regions

SYNOPSIS

#include <rivl.h>
Rivl_RegionClear (dr)
Rivl_Box
Rivl_RegionClipBox (reg)
int
Rivl_RegionContained (sra, srb)
Rivl_RegionCopy (sr, dr)
Rivl_RegionCopyFromBox (box, dr)
Rivl_Region
Rivl_RegionCreate ()
Rivl_Region
Rivl_RegionCreateFromBox (box)
Rivl_Region
Rivl_RegionCreateFromRegion (sr)
Rivl_RegionDestroy (dr)
int
Rivl_RegionEmpty (reg)
Rivl_RegionGetBoxes (reg, **boxesPtr, *boxCountPtr)
Rivl_RegionIntersect (sra, srb, dr)
Rivl_RegionIntersectWithBox (sra, box, dr)
Rivl_RegionOffset (dr, tx, ty)
Rivl_RegionPad (dr, dx, dy)
Rivl_RegionScale (dr, sx, sy)
Rivl_RegionSetInf (dr, sampleRate)
Rivl_RegionSubtract (sra, srb, dr)
Rivl_RegionSubtractBox (sra, box, dr)
Rivl_RegionUnion (sra, srb, dr)
Rivl_RegionUnionWithBox (sra, box, dr)
unsigned long
Rivl_RegionArea (reg)

ARGUMENTS

Rivl_Region reg (in)
A region to query.
Rivl_Region sr, sra, srb (in)
A source region.
Rivl_Region dr (in, out)
An existing region to be changed or deleted.
double sx, sy (in)
Factors to scale region by.
long tx, ty (in)
Factors to offset region by.
long dx, dy
Factors to pad region by.
Rivl_Box box (in)
A box.
Rivl_Box **boxesPtr (out)
*boxesPtr will be filled with the address of an array of boxes. There will be *boxCountPtr entries in the array.
int *boxCountPtr (out)
Filled in with number of boxes in region.
double sampleRate
Sample rate at which to express the region.

DESCRIPTION

A region is composed of zero or more non-overlapping boxes. In Rivl, regions are generally used to describe a set of coordinates in a signal or buffer. For example, the have region of a signal is a Rivl_Region that gives an upper bound on the area of non-zero values in the signal.

Rivl_Region is built on top of the X11R5 region library: XCreateRegion, XUnionRegion, etc. The names have changed to match the rest of Rivl's external interface, the internal structure has been changed to use long ints instead of short ints, and many new interface functions have been added.

Storage for regions works as follows. A variable declared as Rivl_Region is a pointer to an opaque structure. Before the variable is used it must be assigned to a new initialized region by calling one of the three Rivl_Create functions. After that, it may be passed to any of the Rivl_Region functions until it is destroyed with Rivl_RegionDestroy. Functions such as Rivl_RegionUnion work by overwriting the value in the argument named dr, which must be an initialized region but need not be empty.

Rivl_RegionCreate creates and returns a new empty region. Rivl_RegionClear sets dr to the empty region.

Rivl_RegionCreateFromBox creates and returns a new region containing only box. Rivl_RegionCopyFromBox sets dr to contain only box.

Rivl_RegionCreateFromRegion creates and returns a duplicate of sr. Rivl_RegionCopy copies sr into dr.

Rivl_RegionIntersect sets dr to the intersection of sra and srb. Rivl_RegionIntersectWithBox sets dr to the intersection of sra and box.

Rivl_RegionUnion sets dr to the union of sra and srb. Rivl_RegionUnionWithBox sets dr to the union of sra and box.

Rivl_RegionSubtract subtracts srb from sra and places the difference in dr. Rivl_RegionSubtractBox sets dr to the union of sra and box.

Rivl_RegionDestroy destroys dr and frees up resources associated with it.

Rivl_RegionSetInf sets dr to the region from negative infinity to positive infinity, with respect to sampleRate, on both axes.

Rivl_RegionOffset, Rivl_RegionPad, and RivlRegionScale destructively apply the functions Rivl_BoxOffset, Rivl_BoxPad, and Rivl_BoxScale (respectively) to all of the boxes in dr.

Rivl_RegionClipBox returns the smallest box enclosing all the boxes in reg.

Rivl_RegionEmpty returns 1 if reg is empty, 0 otherwise. Rivl_RegionContained returns 1 if sra is contained in srb, 0 otherwise.

Rivl_RegionGetBoxes returns the list of boxes that make up reg. It places a pointer to an array of boxes in **boxesPtr and the number of boxes in *boxCountPtr. The array is not NULL terminated. The area of memory pointed to by *boxesPtr is contained within the region data structure and is guaranteed not to change until the next call that modifies or destroys the region. The array and the boxes inside it should not be modified.

Rivl_RegionArea sums up the areas of the boxes in reg, and returns the sum.