OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends
ImageHandle Class Reference

#include <image_handle.hh>

Inherits Data.

Public Member Functions

 ImageHandle ()
 ImageHandle (const ImageHandle &h)
ImageHandleoperator= (const ImageHandle &h)
Vec3 GetAbsoluteOrigin () const
void SetAbsoluteOrigin (const Vec3 &c)
Vec3 IndexToCoord (const Point &p) const
Vec3 CoordToIndex (const Vec3 &c) const
Vec3 FractionalIndexToCoord (const Vec3 &p) const
virtual Real GetIntpolReal (const Vec3 &v) const
virtual Real GetIntpolReal (const Vec2 &v) const
virtual Real GetIntpolReal (const Real &d) const
virtual Complex GetIntpolComplex (const Vec3 &v) const
virtual Complex GetIntpolComplex (const Vec2 &v) const
virtual Complex GetIntpolComplex (const Real &d) const
ImageHandle Copy (bool cc=true) const
ImageHandle Extract (const Extent &e) const
void Paste (const Data &d)
void Set (const ImageHandle &h)
void Swap (ImageHandle &h)
void Reset (const Extent &e, DataType type=REAL, DataDomain dom=SPATIAL)
bool IsValid () const
long MemSize () const
Properties interface
virtual DataType GetType () const
virtual DataDomain GetDomain () const
virtual Extent GetExtent () const
virtual Point GetSpatialOrigin () const
void SetSpatialOrigin (const Point &p)
void CenterSpatialOrigin ()
Value access

All value access with these getters/setters is boundary-checked; as a consequence, reading outside of the defined region will return 0, and writing outside is silently ignored.

virtual Real GetReal (const Point &p) const
void SetReal (const Point &p, Real r)
virtual Complex GetComplex (const Point &p) const
void SetComplex (const Point &p, const Complex &c)
DataObserver interface

Allows (de)registration of a DataObserver as well as broadcasting a notification to all attached observers.

virtual void Attach (DataObserver *o) const
virtual void Detach (DataObserver *o) const
virtual void Notify () const
virtual void Notify (const Extent &e) const
virtual void Notify (const Point &p) const
DataAlgorithm interface

A collection of methods that form the main interaction between the underlying image and algorithms derived from one of the abstract algorithm classes.

void Apply (NonModAlgorithm &a) const
void ApplyIP (NonModAlgorithm &a) const
void ApplyIP (ModIPAlgorithm &a)
ImageHandle Apply (ModIPAlgorithm &a) const
void ApplyIP (const ConstModIPAlgorithm &a)
ImageHandle Apply (const ConstModIPAlgorithm &a) const
void ApplyIP (ModOPAlgorithm &a)
ImageHandle Apply (ModOPAlgorithm &a) const
void ApplyIP (const ConstModOPAlgorithm &a)
ImageHandle Apply (const ConstModOPAlgorithm &a) const
StateVisitor interface

Allows access to underlying image state via ImageStateVisitor pattern.

void StateApply (ImageStateNonModVisitorBase &v) const
void StateApplyIP (ImageStateModIPVisitorBase &v)
ImageHandle StateApply (ImageStateModIPVisitorBase &v) const
void StateApplyIP (const ImageStateConstModIPVisitorBase &v)
ImageHandle StateApply (const ImageStateConstModIPVisitorBase &v) const
void StateApplyIP (ImageStateModOPVisitorBase &v)
ImageHandle StateApply (ImageStateModOPVisitorBase &v) const
void StateApplyIP (const ImageStateConstModOPVisitorBase &v)
ImageHandle StateApply (const ImageStateConstModOPVisitorBase &v) const
void StateApplyIP (ImageStateMorphVisitorBase &v)
ImageHandle StateApply (ImageStateMorphVisitorBase &v) const
ExtentIterator GetIterator () const
Comparison

Returns true if this handle and reference handle point to the same image, false otherwise

