#### Description:

This function modifies a Moc by combining it with a supplied Region. The Region must be defined within a SkyFrame, or within a CmpFrame that contains a SkyFrame. The Region will be converted to ICRS before being combined with the Moc. The way in which they are combined is determined by the `"` cmode`"` parameter.

Note, since Moc is a subclass of Region this method can be used to add a Moc into another Moc. In such cases, the data is transferred from one Moc to another directly. For other classes of Region an adaptive algorithm is used to find the HEALPix cells that are inside the Region. An initial grid, corresponding to the HEALPix cells at the order given by the Moc`’` s `"` MinOrder`"` attribute, is placed over the bounding box of the supplied Region. Each of these cells is tested at 9 positions (corners, edge-centres and cell-centre). If all 9 positions are inside the supplied Region, then the whole cell is assumed to be inside the Region. If no positions are inside the supplied Region, then the whole cell is assumed to be outside the Region. If there is a mix of inside and outside positions, the cell is divided into four sub-cells at HEALPix order `"` MinOrder+1`"` , and the same test is applied to each sub-cell in turn. When the HEALPix order reaches the value of the Moc`’` s `"` MaxOrder`"` attribute, each cell is tested only at the cell centre, and is assumed to be inside the Region if the cell centre is in the Region.

This process means that contiguous `"` islands`"` or `"` holes`"` in the supplied region may be missed if they are smaller than the cell size associated with HEALPix order `"` MinOrder`"` .

#### Synopsis

void astAddRegion( AstMoc ∗this, int cmode, AstRegion ∗region )

#### Parameters:

##### this

Pointer to the Moc to be modified.

##### cmode

Indicates how the Moc and Region are to be combined. Any of the following values may be supplied:

- AST__AND: The modified Moc is the intersection of the original Moc and the Region.

- AST__OR: The modified Moc is the union of the original Moc and the Region.

- AST__XOR: The modified Moc is the exclusive disjunction of the original Moc and the Region.

##### region

Pointer to the Region to be combined with the Moc.

#### Notes:

- When combining the Region with the Moc, it is assumed that the Moc has not been inverted (i.e. the current value of the Moc`’` s `’` Negated`’` attribute is ignored).

- If no value has yet been set for attribute MaxOrder, then this function will automatically set it to a value that depends on the class of Region being added. If the Region being added is another Moc, the MaxOrder attribute of the Moc is used. For other classes of Region, the value used corresponds to the resolution closest to 0.1% of the linear size of the Region being added (determined using method astGetRegionDisc).

Copyright (C) 2021 East Asian Observatory