2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008,2009 Oliver Gloth +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
28 #include "egvtkobject.h"
30 class PolyMesh
: public EgVtkObject
33 protected: // data types
35 enum idx_t
{ node
, edge
, face
, cell
};
46 node_t(PolyMesh
*p
, idx_t t
, int i
, int si
) { poly
= p
; type
= t
; idx
= i
; subidx
= si
; };
47 node_t() { poly
= NULL
, type
= node
, idx
= 0; subidx
= 0; };
48 bool operator==(const node_t N
) const;
51 friend uint
qHash(node_t N
);
52 friend ostream
& operator<<(ostream
& s
, node_t N
);
56 int owner
, neighbour
, bc
;
57 node_t
operator[](int i
) { while(i
<0) i
+=node
.size(); while(i
>=node
.size()) i
-=node
.size(); return node
[i
]; };
58 void checkOrientation();
59 bool operator<(const face_t
&F
) const;
63 friend ostream
& operator<<(ostream
& s
, face_t F
);
65 protected: // attributes
68 vtkUnstructuredGrid
*grid
;
69 QList
<face_t
> face_list
;
70 QVector
<face_t
> faces
;
74 QVector
<vtkIdType
> cells
;
75 QVector
<vec3_t
> nodes
;
76 QVector
<QVector
<int> > c2c
;
78 QVector
<double> weight
;
83 int pcIdxNode(vtkIdType id_node
);
84 int pcIdxCell(vtkIdType id_node
);
92 face_t
combineFaces(QList
<face_t
> faces
);
93 double faceW(double w
) { if (w
> 1.01) return 0.5*w
; else return w
; };
100 PolyMesh(vtkUnstructuredGrid
*a_grid
, bool dual_mesh
= true);
101 int totalNumNodes() const { return nodes
.size(); };
102 vec3_t
nodeVector(int i
) const { return nodes
[i
]; };
103 int numNodes(int i
) const { return faces
[i
].node
.size(); };
104 int nodeIndex(int i
, int j
) const { return faces
[i
].node
[j
].idx
; };
105 int numFaces() const { return faces
.size(); };
106 int numCells() const { return id_newpc
; };
107 int owner(int i
) const { return faces
[i
].owner
; };
108 int neighbour(int i
) const { return faces
[i
].neighbour
; };
109 int boundaryCode(int i
) const { return faces
[i
].bc
; };
110 int numBCs() const { return bcs
.size()-1; };
111 void getFace(vtkIdType idx
, int subidx
, QList
<vtkIdType
> &nodes
);
112 void getEdge(vtkIdType idx
, int subidx
, QList
<vtkIdType
> &nodes
);
117 uint
qHash(PolyMesh::node_t N
);