bool operator== (const ImageHandle &ih) const
bool operator!= (const ImageHandle &ih) const
Member operators
ImageHandleoperator+= (Real v)
ImageHandleoperator+= (const Complex &v)
ImageHandleoperator-= (Real v)
ImageHandleoperator-= (const Complex &v)
ImageHandleoperator*= (Real v)
ImageHandleoperator*= (const Complex &v)
ImageHandleoperator/= (Real v)
ImageHandleoperator/= (const Complex &v)
void Reciproce ()
ImageHandleoperator+= (const ConstImageHandle &h)
ImageHandleoperator-= (const ConstImageHandle &h)
ImageHandleoperator*= (const ConstImageHandle &h)
ImageHandleoperator/= (const ConstImageHandle &h)
low-level access
ImageStateBasePtr & ImageStatePtr ()
const ImageStateBasePtr & ImageStatePtr () const
- Public Member Functions inherited from Data
 Data ()
virtual ~Data ()
void SetPixelSampling (const Vec3 &)
void SetPixelSampling (Real d)
void SetSpatialSampling (const Vec3 &)
void SetSpatialSampling (Real d)
- Public Member Functions inherited from ConstData
 ConstData ()
virtual ~ConstData ()
bool IsSpatial () const
bool IsFrequency () const
bool IsReal () const
bool IsComplex () const
Size GetSize () const
virtual Real OverallDifference (const ConstData &d) const
virtual Real NormDifference (const ConstData &d) const
Vec3 GetPixelSampling () const
Vec3 GetSpatialSampling () const
Vec3 GetFrequencySampling () const

Protected Member Functions

 ImageHandle (const StatePtrPtr &spp)
virtual PixelSamplingSampling ()
virtual const PixelSamplingSampling () const
- Protected Member Functions inherited from Data
 Data (const Data &d)
Dataoperator= (const Data &d)

Static Protected Member Functions

static ImageHandle Create (const Extent &e, DataType type, DataDomain dom)

Friends

class ConstImageHandle
ImageHandle DoCreateImage (const Extent &e, DataType type, DataDomain dom)
void test_image::test_Observer ()

Detailed Description

Manage shared instances of images.

An ImageHandle is used to access an underlying implementation of an image. ImageHandle uses reference counting, ie copy and assignement return a new handle which points to the same image. This makes it cheap to pass ImageHandle around as value. The resources allocated by the underlying image implementation will be freed as soon as the reference count drops to zero.

ImageHandle derives from Data and thus implements its interface. It extends it to include image specific functionality. ImageHandle does shared_ptr management of an ImageImpl instance. The observer functionality is implemented in parallel using shared_ptr as well, so that the set of observers is preserved among the shared ImageHandles.

Creating a new image is done with the CreateImage() function:

ImageHandle ih = CreateImage(Extent(Point(0,0),Size(10,10)));

To import and export an image from or to a file, the IOManager must be used.

All image manipulation routines are provided as algorithms, which are applied with the Apply() and ApplyIP() methods.

Definition at line 111 of file image_handle.hh.


Constructor & Destructor Documentation

Creates an empty, ie invalid handle.

The default ctor is provided for e.g. using ImageHandle in STL containers. Any attempt to use the interface of an emtpy ImageHandle will throw an InvalidImageHandle exception.

ImageHandle ( const ImageHandle h)

Initialize with an existing handle.

The newly created handle will share the image with the existing one

ImageHandle ( const StatePtrPtr &  spp)
protected

Initialization based on a StatePtrPtr.


Member Function Documentation

void Apply ( NonModAlgorithm a) const
virtual

Apply a const algorithm to this image.

Calls the implemented NonModAlgorithm::Visit(const ImageHandle&) method

Implements Data.

ImageHandle Apply ( ModIPAlgorithm a) const

Apply in-place Algorithm, return new image with modifications.

The modifications will be done on a copy of this image, which is then returned.

ImageHandle Apply ( const ConstModIPAlgorithm a) const

Apply in-place const Algorithm, return new image with modifications.

The modifications will be done on a copy of this image, which is then returned.

ImageHandle Apply ( ModOPAlgorithm a) const

Apply out-of-place Algorithm.

The image modified by the out-of-place algorithm is returned.

ImageHandle Apply ( const ConstModOPAlgorithm a) const

Apply out-of-place const Algorithm.

