Debian Codegraph @

avogadro/qtgui/meshgenerator.cpp

raw
1 /******************************************************************************
2 This source file is part of the Avogadro project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #include "meshgenerator.h"
7
8 #include <avogadro/core/cube.h>
9 #include <avogadro/core/mesh.h>
10 #include <avogadro/core/mutex.h>
11
12 #include <QDebug>
13 #include <QReadWriteLock>
14
15 namespace Avogadro::QtGui {
16
17 using Core::Cube;
18 using Core::Mesh;
19
20 MeshGenerator::MeshGenerator(QObject* p)
21 : QThread(p), m_iso(0.0), m_passes(6), m_reverseWinding(false),
22 m_cube(nullptr), m_mesh(nullptr), m_stepSize(0.0, 0.0, 0.0),
23 m_min(0.0, 0.0, 0.0), m_dim(0, 0, 0), m_progmin(0), m_progmax(0)
24 {
25 }
26
27 MeshGenerator::MeshGenerator(const Cube* cube_, Mesh* mesh_, float iso,
28 int passes, bool reverse, QObject* p)
29 : QThread(p), m_iso(0.0), m_passes(6), m_reverseWinding(reverse),
30 m_cube(nullptr), m_mesh(nullptr), m_stepSize(0.0, 0.0, 0.0),
31 m_min(0.0, 0.0, 0.0), m_dim(0, 0, 0), m_progmin(0), m_progmax(0)
32 {
33 initialize(cube_, mesh_, iso, passes);
34 }
35
36 MeshGenerator::~MeshGenerator() {}
37
38 bool MeshGenerator::initialize(const Cube* cube_, Mesh* mesh_, float iso,
39 int passes, bool reverse)
40 {
41 if (!cube_ || !mesh_)
42 return false;
43 m_cube = cube_;
44 m_mesh = mesh_;
45 m_iso = iso;
46 m_passes = passes;
47 m_reverseWinding = reverse;
48
49 for (unsigned int i = 0; i < 3; ++i)
50 m_stepSize[i] = static_cast<float>(m_cube->spacing()[i]);
51 m_min = m_cube->min().cast<float>();
52 m_dim = m_cube->dimensions();
53 edgeCases.resize((m_dim.x() - 1) * (m_dim.y()) * (m_dim.z()));
54 cubeCases.resize((m_dim.x() - 1) * (m_dim.y() - 1) * (m_dim.z() - 1));
55 gridEdges.resize(m_dim.y() * m_dim.z());
56 triCounter.resize((m_dim.y() - 1) * (m_dim.z() - 1));
57
58 m_progmax = m_dim.x();
59
60 return true;
61 }
62
63 void MeshGenerator::FlyingEdgesAlgorithmPass1()
64 {
65 for (int k = 0; k != m_dim.z(); ++k) {
66 for (int j = 0; j != m_dim.y(); ++j) {
67
68 auto curEdgeCases =
69 edgeCases.begin() + (m_dim.x() - 1) * (k * m_dim.y() + j);
70 std::array<bool, 2> isGE;
71 isGE[0] = (m_cube->getData(0, j, k) >= m_iso);
72
73 for (int i = 1; i != m_dim.x(); ++i) {
74 isGE[i % 2] = (m_cube->getData(i, j, k) >= m_iso);
75 curEdgeCases[i - 1] = calcCaseEdge(isGE[(i + 1) % 2], isGE[i % 2]);
76 }
77 }
78 }
79
80 for (int k = 0; k != m_dim.z(); ++k) {
81 for (int j = 0; j != m_dim.y(); ++j) {
82 gridEdge& curGridEdge = gridEdges[k * m_dim.y() + j];
83 curGridEdge.xl = m_dim.x();
84
85 for (int i = 1; i != m_dim.x(); ++i) {
86 // if the edge is cut
87 if (isCutEdge(i - 1, j, k)) {
88 if (curGridEdge.xl == m_dim.x()) {
89 curGridEdge.xl = i - 1;
90 }
91 curGridEdge.xr = i;
92 }
93 }
94 }
95 }
96 }
97
98 void MeshGenerator::FlyingEdgesAlgorithmPass2()
99 {
100 for (int k = 0; k != m_dim.z() - 1; ++k) {
101 for (int j = 0; j != m_dim.y() - 1; ++j) {
102 int xl, xr;
103 calcTrimValues(xl, xr, j, k); // xl, xr set in this function
104
105 gridEdge& ge0 = gridEdges[k * m_dim.y() + j];
106 gridEdge& ge1 = gridEdges[k * m_dim.y() + j + 1];
107 gridEdge& ge2 = gridEdges[(k + 1) * m_dim.y() + j];
108 gridEdge& ge3 = gridEdges[(k + 1) * m_dim.y() + j + 1];
109
110 auto const& ec0 =
111 edgeCases.begin() + (m_dim.x() - 1) * (k * m_dim.y() + j);
112 auto const& ec1 =
113 edgeCases.begin() + (m_dim.x() - 1) * (k * m_dim.y() + j + 1);
114 auto const& ec2 =
115 edgeCases.begin() + (m_dim.x() - 1) * ((k + 1) * m_dim.y() + j);
116 auto const& ec3 =
117 edgeCases.begin() + (m_dim.x() - 1) * ((k + 1) * m_dim.y() + j + 1);
118
119 // Count the number of triangles along this row of cubes
120 int& curTriCounter = *(triCounter.begin() + k * (m_dim.y() - 1) + j);
121
122 auto curCubeCaseIds =
123 cubeCases.begin() + (m_dim.x() - 1) * (k * (m_dim.y() - 1) + j);
124
125 bool isYEnd = (j == m_dim.y() - 2);
126 bool isZEnd = (k == m_dim.z() - 2);
127
128 for (int i = xl; i != xr; ++i) {
129 bool isXEnd = (i == m_dim.x() - 2);
130
131 unsigned char caseId = calcCubeCase(
132 ec0[i], ec1[i], ec2[i], ec3[i]); // todo cubeCase not decleared
133 curCubeCaseIds[i] = caseId;
134
135 if (caseId == 0 || caseId == 255) {
136 continue;
137 }
138
139 curTriCounter += m_numTris[caseId]; // not declared
140
141 const bool* isCutCase = m_isCut[caseId]; // size 12
142
143 ge0.xstart += isCutCase[0];
144 ge0.ystart += isCutCase[3];
145 ge0.zstart += isCutCase[8];
146
147 if (isXEnd) {
148 ge0.ystart += isCutCase[1];
149 ge0.zstart += isCutCase[9];
150 }
151
152 if (isYEnd) {
153 ge1.xstart += isCutCase[2];
154 ge1.zstart += isCutCase[10];
155 }
156 if (isZEnd) {
157 ge2.xstart += isCutCase[4];
158 ge2.ystart += isCutCase[7];
159 }
160 if (isXEnd && isYEnd) {
161 ge1.zstart += isCutCase[11];
162 }
163 if (isXEnd && isZEnd) {
164 ge2.ystart += isCutCase[5];
165 }
166 if (isYEnd && isZEnd) {
167 ge3.xstart += isCutCase[6];
168 }
169 }
170 }
171 }
172 }
173
174 void MeshGenerator::FlyingEdgesAlgorithmPass3()
175 {
176 int tmp;
177 int triAccum = 0;
178 for (int k = 0; k != m_dim.z() - 1; ++k) {
179 for (int j = 0; j != m_dim.y() - 1; ++j) {
180 int& curTriCounter = triCounter[k * (m_dim.y() - 1) + j];
181
182 tmp = curTriCounter;
183 curTriCounter = triAccum;
184 triAccum += tmp;
185 }
186 }
187
188 int pointAccum = 0;
189 for (int k = 0; k != m_dim.z(); ++k) {
190 for (int j = 0; j != m_dim.y(); ++j) {
191 gridEdge& curGridEdge = gridEdges[(k * m_dim.y()) + j];
192
193 tmp = curGridEdge.xstart;
194 curGridEdge.xstart = pointAccum;
195 pointAccum += tmp;
196
197 tmp = curGridEdge.ystart;
198 curGridEdge.ystart = pointAccum;
199 pointAccum += tmp;
200
201 tmp = curGridEdge.zstart;
202 curGridEdge.zstart = pointAccum;
203 pointAccum += tmp;
204 }
205 }
206
207 m_vertices.resize(pointAccum);
208 m_normals.resize(pointAccum);
209 m_triangles.resize(triAccum);
210 }
211
212 void MeshGenerator::FlyingEdgesAlgorithmPass4()
213 {
214
215 for (int k = 0; k != m_dim.z() - 1; ++k) {
216 for (int j = 0; j != m_dim.y() - 1; ++j) {
217 // find adjusted trim values
218 int xl, xr;
219 calcTrimValues(xl, xr, j, k); // xl, xr set in this function
220
221 if (xl == xr)
222 continue;
223
224 int triIdx = triCounter[(k * (m_dim.y() - 1)) + j];
225 auto curCubeCaseIds =
226 cubeCases.begin() + (m_dim.x() - 1) * (k * (m_dim.y() - 1) + j);
227
228 gridEdge const& ge0 = gridEdges[k * m_dim.y() + j];
229 gridEdge const& ge1 = gridEdges[k * m_dim.y() + j + 1];
230 gridEdge const& ge2 = gridEdges[(k + 1) * m_dim.y() + j];
231 gridEdge const& ge3 = gridEdges[(k + 1) * m_dim.y() + j + 1];
232
233 int x0counter = 0;
234 int y0counter = 0;
235 int z0counter = 0;
236
237 int x1counter = 0;
238 int z1counter = 0;
239
240 int x2counter = 0;
241 int y2counter = 0;
242
243 int x3counter = 0;
244
245 bool isYEnd = (j == m_dim.y() - 2);
246 bool isZEnd = (k == m_dim.z() - 2);
247
248 for (int i = xl; i != xr; ++i) {
249 bool isXEnd = (i == m_dim.x() - 2);
250
251 unsigned char caseId = curCubeCaseIds[i];
252
253 if (caseId == 0 || caseId == 255) {
254 continue;
255 }
256
257 const bool* isCutCase = m_isCut[caseId]; // size 12
258 std::array<std::array<float, 3>, 8> pointCube =
259 m_cube->getPosCube(i, j, k);
260 std::array<float, 8> isovalCube = m_cube->getValsCube(i, j, k);
261 std::array<std::array<float, 3>, 8> gradCube =
262 m_cube->getGradCube(i, j, k);
263
264 // Add Points and normals.
265 // Calculate global indices for triangles
266 std::array<int, 12> globalIdxs;
267
268 if (isCutCase[0]) {
269 // points-> array<vector3f>
270 int idx = ge0.xstart + x0counter;
271 std::array<float, 3> interpolatedPoint =
272 interpolateOnCube(pointCube, isovalCube, 0);
273 std::array<float, 3> interpolatedNormal =
274 interpolateOnCube(gradCube, isovalCube, 0);
275
276 m_vertices[idx] = Vector3f(interpolatedPoint[0], interpolatedPoint[1],
277 interpolatedPoint[2]);
278 m_normals[idx] =
279 Vector3f(interpolatedNormal[0], interpolatedNormal[1],
280 interpolatedNormal[2]);
281 globalIdxs[0] = idx;
282 ++x0counter;
283 }
284
285 if (isCutCase[3]) {
286 int idx = ge0.ystart + y0counter;
287 std::array<float, 3> interpolatedPoint =
288 interpolateOnCube(pointCube, isovalCube, 3);
289 std::array<float, 3> interpolatedNormal =
290 interpolateOnCube(gradCube, isovalCube, 3);
291 m_vertices[idx] = Vector3f(interpolatedPoint[0], interpolatedPoint[1],
292 interpolatedPoint[2]);
293 m_normals[idx] =
294 Vector3f(interpolatedNormal[0], interpolatedNormal[1],
295 interpolatedNormal[2]);
296 globalIdxs[3] = idx;
297 ++y0counter;
298 }
299
300 if (isCutCase[8]) {
301 int idx = ge0.zstart + z0counter;
302 std::array<float, 3> interpolatedPoint =
303 interpolateOnCube(pointCube, isovalCube, 8);
304 std::array<float, 3> interpolatedNormal =
305 interpolateOnCube(gradCube, isovalCube, 8);
306 m_vertices[idx] = Vector3f(interpolatedPoint[0], interpolatedPoint[1],
307 interpolatedPoint[2]);
308 m_normals[idx] =
309 Vector3f(interpolatedNormal[0], interpolatedNormal[1],
310 interpolatedNormal[2]);
311 globalIdxs[8] = idx;
312 ++z0counter;
313 }
314
315 if (isCutCase[1]) {
316 int idx = ge0.ystart + y0counter;
317 if (isXEnd) {
318 std::array<float, 3> interpolatedPoint =
319 interpolateOnCube(pointCube, isovalCube, 1);
320 std::array<float, 3> interpolatedNormal =
321 interpolateOnCube(gradCube, isovalCube, 1);
322 m_vertices[idx] = Vector3f(
323 interpolatedPoint[0], interpolatedPoint[1], interpolatedPoint[2]);
324 m_normals[idx] =
325 Vector3f(interpolatedNormal[0], interpolatedNormal[1],
326 interpolatedNormal[2]);
327 // y0counter counter doesn't need to be incremented
328 // because it won't be used again.
329 }
330 globalIdxs[1] = idx;
331 }
332
333 if (isCutCase[9]) {
334 int idx = ge0.zstart + z0counter;
335 if (isXEnd) {
336 std::array<float, 3> interpolatedPoint =
337 interpolateOnCube(pointCube, isovalCube, 9);
338 std::array<float, 3> interpolatedNormal =
339 interpolateOnCube(gradCube, isovalCube, 9);
340 m_vertices[idx] = Vector3f(
341 interpolatedPoint[0], interpolatedPoint[1], interpolatedPoint[2]);
342 m_normals[idx] =
343 Vector3f(interpolatedNormal[0], interpolatedNormal[1],
344 interpolatedNormal[2]);
345 // z0counter doesn't need to in incremented.
346 }
347 globalIdxs[9] = idx;
348 }
349
350 if (isCutCase[2]) {
351 int idx = ge1.xstart + x1counter;
352 if (isYEnd) {
353 std::array<float, 3> interpolatedPoint =
354 interpolateOnCube(pointCube, isovalCube, 2);
355 std::array<float, 3> interpolatedNormal =
356 interpolateOnCube(gradCube, isovalCube, 2);
357 m_vertices[idx] = Vector3f(
358 interpolatedPoint[0], interpolatedPoint[1], interpolatedPoint[2]);
359 m_normals[idx] =
360 Vector3f(interpolatedNormal[0], interpolatedNormal[1],
361 interpolatedNormal[2]);
362 }
363 globalIdxs[2] = idx;
364 ++x1counter;
365 }
366
367 if (isCutCase[10]) {
368 int idx = ge1.zstart + z1counter;
369
370 if (isYEnd) {
371 std::array<float, 3> interpolatedPoint =
372 interpolateOnCube(pointCube, isovalCube, 10);
373 std::array<float, 3> interpolatedNormal =
374 interpolateOnCube(gradCube, isovalCube, 10);
375
376 m_vertices[idx] = Vector3f(
377 interpolatedPoint[0], interpolatedPoint[1], interpolatedPoint[2]);
378 m_normals[idx] =
379 Vector3f(interpolatedNormal[0], interpolatedNormal[1],
380 interpolatedNormal[2]);
381 }
382 globalIdxs[10] = idx;
383 ++z1counter;
384 }
385
386 if (isCutCase[4]) {
387 int idx = ge2.xstart + x2counter;
388 if (isZEnd) {
389 std::array<float, 3> interpolatedPoint =
390 interpolateOnCube(pointCube, isovalCube, 4);
391
392 std::array<float, 3> interpolatedNormal =
393 interpolateOnCube(gradCube, isovalCube, 4);
394
395 m_vertices[idx] = Vector3f(
396 interpolatedPoint[0], interpolatedPoint[1], interpolatedPoint[2]);
397 m_normals[idx] =
398 Vector3f(interpolatedNormal[0], interpolatedNormal[1],
399 interpolatedNormal[2]);
400 }
401 globalIdxs[4] = idx;
402 ++x2counter;
403 }
404
405 if (isCutCase[7]) {
406 int idx = ge2.ystart + y2counter;
407 if (isZEnd) {
408 std::array<float, 3> interpolatedPoint =
409 interpolateOnCube(pointCube, isovalCube, 7);
410
411 std::array<float, 3> interpolatedNormal =
412 interpolateOnCube(gradCube, isovalCube, 7);
413
414 m_vertices[idx] = Vector3f(
415 interpolatedPoint[0], interpolatedPoint[1], interpolatedPoint[2]);
416 m_normals[idx] =
417 Vector3f(interpolatedNormal[0], interpolatedNormal[1],
418 interpolatedNormal[2]);
419 }
420 globalIdxs[7] = idx;
421 ++y2counter;
422 }
423
424 if (isCutCase[11]) {
425 int idx = ge1.zstart + z1counter;
426 if (isXEnd && isYEnd) {
427 std::array<float, 3> interpolatedPoint =
428 interpolateOnCube(pointCube, isovalCube, 11);
429
430 std::array<float, 3> interpolatedNormal =
431 interpolateOnCube(gradCube, isovalCube, 11);
432
433 m_vertices[idx] = Vector3f(
434 interpolatedPoint[0], interpolatedPoint[1], interpolatedPoint[2]);
435 m_normals[idx] =
436 Vector3f(interpolatedNormal[0], interpolatedNormal[1],
437 interpolatedNormal[2]);
438 }
439 globalIdxs[11] = idx;
440 }
441
442 if (isCutCase[5]) {
443 int idx = ge2.ystart + y2counter;
444 if (isXEnd && isZEnd) {
445 std::array<float, 3> interpolatedPoint =
446 interpolateOnCube(pointCube, isovalCube, 5);
447
448 std::array<float, 3> interpolatedNormal =
449 interpolateOnCube(gradCube, isovalCube, 5);
450
451 m_vertices[idx] = Vector3f(
452 interpolatedPoint[0], interpolatedPoint[1], interpolatedPoint[2]);
453 m_normals[idx] =
454 Vector3f(interpolatedNormal[0], interpolatedNormal[1],
455 interpolatedNormal[2]);
456 // y2 counter does not need to be incremented.
457 }
458 globalIdxs[5] = idx;
459 }
460
461 if (isCutCase[6]) {
462 int idx = ge3.xstart + x3counter;
463 if (isYEnd && isZEnd) {
464 std::array<float, 3> interpolatedPoint =
465 interpolateOnCube(pointCube, isovalCube, 6);
466 std::array<float, 3> interpolatedNormal =
467 interpolateOnCube(gradCube, isovalCube, 6);
468
469 m_vertices[idx] = Vector3f(
470 interpolatedPoint[0], interpolatedPoint[1], interpolatedPoint[2]);
471 m_normals[idx] =
472 Vector3f(interpolatedNormal[0], interpolatedNormal[1],
473 interpolatedNormal[2]);
474 }
475 globalIdxs[6] = idx;
476 ++x3counter;
477 }
478
479 // Add triangles
480 const signed char* caseTri = m_caseTriangles[caseId]; // size 16
481 for (int idx = 0; caseTri[idx] != -1; idx += 3) {
482 if (!m_reverseWinding) {
483 // Reverse winding order by swapping vertices 1 and 2
484 m_triangles[triIdx][0] = globalIdxs[caseTri[idx]];
485 m_triangles[triIdx][1] = globalIdxs[caseTri[idx + 2]];
486 m_triangles[triIdx][2] = globalIdxs[caseTri[idx + 1]];
487 } else {
488 m_triangles[triIdx][0] = globalIdxs[caseTri[idx]];
489 m_triangles[triIdx][1] = globalIdxs[caseTri[idx + 1]];
490 m_triangles[triIdx][2] = globalIdxs[caseTri[idx + 2]];
491 }
492 ++triIdx;
493 }
494 }
495 }
496 }
497 }
498
499 void MeshGenerator::run()
500 {
501 if (!m_cube || !m_mesh) {
502 qDebug() << "No mesh or cube set - nothing to find isosurface of…";
503 return;
504 }
505
506 m_mesh->setStable(false);
507 m_mesh->clear();
508
509 // flying-edges passes for the creation of normal, vertices and triangles
510 FlyingEdgesAlgorithmPass1();
511 FlyingEdgesAlgorithmPass2();
512 FlyingEdgesAlgorithmPass3();
513 FlyingEdgesAlgorithmPass4();
514
515 m_mesh->setVertices(m_vertices);
516 m_mesh->setNormals(m_normals);
517 m_mesh->setTriangles(m_triangles);
518 m_mesh->smooth(m_passes);
519 m_mesh->setStable(true);
520
521 // clearing the memory
522 m_vertices.resize(0);
523 m_normals.resize(0);
524 m_triangles.resize(0);
525 edgeCases.resize(0);
526 cubeCases.resize(0);
527 gridEdges.resize(0);
528 triCounter.resize(0);
529 }
530
531 void MeshGenerator::clear()
532 {
533 m_iso = 0.0;
534 m_passes = 6;
535 m_cube = nullptr;
536 m_mesh = nullptr;
537 m_stepSize.setZero();
538 m_min.setZero();
539 m_dim.setZero();
540 m_progmin = 0;
541 m_progmax = 0;
542 }
543
544 unsigned char MeshGenerator::calcCubeCase(unsigned char const& ec0,
545 unsigned char const& ec1,
546 unsigned char const& ec2,
547 unsigned char const& ec3) const
548 {
549 unsigned char caseId = 0;
550 if ((ec0 == 0) || (ec0 == 2)) // Vertex 0 at (i, j, k)
551 caseId |= 1;
552 if ((ec0 == 0) || (ec0 == 1)) // Vertex 1 at (i+1, j, k)
553 caseId |= 2;
554 if ((ec1 == 0) || (ec1 == 1)) // Vertex 2 at (i+1, j+1, k)
555 caseId |= 4;
556 if ((ec1 == 0) || (ec1 == 2)) // Vertex 3 at (i, j+1, k)
557 caseId |= 8;
558 if ((ec2 == 0) || (ec2 == 2)) // Vertex 4 at (i, j, k+1)
559 caseId |= 16;
560 if ((ec2 == 0) || (ec2 == 1)) // Vertex 5 at (i+1, j, k+1)
561 caseId |= 32;
562 if ((ec3 == 0) || (ec3 == 1)) // Vertex 6 at (i+1, j+1, k+1)
563 caseId |= 64;
564 if ((ec3 == 0) || (ec3 == 2)) // Vertex 7 at (i, j+1, k+1)
565 caseId |= 128;
566 return caseId;
567 }
568
569 bool MeshGenerator::isCutEdge(int const& i, int const& j, int const& k) const
570 {
571 // Assuming edgeCases are all set
572 int edgeCaseIdx =
573 k * ((m_dim.x() - 1) * m_dim.y()) + (j * (m_dim.x() - 1)) + i;
574 unsigned char edgeCase = edgeCases[edgeCaseIdx];
575
576 if (edgeCase == 1 || edgeCase == 2) {
577 return true;
578 }
579
580 if (j != m_dim.y() - 1) {
581 int edgeCaseIdxY =
582 (k * (m_dim.x() - 1) * m_dim.y()) + ((j + 1) * (m_dim.x() - 1)) + i;
583 unsigned char edgeCaseY = edgeCases[edgeCaseIdxY];
584
585 // If the sum is odd, the edge along the y-axis is cut
586 if ((edgeCase + edgeCaseY) % 2 == 1) {
587 return true;
588 }
589 }
590
591 if (k != m_dim.z() - 1) {
592 int edgeCaseIdxZ =
593 ((k + 1) * (m_dim.x() - 1) * m_dim.y()) + (j * (m_dim.x() - 1)) + i;
594 unsigned char edgeCaseZ = edgeCases[edgeCaseIdxZ];
595
596 // If the sum is odd, the edge along the z-axis is cut
597 if ((edgeCase + edgeCaseZ) % 2 == 1) {
598 return true;
599 }
600 }
601 return false;
602 }
603
604 unsigned char MeshGenerator::calcCaseEdge(bool const& prevEdge,
605 bool const& currEdge) const
606 {
607 // o -- is greater than or equal to
608 // case 0: prevEdge = true, currEdge = true
609 // case 1: prevEdge = false, currEdge = true
610 // case 2: prevEdge = true, currEdge = false
611 // case 3: prevEdge = false, currEdge = false
612 if (prevEdge && currEdge)
613 return 0;
614 if (!prevEdge && currEdge)
615 return 1;
616 if (prevEdge && !currEdge)
617 return 2;
618 else // !prevEdge && !currEdge
619 return 3;
620 }
621
622 unsigned long MeshGenerator::duplicate(const Vector3i&, const Vector3f&)
623 {
624 // FIXME Not implemented yet.
625 return 0;
626 }
627
628 void MeshGenerator::calcTrimValues(int& xl, int& xr, int const& j,
629 int const& k) const
630 {
631
632 const gridEdge& ge0 = gridEdges[k * m_dim.y() + j];
633 const gridEdge& ge1 = gridEdges[k * m_dim.y() + j + 1];
634 const gridEdge& ge2 = gridEdges[(k + 1) * m_dim.y() + j];
635 const gridEdge& ge3 = gridEdges[(k + 1) * m_dim.y() + j + 1];
636
637 xl = std::min({ ge0.xl, ge1.xl, ge2.xl, ge3.xl });
638 xr = std::max({ ge0.xr, ge1.xr, ge2.xr, ge3.xr });
639
640 if (xl > xr)
641 xl = xr;
642 }
643
644 inline std::array<float, 3> MeshGenerator::interpolateOnCube(
645 std::array<std::array<float, 3>, 8> const& pts,
646 std::array<float, 8> const& isovals, unsigned char const& edge) const
647 {
648 unsigned char i0 = m_edgeVertices[edge][0];
649 unsigned char i1 = m_edgeVertices[edge][1];
650
651 float weight = (m_iso - isovals[i0]) / (isovals[i1] - isovals[i0]);
652 return interpolate(pts[i0], pts[i1], weight);
653 }
654
655 inline std::array<float, 3> MeshGenerator::interpolate(
656 std::array<float, 3> const& a, std::array<float, 3> const& b,
657 float const& weight) const
658 {
659 std::array<float, 3> ret;
660 ret[0] = a[0] + (weight * (b[0] - a[0]));
661 ret[1] = a[1] + (weight * (b[1] - a[1]));
662 ret[2] = a[2] + (weight * (b[2] - a[2]));
663 return ret;
664 }
665
666 // flying edges tables using:
667
668 const unsigned char MeshGenerator::m_numTris[256] = {
669 // clang-format off
670 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 2,
671 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 3,
672 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 3,
673 2, 3, 3, 2, 3, 4, 4, 3, 3, 4, 4, 3, 4, 5, 5, 2,
674 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 3,
675 2, 3, 3, 4, 3,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0, 0, 1 },
926 { 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0 },
927 { 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0 },
928 { 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0 },
929 { 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0 },
930 { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 },
931 { 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1 },
932 { 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1 },
933 { 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1 },
934 { 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0 },
935 { 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0 },
936 { 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0 },
937 { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0 },
938 { 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1 },
939 { 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1 },
940 { 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1 },
941 { 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
942 { 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0 },
943 { 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 },
944 { 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0 },
945 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
946 };
947
948 const signed char MeshGenerator::m_caseTriangles[256][16]{
949 { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
950 { 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
951 { 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
952 { 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
953 { 1, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
954 { 0, 3, 8, 1, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
955 { 9, 11, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
956 { 2, 3, 8, 2, 8, 11, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1 },
957 { 3, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
958 { 0, 2, 10, 8, 0, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
959 { 1, 0, 9, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
960 { 1, 2, 10, 1, 10, 9, 9, 10, 8, -1, -1, -1, -1, -1, -1, -1 },
961 { 3, 1, 11, 10, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
962 { 0, 1, 11, 0, 11, 8, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1 },
963 { 3, 0, 9, 3, 9, 10, 10, 9, 11, -1, -1, -1, -1, -1, -1, -1 },
964 { 9, 11, 8, 11, 10, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
965 { 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
966 { 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
967 { 0, 9, 1, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
968 { 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1 },
969 { 1, 11, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
970 { 3, 7, 4, 3, 4, 0, 1, 11, 2, -1, -1, -1, -1, -1, -1, -1 },
971 { 9, 11, 2, 9, 2, 0, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1 },
972 { 2, 9, 11, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1 },
973 { 8, 7, 4, 3, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
974 { 10, 7, 4, 10, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1 },
975 { 9, 1, 0, 8, 7, 4, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1 },
976 { 4, 10, 7, 9, 10, 4, 9, 2, 10, 9, 1, 2, -1, -1, -1, -1 },
977 { 3, 1, 11, 3, 11, 10, 7, 4, 8, -1, -1, -1, -1, -1, -1, -1 },
978 { 1, 11, 10, 1, 10, 4, 1, 4, 0, 7, 4, 10, -1, -1, -1, -1 },
979 { 4, 8, 7, 9, 10, 0, 9, 11, 10, 10, 3, 0, -1, -1, -1, -1 },
980 { 4, 10, 7, 4, 9, 10, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1 },
981 { 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
982 { 9, 4, 5, 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
983 { 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
984 { 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1 },
985 { 1, 11, 2, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
986 { 3, 8, 0, 1, 11, 2, 4, 5, 9, -1, -1, -1, -1, -1, -1, -1 },
987 { 5, 11, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1 },
988 { 2, 5, 11, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1 },
989 { 9, 4, 5, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
990 { 0, 2, 10, 0, 10, 8, 4, 5, 9, -1, -1, -1, -1, -1, -1, -1 },
991 { 0, 4, 5, 0, 5, 1, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1 },
992 { 2, 5, 1, 2, 8, 5, 2, 10, 8, 4, 5, 8, -1, -1, -1, -1 },
993 { 11, 10, 3, 11, 3, 1, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1 },
994 { 4, 5, 9, 0, 1, 8, 8, 1, 11, 8, 11, 10, -1, -1, -1, -1 },
995 { 5, 0, 4, 5, 10, 0, 5, 11, 10, 10, 3, 0, -1, -1, -1, -1 },
996 { 5, 8, 4, 5, 11, 8, 11, 10, 8, -1, -1, -1, -1, -1, -1, -1 },
997 { 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
998 { 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1 },
999 { 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1 },
1000 { 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1001 { 9, 8, 7, 9, 7, 5, 11, 2, 1, -1, -1, -1, -1, -1, -1, -1 },
1002 { 11, 2, 1, 9, 0, 5, 5, 0, 3, 5, 3, 7, -1, -1, -1, -1 },
1003 { 8, 2, 0, 8, 5, 2, 8, 7, 5, 11, 2, 5, -1, -1, -1, -1 },
1004 { 2, 5, 11, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1 },
1005 { 7, 5, 9, 7, 9, 8, 3, 2, 10, -1, -1, -1, -1, -1, -1, -1 },
1006 { 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 10, 7, -1, -1, -1, -1 },
1007 { 2, 10, 3, 0, 8, 1, 1, 8, 7, 1, 7, 5, -1, -1, -1, -1 },
1008 { 10, 1, 2, 10, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1 },
1009 { 9, 8, 5, 8, 7, 5, 11, 3, 1, 11, 10, 3, -1, -1, -1, -1 },
1010 { 5, 0, 7, 5, 9, 0, 7, 0, 10, 1, 11, 0, 10, 0, 11, -1 },
1011 { 10, 0, 11, 10, 3, 0, 11, 0, 5, 8, 7, 0, 5, 0, 7, -1 },
1012 { 10, 5, 11, 7, 5, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1013 { 11, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1014 { 0, 3, 8, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1015 { 9, 1, 0, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1016 { 1, 3, 8, 1, 8, 9, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1 },
1017 { 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1018 { 1, 5, 6, 1, 6, 2, 3, 8, 0, -1, -1, -1, -1, -1, -1, -1 },
1019 { 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1 },
1020 { 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1 },
1021 { 2, 10, 3, 11, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1022 { 10, 8, 0, 10, 0, 2, 11, 5, 6, -1, -1, -1, -1, -1, -1, -1 },
1023 { 0, 9, 1, 2, 10, 3, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1 },
1024 { 5, 6, 11, 1, 2, 9, 9, 2, 10, 9, 10, 8, -1, -1, -1, -1 },
1025 { 6, 10, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1 },
1026 { 0, 10, 8, 0, 5, 10, 0, 1, 5, 5, 6, 10, -1, -1, -1, -1 },
1027 { 3, 6, 10, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1 },
1028 { 6, 9, 5, 6, 10, 9, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1 },
1029 { 5, 6, 11, 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1030 { 4, 0, 3, 4, 3, 7, 6, 11, 5, -1, -1, -1, -1, -1, -1, -1 },
1031 { 1, 0, 9, 5, 6, 11, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1 },
1032 { 11, 5, 6, 1, 7, 9, 1, 3, 7, 7, 4, 9, -1, -1, -1, -1 },
1033 { 6, 2, 1, 6, 1, 5, 4, 8, 7, -1, -1, -1, -1, -1, -1, -1 },
1034 { 1, 5, 2, 5, 6, 2, 3, 4, 0, 3, 7, 4, -1, -1, -1, -1 },
1035 { 8, 7, 4, 9, 5, 0, 0, 5, 6, 0, 6, 2, -1, -1, -1, -1 },
1036 { 7, 9, 3, 7, 4, 9, 3, 9, 2, 5, 6, 9, 2, 9, 6, -1 },
1037 { 3, 2, 10, 7, 4, 8, 11, 5, 6, -1, -1, -1, -1, -1, -1, -1 },
1038 { 5, 6, 11, 4, 2, 7, 4, 0, 2, 2, 10, 7, -1, -1, -1, -1 },
1039 { 0, 9, 1, 4, 8, 7, 2, 10, 3, 5, 6, 11, -1, -1, -1, -1 },
1040 { 9, 1, 2, 9, 2, 10, 9, 10, 4, 7, 4, 10, 5, 6, 11, -1 },
1041 { 8, 7, 4, 3, 5, 10, 3, 1, 5, 5, 6, 10, -1, -1, -1, -1 },
1042 { 5, 10, 1, 5, 6, 10, 1, 10, 0, 7, 4, 10, 0, 10, 4, -1 },
1043 { 0, 9, 5, 0, 5, 6, 0, 6, 3, 10, 3, 6, 8, 7, 4, -1 },
1044 { 6, 9, 5, 6, 10, 9, 4, 9, 7, 7, 9, 10, -1, -1, -1, -1 },
1045 { 11, 9, 4, 6, 11, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1046 { 4, 6, 11, 4, 11, 9, 0, 3, 8, -1, -1, -1, -1, -1, -1, -1 },
1047 { 11, 1, 0, 11, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1 },
1048 { 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 11, 1, -1, -1, -1, -1 },
1049 { 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1 },
1050 { 3, 8, 0, 1, 9, 2, 2, 9, 4, 2, 4, 6, -1, -1, -1, -1 },
1051 { 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1052 { 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1 },
1053 { 11, 9, 4, 11, 4, 6, 10, 3, 2, -1, -1, -1, -1, -1, -1, -1 },
1054 { 0, 2, 8, 2, 10, 8, 4, 11, 9, 4, 6, 11, -1, -1, -1, -1 },
1055 { 3, 2, 10, 0, 6, 1, 0, 4, 6, 6, 11, 1, -1, -1, -1, -1 },
1056 { 6, 1, 4, 6, 11, 1, 4, 1, 8, 2, 10, 1, 8, 1, 10, -1 },
1057 { 9, 4, 6, 9, 6, 3, 9, 3, 1, 10, 3, 6, -1, -1, -1, -1 },
1058 { 8, 1, 10, 8, 0, 1, 10, 1, 6, 9, 4, 1, 6, 1, 4, -1 },
1059 { 3, 6, 10, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1 },
1060 { 6, 8, 4, 10, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1061 { 7, 6, 11, 7, 11, 8, 8, 11, 9, -1, -1, -1, -1, -1, -1, -1 },
1062 { 0, 3, 7, 0, 7, 11, 0, 11, 9, 6, 11, 7, -1, -1, -1, -1 },
1063 { 11, 7, 6, 1, 7, 11, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1 },
1064 { 11, 7, 6, 11, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1 },
1065 { 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1 },
1066 { 2, 9, 6, 2, 1, 9, 6, 9, 7, 0, 3, 9, 7, 9, 3, -1 },
1067 { 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1 },
1068 { 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1069 { 2, 10, 3, 11, 8, 6, 11, 9, 8, 8, 7, 6, -1, -1, -1, -1 },
1070 { 2, 7, 0, 2, 10, 7, 0, 7, 9, 6, 11, 7, 9, 7, 11, -1 },
1071 { 1, 0, 8, 1, 8, 7, 1, 7, 11, 6, 11, 7, 2, 10, 3, -1 },
1072 { 10, 1, 2, 10, 7, 1, 11, 1, 6, 6, 1, 7, -1, -1, -1, -1 },
1073 { 8, 6, 9, 8, 7, 6, 9, 6, 1, 10, 3, 6, 1, 6, 3, -1 },
1074 { 0, 1, 9, 10, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1075 { 7, 0, 8, 7, 6, 0, 3, 0, 10, 10, 0, 6, -1, -1, -1, -1 },
1076 { 7, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1077 { 7, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1078 { 3, 8, 0, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1079 { 0, 9, 1, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1080 { 8, 9, 1, 8, 1, 3, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1 },
1081 { 11, 2, 1, 6, 7, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1082 { 1, 11, 2, 3, 8, 0, 6, 7, 10, -1, -1, -1, -1, -1, -1, -1 },
1083 { 2, 0, 9, 2, 9, 11, 6, 7, 10, -1, -1, -1, -1, -1, -1, -1 },
1084 { 6, 7, 10, 2, 3, 11, 11, 3, 8, 11, 8, 9, -1, -1, -1, -1 },
1085 { 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1086 { 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1 },
1087 { 2, 6, 7, 2, 7, 3, 0, 9, 1, -1, -1, -1, -1, -1, -1, -1 },
1088 { 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1 },
1089 { 11, 6, 7, 11, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1 },
1090 { 11, 6, 7, 1, 11, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1 },
1091 { 0, 7, 3, 0, 11, 7, 0, 9, 11, 6, 7, 11, -1, -1, -1, -1 },
1092 { 7, 11, 6, 7, 8, 11, 8, 9, 11, -1, -1, -1, -1, -1, -1, -1 },
1093 { 6, 4, 8, 10, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1094 { 3, 10, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1 },
1095 { 8, 10, 6, 8, 6, 4, 9, 1, 0, -1, -1, -1, -1, -1, -1, -1 },
1096 { 9, 6, 4, 9, 3, 6, 9, 1, 3, 10, 6, 3, -1, -1, -1, -1 },
1097 { 6, 4, 8, 6, 8, 10, 2, 1, 11, -1, -1, -1, -1, -1, -1, -1 },
1098 { 1, 11, 2, 3, 10, 0, 0, 10, 6, 0, 6, 4, -1, -1, -1, -1 },
1099 { 4, 8, 10, 4, 10, 6, 0, 9, 2, 2, 9, 11, -1, -1, -1, -1 },
1100 { 11, 3, 9, 11, 2, 3, 9, 3, 4, 10, 6, 3, 4, 3, 6, -1 },
1101 { 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1 },
1102 { 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1103 { 1, 0, 9, 2, 4, 3, 2, 6, 4, 4, 8, 3, -1, -1, -1, -1 },
1104 { 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1 },
1105 { 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 11, -1, -1, -1, -1 },
1106 { 11, 0, 1, 11, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1 },
1107 { 4, 3, 6, 4, 8, 3, 6, 3, 11, 0, 9, 3, 11, 3, 9, -1 },
1108 { 11, 4, 9, 6, 4, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1109 { 4, 5, 9, 7, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1110 { 0, 3, 8, 4, 5, 9, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1 },
1111 { 5, 1, 0, 5, 0, 4, 7, 10, 6, -1, -1, -1, -1, -1, -1, -1 },
1112 { 10, 6, 7, 8, 4, 3, 3, 4, 5, 3, 5, 1, -1, -1, -1, -1 },
1113 { 9, 4, 5, 11, 2, 1, 7, 10, 6, -1, -1, -1, -1, -1, -1, -1 },
1114 { 6, 7, 10, 1, 11, 2, 0, 3, 8, 4, 5, 9, -1, -1, -1, -1 },
1115 { 7, 10, 6, 5, 11, 4, 4, 11, 2, 4, 2, 0, -1, -1, -1, -1 },
1116 { 3, 8, 4, 3, 4, 5, 3, 5, 2, 11, 2, 5, 10, 6, 7, -1 },
1117 { 7, 3, 2, 7, 2, 6, 5, 9, 4, -1, -1, -1, -1, -1, -1, -1 },
1118 { 9, 4, 5, 0, 6, 8, 0, 2, 6, 6, 7, 8, -1, -1, -1, -1 },
1119 { 3, 2, 6, 3, 6, 7, 1, 0, 5, 5, 0, 4, -1, -1, -1, -1 },
1120 { 6, 8, 2, 6, 7, 8, 2, 8, 1, 4, 5, 8, 1, 8, 5, -1 },
1121 { 9, 4, 5, 11, 6, 1, 1, 6, 7, 1, 7, 3, -1, -1, -1, -1 },
1122 { 1, 11, 6, 1, 6, 7, 1, 7, 0, 8, 0, 7, 9, 4, 5, -1 },
1123 { 4, 11, 0, 4, 5, 11, 0, 11, 3, 6, 7, 11, 3, 11, 7, -1 },
1124 { 7, 11, 6, 7, 8, 11, 5, 11, 4, 4, 11, 8, -1, -1, -1, -1 },
1125 { 6, 5, 9, 6, 9, 10, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1 },
1126 { 3, 10, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1 },
1127 { 0, 8, 10, 0, 10, 5, 0, 5, 1, 5, 10, 6, -1, -1, -1, -1 },
1128 { 6, 3, 10, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1 },
1129 { 1, 11, 2, 9, 10, 5, 9, 8, 10, 10, 6, 5, -1, -1, -1, -1 },
1130 { 0, 3, 10, 0, 10, 6, 0, 6, 9, 5, 9, 6, 1, 11, 2, -1 },
1131 { 10, 5, 8, 10, 6, 5, 8, 5, 0, 11, 2, 5, 0, 5, 2, -1 },
1132 { 6, 3, 10, 6, 5, 3, 2, 3, 11, 11, 3, 5, -1, -1, -1, -1 },
1133 { 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1 },
1134 { 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1 },
1135 { 1, 8, 5, 1, 0, 8, 5, 8, 6, 3, 2, 8, 6, 8, 2, -1 },
1136 { 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1137 { 1, 6, 3, 1, 11, 6, 3, 6, 8, 5, 9, 6, 8, 6, 9, -1 },
1138 { 11, 0, 1, 11, 6, 0, 9, 0, 5, 5, 0, 6, -1, -1, -1, -1 },
1139 { 0, 8, 3, 5, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1140 { 11, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1141 { 10, 11, 5, 7, 10, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1142 { 10, 11, 5, 10, 5, 7, 8, 0, 3, -1, -1, -1, -1, -1, -1, -1 },
1143 { 5, 7, 10, 5, 10, 11, 1, 0, 9, -1, -1, -1, -1, -1, -1, -1 },
1144 { 11, 5, 7, 11, 7, 10, 9, 1, 8, 8, 1, 3, -1, -1, -1, -1 },
1145 { 10, 2, 1, 10, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1 },
1146 { 0, 3, 8, 1, 7, 2, 1, 5, 7, 7, 10, 2, -1, -1, -1, -1 },
1147 { 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 10, -1, -1, -1, -1 },
1148 { 7, 2, 5, 7, 10, 2, 5, 2, 9, 3, 8, 2, 9, 2, 8, -1 },
1149 { 2, 11, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1 },
1150 { 8, 0, 2, 8, 2, 5, 8, 5, 7, 11, 5, 2, -1, -1, -1, -1 },
1151 { 9, 1, 0, 5, 3, 11, 5, 7, 3, 3, 2, 11, -1, -1, -1, -1 },
1152 { 9, 2, 8, 9, 1, 2, 8, 2, 7, 11, 5, 2, 7, 2, 5, -1 },
1153 { 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1154 { 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1 },
1155 { 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1 },
1156 { 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1157 { 5, 4, 8, 5, 8, 11, 11, 8, 10, -1, -1, -1, -1, -1, -1, -1 },
1158 { 5, 4, 0, 5, 0, 10, 5, 10, 11, 10, 0, 3, -1, -1, -1, -1 },
1159 { 0, 9, 1, 8, 11, 4, 8, 10, 11, 11, 5, 4, -1, -1, -1, -1 },
1160 { 11, 4, 10, 11, 5, 4, 10, 4, 3, 9, 1, 4, 3, 4, 1, -1 },
1161 { 2, 1, 5, 2, 5, 8, 2, 8, 10, 4, 8, 5, -1, -1, -1, -1 },
1162 { 0, 10, 4, 0, 3, 10, 4, 10, 5, 2, 1, 10, 5, 10, 1, -1 },
1163 { 0, 5, 2, 0, 9, 5, 2, 5, 10, 4, 8, 5, 10, 5, 8, -1 },
1164 { 9, 5, 4, 2, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1165 { 2, 11, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1 },
1166 { 5, 2, 11, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1 },
1167 { 3, 2, 11, 3, 11, 5, 3, 5, 8, 4, 8, 5, 0, 9, 1, -1 },
1168 { 5, 2, 11, 5, 4, 2, 1, 2, 9, 9, 2, 4, -1, -1, -1, -1 },
1169 { 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1 },
1170 { 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1171 { 8, 5, 4, 8, 3, 5, 9, 5, 0, 0, 5, 3, -1, -1, -1, -1 },
1172 { 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1173 { 4, 7, 10, 4, 10, 9, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1 },
1174 { 0, 3, 8, 4, 7, 9, 9, 7, 10, 9, 10, 11, -1, -1, -1, -1 },
1175 { 1, 10, 11, 1, 4, 10, 1, 0, 4, 7, 10, 4, -1, -1, -1, -1 },
1176 { 3, 4, 1, 3, 8, 4, 1, 4, 11, 7, 10, 4, 11, 4, 10, -1 },
1177 { 4, 7, 10, 9, 4, 10, 9, 10, 2, 9, 2, 1, -1, -1, -1, -1 },
1178 { 9, 4, 7, 9, 7, 10, 9, 10, 1, 2, 1, 10, 0, 3, 8, -1 },
1179 { 10, 4, 7, 10, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1 },
1180 { 10, 4, 7, 10, 2, 4, 8, 4, 3, 3, 4, 2, -1, -1, -1, -1 },
1181 { 2, 11, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1 },
1182 { 9, 7, 11, 9, 4, 7, 11, 7, 2, 8, 0, 7, 2, 7, 0, -1 },
1183 { 3, 11, 7, 3, 2, 11, 7, 11, 4, 1, 0, 11, 4, 11, 0, -1 },
1184 { 1, 2, 11, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1185 { 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1 },
1186 { 4, 1, 9, 4, 7, 1, 0, 1, 8, 8, 1, 7, -1, -1, -1, -1 },
1187 { 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1188 { 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1189 { 9, 8, 11, 11, 8, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1190 { 3, 9, 0, 3, 10, 9, 10, 11, 9, -1, -1, -1, -1, -1, -1, -1 },
1191 { 0, 11, 1, 0, 8, 11, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1 },
1192 { 3, 11, 1, 10, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1193 { 1, 10, 2, 1, 9, 10, 9, 8, 10, -1, -1, -1, -1, -1, -1, -1 },
1194 { 3, 9, 0, 3, 10, 9, 1, 9, 2, 2, 9, 10, -1, -1, -1, -1 },
1195 { 0, 10, 2, 8, 10, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1196 { 3, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1197 { 2, 8, 3, 2, 11, 8, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1 },
1198 { 9, 2, 11, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1199 { 2, 8, 3, 2, 11, 8, 0, 8, 1, 1, 8, 11, -1, -1, -1, -1 },
1200 { 1, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1201 { 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1202 { 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1203 { 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
1204 { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }
1205 };
1206
1207 const unsigned char MeshGenerator::m_edgeVertices[12][2] = {
1208 { 0, 1 }, { 1, 2 }, { 3, 2 }, { 0, 3 }, { 4, 5 }, { 5, 6 },
1209 { 7, 6 }, { 4, 7 }, { 0, 4 }, { 1, 5 }, { 3, 7 }, { 2, 6 }
1210 };
1211
1212 } // namespace Avogadro::QtGui