Allink  v0.1
VarDataMarchCubes.cpp
1 #include "VarData.h"
2 
3 //
4 // Marching Cubes Example Program
5 // by Cory Bloyd (corysama@yahoo.com)
6 //
7 // A simple, portable and complete implementation of the Marching Cubes
8 // and Marching Tetrahedrons algorithms in a single source file.
9 // There are many ways that this code could be made faster, but the
10 // intent is for the code to be easy to understand.
11 //
12 // For a description of the algorithm go to
13 // http://astronomy.swin.edu.au/pbourke/modelling/polygonise/
14 //
15 // This code is public domain.
16 //
17 XYZ VertexInterp(double isolevel,XYZ p1,XYZ p2,double valp1,double valp2);
18 int PolygoniseCube(GRIDCELL g,double iso,VAR_TRIANGLE *tri);
19 int PolygoniseSquare(GRIDCELL g,double iso,VAR_LINE *tri);
20 XYZ TriangNorm(XYZ p1,XYZ p2,XYZ p3);
21 VAR_TRIANGLE *VarData::MarchingCubes(double *Plot,int NSample,double IsoLevel,int *NTriang){
22  int NTri = 0;
23  double InvNSample = 1./(double)NSample;
24  int NVertex = 2*NSample-1;
25  GRIDCELL Grid;
26  VAR_TRIANGLE triangles[10];
27  VAR_TRIANGLE *Triang = NULL;
28  for(int sx = 0;sx<NSample-1;sx++){
29  for(int sy = 0;sy<NSample-1;sy++){
30  for(int sz = 0;sz<NSample-1;sz++){
31  Grid.p[0].x[0] = (sx)*InvNSample*pEdge(0);
32  Grid.p[0].x[1] = (sy)*InvNSample*pEdge(1);
33  Grid.p[0].x[2] = (sz)*InvNSample*pEdge(2);
34  Grid.val[0] = Plot[((sx)*NSample+(sy))*NSample+sz];
35  Grid.p[1].x[0] = (sx+1)*InvNSample*pEdge(0);
36  Grid.p[1].x[1] = (sy)*InvNSample*pEdge(1);
37  Grid.p[1].x[2] = (sz)*InvNSample*pEdge(2);
38  Grid.val[1] = Plot[((sx+1)*NSample+(sy))*NSample+sz];
39  Grid.p[2].x[0] = (sx+1)*InvNSample*pEdge(0);
40  Grid.p[2].x[1] = (sy+1)*InvNSample*pEdge(1);
41  Grid.p[2].x[2] = (sz)*InvNSample*pEdge(2);
42  Grid.val[2] = Plot[((sx+1)*NSample+(sy+1))*NSample+sz];
43  Grid.p[3].x[0] = (sx)*InvNSample*pEdge(0);
44  Grid.p[3].x[1] = (sy+1)*InvNSample*pEdge(1);
45  Grid.p[3].x[2] = (sz)*InvNSample*pEdge(2);
46  Grid.val[3] = Plot[((sx)*NSample+(sy+1))*NSample+sz];
47  Grid.p[4].x[0] = (sx)*InvNSample*pEdge(0);
48  Grid.p[4].x[1] = (sy)*InvNSample*pEdge(1);
49  Grid.p[4].x[2] = (sz+1)*InvNSample*pEdge(2);
50  Grid.val[4] = Plot[((sx)*NSample+(sy))*NSample+sz+1];
51  Grid.p[5].x[0] = (sx+1)*InvNSample*pEdge(0);
52  Grid.p[5].x[1] = (sy)*InvNSample*pEdge(1);
53  Grid.p[5].x[2] = (sz+1)*InvNSample*pEdge(2);
54  Grid.val[5] = Plot[((sx+1)*NSample+(sy))*NSample+sz+1];
55  Grid.p[6].x[0] = (sx+1)*InvNSample*pEdge(0);
56  Grid.p[6].x[1] = (sy+1)*InvNSample*pEdge(1);
57  Grid.p[6].x[2] = (sz+1)*InvNSample*pEdge(2);
58  Grid.val[6] = Plot[((sx+1)*NSample+(sy+1))*NSample+sz+1];
59  Grid.p[7].x[0] = (sx)*InvNSample*pEdge(0);
60  Grid.p[7].x[1] = (sy+1)*InvNSample*pEdge(1);
61  Grid.p[7].x[2] = (sz+1)*InvNSample*pEdge(2);
62  Grid.val[7] = Plot[((sx)*NSample+(sy+1))*NSample+sz+1];
63  int n = PolygoniseCube(Grid,IsoLevel,triangles);
64  Triang = (VAR_TRIANGLE *)realloc(Triang,(NTri+n)*sizeof(VAR_TRIANGLE));
65  int s[3];
66  for(int l=0;l<n;l++){
67  for(int v=0;v<3;v++){
68  for(int d=0;d<3;d++){
69  s[d] = (int)(triangles[l].p[v].x[d]*pInvEdge(d)*NVertex);
70  if(s[d] < 0 || s[d] >= NVertex){
71  printf("Marching: 0 <= sx %d < NVertex %d 0. < %lf < %lf\n",sx,NVertex,triangles[l].p[v].x[d],pEdge(d));
72  continue;
73  }
74  }
75  triangles[l].v[v] = (s[0]*NVertex+s[1])*NVertex+s[2];
76  }
77  Triang[NTri+l] = triangles[l];
78  }
79  NTri += n;
80  }
81  }
82  }
83  *NTriang = NTri;
84  return Triang;
85 }
94 int PolygoniseCube(GRIDCELL g,double iso,VAR_TRIANGLE *tri){
95  extern int edgeTable[256];
96  extern int triTable[256][16];
97  int i,ntri = 0;
98  int cubeindex;
99  XYZ vertlist[12];
100  double OneThird = 1./3.;
101  /*
102  Determine the index into the edge table which
103  tells us which vertices are inside of the surface
104  */
105  cubeindex = 0;
106  if (g.val[0] < iso) cubeindex |= 1;
107  if (g.val[1] < iso) cubeindex |= 2;
108  if (g.val[2] < iso) cubeindex |= 4;
109  if (g.val[3] < iso) cubeindex |= 8;
110  if (g.val[4] < iso) cubeindex |= 16;
111  if (g.val[5] < iso) cubeindex |= 32;
112  if (g.val[6] < iso) cubeindex |= 64;
113  if (g.val[7] < iso) cubeindex |= 128;
114 
115  /* Cube is entirely in/out of the surface */
116  if (edgeTable[cubeindex] == 0)
117  return(0);
118 
119  /* Find the vertices where the surface intersects the cube */
120  if (edgeTable[cubeindex] & 1) {
121  vertlist[0] = VertexInterp(iso,g.p[0],g.p[1],g.val[0],g.val[1]);
122  }
123  if (edgeTable[cubeindex] & 2) {
124  vertlist[1] = VertexInterp(iso,g.p[1],g.p[2],g.val[1],g.val[2]);
125  }
126  if (edgeTable[cubeindex] & 4) {
127  vertlist[2] = VertexInterp(iso,g.p[2],g.p[3],g.val[2],g.val[3]);
128  }
129  if (edgeTable[cubeindex] & 8) {
130  vertlist[3] = VertexInterp(iso,g.p[3],g.p[0],g.val[3],g.val[0]);
131  }
132  if (edgeTable[cubeindex] & 16) {
133  vertlist[4] = VertexInterp(iso,g.p[4],g.p[5],g.val[4],g.val[5]);
134  }
135  if (edgeTable[cubeindex] & 32) {
136  vertlist[5] = VertexInterp(iso,g.p[5],g.p[6],g.val[5],g.val[6]);
137  }
138  if (edgeTable[cubeindex] & 64) {
139  vertlist[6] = VertexInterp(iso,g.p[6],g.p[7],g.val[6],g.val[7]);
140  }
141  if (edgeTable[cubeindex] & 128) {
142  vertlist[7] = VertexInterp(iso,g.p[7],g.p[4],g.val[7],g.val[4]);
143  }
144  if (edgeTable[cubeindex] & 256) {
145  vertlist[8] = VertexInterp(iso,g.p[0],g.p[4],g.val[0],g.val[4]);
146  }
147  if (edgeTable[cubeindex] & 512) {
148  vertlist[9] = VertexInterp(iso,g.p[1],g.p[5],g.val[1],g.val[5]);
149  }
150  if (edgeTable[cubeindex] & 1024) {
151  vertlist[10] = VertexInterp(iso,g.p[2],g.p[6],g.val[2],g.val[6]);
152  }
153  if (edgeTable[cubeindex] & 2048) {
154  vertlist[11] = VertexInterp(iso,g.p[3],g.p[7],g.val[3],g.val[7]);
155  }
156  /* Create the triangles */
157  for (i=0;triTable[cubeindex][i]!=-1;i+=3) {
158  tri[ntri].p[0] = vertlist[triTable[cubeindex][i ]];
159  tri[ntri].p[1] = vertlist[triTable[cubeindex][i+1]];
160  tri[ntri].p[2] = vertlist[triTable[cubeindex][i+2]];
161  for(int d=0;d<3;d++){
162  tri[ntri].c.x[d] = (tri[ntri].p[0].x[d]+tri[ntri].p[1].x[d]+tri[ntri].p[2].x[d])*OneThird;
163  }
164  //TODO: Find the normal to the vertices,
165  // i.e. how the triangles are connected
166  tri[ntri].n[0] = TriangNorm(tri[ntri].p[0],tri[ntri].p[1],tri[ntri].p[2]);
167  tri[ntri].n[1] = TriangNorm(tri[ntri].p[0],tri[ntri].p[1],tri[ntri].p[2]);
168  tri[ntri].n[2] = TriangNorm(tri[ntri].p[0],tri[ntri].p[1],tri[ntri].p[2]);
169  //if(fabs(tri[ntri].n[0].x+tri[ntri].n[0].y+tri[ntri].n[0].z) <= 0.) continue;
170  ntri++;
171  }
172  return(ntri);
173 }
174 VAR_LINE *VarData::MarchingSquares(double *Plot,int NSample,double IsoLevel,int *NTriang){
175  int NTri = 0;
176  double InvNSample = 1./(double)NSample;
177  int NVertex = 2*NSample-1;
178  GRIDCELL Grid;
179  VAR_LINE triangles[4];
180  VAR_LINE *Triang = NULL;
181  for(int sx = 0;sx<NSample-1;sx++){
182  for(int sy = 0;sy<NSample-1;sy++){
183  Grid.p[0].x[0] = (sx)*InvNSample*pEdge(0);
184  Grid.p[0].x[1] = (sy)*InvNSample*pEdge(1);
185  Grid.p[0].x[2] = IsoLevel;
186  Grid.val[0] = Plot[(sx)*NSample+(sy)];
187  Grid.p[1].x[0] = (sx+1)*InvNSample*pEdge(0);
188  Grid.p[1].x[1] = (sy)*InvNSample*pEdge(1);
189  Grid.p[1].x[2] = IsoLevel;
190  Grid.val[1] = Plot[(sx+1)*NSample+(sy)];
191  Grid.p[2].x[0] = (sx+1)*InvNSample*pEdge(0);
192  Grid.p[2].x[1] = (sy+1)*InvNSample*pEdge(1);
193  Grid.p[2].x[2] = IsoLevel;
194  Grid.val[2] = Plot[(sx+1)*NSample+(sy+1)];
195  Grid.p[3].x[0] = (sx)*InvNSample*pEdge(0);
196  Grid.p[3].x[1] = (sy+1)*InvNSample*pEdge(1);
197  Grid.p[3].x[2] = IsoLevel;
198  Grid.val[3] = Plot[(sx)*NSample+(sy+1)];
199  int n = PolygoniseSquare(Grid,IsoLevel,triangles);
200  Triang = (VAR_LINE *)realloc(Triang,(NTri+n)*sizeof(VAR_LINE));
201  int s[3];
202  for(int l=0;l<n;l++){
203  for(int v=0;v<2;v++){
204  for(int d=0;d<2;d++){
205  s[d] = (int)(triangles[l].p[v].x[d]*pInvEdge(d)*NVertex);
206  if(s[d] < 0 || s[d] >= NVertex){
207  printf("Marching squares: 0 <= sx %d < NVertex %d 0. < %lf < %lf\n",s[d],NVertex,triangles[l].p[v].x[d],pEdge(d));
208  continue;
209  }
210  }
211  triangles[l].v[v] = s[0]*NVertex+s[1];
212  }
213  Triang[NTri+l] = triangles[l];
214  }
215  NTri += n;
216  }
217  }
218  *NTriang = NTri;
219  return Triang;
220 }
229 int PolygoniseSquare(GRIDCELL g,double iso,VAR_LINE *tri){
230  extern int edgeTable2d[16];
231  extern int triTable2d[16][4];
232  int i,ntri = 0;
233  int cubeindex;
234  XYZ vertlist[4];
235  XYZ Normal;
236  Normal.x[0] = 0.;
237  Normal.x[1] = 0.;
238  Normal.x[2] = 1.;
239  /*
240  Determine the index into the edge table which
241  tells us which vertices are inside of the surface
242  */
243  cubeindex = 0;
244  if (g.val[0] < iso) cubeindex |= 1;
245  if (g.val[1] < iso) cubeindex |= 2;
246  if (g.val[2] < iso) cubeindex |= 4;
247  if (g.val[3] < iso) cubeindex |= 8;
248  /* Square is entirely in/out of the surface */
249  if (edgeTable2d[cubeindex] == 0)
250  return(0);
251  /* Find the vertices where the surface intersects the cube */
252  if (edgeTable2d[cubeindex] & 1) {
253  vertlist[0] = VertexInterp(iso,g.p[0],g.p[1],g.val[0],g.val[1]);
254  }
255  if (edgeTable2d[cubeindex] & 2) {
256  vertlist[1] = VertexInterp(iso,g.p[1],g.p[2],g.val[1],g.val[2]);
257  }
258  if (edgeTable2d[cubeindex] & 4) {
259  vertlist[2] = VertexInterp(iso,g.p[2],g.p[3],g.val[2],g.val[3]);
260  }
261  if (edgeTable2d[cubeindex] & 8) {
262  vertlist[3] = VertexInterp(iso,g.p[3],g.p[0],g.val[3],g.val[0]);
263  }
264  /* Create the triangles */
265  for(i=0;triTable2d[cubeindex][i]!=-1;i+=2){
266  tri[ntri].p[0] = vertlist[triTable2d[cubeindex][i ]];
267  tri[ntri].p[1] = vertlist[triTable2d[cubeindex][i+1]];
268  for(int d=0;d<2;d++){
269  tri[ntri].c.x[d] = (tri[ntri].p[0].x[d]+tri[ntri].p[1].x[d])*.5;
270  }
271  //TODO: Find the normal to the vertices,
272  // i.e. how the triangles are connected
273  tri[ntri].n[0] = Normal;
274  tri[ntri].n[1] = Normal;
275  //if(fabs(tri[ntri].n[0].x+tri[ntri].n[0].y+tri[ntri].n[0].z) <= 0.) continue;
276  ntri++;
277  }
278  return(ntri);
279 }
280 XYZ TriangNorm(XYZ p1,XYZ p2,XYZ p3){
281  XYZ n;
282  double Norm = 0.;
283  n.x[0] = (p2.x[1]-p1.x[1])*(p2.x[2]-p3.x[2])
284  - (p2.x[1]-p3.x[1])*(p2.x[2]-p1.x[2]);
285  n.x[1] = (p2.x[2]-p1.x[2])*(p2.x[0]-p3.x[0])
286  - (p2.x[2]-p3.x[2])*(p2.x[0]-p1.x[0]);
287  n.x[2] = (p2.x[0]-p1.x[0])*(p2.x[1]-p3.x[1])
288  - (p2.x[0]-p3.x[0])*(p2.x[1]-p1.x[1]);
289  Norm = sqrt(SQR(n.x[0])+SQR(n.x[1])+SQR(n.x[2]));
290  if(Norm > 0.){
291  Norm = 1./Norm;
292  n.x[0] *= Norm;
293  n.x[1] *= Norm;
294  n.x[2] *= Norm;
295  }
296  return n;
297 }
302 XYZ VertexInterp(double isolevel,XYZ p1,XYZ p2,double valp1,double valp2){
303  double mu;
304  XYZ p;
305  if (ABS(isolevel-valp1) < 0.00001)
306  return(p1);
307  if (ABS(isolevel-valp2) < 0.00001)
308  return(p2);
309  if (ABS(valp1-valp2) < 0.00001)
310  return(p1);
311  mu = (isolevel - valp1) / (valp2 - valp1);
312  p.x[0] = p1.x[0] + mu * (p2.x[0] - p1.x[0]);
313  p.x[1] = p1.x[1] + mu * (p2.x[1] - p1.x[1]);
314  p.x[2] = p1.x[2] + mu * (p2.x[2] - p1.x[2]);
315  return(p);
316 }
350 int edgeTable[256]={
351  0x0 , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
352  0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
353  0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
354  0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
355  0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c,
356  0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
357  0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac,
358  0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
359  0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c,
360  0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
361  0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc,
362  0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
363  0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c,
364  0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
365  0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc ,
366  0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
367  0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,
368  0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
369  0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,
370  0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
371  0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,
372  0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
373  0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,
374  0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460,
375  0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,
376  0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0,
377  0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,
378  0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230,
379  0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
380  0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
381  0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
382  0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0
383 };
407 int triTable[256][16] =
408  {{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
409  {0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
410  {0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
411  {1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
412  {1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
413  {0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
414  {9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
415  {2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1},
416  {3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
417  {0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
418  {1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
419  {1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1},
420  {3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
421  {0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1},
422  {3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1},
423  {9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
424  {4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
425  {4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
426  {0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
427  {4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1},
428  {1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
429  {3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1},
430  {9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
431  {2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1},
432  {8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
433  {11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1},
434  {9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
435  {4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1},
436  {3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1},
437  {1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1},
438  {4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1},
439  {4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1},
440  {9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
441  {9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
442  {0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
443  {8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1},
444  {1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
445  {3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
446  {5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1},
447  {2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1},
448  {9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
449  {0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
450  {0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
451  {2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1},
452  {10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1},
453  {4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1},
454  {5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1},
455  {5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1},
456  {9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
457  {9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1},
458  {0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1},
459  {1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
460  {9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1},
461  {10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1},
462  {8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1},
463  {2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1},
464  {7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1},
465  {9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1},
466  {2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1},
467  {11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1},
468  {9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1},
469  {5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1},
470  {11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1},
471  {11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
472  {10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
473  {0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
474  {9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
475  {1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
476  {1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
477  {1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1},
478  {9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1},
479  {5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1},
480  {2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
481  {11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
482  {0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
483  {5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1},
484  {6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1},
485  {0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1},
486  {3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1},
487  {6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1},
488  {5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
489  {4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1},
490  {1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
491  {10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1},
492  {6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1},
493  {1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1},
494  {8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1},
495  {7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1},
496  {3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
497  {5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1},
498  {0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1},
499  {9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1},
500  {8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1},
501  {5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1},
502  {0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1},
503  {6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1},
504  {10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
505  {4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1},
506  {10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1},
507  {8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1},
508  {1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1},
509  {3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1},
510  {0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
511  {8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1},
512  {10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1},
513  {0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1},
514  {3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1},
515  {6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1},
516  {9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1},
517  {8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1},
518  {3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1},
519  {6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
520  {7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1},
521  {0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1},
522  {10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1},
523  {10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1},
524  {1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1},
525  {2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1},
526  {7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1},
527  {7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
528  {2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1},
529  {2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1},
530  {1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1},
531  {11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1},
532  {8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1},
533  {0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
534  {7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1},
535  {7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
536  {7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
537  {3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
538  {0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
539  {8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
540  {10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
541  {1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
542  {2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
543  {6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1},
544  {7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
545  {7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1},
546  {2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1},
547  {1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1},
548  {10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1},
549  {10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1},
550  {0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1},
551  {7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1},
552  {6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
553  {3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1},
554  {8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1},
555  {9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1},
556  {6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1},
557  {1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1},
558  {4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1},
559  {10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1},
560  {8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1},
561  {0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
562  {1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1},
563  {1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1},
564  {8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1},
565  {10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1},
566  {4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1},
567  {10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
568  {4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
569  {0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
570  {5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
571  {11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1},
572  {9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
573  {6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1},
574  {7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1},
575  {3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1},
576  {7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1},
577  {9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1},
578  {3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1},
579  {6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1},
580  {9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1},
581  {1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1},
582  {4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1},
583  {7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1},
584  {6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1},
585  {3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1},
586  {0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1},
587  {6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1},
588  {1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1},
589  {0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1},
590  {11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1},
591  {6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1},
592  {5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1},
593  {9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1},
594  {1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1},
595  {1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
596  {1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1},
597  {10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1},
598  {0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
599  {10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
600  {11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
601  {11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1},
602  {5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1},
603  {10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1},
604  {11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1},
605  {0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1},
606  {9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1},
607  {7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1},
608  {2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1},
609  {8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1},
610  {9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1},
611  {9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1},
612  {1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
613  {0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1},
614  {9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1},
615  {9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
616  {5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1},
617  {5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1},
618  {0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1},
619  {10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1},
620  {2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1},
621  {0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1},
622  {0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1},
623  {9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
624  {2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1},
625  {5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1},
626  {3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1},
627  {5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1},
628  {8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1},
629  {0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
630  {8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1},
631  {9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
632  {4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1},
633  {0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1},
634  {1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1},
635  {3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1},
636  {4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1},
637  {9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1},
638  {11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1},
639  {11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1},
640  {2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1},
641  {9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1},
642  {3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1},
643  {1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
644  {4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1},
645  {4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1},
646  {4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
647  {4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
648  {9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
649  {3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1},
650  {0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1},
651  {3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
652  {1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1},
653  {3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1},
654  {0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
655  {3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
656  {2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1},
657  {9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
658  {2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1},
659  {1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
660  {1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
661  {0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
662  {0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
663  {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}
664 };
693 int edgeTable2d[16]={
694  0x0 , 0x09, 0x03, 0x0a, 0x06, 0x0f, 0x05, 0x0c,
695  0x0c, 0x05, 0x0f, 0x06, 0x0a, 0x03, 0x09, 0x0
696 };
697 int triTable2d[16][4] = {
698  {-1,-1,-1,-1},
699  {0,3,-1,-1},
700  {0,1,-1,-1},
701  {3,1,-1,-1},
702  {1,2,-1,-1},
703  {0,1,2,3},
704  {0,2,-1,-1},
705  {2,3,-1,-1},
706  {2,3,-1,-1},
707  {2,0,-1,-1},
708  {3,0,1,2},
709  {1,2,-1,-1},
710  {1,3,-1,-1},
711  {0,1,-1,-1},
712  {3,0,-1,-1},
713  {-1,-1,-1,-1}
714 };
715 
XYZ n[3]
Normal to the vertices.
Definition: VarData.h:506
double val[8]
Density at the vertices.
Definition: VarData.h:495
double x[3]
Cartesian coordinates.
Definition: VarData.h:486
A Cartesian tern.
Definition: VarData.h:484
Define a triangle.
Definition: VarData.h:509
double pInvEdge(int d)
Inverted xyzr edges of the simulation box.
Definition: VarData.h:920
Define a triangle.
Definition: VarData.h:498
int v[2]
Reference for the vectors.
Definition: VarData.h:515
VAR_TRIANGLE * MarchingCubes(double *Plot, int NSample, double IsoLevel, int *NTri)
Defines the triangles close to the IsoLevel of the 3d density Plot.
XYZ p[3]
The three vertices.
Definition: VarData.h:500
VAR_LINE * MarchingSquares(double *Plot, int NSample, double IsoLevel, int *NTri)
Defines the triangles close to the IsoLevel of the 3d density Plot.
int v[3]
Reference for the vectors.
Definition: VarData.h:504
XYZ n[2]
Normal to the vertices.
Definition: VarData.h:517
double pEdge(int d)
xyzr edges of the simulation box
Definition: VarData.h:918
XYZ c
Centroid.
Definition: VarData.h:513
All the vertex in a cell.
Definition: VarData.h:489
XYZ p[2]
The two vertices.
Definition: VarData.h:511
XYZ p[8]
Vertices.
Definition: VarData.h:491
XYZ c
Centroid.
Definition: VarData.h:502