Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
unittests_common.cc
1 /*
2 * unittests_common.cc
3 *
4 * Created on: Jan 10, 2012
5 * Author: kremer
6 */
7
8 #include "unittests_common.hh"
9
10 using namespace OpenVolumeMesh::Geometry;
11
12 void PolyhedralMeshBase::generatePolyhedralMesh(PolyhedralMesh& _mesh) {
13
14 Vec3d p1(0.0, 0.0, 0.0);
15 Vec3d p2(1.0, 0.0, 0.0);
16 Vec3d p3(1.0, 1.0, 0.0);
17 Vec3d p4(0.0, 1.0, 0.0);
18
19 Vec3d p5(0.0, 0.0, 1.0);
20 Vec3d p6(1.0, 0.0, 1.0);
21 Vec3d p7(1.0, 1.0, 1.0);
22 Vec3d p8(0.0, 1.0, 1.0);
23
24 Vec3d p9(0.0, 0.0, 2.0);
25 Vec3d p10(1.0, 0.0, 2.0);
26 Vec3d p11(1.0, 1.0, 2.0);
27 Vec3d p12(0.0, 1.0, 2.0);
28
29 VertexHandle v1 = _mesh.add_vertex(p1);
30 VertexHandle v2 = _mesh.add_vertex(p2);
31 VertexHandle v3 = _mesh.add_vertex(p3);
32 VertexHandle v4 = _mesh.add_vertex(p4);
33
34 VertexHandle v5 = _mesh.add_vertex(p5);
35 VertexHandle v6 = _mesh.add_vertex(p6);
36 VertexHandle v7 = _mesh.add_vertex(p7);
37 VertexHandle v8 = _mesh.add_vertex(p8);
38
39 VertexHandle v9 = _mesh.add_vertex(p9);
40 VertexHandle v10 = _mesh.add_vertex(p10);
41 VertexHandle v11 = _mesh.add_vertex(p11);
42 VertexHandle v12 = _mesh.add_vertex(p12);
43
44 std::vector<VertexHandle> vertices;
45 vertices.push_back(v1); vertices.push_back(v2);
46 vertices.push_back(v3); vertices.push_back(v4);
47 FaceHandle f1 = _mesh.add_face(vertices);
48
49 vertices.clear();
50 vertices.push_back(v5); vertices.push_back(v6);
51 vertices.push_back(v7); vertices.push_back(v8);
52 FaceHandle f2 = _mesh.add_face(vertices);
53
54 vertices.clear();
55 vertices.push_back(v2); vertices.push_back(v6);
56 vertices.push_back(v7); vertices.push_back(v3);
57 FaceHandle f3 = _mesh.add_face(vertices);
58
59 vertices.clear();
60 vertices.push_back(v1); vertices.push_back(v4);
61 vertices.push_back(v8); vertices.push_back(v5);
62 FaceHandle f4 = _mesh.add_face(vertices);
63
64 vertices.clear();
65 vertices.push_back(v4); vertices.push_back(v3);
66 vertices.push_back(v7); vertices.push_back(v8);
67 FaceHandle f5 = _mesh.add_face(vertices);
68
69 vertices.clear();
70 vertices.push_back(v6); vertices.push_back(v5);
71 vertices.push_back(v1); vertices.push_back(v2);
72 FaceHandle f6 = _mesh.add_face(vertices);
73
74 // Add first cell
75 std::vector<HalfFaceHandle> halffaces;
76 halffaces.push_back(_mesh.halfface_handle(f1, 1)); halffaces.push_back(_mesh.halfface_handle(f2, 0));
77 halffaces.push_back(_mesh.halfface_handle(f3, 1)); halffaces.push_back(_mesh.halfface_handle(f4, 1));
78 halffaces.push_back(_mesh.halfface_handle(f5, 1)); halffaces.push_back(_mesh.halfface_handle(f6, 0));
79 _mesh.add_cell(halffaces);
80
81 vertices.clear();
82 vertices.push_back(v9); vertices.push_back(v10);
83 vertices.push_back(v11); vertices.push_back(v12);
84 FaceHandle f7 = _mesh.add_face(vertices);
85
86 vertices.clear();
87 vertices.push_back(v10); vertices.push_back(v11);
88 vertices.push_back(v7); vertices.push_back(v6);
89 FaceHandle f8 = _mesh.add_face(vertices);
90
91 vertices.clear();
92 vertices.push_back(v5); vertices.push_back(v8);
93 vertices.push_back(v12); vertices.push_back(v9);
94 FaceHandle f9 = _mesh.add_face(vertices);
95
96 vertices.clear();
97 vertices.push_back(v8); vertices.push_back(v7);
98 vertices.push_back(v11); vertices.push_back(v12);
99 FaceHandle f10 = _mesh.add_face(vertices);
100
101 vertices.clear();
102 vertices.push_back(v10); vertices.push_back(v9);
103 vertices.push_back(v5); vertices.push_back(v6);
104 FaceHandle f11 = _mesh.add_face(vertices);
105
106 halffaces.clear();
107 halffaces.push_back(_mesh.halfface_handle(f2, 1)); halffaces.push_back(_mesh.halfface_handle(f7, 0));
108 halffaces.push_back(_mesh.halfface_handle(f8, 1)); halffaces.push_back(_mesh.halfface_handle(f9, 1));
109 halffaces.push_back(_mesh.halfface_handle(f10, 1)); halffaces.push_back(_mesh.halfface_handle(f11, 0));
110 _mesh.add_cell(halffaces);
111 }
112
113 void HexahedralMeshBase::generateHexahedralMesh(HexahedralMesh& _mesh) {
114
115 Vec3d p1(0.0, 0.0, 0.0);
116 Vec3d p2(1.0, 0.0, 0.0);
117 Vec3d p3(1.0, 1.0, 0.0);
118 Vec3d p4(0.0, 1.0, 0.0);
119
120 Vec3d p5(0.0, 0.0, 1.0);
121 Vec3d p6(1.0, 0.0, 1.0);
122 Vec3d p7(1.0, 1.0, 1.0);
123 Vec3d p8(0.0, 1.0, 1.0);
124
125 Vec3d p9(0.0, 0.0, 2.0);
126 Vec3d p10(1.0, 0.0, 2.0);
127 Vec3d p11(1.0, 1.0, 2.0);
128 Vec3d p12(0.0, 1.0, 2.0);
129
130 VertexHandle v1 = _mesh.add_vertex(p1);
131 VertexHandle v2 = _mesh.add_vertex(p2);
132 VertexHandle v3 = _mesh.add_vertex(p3);
133 VertexHandle v4 = _mesh.add_vertex(p4);
134
135 VertexHandle v5 = _mesh.add_vertex(p5);
136 VertexHandle v6 = _mesh.add_vertex(p6);
137 VertexHandle v7 = _mesh.add_vertex(p7);
138 VertexHandle v8 = _mesh.add_vertex(p8);
139
140 VertexHandle v9 = _mesh.add_vertex(p9);
141 VertexHandle v10 = _mesh.add_vertex(p10);
142 VertexHandle v11 = _mesh.add_vertex(p11);
143 VertexHandle v12 = _mesh.add_vertex(p12);
144
145 std::vector<VertexHandle> vertices;
146 vertices.push_back(v1); vertices.push_back(v2);
147 vertices.push_back(v3); vertices.push_back(v4);
148 FaceHandle f0 = _mesh.add_face(vertices);
149
150 vertices.clear();
151 vertices.push_back(v5); vertices.push_back(v6);
152 vertices.push_back(v7); vertices.push_back(v8);
153 FaceHandle f1 = _mesh.add_face(vertices);
154
155 vertices.clear();
156 vertices.push_back(v2); vertices.push_back(v6);
157 vertices.push_back(v7); vertices.push_back(v3);
158 FaceHandle f2 = _mesh.add_face(vertices);
159
160 vertices.clear();
161 vertices.push_back(v1); vertices.push_back(v5);
162 vertices.push_back(v8); vertices.push_back(v4);
163 FaceHandle f3 = _mesh.add_face(vertices);
164
165 vertices.clear();
166 vertices.push_back(v1); vertices.push_back(v2);
167 vertices.push_back(v6); vertices.push_back(v5);
168 FaceHandle f4 = _mesh.add_face(vertices);
169
170 vertices.clear();
171 vertices.push_back(v4); vertices.push_back(v3);
172 vertices.push_back(v7); vertices.push_back(v8);
173 FaceHandle f5 = _mesh.add_face(vertices);
174
175 // Add first cell
176 std::vector<HalfFaceHandle> halffaces;
177 halffaces.push_back(_mesh.halfface_handle(f0, 1)); halffaces.push_back(_mesh.halfface_handle(f1, 0));
178 halffaces.push_back(_mesh.halfface_handle(f2, 1)); halffaces.push_back(_mesh.halfface_handle(f3, 0));
179 halffaces.push_back(_mesh.halfface_handle(f4, 0)); halffaces.push_back(_mesh.halfface_handle(f5, 1));
180 _mesh.add_cell(halffaces);
181
182 vertices.clear();
183 vertices.push_back(v9); vertices.push_back(v10);
184 vertices.push_back(v11); vertices.push_back(v12);
185 FaceHandle f6 = _mesh.add_face(vertices);
186
187 vertices.clear();
188 vertices.push_back(v6); vertices.push_back(v10);
189 vertices.push_back(v11); vertices.push_back(v7);
190 FaceHandle f7 = _mesh.add_face(vertices);
191
192 vertices.clear();
193 vertices.push_back(v5); vertices.push_back(v9);
194 vertices.push_back(v12); vertices.push_back(v8);
195 FaceHandle f8 = _mesh.add_face(vertices);
196
197 vertices.clear();
198 vertices.push_back(v5); vertices.push_back(v6);
199 vertices.push_back(v10); vertices.push_back(v9);
200 FaceHandle f9 = _mesh.add_face(vertices);
201
202 vertices.clear();
203 vertices.push_back(v8); vertices.push_back(v7);
204 vertices.push_back(v11); vertices.push_back(v12);
205 FaceHandle f10 = _mesh.add_face(vertices);
206
207 halffaces.clear();
208 halffaces.push_back(_mesh.halfface_handle(f1, 1)); halffaces.push_back(_mesh.halfface_handle(f6, 0));
209 halffaces.push_back(_mesh.halfface_handle(f7, 1)); halffaces.push_back(_mesh.halfface_handle(f8, 0));
210 halffaces.push_back(_mesh.halfface_handle(f9, 0)); halffaces.push_back(_mesh.halfface_handle(f10, 1));
211 _mesh.add_cell(halffaces);
212 }
OpenVolumeMesh::Geometry
Definition: Vector11T.hh:59
OpenVolumeMesh::GeometryKernel::add_vertex
virtual VertexHandle add_vertex()
Override of empty add_vertex function.
Definition: GeometryKernel.hh:68
OpenVolumeMesh::Geometry::VectorT
Definition: Vector11T.hh:78
OpenVolumeMesh::GeometryKernel
Definition: GeometryKernel.hh:55