Static Public Member Functions | Static Protected Attributes | Friends

chomp::homology::tPointBase< coordtype > Class Template Reference

This class keeps a common set of points which are indexed for the use of other classes, like cubes or cubical cells. More...

#include <pointbas.h>

Inheritance diagram for chomp::homology::tPointBase< coordtype >:
chomp::homology::tWrapBase< coordtype >

List of all members.

Static Public Member Functions

static int_t number (const coordtype *c, int d)
 Returns the number of the point with given coordinates.
static bool check (const coordtype *c, int d)
 Checks whether this point is already included in the list.
static const coordtype * coord (int_t number, int d)
 Retrieves the coordinates of the given point.
static int defaultdimension (void)
 Determines the default dimension of points.
static void quiet (bool what=true)
 Sets the point base to be quiet or not.
static void setwrapping (const coordtype *c, int mindim=1, int maxdim=MaxBasDim)
 Sets space wrapping for all the dimensions in the range starting with 'mindim' and strictly smaller than 'maxdim'.
static void setwrapping (coordtype c, int mindim=1, int maxdim=MaxBasDim)
 Sets space wrapping for all the dimensions in the range starting with 'mindim' and strictly smaller than 'maxdim'.
static const coordtype * getwrapping (int d)
 Returns the space wrapping for the given dimension.
static void wrapcoord (coordtype *c, int dim)
 Wraps the given coordinates if necessary.
static void wrapcopy (coordtype *dest, const coordtype *src, int dim)
 Copies the coordinates and wraps them if necessary.
static void reset (void)
 Resets the internal data.
static void forget (void)
 Forgets the base points, frees memory and makes this data structure ususable: An exception is thrown if this data is used.
static outputstreamshowused (outputstream &out)
 Shows the number of vertices stored for all the dimensions.
static std::ostream & showused (std::ostream &out)
 Shows the number of vertices stored for all the dimensions.

Static Protected Attributes

static tPointset< coordtype > ** p = NULL
 The sets of points from which numbers are taken.
static int n = 0
 The number of allocated sets of points.
static bool show = true
 Should the summary of points' usage be displayed?
static bool forgotten = false
 Were the base points forgotten?
static tPointBaseInitializer
< coordtype > 
pointBaseInitializer
 An object responsible for deleting the pointsets at exit.

Friends

class tPointBaseInitializer< coordtype >
 Friendship class which shows the statistics in its destructor.

Detailed Description

template<class coordtype>
class chomp::homology::tPointBase< coordtype >

This class keeps a common set of points which are indexed for the use of other classes, like cubes or cubical cells.

This base is used to give each n-dimensional point its unique number. The consecutive numbers for each dimension begin with 1.

Definition at line 102 of file pointbas.h.


Member Function Documentation

template<class coordtype >
bool chomp::homology::tPointBase< coordtype >::check ( const coordtype *  c,
int  d 
) [inline, static]

Checks whether this point is already included in the list.

Return false if not, true if yes. Does not add the point to the structure.

Reimplemented in chomp::homology::tWrapBase< coordtype >.

Definition at line 195 of file pointbas.h.

References chomp::homology::tPointBase< coordtype >::forgotten, chomp::homology::tPointBase< coordtype >::n, and chomp::homology::tPointBase< coordtype >::p.

{
        if (forgotten)
                throw "Trying to check forgotten coordinates.";
        if ((d > n) || (d <= 0) || (p [d - 1] == NULL))
                return 0;
        return p [d - 1] -> check (c);
} /* tPointBase::check */

template<class coordtype >
const coordtype * chomp::homology::tPointBase< coordtype >::coord ( int_t  number,
int  d 
) [inline, static]

Retrieves the coordinates of the given point.

Reimplemented in chomp::homology::tWrapBase< coordtype >.

Definition at line 184 of file pointbas.h.

References chomp::homology::tPointBase< coordtype >::forgotten, chomp::homology::tPointBase< coordtype >::n, and chomp::homology::tPointBase< coordtype >::p.

