33 #ifndef __H__LIB_GRID__DUAL_GRAPH__
34 #define __H__LIB_GRID__DUAL_GRAPH__
79 template <
class TGeomBaseObj,
class TIndexType>
81 std::vector<TIndexType>& adjacencyMapOut,
83 TGeomBaseObj** pGeomObjsOut = NULL,
88 typedef TGeomBaseObj Elem;
110 for(
size_t lvl = 0; lvl < goc.
num_levels(); ++lvl)
112 for(ElemIterator iter = goc.
begin<Elem>(lvl); iter != goc.
end<Elem>(lvl);
120 adjacencyMapStructureOut.resize(goc.
num<Elem>() + 1);
121 adjacencyMapOut.clear();
125 vector<Elem*> vNeighbours;
129 for(
size_t lvl = 0; lvl < goc.
num_levels(); ++lvl)
131 for(ElemIterator iter = goc.
begin<Elem>(lvl);
132 iter != goc.
end<Elem>(lvl); ++iter, ++ind)
138 adjacencyMapStructureOut[ind] = adjacencyMapOut.size();
141 for(
size_t i = 0; i < vNeighbours.size(); ++i)
142 adjacencyMapOut.push_back(aaInd[vNeighbours[i]]);
148 adjacencyMapStructureOut[adjacencyMapStructureOut.size() - 1] = adjacencyMapOut.size();
154 for(
size_t lvl = 0; lvl < goc.
num_levels(); ++lvl){
155 for(ElemIterator iter = goc.
begin<Elem>(lvl);
156 iter != goc.
end<Elem>(lvl); ++iter, ++ind)
158 pGeomObjsOut[ind] = *iter;
207 template <
class TGeomBaseObj,
class TIndexType>
209 std::vector<TIndexType>& adjacencyMapOut,
210 std::vector<TIndexType>* pEdgeWeightsOut,
212 int hWeight = 1,
int vWeight = 1,
214 TGeomBaseObj** pGeomObjsOut = NULL,
218 typedef TGeomBaseObj Elem;
235 for(
size_t lvl = baseLevel; lvl < mg.
num_levels(); ++lvl)
237 numElems += mg.
num<Elem>(lvl);
238 for(ElemIterator iter = mg.
begin<Elem>(lvl); iter != mg.
end<Elem>(lvl);
246 adjacencyMapStructureOut.resize(numElems + 1);
247 adjacencyMapOut.clear();
249 pEdgeWeightsOut->clear();
253 vector<Elem*> vNeighbours;
257 for(
size_t lvl = baseLevel; lvl < mg.
num_levels(); ++lvl)
259 for(ElemIterator iter = mg.
begin<Elem>(lvl);
260 iter != mg.
end<Elem>(lvl); ++iter, ++ind)
268 adjacencyMapStructureOut[ind] = adjacencyMapOut.size();
271 for(
size_t i = 0; i < vNeighbours.size(); ++i)
272 adjacencyMapOut.push_back(aaInd[vNeighbours[i]]);
275 for(
size_t i = 0; i < vNeighbours.size(); ++i)
276 pEdgeWeightsOut->push_back(hWeight);
281 if(parent && Elem::type_match(parent)){
282 adjacencyMapOut.push_back(aaInd[
static_cast<Elem*
>(parent)]);
284 pEdgeWeightsOut->push_back(vWeight);
290 for(
size_t i = 0; i < numChildren; ++i){
291 adjacencyMapOut.push_back(aaInd[mg.
get_child<Elem>(elem, i)]);
295 for(
size_t i = 0; i < numChildren; ++i)
296 pEdgeWeightsOut->push_back(1);
303 adjacencyMapStructureOut[adjacencyMapStructureOut.size() - 1] = adjacencyMapOut.size();
309 for(
size_t lvl = baseLevel; lvl < mg.
num_levels(); ++lvl){
310 for(ElemIterator iter = mg.
begin<Elem>(lvl);
311 iter != mg.
end<Elem>(lvl); ++iter, ++ind)
313 pGeomObjsOut[ind] = *iter;
324 template <
typename TBaseElem>
369 template <
class TGeomBaseObj,
class TIndexType>
371 std::vector<TIndexType>& adjacencyMapStructureOut,
372 std::vector<TIndexType>& adjacencyMapOut,
375 TGeomBaseObj** pGeomObjsOut = NULL,
380 typedef TGeomBaseObj Elem;
395 size_t numElems = mg.
num<Elem>(level);
398 for(ElemIterator iter = mg.
begin<Elem>(level); iter != mg.
end<Elem>(level);
406 adjacencyMapStructureOut.resize(numElems + 1);
407 adjacencyMapOut.clear();
410 vector<Elem*> vNeighbours;
414 for(ElemIterator iter = mg.
begin<Elem>(level);
415 iter != mg.
end<Elem>(level); ++iter, ++ind)
420 if (neighborCollector)
421 neighborCollector->collect_neighbors(vNeighbours, elem);
426 adjacencyMapStructureOut[ind] = adjacencyMapOut.size();
429 for(
size_t i = 0; i < vNeighbours.size(); ++i)
430 adjacencyMapOut.push_back(aaInd[vNeighbours[i]]);
434 adjacencyMapStructureOut[adjacencyMapStructureOut.size() - 1] = adjacencyMapOut.size();
440 for(ElemIterator iter = mg.
begin<Elem>(level);
441 iter != mg.
end<Elem>(level); ++iter, ++ind)
443 pGeomObjsOut[ind] = *iter;
A generic specialization of IAttachment.
Definition: attachment_pipe.h:263
Definition: dual_graph.h:326
virtual void collect_neighbors(std::vector< TBaseElem * > &neighborsOut, TBaseElem *elem)=0
virtual ~DualGraphNeighborCollector()
Definition: dual_graph.h:328
the generic attachment-accessor for access to grids attachment pipes.
Definition: grid.h:182
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
void detach_from(IAttachment &attachment)
Definition: grid_impl.hpp:369
void attach_to(IAttachment &attachment, bool passOnValues)
attach with custom pass-on-behaviour and unspecified default value.
Definition: grid_impl.hpp:296
bool has_attachment(IAttachment &attachment)
Definition: grid.h:796
virtual GridObjectCollection get_grid_objects()
returns the the GridObjectCollection of the grid:
Definition: grid.cpp:527
void attach_to_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue)
Definition: grid_impl.hpp:326
a helper class that holds a collection of possibly unconnected geometric-objects.
Definition: grid_object_collection.h:96
geometry_traits< TGeomObj >::iterator begin(size_t level=0)
Definition: grid_object_collection_impl.hpp:95
geometry_traits< TGeomObj >::iterator end(size_t level=0)
Definition: grid_object_collection_impl.hpp:106
size_t num() const
Definition: grid_object_collection_impl.hpp:130
size_t num_levels() const
returns the number of levels
Definition: grid_object_collection.h:128
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
Definition: multi_grid.h:72
size_t num_levels() const
number of levels
Definition: multi_grid.h:145
TChild * get_child(TElem *elem, size_t ind) const
returns the i-th child of the given child-type
Definition: multi_grid.h:268
size_t num(int level) const
Definition: multi_grid.h:154
GridObject * get_parent(GridObject *parent) const
Definition: multi_grid.cpp:180
geometry_traits< TElem >::iterator end(int level)
Definition: multi_grid.h:168
geometry_traits< TElem >::iterator begin(int level)
Definition: multi_grid.h:158
size_t num_children(TElem *elem) const
returns the number of children of the given child-type
Definition: multi_grid.h:225
Definition: grid_base_object_traits.h:68
NeighborhoodType
Constants to specify a neighborhood.
Definition: neighborhood.h:53
void CollectNeighbors(std::vector< Vertex * > &vNeighborsOut, Grid &grid, Vertex *vrt, uint nbhType, Grid::edge_traits::callback considerEdge, Grid::face_traits::callback considerFace, Grid::volume_traits::callback considerVol)
Collects all vertices that are connected by elements of the specified type.
Definition: neighborhood.cpp:43
@ NHT_DEFAULT
Definition: neighborhood.h:54
base_type::TBaseElem TBaseElem
Definition: smart_pointer.h:814
void ConstructDualGraph(std::vector< TIndexType > &adjacencyMapStructureOut, std::vector< TIndexType > &adjacencyMapOut, Grid &grid, Attachment< TIndexType > *paIndex=NULL, TGeomBaseObj **pGeomObjsOut=NULL, NeighborhoodType nbhType=NHT_DEFAULT, const GridObjectCollection *pgoc=NULL)
Definition: dual_graph.h:80
void ConstructDualGraphMG(std::vector< TIndexType > &adjacencyMapStructureOut, std::vector< TIndexType > &adjacencyMapOut, std::vector< TIndexType > *pEdgeWeightsOut, MultiGrid &mg, size_t baseLevel=0, int hWeight=1, int vWeight=1, Attachment< TIndexType > *paIndex=NULL, TGeomBaseObj **pGeomObjsOut=NULL, NeighborhoodType nbhType=NHT_DEFAULT)
Definition: dual_graph.h:208
void ConstructDualGraphMGLevel(std::vector< TIndexType > &adjacencyMapStructureOut, std::vector< TIndexType > &adjacencyMapOut, MultiGrid &mg, size_t level, Attachment< TIndexType > *paIndex=NULL, TGeomBaseObj **pGeomObjsOut=NULL, NeighborhoodType nbhType=NHT_DEFAULT, DualGraphNeighborCollector< TGeomBaseObj > *neighborCollector=NULL)
Definition: dual_graph.h:370