28 #ifndef _CHAINCON_WRAPPING_H_ 29 #define _CHAINCON_WRAPPING_H_ 49 template <
class CoordT>
57 template <
class ArrayT>
58 static void wrap (ArrayT &coords,
int dim);
62 template <
class ArrayT>
63 static void setWrapping (
const ArrayT &coords,
int dim);
69 template <
class CoordT>
70 template <
class ArrayT>
76 template <
class CoordT>
77 template <
class ArrayT>
80 throw "Coordinate wrapping not supported.";
91 template <
class CoordT>
100 template <
class ArrayT>
101 static void wrap (ArrayT &coords,
int dim);
104 template <
class ArrayT>
105 static void setWrapping (
const ArrayT &coords,
int dim);
115 template <
class CoordT>
120 template <
class CoordT>
121 template <
class ArrayT>
125 if (static_cast<int> (wrapping. size ()) <= dim)
127 const std::vector<CoordT> &w (wrapping [dim]);
128 if (static_cast<int> (w. size ()) != dim)
132 for (
int i = 0; i < dim; ++ i)
138 if (coords [i] < w [i])
141 else if (coords [i] == w [i])
145 else if (coords [i] > w [i])
150 else if (coords [i] == -1)
152 coords [i] = w [i] - 1;
156 coords [i] = (w [i] - 1) -
157 ((-coords [i] - 1) % w [i]);
164 template <
class CoordT>
165 template <
class ArrayT>
167 (
const ArrayT &coords,
int dim)
170 while (static_cast<int> (wrapping. size ()) <= dim)
172 std::vector<CoordT> dummy;
173 wrapping. push_back (dummy);
177 std::vector<CoordT> w (dim);
178 for (
int i = 0; i < dim; ++ i)
193 template <
class WrapT>
196 typedef typename WrapT::CoordType
CoordType;
197 std::vector<CoordType> coords;
198 std::istringstream in (s);
199 while (in. peek () != EOF)
203 if (n == static_cast<CoordType> (-1))
205 coords. push_back (n);
206 if (in. peek () ==
',')
209 if (!coords. empty ())
215 #endif // _CHAINCON_WRAPPING_H_ CoordT CoordType
The type of coordinates for wrapping.
A simple class for wrapping cubical cell coordinstes, which does not wrap anything.
static void setWrapping(const ArrayT &coords, int dim)
Sets wrapping for all spaces of the given dimension.
CoordT CoordType
The type of coordinates for wrapping.
void setWrapping(const std::string &s)
Sets wrapping based on a text with comma-separated numbers.
A simple class for wrapping cubical cell coordinstes, using the one defined in the CHomP package...
static void wrap(ArrayT &coords, int dim)
A dummy wrapping function that does nothing.
static void setWrapping(const ArrayT &coords, int dim)
A dummy function for setting wrapping that throws an exception if called.
static std::vector< std::vector< CoordT > > wrapping
An array of wrapping vectors for each dimension where defined.
static void wrap(ArrayT &coords, int dim)
Makes a correction to the given array of coordinates if wrapping is in effect.