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>
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 outputstream & | showused (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. |
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.
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.
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().
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.
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().
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().
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 */
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 */
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().
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 */
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 */
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 */
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 */
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 */
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 */
friend class tPointBaseInitializer< coordtype > [friend] |
Friendship class which shows the statistics in its destructor.
Definition at line 161 of file pointbas.h.
bool chomp::homology::tPointBase< coordtype >::forgotten = false [static, protected] |
Were the base points forgotten?
Definition at line 174 of file pointbas.h.
Referenced by chomp::homology::tPointBase< coordtype >::check(), chomp::homology::tPointBase< coordtype >::coord(), chomp::homology::tPointBase< coordtype >::forget(), chomp::homology::tPointBase< coordtype >::getwrapping(), chomp::homology::tPointBase< coordtype >::number(), chomp::homology::tPointBase< coordtype >::reset(), chomp::homology::tPointBase< coordtype >::setwrapping(), and chomp::homology::tPointBase< coordtype >::showused().
int chomp::homology::tPointBase< coordtype >::n = 0 [static, protected] |
The number of allocated sets of points.
Definition at line 168 of file pointbas.h.
Referenced by chomp::homology::tPointBase< coordtype >::check(), chomp::homology::tPointBase< coordtype >::coord(), chomp::homology::tPointBase< coordtype >::defaultdimension(), chomp::homology::tPointBase< coordtype >::getwrapping(), chomp::homology::tPointBase< coordtype >::number(), chomp::homology::tPointBase< coordtype >::reset(), chomp::homology::tPointBase< coordtype >::setwrapping(), chomp::homology::tPointBase< coordtype >::showused(), chomp::homology::tPointBase< coordtype >::wrapcoord(), and chomp::homology::tPointBase< coordtype >::wrapcopy().
tPointset< coordtype > ** chomp::homology::tPointBase< coordtype >::p = NULL [static, protected] |
The sets of points from which numbers are taken.
Definition at line 165 of file pointbas.h.
Referenced by chomp::homology::tPointBase< coordtype >::check(), chomp::homology::tPointBase< coordtype >::coord(), chomp::homology::tPointBase< coordtype >::defaultdimension(), chomp::homology::tPointBase< coordtype >::getwrapping(), chomp::homology::tPointBase< coordtype >::number(), chomp::homology::tPointBase< coordtype >::reset(), chomp::homology::tPointBase< coordtype >::setwrapping(), chomp::homology::tPointBase< coordtype >::showused(), chomp::homology::tPointBase< coordtype >::wrapcoord(), and chomp::homology::tPointBase< coordtype >::wrapcopy().
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.
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().