ug4
polychain_util.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3  * Author: Sebastian Reiter
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef __H__LIB_GRID__POLYCHAIN_UTIL__
34 #define __H__LIB_GRID__POLYCHAIN_UTIL__
35 
36 #include <utility>
37 #include "lib_grid/lg_base.h"
38 
39 namespace ug
40 {
41 
50 {
53  PCT_OPEN = 1 << 1,
54  PCT_SEPARATED = 1 << 2,
55  PCT_IRREGULAR = 1 << 3,
56  PCT_EMPTY = 1 << 4
57 };
58 
61 template <class TEdgeIterator>
62 size_t
63 GetPolyChainType(Grid& grid, TEdgeIterator edgesBegin,
64  TEdgeIterator edgesEnd,
65  Grid::edge_traits::callback cbEdgeIsInPolyChain);
66 
69 
86 template <class TEdgeIterator>
87 std::pair<Vertex*, Edge*>
88 GetFirstSectionOfPolyChain(Grid& grid, TEdgeIterator edgesBegin,
89  TEdgeIterator edgesEnd,
90  Grid::edge_traits::callback cbEdgeIsInPolyChain);
91 
94 
107 std::pair<Vertex*, Edge*>
108 GetNextSectionOfPolyChain(Grid& grid, std::pair<Vertex*, Edge*> lastSection,
109  Grid::edge_traits::callback cbEdgeIsInPolyChain);
110 
113 
120 bool SplitIrregularPolyChain(SubsetHandler& sh, int srcIndex, int targetIndex);
121 
122 
125 
128 template <class TEdgeIter>
129 bool CreatePolyChain(std::vector<Vertex*>& polyChainOut, Grid& grid,
130  TEdgeIter edgesBegin, TEdgeIter edgesEnd);
131  // end of doxygen defgroup command
133 
134 }// end of namespace
135 
136 
138 // include implementation
139 #include "polychain_util_impl.hpp"
140 
141 #endif
size_t GetPolyChainType(Grid &grid, TEdgeIterator edgesBegin, TEdgeIterator edgesEnd, Grid::edge_traits::callback cbEdgeIsInPolyChain)
returns an or combination of constants enumerated in PolyChainTypes.
Definition: polychain_util_impl.hpp:44
std::pair< Vertex *, Edge * > GetFirstSectionOfPolyChain(Grid &grid, TEdgeIterator edgesBegin, TEdgeIterator edgesEnd, Grid::edge_traits::callback cbEdgeIsInPolyChain)
Returns the start-vertex and start-edge of a polygonal chain.
Definition: polychain_util_impl.hpp:100
std::pair< Vertex *, Edge * > GetNextSectionOfPolyChain(Grid &grid, std::pair< Vertex *, Edge * > lastSection, Grid::edge_traits::callback cbEdgeIsInPolyChain)
returns the next section in a polygonal chain.
Definition: polychain_util.cpp:43
bool SplitIrregularPolyChain(SubsetHandler &sh, int srcIndex, int targetIndex)
Makes sure that the polychain at srcIndex is regular and not separated.
Definition: polychain_util.cpp:72
PolyChainTypes
Definition: polychain_util.h:50
bool CreatePolyChain(std::vector< Vertex * > &polyChainOut, Grid &grid, TEdgeIter edgesBegin, TEdgeIter edgesEnd)
given a list of edges, this method collects associated vertices in a polychain
Definition: polychain_util_impl.hpp:127
@ PCT_OPEN
Definition: polychain_util.h:53
@ PCT_EMPTY
Definition: polychain_util.h:56
@ PCT_SEPARATED
Definition: polychain_util.h:54
@ PCT_CLOSED
Definition: polychain_util.h:52
@ PCT_IRREGULAR
Definition: polychain_util.h:55
@ PCT_UNKNOWN
Definition: polychain_util.h:51
the ug namespace
GridSubsetHandler SubsetHandler
Definition: subset_handler_grid.h:376
boost::function< bool(base_object *)> callback
callback type for the elements base type.
Definition: grid.h:150