38#ifndef _CHOMP_CUBES_POINTBAS_H_
39#define _CHOMP_CUBES_POINTBAS_H_
55template <
class coordtype>
58template <
class coordtype>
59class tPointBaseInitializer;
100template <
class coordtype>
111 static bool check (
const coordtype *c,
int d);
121 static void quiet (
bool what =
true);
139 static void wrapcoord (coordtype *c,
int dim);
142 static void wrapcopy (coordtype *dest,
const coordtype *src,
147 static void reset (
void);
151 static void forget (
void);
182template <
class coordtype>
186 throw "Trying to retrieve forgotten coordinates.";
187 if ((d > n) || (d <= 0) || (p [d - 1] == NULL))
190 return (*(p [d - 1])) [nr];
193template <
class coordtype>
197 throw "Trying to check forgotten coordinates.";
198 if ((d > n) || (d <= 0) || (p [d - 1] == NULL))
200 return p [d - 1] -> check (c);
203template <
class coordtype>
210template <
class coordtype>
214 throw "Trying to find the number of forgotten coordinates.";
219 throw "Dimension too high.";
226 for (
int i = 0; i < d; ++ i)
227 newtable [i] = (i < n) ? p [i] : NULL;
237 p [d - 1] -> dimension (d);
240 int_t number = p [d - 1] -> add (c);
242 throw "Too many points.";
247template <
class coordtype>
249 int mindim,
int maxdim)
252 throw "Trying to wrap forgotten coordinates.";
265 for (
int i = 0; i < maxdim; ++ i)
266 newtable [i] = (i < n) ? p [i] : NULL;
274 for (
int d = mindim; d < maxdim; ++ d)
279 p [d - 1] -> dimension (d);
281 p [d - 1] -> wrapspace (c);
287template <
class coordtype>
289 int mindim,
int maxdim)
294 setwrapping (wraptable, mindim, maxdim);
298template <
class coordtype>
302 throw "Trying to get wrapping of forgotten coordinates.";
304 if ((d <= 0) || (d - 1 >= n) || !p [d - 1])
307 return p [d - 1] -> wrapspace ();
310template <
class coordtype>
313 if ((dim > n) || (dim <= 0) || (p [dim - 1] == NULL))
315 const coordtype *cw = p [dim - 1] -> wrapspace ();
321template <
class coordtype>
323 const coordtype *src,
int dim)
326 if ((dim > n) || (dim <= 0) || (p [dim - 1] == 0))
329 cw = p [dim - 1] -> wrapspace ();
337template <
class coordtype>
340 for (
int i = 0; i < n; ++ i)
355template <
class coordtype>
359 throw "Trying to forget already forgotten coordinates.";
368template <
class coordtype>
371template <
class coordtype>
374template <
class coordtype>
377template <
class coordtype>
380template <
class coordtype>
386 for (
int d = 1; d <= n; ++ d)
390 if (p [d - 1] -> empty ())
398template <
class coordtype>
402 throw "Trying to show forgotten coordinates.";
405 for (
int i = 0; i < n; ++ i)
412 out << (shown ?
", " :
"Vertices used: ") <<
413 pset. size () <<
" of dim " << (i + 1);
421template <
class coordtype>
437template <
class coordtype>
448template <
class coordtype>
451template <
class coordtype>
469template <
class coordtype>
475 {
throw "Trying to get a point number.";}
478 static bool check (
const coordtype *,
int)
483 {
throw "Trying to get the coordinates of a point.";}
485 static void quiet (
bool =
true) {
return;}
493 static std::ostream &
showused (std::ostream &out) {
return out;}
This class defines an output stream for replacing the standard 'cout'.
This class keeps a common set of points which are indexed for the use of other classes,...
static void wrapcoord(coordtype *c, int dim)
Wraps the given coordinates if necessary.
static const coordtype * coord(int_t number, int d)
Retrieves the coordinates of the given point.
static void quiet(bool what=true)
Sets the point base to be quiet or not.
static bool forgotten
Were the base points forgotten?
static void forget(void)
Forgets the base points, frees memory and makes this data structure ususable: An exception is thrown ...
static tPointset< coordtype > ** p
The sets of points from which numbers are taken.
static int defaultdimension(void)
Determines the default dimension of points.
static tPointBaseInitializer< coordtype > pointBaseInitializer
An object responsible for deleting the pointsets at exit.
static void reset(void)
Resets the internal data.
static bool check(const coordtype *c, int d)
Checks whether this point is already included in the list.
static bool show
Should the summary of points' usage be displayed?
static const coordtype * getwrapping(int d)
Returns the space wrapping for the given dimension.
static outputstream & showused(outputstream &out)
Shows the number of vertices stored for all the dimensions.
static int n
The number of allocated sets of points.
static int_t number(const coordtype *c, int d)
Returns the number of the point with given coordinates.
static void wrapcopy(coordtype *dest, const coordtype *src, int dim)
Copies the coordinates and wraps them if necessary.
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 t...
This class is used to deallocate memory kept in the static variables of the corresponding class "tPoi...
~tPointBaseInitializer()
Deallocates memory kept in the static variables of the corresponding class "tPointBase" and shows rel...
This class represents a set of points in R^n with integer coordinates.
This class is a simplified version of the point base class used only for the space wrapping support.
static int_t number(const coordtype *, int)
No coord to number translation is available.
static bool check(const coordtype *, int)
Always says that the point exists.
static outputstream & showused(outputstream &out)
static void quiet(bool=true)
static const coordtype * coord(int_t, int)
No number to coord translation is available.
static std::ostream & showused(std::ostream &out)
This file contains some precompiler definitions which indicate the operating system and/or compiler u...
int int_t
Index type for indexing arrays, counting cubes, etc.
outputstream sout
A replacement for standard output stream, with optional logging and other features provided by the cl...
const int MaxBasDim
The maximal dimension that can be used if the high bits of an integer store the value of the dimensio...
void wrapcoord(coordtype *destination, const coordtype *source, const coordtype *wrap, int dim)
Wraps coordinates stored in 'c' accordint to the wrap table 'wrap' and store the result in the table ...
const int DimBits
The number of signed bits to store the dimension (i.e., 6: max 31).
const int NumBits
The number of bits in an integer number that remain to be used for other purposes,...
const int_t SignBit
The sign bit of the int_t number.
tPointBase< coordinate > PointBase
The default type of the point base class.
const int MaxBasDim2
The maximal dimension which still leaves enough bits in the integer to have one bit for each directio...
const int MaxBasDim1
The maximal dimension that can be represented using 'DimBits' bits.
void copycoord(coordtype *destination, const coordtype *source, int dim)
Copies the coordinates of one point to another.
const int_t NumMask
The mask of the bits remaining after the dimension bits are excluded.
This namespace contains the entire CHomP library interface.
This file contains the definition of a set of n-dimensional points with integer coordinates and sever...
This file contains some useful functions related to the text input/output procedures.