The Dimensions

Definition

A dimension encapsulates size measures specified in Long precision.

dimension.gif

The class Dimension3d.

Types

There are three different classes of Dimension according to the dimension:

Public Attributes

Dimensions are characterized by size measures:

They are read write attributes. It means that they are accessible directly without any member function. For example:

Dimension2d d;
d.w=12; d.h=20;
std::cout << d.h << std::endl;

Construction

A dimension can be created without any argument or with specified sizes, or a specified dimension. For example:
Dimension2d d1; // = Dimension2d d1(0,0)
d1.w=12; d1.h=21;
Dimension2d d2(10,24); // w=24; h=10.
Dimension2d *d3=new Dimension2d(d2); // Same size measures than d2.

Consultation

The basic arithmetic operators (+,-,*,/,==, !=, +=, -=, *=, /=) between dimension and constant or between dimensions has been redefined to handle dimensions. For example:
Dimension d1(12,13), *d2;
d2 = new Dimension(10,10);
if (d1==*d2) d1=(*d2)*5;
d2*=2;

File Transfer

To save a dimension in a file, just use:
Dimension d;
d.SaveFile("foobar.pan");

To load a dimension from a file, just use:

Dimension d;
d.LoadFile("foobar.pan");

Generally, a dimension is not saved directly in a file but by the means of a collection. To save and load a dimension in a collection, use:

Collection cold;
Dimension2d *d1=new Dimension2d(10,20),*d2;
cold.SETPOBJECT("bar",Dimension2d,d1);
d2=(Dimension2d*)cold.GETPOBJECT("bar",Dimension2d);

To save and load an array of dimensions in a collection, use:

Dimension2d **d3=new Dimension2d*[12], **d4;
for (int i=0; i<12; i++) d3[i]=new Dimension2d(i,i);
cold.SETPARRAY("foo",Dimension2d,p3,12);
d4=(Dimension2d**)cols.GETPARRAY("foo",Dimension2d);
std::cout << "Dimensions: " << d4[11]->w << "," << d4[11]->h << std::endl;

The Pantheon project
Image Team GREYC Laboratory
UMR CNRS 6072 - ENSICAEN - University of Caen, France
This page was last modified on 19 June 2015