Referenced by chomp::homology::tCubeBase< coordtype >::coord(), chomp::homology::tCellBase< coordtype >::initialize(), chomp::homology::tCellBase< coordtype >::leftcoord(), chomp::homology::tCellBase< coordtype >::rightcoord(), and chomp::homology::tCellBase< coordtype >::tCellBase().

{
        if (forgotten)
                throw "Trying to retrieve forgotten coordinates.";
        if ((d > n) || (d <= 0) || (p [d - 1] == NULL))
                return NULL;
        else
                return (*(p [d - 1])) [nr];
} /* tPointBase::coord */

template<class coordtype >
int chomp::homology::tPointBase< coordtype >::defaultdimension ( void   )  [static]

Determines the default dimension of points.

Definition at line 382 of file pointbas.h.

References chomp::homology::tPointBase< coordtype >::n, and chomp::homology::tPointBase< coordtype >::p.

{
        static int dim = 0;
        if (dim)
                return dim;
        for (int d = 1; d <= n; ++ d)
        {
                if (!p [d - 1])
                        continue;
                if (p [d - 1] -> empty ())
                        continue;
                return d;
        }
        return 0;
} /* tPointBase::defaultdimension */

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::forget ( void   )  [inline, static]

Forgets the base points, frees memory and makes this data structure ususable: An exception is thrown if this data is used.

Reimplemented in chomp::homology::tWrapBase< coordtype >.

Definition at line 357 of file pointbas.h.

References chomp::homology::tPointBase< coordtype >::forgotten, and chomp::homology::tPointBase< coordtype >::reset().

{
        if (forgotten)
                throw "Trying to forget already forgotten coordinates.";

        reset ();
        forgotten = true;
        return;
} /* tPointBase::forget */

template<class coordtype >
const coordtype * chomp::homology::tPointBase< coordtype >::getwrapping ( int  d  )  [inline, static]

Returns the space wrapping for the given dimension.

Definition at line 300 of file pointbas.h.

References chomp::homology::tPointBase< coordtype >::forgotten, chomp::homology::tPointBase< coordtype >::n, and chomp::homology::tPointBase< coordtype >::p.

Referenced by chomp::homology::tCellBase< coordtype >::tCellBase(), chomp::homology::tCellFix< dimfix, coordtype >::tCellFix(), and chomp::homology::tCellVar< coordtype >::tCellVar().

{
        if (forgotten)
                throw "Trying to get wrapping of forgotten coordinates.";

        if ((d <= 0) || (d - 1 >= n) || !p [d - 1])
                return NULL;
        else
                return p [d - 1] -> wrapspace ();
} /* tPointBase::getwrapping */

template<class coordtype >
int_t chomp::homology::tPointBase< coordtype >::number ( const coordtype *  c,
int  d 
) [inline, static]

Returns the number of the point with given coordinates.

Points for each dimension get numbers starting at 1.

Reimplemented in chomp::homology::tWrapBase< coordtype >.

Definition at line 212 of file pointbas.h.

References chomp::homology::tPointBase< coordtype >::forgotten, chomp::homology::MaxBasDim, chomp::homology::tPointBase< coordtype >::n, chomp::homology::NumMask, and chomp::homology::tPointBase< coordtype >::p.

Referenced by chomp::homology::tCellBase< coordtype >::initialize(), chomp::homology::tCellBase< coordtype >::tCellBase(), and chomp::homology::tCubeBase< coordtype >::tCubeBase().

{
        if (forgotten)
                throw "Trying to find the number of forgotten coordinates.";

        if (d < 0)
                return -1;
        if (d >= MaxBasDim)
                throw "Dimension too high.";

        // enhance the table of sets of points if necessary
        if (d > n)
        {
                tPointset<coordtype> **newtable =
                        new tPointset<coordtype> * [d];
                for (int i = 0; i < d; ++ i)
                        newtable [i] = (i < n) ? p [i] : NULL;
                if (p)
                        delete [] p;
                p = newtable;
                n = d;
        }

        if (!p [d - 1])
        {
                p [d - 1] = new tPointset<coordtype> (1024);
                p [d - 1] -> dimension (d);
        }

        int_t number = p [d - 1] -> add (c);
        if (number > NumMask)
                throw "Too many points.";

        return number;
} /* tPointBase::number */

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::quiet ( bool  what = true  )  [inline, static]

