[1] template<class NBF, class CELLRANGE>
void CalculateNeighborCells
(NBF & Nb, // out
CELLRANGE const& C); // in
[2] template<class NBF, class CELLRANGE, class FACETMAP>
void CalculateNeighborCells
(NBF & Nb, // out
CELLRANGE const& C, // in
FACETMAP & F); // inout
[3] template<class NBF, class CELLRANGE, class FACETMAP, class CGT>
void CalculateNeighborCells
(NBF & Nb, // out
CELLRANGE const& C, // in
FACETMAP & F, // inout
CGT const&); // in (only type used)
CalculateNeighborRange (versions [2], [3]) can be used incrementally in the variable C: If C = C1 U ... U Cn is a partition of a given cell set, then calling CalculateNeighborRange with the cell set C is equivalent to the successive calls with cell sets C1, ..., Cn. (The remaining arguments stay identical.)
The following types must be published by the type CGT (version [3]) or the template grid_types<CELLSET> (versions [1], [2]):
In the following, we use CGT also for grid_types<CELLSET> in versions [1], [2].
D n I = Ø
After the call, F contains exactly the boundary facets, except those that have been in it before (versions [2], [3]). In version [1], the value of Nb is set to an invalid cell handle for boundary facets (that is, facets which have been visited by only facet-on-cell iterator).
D`= (D \ B) U (B \ D)It follows that D` n I = Ø.
#include "Grids/Algorithms/cell-neighbor-search.h"
Triang2D t;
typedef grid_types<Triang2D> gt;
...
hash_map<gt::FacetOnCellIterator> , gt::cell_handle> Nbs;
CalculateNeighborCells(nbf,T);
for(gt::CellIterator c(t); ! c.IsDone(); ++c)
for(gt::FacetOnCellIterator fc(c); ! fc.IsDone(); ++fc)
out << nbf[fc] << ' ';
out << 'n';
The mapping from gt::FacetOnCellIterator to gt::cell_handle
can of course be done much more efficiently than with a hash table, see
the example in test-triang2d-construct.C.
Useqd in test file test-triang2d-construct.C for Triang2D.