34#ifndef _CHOMP_CUBES_NEIGHBOR_H_
35#define _CHOMP_CUBES_NEIGHBOR_H_
64 const int maxdim = 17;
65 const int neighbors [maxdim] = {0, 2, 8, 26, 80, 242, 728,
66 2186, 6560, 19682, 59048, 177146, 531440, 1594322,
67 4782968, 14348906, 43046720};
71 for (
int i = maxdim - 1; i < dim; ++ i)
87 typedef typename tCube::CoordType coordType;
89 coordType c0 [tCube::MaxDim];
91 coordType c1 [tCube::MaxDim];
96 const coordType *wrap = tCube::PointBase::getwrapping (dim);
97 for (
int i = 0; i < dim; ++ i)
101 switch (c1 [i] - c0 [i])
111 if (!wrap || !wrap [i])
113 if ((c1 [i] - c0 [i]) == (wrap [i] - 1))
115 else if ((c1 [i] - c0 [i]) == (1 - wrap [i]))
128template <
class tCube>
132 typedef typename tCube::CoordType coordType;
136 coordType coord [tCube::MaxDim];
138 coordType cLeft [tCube::MaxDim];
139 face. leftcoord (cLeft);
140 coordType cRight [tCube::MaxDim];
141 face. rightcoord (cRight);
145 for (
int i = 0; i < dim; ++ i)
150 if (cLeft [i] != coord [i])
153 else if (cRight [i] == cLeft [i])
164template <
class tCube>
168 typedef typename tCube::CoordType coordType;
170 coordType c0 [tCube::MaxDim];
172 coordType c1 [tCube::MaxDim];
176 for (
int i = dim - 1; i >= 0; -- i)
190 throw "Erratic neighbor.";
195 if (unconditional || tCube::PointBase::check (c1, dim))
196 return tCube (c1, dim);
210template <
class tCube,
class tCubeSet1,
class tCubeSet2>
218 for (
int_t i = 0; i < theset. size (); ++ i)
233 bits -> set (number);
243 if (limit && (count >= limit))
254template <
class tCube,
class tCubeSet1,
class tCubeSet2>
265 for (
int_t number = 0; number < maxneighbors; ++ number)
275 if (!theset. check (neighbor))
280 bits -> set (number);
290 if (limit && (count >= limit))
301template <
class tCube,
class tCubeSet1,
class tCubeSet2>
306 if (theset. empty ())
325template <
class tCube,
class tCubeSet>
327 const tCubeSet &theset,
int_t limit)
341template <
class tCube,
class tCubeSet>
343 const tCubeSet ¬these)
348 int_t number = bits. find (0, maxneighbors);
352 if (!notthese. check (neighbor))
354 number = bits. find (number + 1, maxneighbors);
363template <
class tCube,
class tCubeSet>
365 bool unconditional =
false)
370 int_t number = bits. find (0, maxneighbors);
373 tCube neighbor =
bit2neighbor (q, number, unconditional);
375 number = bits. find (number + 1, maxneighbors);
385template <
class tCube,
class tCell>
390 typedef typename tCube::CoordType coordType;
399 coordType coord [tCube::MaxDim];
403 coordType cLeft [tCube::MaxDim];
404 coordType cRight [tCube::MaxDim];
410 int_t number = bits. find (0, maxneighbors);
416 int_t n = number + 1;
417 for (
int i = dim - 1; i >= 0; -- i)
422 cLeft [i] = coord [i];
423 cRight [i] = coord [i];
426 cLeft [i] = coord [i] + 1;
427 cRight [i] = coord [i] + 1;
430 cLeft [i] = coord [i];
431 cRight [i] = coord [i] + 1;
438 c. add (tCell (cLeft, cRight, dim));
444 number = bits. find (number + 1, maxneighbors);
This file contains functions generated using Binary Decision Diagrams for checking the acyclicity of ...
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 is a template for a set of objects of the given type.
This class can be used for iterating point's neighbors.
This file contains some precompiler definitions which indicate the operating system and/or compiler u...
This file includes header files with various definitions of full cubes and defines the standard types...
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 contains the definition of a tabulated set of configurations of full cubical neighborhood u...
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...
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.
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.
int_t getmaxneighbors(int dim)
Returns the maximal number of neighbors of a cube: 3^dim - 1.
void addneighbors(const int &c, const SetT &s, QueueT &q)
Adds the neighbors of the cube 'c' in the set 's' to the set 'q'.
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.
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 the definition of a class which stores tabulated configuration of full cubical nei...
This file contains some useful functions related to the text input/output procedures.