36#ifndef _CHOMP_CUBES_CELLBASE_H_
37#define _CHOMP_CUBES_CELLBASE_H_
67template <
class coordtype>
87 tCellBase (
const coordtype *c1,
const coordtype *c2,
88 int spcdim,
int celldim = -1);
119 coordtype *
leftcoord (coordtype *c)
const;
131 static const char *
name ();
155 return (c1.
n1 == c2.
n1) && (c1.
n2 == c2.
n2);
174 void initialize (
const coordtype *c1,
const coordtype *c2,
175 int spcdim,
int celldim = -1);
181template<
class coordtype>
186template <
class coordtype>
192template <
class coordtype>
198template <
class coordtype>
200 const coordtype *c2,
int spcdim,
int celldim)
204 throw "Non-positive dimension of the space.";
205 else if (spcdim >= MaxDim)
206 throw "Too high dimension of a cell.";
211 throw "Negative number of the left vertex.";
216 throw "Negative number of the right vertex.";
224 for (
int i = 0; i < spcdim; ++ i)
226 if (c2 [i] != c1 [i])
239template <
class coordtype>
246template <
class coordtype>
248 (
const coordtype *c1,
const coordtype *c2,
int spcdim,
int celldim)
250 initialize (c1, c2, spcdim, celldim);
254template <
class coordtype>
259 int spcdim = q1. dim ();
260 if (spcdim != q2. dim ())
261 throw "Trying to intersect cubes of different dimension.";
264 coordtype c1 [MaxDim];
266 coordtype c2 [MaxDim];
270 coordtype left [MaxDim];
271 coordtype right [MaxDim];
274 int celldim =
CommonCell (left, right, c1, c2, spcdim,
278 initialize (left, right, spcdim, celldim);
283template <
class coordtype>
289 int spcdim =
static_cast<int> (
n1 >>
NumBits);
291 throw "Negative dimension of a face requested.";
292 if (facedim > spcdim)
293 throw "Too high dimension of a face requested.";
298 for (
int i = 0; i < spcdim; ++ i)
299 c2 [i] = c1 [i] + ((i < facedim) ? 1 : 0);
307template <
class coordtype>
312 int spcdim =
static_cast<int> (
n1 >>
NumBits);
315 for (
int i = 0; i < spcdim; ++ i)
324template <
class coordtype>
326 int offset,
int ncoords)
328 int spcdim =
static_cast<int> (q. n1 >>
NumBits);
329 if ((offset < 0) || (ncoords <= 0) || (offset + ncoords > spcdim))
330 throw "Wrong cell projection requested.";
333 initialize (c1 + offset, c2 + offset, ncoords);
337template <
class coordtype>
339: n1 (q. n1), n2 (q. n2)
344template <
class coordtype>
353template <
class coordtype>
356 return static_cast<int> (n2 >>
NumBits);
359template <
class coordtype>
365template <
class coordtype>
370 throw "Null pointer to save left coordinates.";
375template <
class coordtype>
380 throw "Null pointer to save right coordinates.";
385template <
class coordtype>
388 return ((n1 ^ 0x55555555u) << 17) ^ ((n1 ^ 0xAAAAAAAAu) << 7) ^
389 ((n2 ^ 0xAAAAAAAAu) >> 7);
392template <
class coordtype>
398template <
class coordtype>
401 return ((n2 ^ 0xAAAAAAAAu) << 21) ^ ((n2 ^ 0x55555555u) << 10) ^
402 ((n1 ^ 0x55555555u) >> 9);
405template <
class coordtype>
411template <
class coordtype>
414 return "cubical cell";
417template <
class coordtype>
420 return "cubical cells";
426template <
class coordtype>
436template <
class coordtype>
442 int d1 = c1. spacedim (), d2 = c2. spacedim ();
444 throw "Too high dimension of a Cartesian product of cells.";
451 c1. leftcoord (left);
452 c1. rightcoord (right);
455 c2. leftcoord (left + d1);
456 c2. rightcoord (right + d1);
460 c1. dim () + c2. dim ());
464template <
class coordtype>
472template <
class coordtype>
484template <
class coordtype>
486 int i,
bool onlyexisting)
492template <
class coordtype>
500template <
class coordtype>
507template <
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...
friend int operator==(const tCellBase< coordtype > &c1, const tCellBase< coordtype > &c2)
Verifies if two cells are identical.
coordtype * leftcoord(coordtype *c) const
Fills in the given table with the left corner coordinates.
tCubeBase< coordtype >::PointBase PointBase
The point base (for wrapping and tabulating coordinates).
static const int MaxDim
The maximal dimension of a cell.
int_t num1() const
Returns the first number of the cubical cell vertices.
int dim() const
Returns the dimension of the cubical cell.
static const char * name()
Returns the name of the objects represented by this class.
void initialize(const coordtype *c1, const coordtype *c2, int spcdim, int celldim=-1)
Initializes a new cell given its two corners.
static int OutputBits
The output bits which determine how a cell is written.
int_t n2
The right vertex: high 6 bits = cube dim, the remaining bits form the number of the point in an appro...
int_t hashkey1() const
Returns hashing key no. 1 required by the hashing set template.
coordtype CoordType
The type of the coordinates.
coordtype * rightcoord(coordtype *c) const
Fills in the given table with the right corner coordinates.
int_t n1
The left vertex: high 6 bits = space dim, the remaining bits form the number of the point in an appro...
tCellBase()
The constructor of an empty cubical cell.
OutputBitValues
Bit masks that define how to output the cell.
int_t num2() const
Returns the second number of the cubical cell vertices.
int_t hashkey2() const
Return shashing key no. 2 required by the hashing set template.
static const int MaxSpaceDim
The maximal dimension of the embedding space of a cell.
int spacedim() const
Returns the dimension of the embedding space.
static const char * pluralname()
Returns the plural name of the objects represented by this class.
This class defines a hypercube in R^n with edges parallel to the axes and with size 1 in each directi...
This class keeps a common set of points which are indexed for the use of other classes,...
static const coordtype * coord(int_t number, int d)
Retrieves the coordinates of the given point.
static const coordtype * getwrapping(int d)
Returns the space wrapping for the given dimension.
static int_t number(const coordtype *c, int d)
Returns the number of the point with given coordinates.
This file contains some precompiler definitions which indicate the operating system and/or compiler u...
This file contains the definition of full cubes which use a cube base class for indexing all the poss...
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.
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.
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.