vertexList.hh

Go to the documentation of this file.
1 
6 #ifndef geoLists_hh
7 #define geoLists_hh
8 
9 #include <iostream>
11 #include "toolbox/hashMap.hh"
12 #include "toolbox/hashSet.hh"
13 #include "space/postProcess.hh"
14 
15 namespace concepts {
16  // forward declarations
17 } // namespace concepts
18 
19 namespace graphics {
20 
21  using concepts::Real;
22 
23  // ************************************************************ VertexInfo **
24 
35  class VertexInfo {
36  friend std::ostream& operator<< (std::ostream& os, const VertexInfo& v);
37  public:
42  VertexInfo(concepts::Real3d coord, uint index = 0) :
43  index_(index), coord_(coord) {}
44 
46  void addEdge(uint edge) { edges_.insert(edge); }
47 
49  void addFace(uint face) { faces_.insert(face); }
50 
52  void addVolume(uint volume) { volumes_.insert(volume); }
53 
55  uint& index() { return index_; }
57  uint index() const { return index_; }
58 
60  concepts::Real3d coordinates() const { return coord_; }
61  private:
67  uint index_;
68 
71 
73  std::unordered_set<uint> edges_;
74 
76  std::unordered_set<uint> faces_;
77 
79  std::unordered_set<uint> volumes_;
80  };
81 
82  // ************************************************************ VertexList **
83 
97  class VertexList : public concepts::CellPostprocess<Real> {
98  public:
99  typedef std::unordered_map<uint, VertexInfo>::iterator iterator;
100  typedef std::unordered_map<uint, VertexInfo>::const_iterator
102 
109  enum vtxInfo { COORD = 0, EDGES = 1, FACES = 2, VOLUMES = 4, ALL = 7 };
110 
114 
116  VertexList(const VertexList& vl);
117 
118  virtual ~VertexList() {}
119 
124  VertexInfo* vertex(uint v);
125 
132 
134  uint size() const { return vertices_.size(); }
135 
137  iterator begin() { return vertices_.begin(); }
138  const_iterator begin() const { return vertices_.begin(); }
139 
141  iterator end() { return vertices_.end(); }
142  const_iterator end() const { return vertices_.end(); }
143 
145  iterator find(uint k) { return vertices_.find(k); }
146  const_iterator find(uint k) const { return vertices_.find(k); }
147 
153  virtual void operator() (const concepts::Cell& cell);
154 
160  virtual void operator() (const concepts::Element<Real>& elm);
161 
163  enum vtxInfo vertexInfo() const { return vtxInfo_; }
164  protected:
165  virtual std::ostream& info(std::ostream& os) const;
166  private:
168  std::unordered_map<uint, VertexInfo> vertices_;
169 
171  enum vtxInfo vtxInfo_;
172  };
173 
174 } // namespace graphics
175 
176 #endif // geoLists_hh
std::unordered_map< uint, VertexInfo >::const_iterator const_iterator
Definition: vertexList.hh:101
concepts::Real3d coordinates() const
Returns the coordinates.
Definition: vertexList.hh:60
std::unordered_set< uint > edges_
List of edges meeting at this vertex.
Definition: vertexList.hh:73
uint index() const
Returns the index of the vertex.
Definition: vertexList.hh:57
VertexInfo(concepts::Real3d coord, uint index=0)
Constructor.
Definition: vertexList.hh:42
iterator find(uint k)
Finds a vertex in the list.
Definition: vertexList.hh:145
uint & index()
Sets the index of the vertex.
Definition: vertexList.hh:55
std::unordered_map< uint, VertexInfo > vertices_
List of vertices.
Definition: vertexList.hh:168
A cell in a mesh consist of topological information (neighbours, connectivity, orientation) and geome...
Definition: cell.hh:39
iterator end()
End of the list.
Definition: vertexList.hh:141
uint size() const
Returns the size of the list.
Definition: vertexList.hh:134
enum vtxInfo vtxInfo_
What information about the vertices should be stored.
Definition: vertexList.hh:171
void addEdge(uint edge)
Adds an edge to the list of edges.
Definition: vertexList.hh:46
std::unordered_set< uint > faces_
List of faces meeting at this vertex.
Definition: vertexList.hh:76
uint index_
Index of the vertex.
Definition: vertexList.hh:67
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Graphics.
Definition: basis.hh:33
std::unordered_map< uint, VertexInfo >::iterator iterator
Definition: vertexList.hh:99
vtxInfo
Allows to chose if all information should be stored or only some parts.
Definition: vertexList.hh:109
Class containing information about one single vertex.
Definition: vertexList.hh:35
void addFace(uint face)
Adds a face to the list of faces.
Definition: vertexList.hh:49
VertexInfo * addVertex(uint v, concepts::Real3d coord)
Add a new vertex.
const_iterator end() const
Definition: vertexList.hh:142
Class containing a list of vertices.
Definition: vertexList.hh:97
VertexInfo * vertex(uint v)
Looks for the vertex with the given key.
virtual void operator()(const concepts::Cell &cell)
Application operator.
concepts::Real3d coord_
Coordinates of the vertex.
Definition: vertexList.hh:70
VertexList(enum vtxInfo info=ALL)
Constructor.
Definition: vertexList.hh:113
const_iterator find(uint k) const
Definition: vertexList.hh:146
const_iterator begin() const
Definition: vertexList.hh:138
VertexList(const VertexList &vl)
Copy constructor.
std::unordered_set< uint > volumes_
List of volumes meeting at this vertex (only useful for 3D)
Definition: vertexList.hh:79
void addVolume(uint volume)
Adds a volume to the list of volumes.
Definition: vertexList.hh:52
friend std::ostream & operator<<(std::ostream &os, const VertexInfo &v)
enum vtxInfo vertexInfo() const
Returns vtxInfo_.
Definition: vertexList.hh:163
iterator begin()
Beginning of the list.
Definition: vertexList.hh:137
Abstract class for per cell postprocessing.
Definition: postProcess.hh:38
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich