35#ifndef _CHOMP_CUBES_CUBEMAIN_H_
36#define _CHOMP_CUBES_CUBEMAIN_H_
57template <
class dest_cube,
class src_cube>
60 typename dest_cube::CoordType tab [src_cube::MaxDim];
62 return dest_cube (tab, src. dim ());
68template <
class cubetype>
69inline std::ostream &
WriteCube (std::ostream &out,
const cubetype &c)
71 typename cubetype::CoordType coord [cubetype::MaxDim];
75 for (
int i = 0; i < dim; ++ i)
89template <
class cubetype>
90std::istream &
ReadCubeFix (std::istream &in, cubetype &c,
int dimfix)
93 typedef typename cubetype::CoordType coordtype;
101 if (((in. peek () >=
'0') && (in. peek () <=
'9')) ||
102 (in. peek () ==
'-') || (in. peek () ==
'+') ||
103 (in. peek () ==
'#'))
105 bool cubenumber =
false;
106 if (in. peek () ==
'#')
112 if (in. peek () ==
'+')
116 while ((in. peek () ==
' ') || (in. peek () ==
'\t'))
122 (((in. peek () >=
'0') && (in. peek () <=
'9')) ||
123 (in. peek () ==
'-') || (in. peek () ==
'+')))
126 coordtype coord [cubetype::MaxDim];
129 if (in. peek () !=
'\n')
132 cubetype::MaxDim - 1,
'\n');
134 throw "Unable to read a cube: "
140 if ((dimfix >= 0) && (dim != dimfix))
141 throw "Unable to read a cube: Wrong dim.";
144 c = cubetype (coord, dim);
152 int dim = cubetype::PointBase::defaultdimension ();
153 const typename cubetype::CoordType *coord = 0;
154 if ((n > 0) && (dim > 0))
156 coord = cubetype::PointBase::coord
160 throw "Cube no. out of range while reading.";
161 c = cubetype (n - 1, dim);
167 typename cubetype::CoordType coord [cubetype::MaxDim];
170 throw "Unable to read a cube: Dimension too high.";
173 if ((dimfix >= 0) && (dim != dimfix))
174 throw "Unable to read a cube: Wrong dimension.";
177 c = cubetype (coord, dim);
183template <
class cubetype>
184inline std::istream &
ReadCube (std::istream &in, cubetype &c)
192template <
class cubsettype>
193std::istream &
ReadCubes (std::istream &in, cubsettype &s)
199 if (in. peek () ==
'd')
201 in. ignore (20000,
'\n');
210template <
class tCube>
215 while (in. peek () != EOF)
219 ((in. peek () <
'0') || (in. peek () >
'9')) &&
220 (in. peek () != EOF))
227 if (in. peek () == EOF)
242 if ((closing == EOF) ||
252 throw "Can't read cube's number.";
257 typename tCube::CoordType coord
260 tCube::MaxDim, closing);
261 if (!in || (dim <= 0))
262 throw "Unable to read a cube.";
263 e = tCube (coord, dim);
268 while (in. peek () ==
'-')
270 if (in. peek () ==
'>')
283 typename tCube::CoordType argleft [tCube::MaxDim];
284 typename tCube::CoordType argright [tCube::MaxDim];
299 typename tCube::CoordType vleft [tCube::MaxDim];
300 typename tCube::CoordType vright [tCube::MaxDim];
307 if (!in || (in. peek () == EOF))
308 throw "Cannot read a map assignment line.";
315 if ((d1 != dim) || (d2 != dim) || (d3 != dim))
316 throw "Wrong dimensions of vertices.";
319 for (
int i = 0; i < dim; ++ i)
321 if (argright [i] - argleft [i] != 1)
322 throw "Wrong size of an argument.";
330 (vleft, vright, dim);
333 const typename tCube::CoordType *c;
334 while ((c = r. get ()) != NULL)
335 v. add (tCube (c, dim));
This file contains the definition of a bitfield class which works an array of bits.
This class can be used for iterating a rectangular set of points, given its left and right bound.
This file contains some precompiler definitions which indicate the operating system and/or compiler u...
This file contains the definition of the container "hashedset" which can be used to represent a set o...
#define SMALL_SIZE
This constant passed to the function 'write' makes the hashed set be displayed in a way that is appro...
#define LARGE_SIZE
This constant passed to the function 'write' makes the hashed set be displayed in a way that is appro...
This file defines a class "integer" which represents the ring of integers or the field of integers mo...
std::ostream & WriteCube(std::ostream &out, const cubetype &c)
Writes a cube to the output stream in the text mode.
dest_cube cube_cast(const src_cube &src)
Converts one cube into another.
void ignoreline(std::istream &in)
Ignores the input characters until the end of a line, including this end of the line.
int closingparenthesis(int ch)
Returns the matching closing parenthesis for the given opening one or EOF if none.
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 '...
std::istream & ReadCube(std::istream &in, cubetype &c)
Reads a cube from the input text stream.
int readcoordinates(std::istream &in, coordtype *coord, int maxdim, int closing)
Reads the coordinates of a point.
int read(textfile &f, coordtype *c, int maxdim)
Reads a point from a text file and removes a pair of parentheses, braces or brackets if present.
std::istream & ReadCubeFix(std::istream &in, cubetype &c, int dimfix)
Reads a cube from the input text stream.
void ignorecomments(std::istream &in)
Ignores white characters (spaces, tabulators, CRs and LFs), as well as comments from the input text f...
std::istream & ReadCubicalMap(std::istream &in, mvmap< tCube, tCube > &m)
Reads a combinatorial cubical multivalued map from an input text stream.
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.