Loading...
Searching...
No Matches
casacore::RegionHandler Class Reference
images package (libcasa_images) » Regions_module » Regions_module_internal_classes

More...

`#include <RegionHandler.h>`

## Public Types

enum | GroupType { Regions , Masks , Any }
| Define the possible group types (regions or masks). More...

## Public Member Functions

virtual | ~RegionHandler ()
virtual RegionHandler * | clone () const
| Make a copy of the object.
virtual void | setObjectPtr (void *objectPtr)
| Set the object pointer (for RegionHandlerTable's callback).
virtual Bool | canDefineRegion () const
| Can the class indeed define and handle regions?
virtual void | setDefaultMask (const String &maskName)
| Set the default mask to the mask with the given name.
virtual String | getDefaultMask () const
| Get the name of the default mask.
virtual Bool | defineRegion (const String &name, const ImageRegion &region, RegionHandler::GroupType, Bool overwrite=False)
| Define a region belonging to the table.
virtual Bool | hasRegion (const String &name, RegionHandler::GroupType=RegionHandler::Any) const
| Does the table have a region with the given name?
virtual ImageRegion * | getRegion (const String &name, RegionHandler::GroupType=Any, Bool throwIfUnknown=True) const
| Get a region belonging to the table.
virtual Bool | renameRegion (const String &newName, const String &oldName, RegionHandler::GroupType=Any, Bool overwrite=False)
| Rename a region.
virtual Bool | removeRegion (const String &name, RegionHandler::GroupType=Any, Bool throwIfUnknown=True)
| Remove a region belonging to the table.
virtual Vector< String > | regionNames (RegionHandler::GroupType=Any) const
| Get the names of all regions/masks.
String | makeUniqueRegionName (const String &rootName, uInt startNumber=1) const
| Make a unique region name from the given root name, thus make it such that the name is not already in use for a region or mask.
virtual ImageRegion | makeMask (const LatticeBase &lattice, const String &name)
| Make a mask for a lattice (e.g.

## Detailed Description

Base class for handling regions in images

### Intended use:

Internal

### Review Status

Test programs:
  tPagedImage2

### Prerequisite

- PagedImage
- ImageRegion

### Synopsis

Persistent regions are stored as subrecords of the table keywords "regions" and "masks". The user can choose one of both keywords. Keyword "masks" is meant for true image masks, i.e. telling for each pixel if it is good or bad. Keyword "regions" is meant for true regions in an image.

This class handles defining, getting and removing such regions. It is used by class PagedImage, but it can also be used by other code to handle regions in other tables.

Another function performed by this class for PagedImage is the definition of the default region to be used with an image.

### Example

### Motivation

This class has 2 purposes:

1. This untemplated code can be factored out from the templated Image classes.
2. The functions can easily be used by other code.

Definition at line 91 of file RegionHandler.h.

## Member Enumeration Documentation

## GroupType

enum casacore::RegionHandler::GroupType

Define the possible group types (regions or masks).

Enumerator
Regions |
Masks |
Any |

Definition at line 97 of file RegionHandler.h.

## Constructor & Destructor Documentation

## ~RegionHandler()

virtual casacore::RegionHandler::~RegionHandler | ( |  | ) |

virtual

## Member Function Documentation

## canDefineRegion()

virtual Bool casacore::RegionHandler::canDefineRegion | ( |  | ) | const

virtual

Can the class indeed define and handle regions?

The default implementation returns False.

Reimplemented in casacore::RegionHandlerHDF5, casacore::RegionHandlerMemory, and casacore::RegionHandlerTable.

## clone()

virtual RegionHandler * casacore::RegionHandler::clone | ( |  | ) | const

virtual

Make a copy of the object.

Reimplemented in casacore::RegionHandlerHDF5, casacore::RegionHandlerMemory, and casacore::RegionHandlerTable.

## defineRegion()

virtual Bool casacore::RegionHandler::defineRegion | ( | const String & | name,
|  | const ImageRegion & | region,
|  | RegionHandler::GroupType | ,
|  | Bool | overwrite = False )

virtual

Define a region belonging to the table.

The group type determines if it stored as a region or mask. If overwrite=False, an exception will be thrown if the region already exists in the "regions" or "masks" keyword. Otherwise the region will be removed first.
A False status is returned if the table is not writable

Reimplemented in casacore::RegionHandlerHDF5, casacore::RegionHandlerMemory, and casacore::RegionHandlerTable.

References casacore::False, and casacore::name().

## getDefaultMask()

virtual String casacore::RegionHandler::getDefaultMask | ( |  | ) | const

virtual

Get the name of the default mask.

An empty string is returned if no default mask.

Reimplemented in casacore::RegionHandlerHDF5, casacore::RegionHandlerMemory, and casacore::RegionHandlerTable.

## getRegion()

virtual ImageRegion * casacore::RegionHandler::getRegion | ( | const String & | name,
|  | RegionHandler::GroupType | = Any,
|  | Bool | throwIfUnknown = True ) const

virtual

Get a region belonging to the table.

A zero pointer is returned if the region does not exist. The caller has to delete the ImageRegion object created.
No exception is thrown if the region does not exist.

Reimplemented in casacore::RegionHandlerHDF5, casacore::RegionHandlerMemory, and casacore::RegionHandlerTable.

References Any, casacore::name(), and casacore::True.

## hasRegion()

virtual Bool casacore::RegionHandler::hasRegion | ( | const String & | name,
|  | RegionHandler::GroupType | = RegionHandler::Any ) const

virtual

Does the table have a region with the given name?

Reimplemented in casacore::RegionHandlerHDF5, casacore::RegionHandlerMemory, and casacore::RegionHandlerTable.

References Any, and casacore::name().

## makeMask()

virtual ImageRegion casacore::RegionHandler::makeMask | ( | const LatticeBase & | lattice,
|  | const String & | name )

virtual

Make a mask for a lattice (e.g.

a PagedImage or TempImage). It creates it with the shape and tile shape of the lattice.

Reimplemented in casacore::RegionHandlerHDF5, casacore::RegionHandlerMemory, and casacore::RegionHandlerTable.

References casacore::name().

## makeUniqueRegionName()

String casacore::RegionHandler::makeUniqueRegionName | ( | const String & | rootName,
|  | uInt | startNumber = 1 ) const

Make a unique region name from the given root name, thus make it such that the name is not already in use for a region or mask.

The root name is returned if it is already unique. Otherwise a number is appended to the root name to make it unique. The number starts at the given number and is incremented until the name is unique.

## regionNames()

virtual Vector< String > casacore::RegionHandler::regionNames | ( | RegionHandler::GroupType | = Any | ) | const

virtual

Get the names of all regions/masks.

Reimplemented in casacore::RegionHandlerHDF5, casacore::RegionHandlerMemory, and casacore::RegionHandlerTable.

References Any.

## removeRegion()

virtual Bool casacore::RegionHandler::removeRegion | ( | const String & | name,
|  | RegionHandler::GroupType | = Any,
|  | Bool | throwIfUnknown = True )

virtual

Remove a region belonging to the table.

Optionally an exception is thrown if the region does not exist.
A False status is returned if the table is not writable

Reimplemented in casacore::RegionHandlerHDF5, casacore::RegionHandlerMemory, and casacore::RegionHandlerTable.

References Any, casacore::name(), and casacore::True.

## renameRegion()

virtual Bool casacore::RegionHandler::renameRegion | ( | const String & | newName,
|  | const String & | oldName,
|  | RegionHandler::GroupType | = Any,
|  | Bool | overwrite = False )

virtual

Rename a region.

If a region with the new name already exists, it is deleted or an exception is thrown (depending on overwrite). The region name is looked up in the given group(s).
An exception is thrown if the old region name does not exist.

Reimplemented in casacore::RegionHandlerHDF5, casacore::RegionHandlerMemory, and casacore::RegionHandlerTable.

References Any, and casacore::False.

## setDefaultMask()

virtual void casacore::RegionHandler::setDefaultMask | ( | const String & | maskName | ) |

virtual

Set the default mask to the mask with the given name.

It constructs a ImageRegion object for the new default mask. If the table is writable, the setting is persistent by writing the name as a keyword. If the given maskName is the empty string, the default mask is unset.

Reimplemented in casacore::RegionHandlerHDF5, casacore::RegionHandlerMemory, and casacore::RegionHandlerTable.

## setObjectPtr()

virtual void casacore::RegionHandler::setObjectPtr | ( | void * | objectPtr | ) |

virtual

Set the object pointer (for RegionHandlerTable's callback).

Default implementation does nothing.

Reimplemented in casacore::RegionHandlerHDF5, and casacore::RegionHandlerTable.

The documentation for this class was generated from the following file:

- images/Regions/RegionHandler.h