36#ifndef _CHOMP_CUBES_CELLFIX_H_
37#define _CHOMP_CUBES_CELLFIX_H_
67template <
int dimfix,
class coordtype>
89 tCellFix (
const coordtype *c1,
const coordtype *c2,
90 int spcdim = 0,
int celldim = -1);
105 template <
int dimhigh>
107 int offset,
int ncoords);
123 coordtype *
leftcoord (coordtype *c)
const;
135 static const char *
name ();
156 template <
int _dimfix,
class _coordtype>
157 friend inline int operator ==
161 return ((c1.
n == c2.
n) && (!memcmp (c1.
tab, c2.
tab,
162 dimfix * sizeof (coordtype))));
175 void initialize (
const coordtype *c1,
const coordtype *c2,
182template <
int dimfix,
class coordtype>
187template <
int dimfix,
class coordtype>
189 const coordtype *c2,
int celldim)
195 coordtype r [dimfix];
204 for (
int i = 0; i < dimfix; ++ i)
206 if (tab [i] != r [i])
207 n |= (
static_cast<int_t> (1) << i);
215 for (
int i = 0; i < dimfix; ++ i)
217 if (tab [i] != r [i])
219 n |= (
static_cast<int_t> (1) << i);
230template <
int dimfix,
class coordtype>
235 throw "Too high fixed-dim cell dimension.";
239template <
int dimfix,
class coordtype>
241 (
const coordtype *c1,
const coordtype *c2,
int spcdim,
int celldim)
245 throw "Negative dimension of the space.";
246 else if ((spcdim > 0) && (spcdim != dimfix))
247 throw "Wrong dimension of a cell.";
249 throw "Too high fixed-dim cell dimension.";
252 initialize (c1, c2, celldim);
256template <
int dimfix,
class coordtype>
262 throw "Too high fixed-dim cell dimension.";
265 coordtype c1 [dimfix];
267 coordtype c2 [dimfix];
275 int celldim =
CommonCell (left, right, c1, c2, dimfix,
279 initialize (left, right, celldim);
284template <
int dimfix,
class coordtype>
289 throw "Negative dimension of a face requested.";
290 if (facedim > dimfix)
291 throw "Too high dimension of a face requested.";
293 throw "Too high fixed-dim cell dimension.";
296 for (
int i = 0; i < facedim; ++ i)
297 n |=
static_cast<int_t> (1) << i;
301template <
int dimfix,
class coordtype>
307 throw "Too high fixed-dim cell dimension.";
312template <
int dimfix,
class coordtype>
313template <
int dimhigh>
317 if ((offset < 0) || (ncoords <= 0) || (ncoords != dimfix) ||
318 (offset + ncoords > dimhigh))
319 throw "Wrong cell projection requested.";
322 coordtype right [dimhigh];
323 q. rightcoord (right);
324 initialize (q. tab + offset, right + offset);
328template <
int dimfix,
class coordtype>
337template <
int dimfix,
class coordtype>
341 memcpy (tab, q. tab, dimfix * sizeof (coordtype));
346template <
int dimfix,
class coordtype>
349 return static_cast<int> (n >>
NumBits);
352template <
int dimfix,
class coordtype>
358template <
int dimfix,
class coordtype>
362 throw "Null pointer to save left coordinates.";
363 for (
int i = 0; i < dimfix; ++ i)
368template <
int dimfix,
class coordtype>
372 throw "Null pointer to save right coordinates.";
373 for (
int i = 0; i < dimfix; ++ i)
376 ((n & (
static_cast<int_t> (1) << i)) ? 1 : 0);
382template <
int dimfix,
class coordtype>
388 return (
static_cast<int_t> (tab [0]) << 12) ^ n;
390 return (((
static_cast<int_t> (tab [0])) << 18) +
391 ((
static_cast<int_t> (tab [1])) << 6)) ^ n;
393 return (((
static_cast<int_t> (tab [0])) << 18) +
394 ((
static_cast<int_t> (tab [1])) << 6) +
395 ((
static_cast<int_t> (tab [2])) >> 6)) ^ n;
399template <
int dimfix,
class coordtype>
405template <
int dimfix,
class coordtype>
411 return (
static_cast<int_t> (tab [0]) << 3) ^ (n << 5);
413 return ((
static_cast<int_t> (tab [0]) >> 1) +
414 (
static_cast<int_t> (tab [1]) << 13)) ^ (n << 5);
416 return (((
static_cast<int_t> (tab [dimfix - 1])) << 20) +
417 ((
static_cast<int_t> (tab [dimfix - 2])) << 9) +
418 ((
static_cast<int_t> (tab [dimfix - 3])) >> 1)) ^
423template <
int dimfix,
class coordtype>
429template <
int dimfix,
class coordtype>
432 return "cubical cell";
435template <
int dimfix,
class coordtype>
438 return "cubical cells";
444template <
int dimfix,
class coordtype>
454template <
int dim1,
int dim2,
class coordtype>
460 coordtype left [dim1 + dim2];
461 coordtype right [dim1 + dim2];
464 c1. leftcoord (left);
465 c1. rightcoord (right);
468 c2. leftcoord (left + dim1);
469 c2. rightcoord (right + dim1);
473 dim1 + dim2, c1. dim () + c2. dim ());
477template <
int dimfix,
class coordtype>
485template <
int dimfix,
class coordtype>
495template <
int dimfix,
class coordtype>
503template <
int dimfix,
class coordtype>
511template <
int dimfix,
class coordtype>
518template <
int dimfix,
class coordtype>
This file contains the definition of a bitfield class which works an array of bits.
This file contains the definition of some functions that are common for all types of cubical cells,...
This file contains classes and functions related to algebraic chain complexes and chain maps,...
This class defines cubical cell in R^n with edges parallel to the axes and with size 0 or 1 in each d...
int dim() const
Returns the dimension of the cubical cell.
tCubeFix< dimfix, coordtype >::PointBase PointBase
The point base (for wrapping and tabulating coordinates).
OutputBitValues
Bit masks that define how to output the cell.
static const int MaxSpaceDim
The maximal dimension of the embedding space of a cell.
static int OutputBits
The output bits which determine how a cell is written.
coordtype * leftcoord(coordtype *c) const
Fills in the given table with the left corner coordinates.
coordtype * rightcoord(coordtype *c) const
Fills in the given table with the right corner coordinates.
coordtype tab[dimfix]
A table with the left coordinate of the cell.
int spacedim() const
Returns the dimension of the embedding space.
void initialize(const coordtype *c1, const coordtype *c2, int celldim=-1)
Initializes a new cell, given its two corners.
tCellFix()
The constructor of an empty cubical cell.
static const char * pluralname()
Returns the plural name of the objects represented by this class.
int_t hashkey2() const
Returns hashing key no. 2 required by the hashing set template.
int_t hashkey1() const
Returns hashing key no. 1 required by the hashing set template.
static const char * name()
Returns the name of the objects represented by this class.
static const int MaxDim
The maximal dimension of a cell.
coordtype CoordType
The type of the coordinates.
int_t n
High 6 bits = the dimension of the cell (not: space).
This class defines a hypercube in R^n with edges parallel to the axes and with size 1 in each directi...
static void wrapcoord(coordtype *c, int dim)
Wraps the given coordinates if necessary.
static const coordtype * getwrapping(int d)
Returns the space wrapping for the given dimension.
static void wrapcopy(coordtype *dest, const coordtype *src, int dim)
Copies the coordinates and wraps them if necessary.
This class is a simplified version of the point base class used only for the space wrapping support.
This file contains some precompiler definitions which indicate the operating system and/or compiler u...
This class defines full cubes in which the embedding space dimension is known apriori.
This file contains a definition of a general geometric complex which represents a polyhedron.
int int_t
Index type for indexing arrays, counting cubes, etc.
This file contains the definition of the container "hashedset" which can be used to represent a set o...
This file defines a class "integer" which represents the ring of integers or the field of integers mo...
int CubicalBoundaryCoef(const celltype &q, int i)
Returns the i-th coefficient in the boundary of a cubical cell.
const int MaxBasDim
The maximal dimension that can be used if the high bits of an integer store the value of the dimensio...
std::ostream & operator<<(std::ostream &out, const bincube< Dim, twoPower > &b)
int_t hashkey2(const hashNumber< Number > &n)
The second hashing key.
celltype CubicalBoundaryCell(const celltype &q, int i, bool onlyexisting)
Returns the i-th boundary element of a cell.
const int NumBits
The number of bits in an integer number that remain to be used for other purposes,...
int boundarylength(const tCellBase< coordtype > &q)
Returns the length of the boundary of a cell.
std::ostream & WriteCubicalCell(std::ostream &out, const celltype &c)
Writes a cubical cell to the output stream in the text form.
tCellBase< coordtype > boundarycell(const tCellBase< coordtype > &q, int i, bool onlyexisting)
Computes the i-th boundary element of a cell.
int CommonCell(coordtype *left, coordtype *right, const coordtype *c1, const coordtype *c2, int spcdim, const coordtype *wrap=0)
Computes the left and right corner of a cell which is the intersection of the two given cubes.
short int coordinate
The default type of coordinates.
bool operator!=(const typename bincube< Dim, twoPower >::neighborhood_iterator &x1, const typename bincube< Dim, twoPower >::neighborhood_iterator &x2)
std::istream & operator>>(std::istream &in, bincube< Dim, twoPower > &b)
int_t hashkey1(const hashNumber< Number > &n)
The first hashing key.
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.
std::istream & ReadCubicalCell(std::istream &in, celltype &c)
Reads a cubical cell form the input text stream.
int CubicalBoundaryLength(const celltype &q)
Returns the length of the boundary of a cubical cell.
int boundarycoef(const tCellBase< coordtype > &q, int i)
Returns the i-th coefficient in the boundary of a cell.
This namespace contains the entire CHomP library interface.
This file contains the definition of a point base class which is used for indexing all the points (n-...
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.