Sets the point base to be quiet or not.

If not quiet, it displays some usage statistics when the data is reset.

Reimplemented in chomp::homology::tWrapBase< coordtype >.

Definition at line 205 of file pointbas.h.

References chomp::homology::tPointBase< coordtype >::show.

{
        show = !what;
        return;
} /* tPointBase::quiet */

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::reset ( void   )  [inline, static]

Resets the internal data.

Note: Cubes and cells created before resetting may be unusable after the reset.

Reimplemented in chomp::homology::tWrapBase< coordtype >.

Definition at line 339 of file pointbas.h.

References chomp::homology::tPointBase< coordtype >::forgotten, chomp::homology::tPointBase< coordtype >::n, and chomp::homology::tPointBase< coordtype >::p.

Referenced by chomp::homology::tPointBase< coordtype >::forget().

{
        for (int i = 0; i < n; ++ i)
        {
                if (p [i])
                {
                        delete p [i];
                        p [i] = NULL;
                }
        }
        delete [] p;
        p = NULL;
        n = 0;
        forgotten = false;
        return;
} /* tPointBase::reset */

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::setwrapping ( coordtype  c,
int  mindim = 1,
int  maxdim = MaxBasDim 
) [inline, static]

Sets space wrapping for all the dimensions in the range starting with 'mindim' and strictly smaller than 'maxdim'.

The space wrapping in each direction is the same.

Definition at line 289 of file pointbas.h.

References chomp::homology::MaxBasDim, and chomp::homology::tPointBase< coordtype >::setwrapping().

{
        coordtype wraptable [MaxBasDim];
        for (int i = 0; i < MaxBasDim; ++ i)
                wraptable [i] = c;
        setwrapping (wraptable, mindim, maxdim);
        return;
} /* tPointBase::setwrapping */

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::setwrapping ( const coordtype *  c,
int  mindim = 1,
int  maxdim = MaxBasDim 
) [inline, static]

Sets space wrapping for all the dimensions in the range starting with 'mindim' and strictly smaller than 'maxdim'.

The space wrapping in each direction can be different.

Definition at line 249 of file pointbas.h.

References chomp::homology::tPointBase< coordtype >::forgotten, chomp::homology::MaxBasDim, chomp::homology::tPointBase< coordtype >::n, and chomp::homology::tPointBase< coordtype >::p.

Referenced by chomp::homology::SetSpaceWrapping(), and chomp::homology::tPointBase< coordtype >::setwrapping().

{
        if (forgotten)
                throw "Trying to wrap forgotten coordinates.";

        // correct the left and right bound for dimensions
        if (mindim < 1)
                mindim = 1;
        if (maxdim > MaxBasDim)
                maxdim = MaxBasDim;

        // enhance the table of sets of points if necessary
        if (maxdim > n)
        {
                tPointset<coordtype> **newtable =
                        new tPointset<coordtype> * [maxdim];
                for (int i = 0; i < maxdim; ++ i)
                        newtable [i] = (i < n) ? p [i] : NULL;
                if (p)
                        delete [] p;
                p = newtable;
                n = maxdim;
        }

        // set wrapping coordinates and allocate sets of points if needed
        for (int d = mindim; d < maxdim; ++ d)
        {
                if (!p [d - 1])
                {
                        p [d - 1] = new tPointset<coordtype>;
                        p [d - 1] -> dimension (d);
                }
                p [d - 1] -> wrapspace (c);
        }

        return;
} /* tPointBase::setwrapping */

template<class coordtype >
outputstream & chomp::homology::tPointBase< coordtype >::showused ( outputstream out  )  [static]

Shows the number of vertices stored for all the dimensions.