The image modified by the out-of-place algorithm is returned.

void ApplyIP ( NonModAlgorithm a) const
virtual

Apply a const algorithm to this image.

This does exactly the same as ImageHandle::Apply(NonModAlgorithm &) and is provided for syntax consistency.

Implements Data.

void ApplyIP ( ModIPAlgorithm a)

Apply in-place Algorithm in-place.

void ApplyIP ( const ConstModIPAlgorithm a)

Apply in-place const Algorithm in-place.

void ApplyIP ( ModOPAlgorithm a)

Apply out-of-place Algorithm in-place.

The new image returned by the out-of-place algorithm will replace the current one. This replacement will of course reflect in all ImageHandle s that point to the same Image.

void ApplyIP ( const ConstModOPAlgorithm a)

Apply out-of-place const Algorithm in-place.

The new image returned by the out-of-place algorithm will replace the current one. This replacement will of course reflect in all ImageHandle s that point to the same Image.

virtual void Attach ( DataObserver o) const
virtual

Attach observer.

Implements ConstData.

void CenterSpatialOrigin ( )

set origin in center

Vec3 CoordToIndex ( const Vec3 &  c) const

Convert coordinates back to (fractional) indices.

ImageHandle Copy ( bool  cc = true) const

return a handle that manages a new instance of the image

Similar to the Clone concept, the ImageHandle that is returned points to a duplicated image instance

static ImageHandle Create ( const Extent e,
DataType  type,
DataDomain  dom 
)
staticprotected

used by CreateImage factory function

virtual void Detach ( DataObserver o) const
virtual

Detach observer.

Implements ConstData.

ImageHandle Extract ( const Extent e) const

return a handle to a new image containing a partial copy

The returning domain will match the type (ie REAL or COMPLEX), but the domain will always be spatial

Vec3 FractionalIndexToCoord ( const Vec3 &  p) const

Index to coordinate conversion.

Vec3 GetAbsoluteOrigin ( ) const

Get absolute coordinate for the spatial origin of the image.

virtual Complex GetComplex ( const Point p) const
virtual

Retrieve value at given Point as a Complex.

Implements ConstData.

virtual DataDomain GetDomain ( ) const
virtual

Return domain: SPATIAL, FREQUENCY or HALF_FREQUENCY.

Implements ConstData.

virtual Extent GetExtent ( ) const
virtual

retrieve Extent

The extent that is returned here is the logical extent.

Implements ConstData.

virtual Complex GetIntpolComplex ( const Vec3 &  v) const
virtual

Get interpolated complex value from 3D,2D or 1D vec.

Implements ConstData.

virtual Complex GetIntpolComplex ( const Vec2 &  v) const
virtual

Implements ConstData.

virtual Complex GetIntpolComplex ( const Real d) const
virtual

Implements ConstData.

virtual Real GetIntpolReal ( const Vec3 &  v) const
virtual

Get interpolated real value from 3D,2D or 1D vec.

Implements ConstData.

virtual Real GetIntpolReal ( const Vec2 &  v) const
virtual

Implements ConstData.

virtual Real GetIntpolReal ( const Real d) const
virtual

Implements ConstData.

ExtentIterator GetIterator ( ) const
virtual Real GetReal ( const Point p) const
virtual

Retrieve value at given Point as a Real.

Implements ConstData.

virtual Point GetSpatialOrigin ( ) const
virtual

return spatial origin of the image

The spatial origin is independent on the current domain. It affects the FFT operations by introducing a origin-dependent phase shift for each value in the frequency domain.

Implements ConstData.

virtual DataType GetType ( ) const
virtual

Return data type: REAL or COMPLEX.

Implements ConstData.

ImageStateBasePtr& ImageStatePtr ( )
const ImageStateBasePtr& ImageStatePtr ( ) const
Vec3 IndexToCoord ( const Point p) const

Index to coordinate conversion.

bool IsValid ( ) const

Returns true if handle is valid.

long MemSize ( ) const

Returns size in bytes of allocated memory.

virtual void Notify ( ) const
virtual

Notify each observer that state has changed.

Implements ConstData.

