36#ifndef _CHOMP_CUBES_CELLMAIN_H_
37#define _CHOMP_CUBES_CELLMAIN_H_
71template <
class celltype>
75 typedef typename celltype::CoordType coordtype;
76 coordtype origleft [celltype::MaxDim];
77 q. leftcoord (origleft);
78 coordtype origright [celltype::MaxDim];
79 q. rightcoord (origright);
80 coordtype newcoord [celltype::MaxDim];
81 int sd = q. spacedim ();
88 for (
int j = 0; j < sd; ++ j)
91 newcoord [j] = origleft [j];
94 if (origleft [j] != origright [j])
98 newcoord [j] = origright [j];
99 for (j = j + 1; j < sd; ++ j)
100 newcoord [j] = origleft [j];
102 !celltype::PointBase::check
105 return celltype (newcoord,
110 throw "False cubical cell's dimension.";
115 for (
int j = 0; j < sd; ++ j)
118 newcoord [j] = origright [j];
121 if (origleft [j] != origright [j])
125 newcoord [j] = origleft [j];
126 for (j = j + 1; j < sd; j ++)
127 newcoord [j] = origright [j];
129 !celltype::PointBase::check
132 return celltype (origleft,
137 throw "False dimension of a cubical cell.";
142template <
class celltype>
149template <
class celltype>
152 return q. dim () << 1;
156template <
class celltype>
162 return (i & 1) ? 1 : -1;
172template <
class celltype>
176 typedef typename celltype::CoordType coordtype;
177 coordtype lcoord [celltype::MaxDim];
178 c. leftcoord (lcoord);
179 int dim = c. spacedim ();
180 coordtype rcoord [celltype::MaxDim];
181 c. rightcoord (rcoord);
183 if (celltype::OutputBits & celltype::BitProduct)
185 for (
int i = 0; i < dim; ++ i)
189 if (rcoord [i] != lcoord [i])
190 out <<
',' << rcoord [i];
200 for (i = 0; i < dim; ++ i)
207 if (celltype::OutputBits & celltype::BitSpace)
210 for (i = 0; i < dim; ++ i)
234template <
class celltype>
237 typedef typename celltype::CoordType coordtype;
242 throw "Opening parenthesis expected while reading a cell.";
249 coordtype c1 [celltype::MaxDim], c2 [celltype::MaxDim];
257 if (in. peek () ==
',')
266 if ((in. get () != closing) || (dim1 <= 0) || (dim1 != dim2))
267 throw "Failed while reading two vertices of a cell.";
270 for (
int i = 0; i < dim1; ++ i)
272 if ((c1 [i] != c2 [i]) && (c1 [i] + 1 != c2 [i]))
273 throw "Vertices of a read cell are too far.";
277 c = celltype (c1, c2, dim1);
282 coordtype c0 [celltype::MaxDim];
285 throw "Can't read a cell.";
289 if ((count == 1) || (count == 2))
293 c2 [dim ++] = c0 [count - 1];
294 while ((in. peek () ==
'x') || (in. peek () ==
'X'))
300 if ((count < 1) || (count > 2) ||
301 (dim >= celltype::MaxDim))
302 throw "Wrong interval while reading a cell.";
303 if ((count == 2) && (c0 [1] != c0 [0]) &&
304 (c0 [1] - c0 [0] != 1))
305 throw "Too big interval defining a cell.";
307 c2 [dim ++] = c0 [count - 1];
309 c = celltype (c1, c2, dim);
314 for (
int i = 0; i < count; ++ i)
316 c = celltype (c0, c1, count);
327template<
class coordtype>
329 const coordtype *c1,
const coordtype *c2,
int spcdim,
330 const coordtype *wrap = 0)
335 for (
int i = 0; i < spcdim; ++ i)
337 if (c1 [i] == c2 [i])
344 else if ((c1 [i] - c2 [i] == -1) || (wrap && wrap [i] &&
345 (c1 [i] - c2 [i] == wrap [i] - 1)))
350 else if ((c1 [i] - c2 [i] == 1) || (wrap && wrap [i] &&
351 (c1 [i] - c2 [i] == -wrap [i] + 1)))
357 throw "The cubes do not intersect.";
This file contains the definition of a bitfield class which works an array of bits.
This file contains classes and functions related to algebraic chain complexes and chain maps,...
This file contains some precompiler definitions which indicate the operating system and/or compiler u...
This file contains a definition of a general geometric complex which represents a polyhedron.
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.
int closingparenthesis(int ch)
Returns the matching closing parenthesis for the given opening one or EOF if none.
celltype CubicalBoundaryCell(const celltype &q, int i, bool onlyexisting)
Returns the i-th boundary element of a cell.
std::ostream & WriteCubicalCell(std::ostream &out, const celltype &c)
Writes a cubical cell to the output stream in the text form.
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.
int readcoordinates(std::istream &in, coordtype *coord, int maxdim, int closing)
Reads the coordinates of a point.
void ignorecomments(std::istream &in)
Ignores white characters (spaces, tabulators, CRs and LFs), as well as comments from the input text f...
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.
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.