COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
coMiniGrid.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef _COVISE_MINI_GRID_H_
9 #define _COVISE_MINI_GRID_H_
10 
11 // These are auxiliary classes involved in the RainAlgorithm
12 // as used in class coFeatureLines
13 
14 #include "MagmaUtils.h"
15 #include "unordered_set.h"
16 
17 namespace covise
18 {
19 
20 // coTriEdge stands for an ordered pair of nodes defining an
21 // edge in a grid
22 class coTriEdge
23 {
24 public:
25  coTriEdge();
26  coTriEdge(int i, int j);
27  bool operator==(const coTriEdge &rhs) const;
28  bool operator<(const coTriEdge &rhs) const;
29  int getMin() const;
30  int getMax() const;
31 
32 private:
33  int min_;
34  int max_;
35 };
36 
37 // HashCoTriEdge is defined in order to improve
38 // the performance of the algorithm, as it makes
39 // it possible to use hashed containers
41 {
42  size_t operator()(const coTriEdge &edge) const;
43  bool operator()(const coTriEdge &edge0, const coTriEdge &edge1) const;
44 #if defined(__INTEL_COMPILER) || defined(WIN32)
45  enum
46  {
47  bucket_size = 4,
48  min_buckets = 8
49  };
50 #endif
51 };
52 
53 // coTestNeighbour describes a neighbourhood
54 // relationship between a given cell (not the one
55 // indicated in the contructor) and another one (the one
56 // referrred to by parameter cell in constructor or variable cell_).
58 {
59 public:
60  // cell has to refer to the mini-numbering (see below)
61  coTestNeighbour(int cell, coTriEdge edge);
62  int CellLabel() const;
63  coTriEdge GetEdge() const;
64 
65 private:
66  int cell_;
68 };
69 
70 // coFeatureBorder describes a set of edges
72 {
73 public:
74  coFeatureBorder(const unordered_set<coTriEdge, HashCoTriEdge> &set_kanten);
75  virtual ~coFeatureBorder();
76  // tests whether the edge associated with neighbourhood tn
77  // belongs to this set of edges
78  bool IsIn(const coTestNeighbour &tn) const;
79 
80 private:
81  bool IsIn(const coTriEdge &edge) const;
82  unordered_set<coTriEdge, HashCoTriEdge> hash_segments_;
83 };
84 
85 // coTestNeighbourhoodContainer describes a set of
86 // neighbour relationships between a given cell and
87 // its neighbours
89 {
90 public:
91  void Add(const coTestNeighbour &tn)
92  {
93  container_.push_back(tn);
94  }
95  typedef vector<coTestNeighbour>::iterator iterator;
97  {
98  return container_.begin();
99  }
101  {
102  return container_.end();
103  }
104 
105 private:
106  vector<coTestNeighbour> container_;
107 };
108 
109 // coMiniGrid describes a subset of a grid
110 // In our application, it describes the subgrid around
111 // a given node
113 {
114 public:
117 
118  coMiniGrid(const vector<int> &minigrid_cells,
119  const vector<int> &elem_start_neigh,
120  const vector<int> &elem_number_neigh,
121  const vector<int> &elem_neighbours, // neighbour cells of a cell
122  //as long
123  const vector<MagmaUtils::Edge> &edge_neighbours);
124  //as elem_neighbours
125  virtual ~coMiniGrid();
126  int CellSize() const;
127  void GetEdgeNeighbours(int cell, coTestNeighbourhoodContainer &nc) const;
128 
129 private:
130  const vector<int> &minigrid_cells_; // contains the cells in the subset
131  // the following arrays are the neighbour information
132  // for the whole grid
133  const vector<int> &elem_start_neigh_;
134  const vector<int> &elem_number_neigh_;
135  const vector<int> &elem_neighbours_; // neighbour cells of a cell
136  //as long
137  const vector<MagmaUtils::Edge> &edge_neighbours_;
138  //as elem_neighbours_
139 };
140 }
141 #endif
Definition: coMiniGrid.h:71
virtual ~coFeatureBorder()
Definition: coMiniGrid.cpp:105
int getMax() const
Definition: coMiniGrid.cpp:53
const vector< int > & elem_start_neigh_
Definition: coMiniGrid.h:133
int max_
Definition: coMiniGrid.h:34
coTestNeighbourhoodContainer NeighbourhoodContainer
Definition: coMiniGrid.h:116
size_t operator()(const coTriEdge &edge) const
Definition: coMiniGrid.cpp:62
Definition: coMiniGrid.h:57
coMiniGrid(const vector< int > &minigrid_cells, const vector< int > &elem_start_neigh, const vector< int > &elem_number_neigh, const vector< int > &elem_neighbours, const vector< MagmaUtils::Edge > &edge_neighbours)
Definition: coMiniGrid.cpp:123
coFeatureBorder(const unordered_set< coTriEdge, HashCoTriEdge > &set_kanten)
Definition: coMiniGrid.cpp:99
virtual ~coMiniGrid()
Definition: coMiniGrid.cpp:139
bool operator==(const coTriEdge &rhs) const
Definition: coMiniGrid.cpp:34
bool operator<(const coTriEdge &rhs) const
Definition: coMiniGrid.cpp:41
coTestNeighbour(int cell, coTriEdge edge)
Definition: coMiniGrid.cpp:79
Definition: coMiniGrid.h:40
vector< coTestNeighbour >::iterator iterator
Definition: coMiniGrid.h:95
void Add(const coTestNeighbour &tn)
Definition: coMiniGrid.h:91
Definition: coMiniGrid.h:88
vector< coTestNeighbour > container_
Definition: coMiniGrid.h:106
bool IsIn(const coTestNeighbour &tn) const
Definition: coMiniGrid.cpp:116
unordered_set< coTriEdge, HashCoTriEdge > hash_segments_
Definition: coMiniGrid.h:82
const vector< int > & minigrid_cells_
Definition: coMiniGrid.h:130
const vector< MagmaUtils::Edge > & edge_neighbours_
Definition: coMiniGrid.h:137
coFeatureBorder Border
Definition: coMiniGrid.h:115
void GetEdgeNeighbours(int cell, coTestNeighbourhoodContainer &nc) const
Definition: coMiniGrid.cpp:156
coTriEdge GetEdge() const
Definition: coMiniGrid.cpp:92
Definition: coMiniGrid.h:22
const vector< int > & elem_number_neigh_
Definition: coMiniGrid.h:134
coTriEdge()
Definition: coMiniGrid.cpp:15
int CellLabel() const
Definition: coMiniGrid.cpp:86
coTriEdge edge_
Definition: coMiniGrid.h:67
int CellSize() const
Definition: coMiniGrid.cpp:144
int getMin() const
Definition: coMiniGrid.cpp:47
iterator begin()
Definition: coMiniGrid.h:96
int min_
Definition: coMiniGrid.h:33
const vector< int > & elem_neighbours_
Definition: coMiniGrid.h:135
int cell_
Definition: coMiniGrid.h:66
iterator end()
Definition: coMiniGrid.h:100
Definition: coMiniGrid.h:112