virtual void Notify ( const Extent e) const
virtual
virtual void Notify ( const Point p) const
virtual
bool operator!= ( const ImageHandle ih) const
ImageHandle& operator*= ( Real  v)
ImageHandle& operator*= ( const Complex v)
ImageHandle& operator*= ( const ConstImageHandle h)
ImageHandle& operator+= ( Real  v)
ImageHandle& operator+= ( const Complex v)
ImageHandle& operator+= ( const ConstImageHandle h)
ImageHandle& operator-= ( Real  v)
ImageHandle& operator-= ( const Complex v)
ImageHandle& operator-= ( const ConstImageHandle h)
ImageHandle& operator/= ( Real  v)
ImageHandle& operator/= ( const Complex v)
ImageHandle& operator/= ( const ConstImageHandle h)
ImageHandle& operator= ( const ImageHandle h)

Assign another image based on handle.

The reference count the the previously shared images is decreased and the one of the assignee is increased

bool operator== ( const ImageHandle ih) const
void Paste ( const Data d)

pastes given data to this image, using data extent

Effectively replaces a part of the image with the values retrieved from the given data, either another image handle or a function. The region that is replaced in this image is given by the extent of the data.

void Reciproce ( )
void Reset ( const Extent e,
DataType  type = REAL,
DataDomain  dom = SPATIAL 
)

Reset image state to given size, type and domain.

Essentially the same as creating a new ImageHandle with CreateImage() and assigning it to an existing handle. After a call to reset, all values are zero.

This routine exhibits only weak exception safety, as the existing state is first cleared to conserve memory usage.

virtual PixelSampling& Sampling ( )
protectedvirtual

see Data::Sampling()

Implements ConstData.

virtual const PixelSampling& Sampling ( ) const
protectedvirtual

see Data::Sampling()

Implements ConstData.

void Set ( const ImageHandle h)

sets content of image to that of the given one

In contrast to the assignement operator, which affects only the handle mechanism, the Set method assigns the content of the passwd handle to this one. Other image handle pointing to the same image content will therefore also be affected.

void SetAbsoluteOrigin ( const Vec3 &  c)

Sets the absolute coordinate for the spatial origin of the image.

void SetComplex ( const Point p,
const Complex c 
)

Set explicit complex value.

void SetReal ( const Point p,
Real  r 
)

Set explicit real value

See also:
Spoke Pattern Example
void SetSpatialOrigin ( const Point p)
virtual

set spatial origin of image

Implements Data.

void StateApply ( ImageStateNonModVisitorBase &  v) const

Apply non-modifying state visitor.

ImageHandle StateApply ( ImageStateModIPVisitorBase &  v) const

Applies in-place visitor out-of-place.

ImageHandle StateApply ( const ImageStateConstModIPVisitorBase &  v) const

Applies in-place const visitor out-of-place.

ImageHandle StateApply ( ImageStateModOPVisitorBase &  v) const

Applies out-of-place visitor out-of-place.

ImageHandle StateApply ( const ImageStateConstModOPVisitorBase &  v) const

Applies out-of-place const visitor out-of-place.

ImageHandle StateApply ( ImageStateMorphVisitorBase &  v) const

Applies morph visitor out-of-place.

void StateApplyIP ( ImageStateModIPVisitorBase &  v)

Applies in-place visitor in-place.

void StateApplyIP ( const ImageStateConstModIPVisitorBase &  v)

Applies in-place const visitor in-place.

void StateApplyIP ( ImageStateModOPVisitorBase &  v)

Applies out-of-place visitor in-place.

void StateApplyIP ( const ImageStateConstModOPVisitorBase &  v)

Applies out-of-place const visitor in-place.

void StateApplyIP ( ImageStateMorphVisitorBase &  v)

Applies morph visitor in-place.

void Swap ( ImageHandle h)

swap guts with another handle


Friends And Related Function Documentation

friend class ConstImageHandle
friend

Definition at line 118 of file image_handle.hh.

ImageHandle DoCreateImage ( const Extent e,
DataType  type,
DataDomain  dom 
)
friend
void test_image::test_Observer ( )
friend

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