LELCoordinates.h

Classes

LELCoordinates -- Envelope class to handle Lattice Coordinates in LEL. (full description)

class LELCoordinates

Interface

Public Members
LELCoordinates()
LELCoordinates (LELLattCoordBase* coordinates)
LELCoordinates (const LELCoordinates& that)
~LELCoordinates()
LELCoordinates& operator= (const LELCoordinates& that)
Bool isNull() const
Bool hasCoordinates() const
Int compare (const LELCoordinates& other) const
const LELLattCoordBase& coordinates() const

Description

Review Status

Reviewed By:
Bob Garwood
Date Reviewed:
2000/01/25
Programs:
Tests:

Prerequisite

Synopsis

The LatticeExpression classes (LatticeExpr, LatticeExprNode, LEL*) exist so that the C++ programmer can manipulate mathematical expressions involving Lattices. A further usage of these classes is to manipulate ImageInterface objects (which inherit from Lattice) such as PagedImages. These objects have Coordinates as well as the Lattice pixels. In order that Coordinate conformance be enforcable, we must give the LatticeExpression classes access to the Coordinates of the ImageInterface objects.

This is done through the interface of the LELCoordinates class. It is actually an envelope class which holds letter classes which are the actual implementation of the objects which hold the Lattice CoordinateSystems. Lattice objects have a member function called lelCoordinates. This returns a LELCoordinates object. This object contains a pointer (actually a CountedPtr) of type LELLattCoordBase. This is the base class of the letter classes. For Lattices such as ImageInterface, this pointer actually points at the derived letter class LELImageCoord. This class in turn contains a pointer (a CountedPtr) to the actual CoordinateSystem object.

Note that every time the lelCoordinates function is called, the LELLattCoord and LELImageCoord (or whatever the letter class actually being invoked is) objects are constructed. For example the internals of ImageInterface::lelCoordinates are
return LELCoordinates (new LELImageCoord (coords_p));
so that the LELCoordinates constructor invokes the LELImageCoord constructor with the CoordinateSystem as its argument. However, the internal use of CountedPtrs makes subsequent constructions inexpensive.

Having a LELCoordinates object in hand, the programmer then has access to the CoordinateSystem that it ultimately contains. This is via the LELCoordinates member function coordinates which returns a reference to the letter base class LELLattCoordBase. For example, if the actual letter class object was LELImageCoord, one has to then cast the reference returned by LELCoordinates::coordinates() to an LELImageCoord. This is because the LELImageCoord class functions that actually deal with the CoordinateSystem are not virtual (otherwise LELLattCoordBase needs to know about Coordinates).

Example

    PagedImage<Float> im("myimage");
    const LELCoordinates* pLatCoord = &(im.lelCoordinates());
    const LELImageCoord* pImCoord =
                  dynamic_cast<const LELImageCoord*>(pLatCoord);
    CoordinateSystem coords = pImCoord->coordinates();

Motivation

We needed access to CoordinateSystems in the Lattice Expression classes without making the Lattices module dependent on the Images or Coordinates module.

Member Description

LELCoordinates()

Define the possible comparison results. The default constructor creates a null object.

LELCoordinates (LELLattCoordBase* coordinates)

Construct the object from the given letter class. It takes over the pointer and takes care of destructing the LELLattCoordBase object.

LELCoordinates (const LELCoordinates& that)

Copy constructor (reference semantics).

~LELCoordinates()

LELCoordinates& operator= (const LELCoordinates& that)

Assignment (reference semantics).

Bool isNull() const

Is the coordinates a null object?

Bool hasCoordinates() const

Does the class have true coordinates? It returns False if this is a null object.

Int compare (const LELCoordinates& other) const

Check how the coordinates of this and that compare. The return value tells how they compare.
-1: this is subset
0: equal
1: this is superset
9: invalid (mismatch)

const LELLattCoordBase& coordinates() const

Return the underlying letter object. This should in general not be used, but for specific (Image) cases it might be needed.