Reimplemented in chomp::homology::tWrapBase< coordtype >.

Definition at line 399 of file pointbas.h.

References chomp::homology::tPointBase< coordtype >::forgotten, chomp::homology::tPointBase< coordtype >::n, and chomp::homology::tPointBase< coordtype >::p.

Referenced by chomp::homology::tPointBase< coordtype >::showused().

{
        if (forgotten)
                throw "Trying to show forgotten coordinates.";

        bool shown = false;
        for (int i = 0; i < n; ++ i)
        {
                if (!p [i])
                        continue;
                const tPointset<coordtype> &pset = *(p [i]);
                if (pset. empty ())
                        continue;
                out << (shown ? ", " : "Vertices used: ") <<
                        pset. size () << " of dim " << (i + 1);
                shown = true;
        }
        if (shown)
                out << ".\n";
        return out;
} /* tPointBase::showused */

template<class coordtype >
std::ostream & chomp::homology::tPointBase< coordtype >::showused ( std::ostream &  out  )  [static]

Shows the number of vertices stored for all the dimensions.

Reimplemented in chomp::homology::tWrapBase< coordtype >.

Definition at line 422 of file pointbas.h.

References chomp::homology::tPointBase< coordtype >::showused().

{
        outputstream tout (out);
        showused (tout);
        return out;
} /* tPointBase::showused */

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::wrapcoord ( coordtype *  c,
int  dim 
) [inline, static]

Wraps the given coordinates if necessary.

Definition at line 312 of file pointbas.h.

References chomp::homology::tPointBase< coordtype >::n, and chomp::homology::tPointBase< coordtype >::p.

Referenced by chomp::homology::tCellVar< coordtype >::rightcoord(), chomp::homology::tCellFix< dimfix, coordtype >::rightcoord(), and chomp::homology::tPointBase< coordtype >::wrapcopy().

{
        if ((dim > n) || (dim <= 0) || (p [dim - 1] == NULL))
                return;
        const coordtype *cw = p [dim - 1] -> wrapspace ();
        if (cw)
                chomp::homology::wrapcoord (c, c, cw, dim);
        return;
} /* tPointBase::wrapcoord */

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::wrapcopy ( coordtype *  dest,
const coordtype *  src,
int  dim 
) [inline, static]

Copies the coordinates and wraps them if necessary.

Definition at line 323 of file pointbas.h.

References chomp::homology::copycoord(), chomp::homology::tPointBase< coordtype >::n, chomp::homology::tPointBase< coordtype >::p, and chomp::homology::tPointBase< coordtype >::wrapcoord().

Referenced by chomp::homology::tCellVar< coordtype >::initialize(), chomp::homology::tCellFix< dimfix, coordtype >::initialize(), chomp::homology::tCubeFix< dimfix, coordtype >::tCubeFix(), and chomp::homology::tCubeVar< coordtype >::tCubeVar().

{
        const coordtype *cw;
        if ((dim > n) || (dim <= 0) || (p [dim - 1] == 0))
                cw = 0;
        else
                cw = p [dim - 1] -> wrapspace ();
        if (cw)
                chomp::homology::wrapcoord (dest, src, cw, dim);
        else
                copycoord (dest, src, dim);
        return;
} /* tPointBase::wrapcopy */


Friends And Related Function Documentation

template<class coordtype >
friend class tPointBaseInitializer< coordtype > [friend]

Friendship class which shows the statistics in its destructor.

Definition at line 161 of file pointbas.h.


Member Data Documentation

template<class coordtype >
tPointBaseInitializer< coordtype > chomp::homology::tPointBase< coordtype >::pointBaseInitializer [static, protected]

An object responsible for deleting the pointsets at exit.

Definition at line 177 of file pointbas.h.

template<class coordtype >
bool chomp::homology::tPointBase< coordtype >::show = true [static, protected]

Should the summary of points' usage be displayed?

Definition at line 171 of file pointbas.h.

Referenced by chomp::homology::tPointBase< coordtype >::quiet().


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