41#ifndef _CHOMP_CUBES_TWOLAYER_H_
42#define _CHOMP_CUBES_TWOLAYER_H_
95 static const int MaxDim = tCube::MaxDim;
125 template <
class intType>
126 intType *
coord (intType *c)
const;
135 static const char *
name ();
144 const tCube &
cube ()
const;
191template <
class tCube>
194template <
class tCube>
197template <
class tCube>
202template <
class tCube>
208template <
class tCube>
215template <
class tCube>
217 q (coord, dim), l (layer1set. check (q) ? 1 : 0)
222template <
class tCube>
224 const LayerType &_l): q (coord, dim), l (_l)
229template <
class tCube>
231: q (number, dim), l (layer1set. check (q) ? 1 : 0)
236template <
class tCube>
242template <
class tCube>
250template <
class tCube>
256template <
class tCube>
257template <
class intType>
263template <
class tCube>
269template <
class tCube>
275template <
class tCube>
281template <
class tCube>
287template <
class tCube>
290 return tCube::name ();
293template <
class tCube>
296 return tCube::pluralname ();
299template <
class tCube>
305template <
class tCube>
312template <
class tCube>
320template <
class tCube>
328 layer1boundary = empty;
337 for (
int_t i = 0; i < X. size (); ++ i)
339 const tCube &q = X [i];
344 layer1boundary. add (q);
345 for (
int_t j = 0; j < ncount; ++ j)
347 idcells. add (
typename tCube::CellType
353 for (
int_t i = 0; i < idcells. size (); ++ i)
355 const typename tCube::CellType &c = idcells [i];
357 for (
int j = 0; j < bsize; ++ j)
362 CellType::identify (idcells, layer1set [0]. dim ());
366template <
class tCube>
372template <
class tCube>
375 return layer1boundary;
378template <
class tCube>
387template <
class tCube>
391 return (c1.
cube () == c2.
cube ()) &&
392 (c1. layer () == c2. layer ());
397template <
class tCube>
405template <
class tCube>
409 tCube q (c1.
cube () * c2.
cube ());
411 l ((c1. layer () << 2) | c2. layer ());
416template <
class tCube>
424 out <<
'^' << c. layer ();
430template <
class tCube>
440 if (in. peek () ==
'^')
455template <
class tCube>
467template <
class tCube>
481template <
class tCell>
508 int spcdim,
int celldim = -1,
int layer = 0);
511 template <
class tCube>
516 template <
class tCube>
520 template <
class tCube>
526 template <
class tCellSrc>
542 template <
class intType>
546 template <
class intType>
556 static const char *
name ();
574 const tCell &
cell ()
const;
607template <
class tCell>
610template <
class tCell>
613template <
class tCell>
618template <
class tCell>
624template <
class tCell>
628 if ((
l == 1) &&
idset. check (
q))
633template <
class tCell>
636 int spcdim,
int celldim,
int layer)
637: q (c1, c2, spcdim, celldim), l (layer)
639 if ((
l == 1) &&
idset. check (
q))
644template <
class tCell>
645template <
class tCube>
648: q (q1.
cube (), q2.
cube ()), l ((q1. layer () < q2. layer ()) ?
649 q1. layer () : q2. layer ())
651 if ((
l == 1) &&
idset. check (
q))
656template <
class tCell>
657template <
class tCube>
659: q (c.
cube (), facedim), l (c. layer ())
665template <
class tCell>
666template <
class tCube>
668: q (c.
cube ()), l (c. layer ())
670 if ((
l == 1) &&
idset. check (
q))
675template <
class tCell>
676template <
class tCellSrc>
678 int offset,
int ncoords)
679: q (c. cell (), offset, ncoords), l (c. layer ())
688 if ((
l == 1) &&
idset. check (
q))
693template <
class tCell>
699template <
class tCell>
707template <
class tCell>
713template <
class tCell>
716 return q. spacedim ();
719template <
class tCell>
720template <
class intType>
723 return q. leftcoord (c);
726template <
class tCell>
727template <
class intType>
730 return q. rightcoord (c);
733template <
class tCell>
739template <
class tCell>
745template <
class tCell>
751template <
class tCell>
757template <
class tCell>
760 return tCell::name ();
763template <
class tCell>
766 return tCell::pluralname ();
769template <
class tCell>
776template <
class tCell>
782template <
class tCell>
790template <
class tCell>
798template <
class tCell>
804template <
class tCell>
810 int dim = q. spacedim ();
813 if (idset. check (q))
818 if (dim != iddim + iddim)
819 throw "Unknown cells for layer analysis.";
822 if ((layer1) && idset. check (tCell (q, 0, iddim)))
824 if ((layer2) && idset. check (tCell (q, iddim, iddim)))
826 return (layer1 << 2) | layer2;
832template <
class tCell>
836 return (c1. cell () == c2. cell ()) &&
837 (c1. layer () == c2. layer ());
842template <
class tCell>
850template <
class tCell>
854 tCell q (c1. cell () * c2. cell ());
856 l ((c1. layer () << 2) | c2. layer ());
861template <
class tCell>
869 out <<
'^' << c. layer ();
875template <
class tCell>
885 if (in. peek () ==
'^')
900template <
class tCell>
913template <
class tCell>
923template <
class tCell>
930template <
class tCell>
944template <
class tCube>
946 bool unconditional =
false)
948 throw "Trying to use 'bit2neighbor' for a 2-layer cube.";
955template <
class tCube>
958 throw "Trying to use 'neighbor2bit' for a 2-layer cube.";
967template <
class tCube>
975 typename tCube::CellType intersection (q0, q1);
977 faces. add (intersection);
982 while (current < faces. size ())
984 const typename tCube::CellType &face = faces [current ++];
985 if (ident. check (face))
997 return (counter > 0);
1002template <
class tCube,
class tCubeSet1,
class tCubeSet2>
1007 const tCube &q0 = q2l.
cube ();
1017 for (
int_t i = 0; i < theset. size (); ++ i)
1027 const tCube &q1 = q1l.
cube ();
1039 ((l0 == 0) && (l1 == 1) && (layer0. check (q0))) ||
1040 ((l0 == 1) && (l1 == 0) && (layer0. check (q1))))
1044 bits -> set (number);
1059 if (limit && (count >= limit))
1069template <
class tCube,
class tCubeSet1,
class tCubeSet2>
1074 const tCube &q0 = q2l.
cube ();
1090 for (
int_t number = 0; number < maxneighbors; ++ number)
1096 int l1 = layer1. check (q1) ? 1 : 0;
1102 if (!theset. check (q1l))
1107 ((l0 == 0) && (l1 == 1) && (layer0. check (q0))) ||
1108 ((l0 == 1) && (l1 == 0) && (layer0. check (q1))))
1112 bits -> set (number);
1127 if (limit && (count >= limit))
1139template <
class eucl
idom,
class tCell,
class tCube>
1146 typedef typename tCube::CoordType coordType;
1147 int_t countimages = 0;
1148 coordType leftbound [tCell::MaxDim];
1149 coordType rightbound [tCell::MaxDim];
1150 coordType left [tCell::MaxDim];
1151 coordType right [tCell::MaxDim];
1154 for (
int d = 0; d <= m. dim (); ++ d)
1159 const int spacedim = cset [0]. spacedim ();
1162 for (
int_t i = 0; i < cset. size (); ++ i)
1173 check (thecell. cell ());
1176 thecell. leftcoord (left);
1177 thecell. rightcoord (right);
1180 for (
int j = 0; j < spacedim; ++ j)
1183 if (right [j] < left [j])
1184 right [j] = left [j] + 1;
1187 leftbound [j] =
static_cast<coordType
>
1188 (left [j] - (left [j] == right [j]));
1189 rightbound [j] =
static_cast<coordType
>
1191 (left [j] == right [j]));
1198 while ((c = r. get ()) != NULL)
1201 if (!tCube::PointBase::check (c, spacedim))
1203 tCube q0 (c, spacedim);
1207 if (dom1. check (q))
1208 m. add (d, i, f1 (q));
1209 if (dom2. check (q))
1210 m. add (d, i, f2 (q));
1215 if (idlayers && !layer &&
1221 else if (idlayers && layer &&
1230 if (dom1. check (ql))
1231 m. add (d, i, f1 (ql));
1232 if (dom2. check (ql))
1233 m. add (d, i, f2 (ql));
1236 countimages += m (thecell). size ();
This file contains the definition of a bitfield class which works an array of bits.
This file includes header files with various definitions of cubical cells and defines the standard ty...
This class defines a bit field that is part of some larger array or that uses an allocated piece of m...
The class that defines a geometric complex - a set of cells (cubes, simplices, etc).
This class represents a multivalued map whose domain is a geometric complex.
This class defines a multivalued map.
A general cubical cell with additional information about the layer number.
static LayerType droplayer(const tCell &q, const LayerType &layer)
Drops the layer of the cell if necessary by the identification.
const LayerType & layer() const
Returns the layer number.
static int iddim
The space dimension of cells for which the identification takes place.
int dim() const
Returns the dimension of the cubical cell.
tCell::PointBase PointBase
The point base (for wrapping and tabulating coordinates).
LayerType l
The layer to which the cell belongs.
static const char * name()
Returns the name of the objects represented by this class.
int_t hashkey1() const
Returns the hash key no. 1 required by the hashing set template.
static const char * pluralname()
Returns the plural name of the objects represented by this class.
tCell CellType
The type for keeping the cell at the given layer.
static const hashedset< tCell > & identify()
Returns the set of cells for the identification of layers.
tCell2l()
The default constructor.
tCell q
The actual cubical cell at the given layer.
static hashedset< tCell > idset
The set of cells at which the identification takes place.
intType * rightcoord(intType *c) const
Fills the given table with the right corner coordinates.
const tCell & cell() const
Returns the cell without the layer.
tCell2l & operator=(const tCell2l &c)
The assignment operator.
int_t hashkey2() const
Returns the hash key no. 2 required by the hashing set template.
int spacedim() const
Returns the dimension of the embedding space.
OutputBitValues
How to output the cell: As a cartesian product or by two opposite vertices? Also, should ' ' be inser...
tCell2l(const CoordType *c1, const CoordType *c2, int spcdim, int celldim=-1, int layer=0)
The constructor of a cell spanning from one point to another.
static const int MaxDim
The maximal dimension of a cube.
intType * leftcoord(intType *c) const
Fills the given table with the left corner coordinates.
theLayerType LayerType
The type for keeping the layer number.
tCell::CoordType CoordType
The type of the coordinates.
A (hyper)cube with additional information about the layer number.
tCell2l< typename tCube::CellType > CellType
The type of a cell related to this cube type.
LayerType l
The layer to which the cube belongs.
int dim() const
Returns the dimension of the cube.
tCube::PointBase PointBase
The point base (for wrapping and tabulating coordinates).
tCube q
The actual cube at the given layer.
tCube CubeType
The type for keeping the cube at the given layer.
tCube::CoordType CoordType
The type of the coordinates.
static const int MaxDim
The maximal dimension of a cube.
static void setlayers(const hashedset< tCube > &X, const hashedset< tCube > &A)
Defines the set of cubes at layer 1 (X).
static const hashedset< tCube > & layer1b()
Returns the set of cubes at the boundary of layer 1.
static hashedset< tCube > layer0set
The set of full-dimensional cubes at layer 0 which are adjacent to the cubes at layer 1.
static const char * name()
Returns the name of the objects represented by this class.
const tCube & cube() const
Returns the cube without the layer.
int_t hashkey1() const
Returns the hash key no. 1 required by the hashing set template.
static const hashedset< tCube > & layer1()
Returns the set of cubes at layer 1.
const LayerType & layer() const
Returns the layer number.
static const char * pluralname()
Returns the plural name of the objects represented by this class.
int_t hashkey2() const
Returns the hash key no. 2 required by the hashing set template.
static const hashedset< tCube > & layer0()
Returns the set of cubes at layer 0 which are neighbors of cubes at layer 1 by the identification of ...
theLayerType LayerType
The type for keeping the layer number.
static hashedset< tCube > layer1set
The set of full-dimensional cubes at layer 1.
tCube2l & operator=(const tCube2l &c)
The assignment operator.
intType * coord(intType *c) const
Fills out the coordinate table with the cube's coordinates.
tCube2l()
The default constructor.
static hashedset< tCube > layer1boundary
The set of full-dimensional cubes at layer 1 adjacent to cubes at layer 0.
This class defines a hypercube in R^n with edges parallel to the axes and with size 1 in each directi...
This class can be used for iterating point's neighbors.
This class can be used for iterating a rectangular set of points, given its left and right bound.
This file includes header files with various definitions of full cubes and defines the standard types...
This file contains some procedures defined for cubical maps.
int int_t
Index type for indexing arrays, counting cubes, etc.
tCube bit2neighbor(const tCube &q, int_t number, bool unconditional=false)
Creates the neighbor of the given cube with the specified number.
int_t neighbor2bit(const tCube &q, const tCube &neighbor)
Returns the number of the neighbor bit for the given neighbor of 'q' or -1 if not a neighbor or the s...
short int theLayerType
The type of the layer variable.
std::ostream & WriteCube(std::ostream &out, const cubetype &c)
Writes a cube to the output stream in the text mode.
int CubicalBoundaryCoef(const celltype &q, int i)
Returns the i-th coefficient in the boundary of a cubical cell.
gcomplex< CubicalCell2l, integer > CubicalComplex2l
A typical cubical complex in the two-layer setting.
hashedset< Cube2l > SetOfCubes2l
A typical set of full cubes in the two-layer setting.
int_t getneighbors(const tCube &q, BitField *bits, const tCubeSet1 &theset, tCubeSet2 *neighbors, int_t limit)
Gets neighbors of the given cube from the given set and indicates them in the bit field provided.
tCube2l< tCubeBase< coordinate > > Cube2l
A typical full cube in the two-layer setting.
int_t getneighbors_scan(const tCube &q, BitField *bits, const tCubeSet1 &theset, tCubeSet2 *neighbors, int_t limit)
Gets neighbors of the given cube from the given set and indicates them in the bit field provided.
std::ostream & operator<<(std::ostream &out, const bincube< Dim, twoPower > &b)
std::istream & ReadCubes(std::istream &in, cubsettype &s)
Reads a set of cubes and ignores the line at the beginning of the file which starts with the letter '...
tCell2l< tCellBase< coordinate > > CubicalCell2l
A typical cubical cell in the two-layer setting.
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.
int_t getmaxneighbors(int dim)
Returns the maximal number of neighbors of a cube: 3^dim - 1.
tCellBase< coordtype > operator*(const tCellBase< coordtype > &c1, const tCellBase< coordtype > &c2)
Computes the Cartesian product of two cells.
Cube cube
A lower-case name of a cube [deprecated].
hashedset< CubicalCell2l > SetOfCubicalCells2l
A typical set of cubical cells in the two-layer setting.
tNeighbors< coordinate > neighbors
The neighbors class with the default type of coordinates.
int boundarylength(const tCellBase< coordtype > &q)
Returns the length of the boundary of a cell.
tPointBase< coordinate > PointBase
The default type of the point base class.
int_t createimages(mvcellmap< tCell, euclidom, tCube > &m, const mvmap< tCube, tCube > &f1, const mvmap< tCube, tCube > &f2, const hashedset< tCube > &dom1, const hashedset< tCube > &dom2)
Creates images of cells in 'm' as unions of cubes determined by f1 and f2.
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.
std::istream & ReadCube(std::istream &in, cubetype &c)
Reads a cube from the input text stream.
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.
bool intersection2l(const tCube &q0, const tCube &q1, BitField *bits)
Computes the intersection between two cubes at different layers.
bool operator==(const typename bincube< Dim, twoPower >::neighborhood_iterator &x1, const typename bincube< Dim, twoPower >::neighborhood_iterator &x2)
void ignorecomments(std::istream &in)
Ignores white characters (spaces, tabulators, CRs and LFs), as well as comments from the input text f...
int_t getneighbors_generate(const tCube &q, BitField *bits, const tCubeSet1 &theset, tCubeSet2 *neighbors, int_t limit)
Gets neighbors of the given cube from the given set and indicates them in the bit field provided.
std::istream & ReadCubicalCell(std::istream &in, celltype &c)
Reads a cubical cell form the input text stream.
std::istream & ReadCubicalMap(std::istream &in, mvmap< tCube, tCube > &m)
Reads a combinatorial cubical multivalued map from an input text stream.
mvmap< Cube2l, Cube2l > CombinatorialMultivaluedMap2l
A typical multivalued map on full cubes in the two-layer setting.
mvcellmap< CubicalCell2l, integer, CubicalCell2l > CubicalMultivaluedMap2l
A typical multivalued cubical-cellular map in the two-layer setting.
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 various procedures relating to neighborhoods of cubes in full cubical sets.
This file contains some useful functions related to the text input/output procedures.