[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [analitza] analitzaplot: REVIEW: 117816
From:       Percy_Camilo_Triveño_Aucahuasi <percy.camilo.ta () gmail ! com>
Date:       2014-04-28 23:15:23
Message-ID: E1Weulf-0007S6-7z () scm ! kde ! org
[Download RAW message or body]

Git commit 6a896c373e0940c09a5efae6ee067bb9f59be7e0 by Percy Camilo Triveño \
Aucahuasi. Committed on 28/04/2014 at 23:14.
Pushed by aucahuasi into branch 'master'.

REVIEW: 117816

M  +0    -1    analitzaplot/CMakeLists.txt
M  +21   -9    analitzaplot/private/backends/implicitsurface.cpp
A  +2343 -0    analitzaplot/private/utils/lookuptable.h     [License: GPL (v2+) \
(wrong address)]  * M  +1383 -760  analitzaplot/private/utils/marchingcubes.cpp
M  +340  -67   analitzaplot/private/utils/marchingcubes.h
D  +0    -109  analitzaplot/private/utils/octree.cpp
D  +0    -90   analitzaplot/private/utils/octree.h

The files marked with a * at the end have a non valid license. Please read: \
http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are \
listed at that page.


http://commits.kde.org/analitza/6a896c373e0940c09a5efae6ee067bb9f59be7e0

diff --git a/analitzaplot/CMakeLists.txt b/analitzaplot/CMakeLists.txt
index 9890449..040ce01 100644
--- a/analitzaplot/CMakeLists.txt
+++ b/analitzaplot/CMakeLists.txt
@@ -29,7 +29,6 @@ set ( analitzaplot_SRCS
     private/utils/mathutils.cpp
     private/utils/quadtree.cpp
     private/utils/marchingsquares.cpp
-    private/utils/octree.cpp
     private/utils/marchingcubes.cpp
 
     private/abstractplotitem.cpp
diff --git a/analitzaplot/private/backends/implicitsurface.cpp \
b/analitzaplot/private/backends/implicitsurface.cpp index 68c7918..e27d730 100644
--- a/analitzaplot/private/backends/implicitsurface.cpp
+++ b/analitzaplot/private/backends/implicitsurface.cpp
@@ -45,7 +45,7 @@ public:
     EXAMPLES(QStringList())
 
     //Own
-    virtual ~ImplicitSurf() {}
+    virtual ~ImplicitSurf() {  }
     void update(const QVector3D & oppositecorner1, const QVector3D & \
oppositecorner2);  
     double evalScalarField(double x, double y, double z);
@@ -70,7 +70,7 @@ void ImplicitSurf::update(const QVector3D & oppositecorner1, const \
QVector3D & o  {
     SpaceLimits spaceLimits;
     
-    double tmpsize = 4.0;
+    double tmpsize = 6.0;
     
     spaceLimits.minX = -tmpsize;
     spaceLimits.maxX = tmpsize;
@@ -93,17 +93,29 @@ void ImplicitSurf::update(const QVector3D & oppositecorner1, \
const QVector3D & o  spaceLimits.maxZ = intervalz.second;
     }
     
-    setupSpace(spaceLimits);
     
-    vertices.clear();
-    normals.clear();
-    indexes.clear();
+    setupSpace(spaceLimits);
     
     buildGeometry();
+    
+//     qDebug() << "A: " << ntrigs() << nverts();
+
+    //TODO find a better way to avoi this loops
+    for (int i = 0; i < nverts(); ++i)
+    {
+        vertices.append(vert(i)->x);
+        vertices.append(vert(i)->y);
+        vertices.append(vert(i)->z);
+        
+        normals.append(vert(i)->nx);
+        normals.append(vert(i)->ny);
+        normals.append(vert(i)->nz);
+    }
 
-    vertices << MarchingCubes::_vertices;
-    normals << MarchingCubes::_normals;
-    indexes << MarchingCubes::_indexes;
+    for (int i = 0; i < ntrigs(); ++i)
+    {
+       indexes <<  trig(i)->v1  <<  trig(i)->v2 <<  trig(i)->v3;
+    }
 }
 
 REGISTER_SURFACE(ImplicitSurf)
diff --git a/analitzaplot/private/utils/lookuptable.h \
b/analitzaplot/private/utils/lookuptable.h new file mode 100644
index 0000000..cad24cc
--- /dev/null
+++ b/analitzaplot/private/utils/lookuptable.h
@@ -0,0 +1,2343 @@
+// Aqsis
+// Copyright (C) 2006, Paul C. Gregory
+//
+// Contact: pgregory@aqsis.org
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+
+/** \file
+    \brief   LookUpTable for the MarchingCubes 33 Algorithm
+    \author Thomas Lewiner <thomas.lewiner@polytechnique.org>
+    \author Math Dept, PUC-Rio
+    \version 0.2
+    \date    12/08/2002
+*/
+
+//________________________________________________
+
+
+
+#ifndef _LOOKUPTABLE_H_
+#define _LOOKUPTABLE_H_
+
+
+
+
+
+//_____________________________________________________________________________
+/**
+ * \brief case mapping
+ * For each of the possible vertex states listed in this table there is a
+ * specific triangulation of the edge intersection points.  The table lists
+ * all of them in the form of 0-5 edge triples with the list terminated by
+ * the invalid value -1.  For example: case[3] list the 2 triangles
+ * formed when cube[0] and cube[1] are inside of the surface, but the rest of
+ * the cube is not.
+ *
+ * Cube description:
+ *         7 ________ 6           _____6__             ________
+ *         /|       /|         7/|       /|          /|       /|
+ *       /  |     /  |        /  |     /5 |        /  6     /  |
+ *   4 /_______ /    |      /__4____ /    10     /_______3/    |
+ *    |     |  |5    |     |    11  |     |     |     |  |   2 |
+ *    |    3|__|_____|2    |     |__|__2__|     | 4   |__|_____|
+ *    |    /   |    /      8   3/   9    /      |    /   |    /
+ *    |  /     |  /        |  /     |  /1       |  /     5  /
+ *    |/_______|/          |/___0___|/          |/_1_____|/
+ *   0          1        0          1
+ */
+//-----------------------------------------------------------------------------
+static const int cases[256][2] = {
+/*   0:                          */  {  0, -1 },
+/*   1: 0,                       */  {  1,  0 },
+/*   2:    1,                    */  {  1,  1 },
+/*   3: 0, 1,                    */  {  2,  0 },
+/*   4:       2,                 */  {  1,  2 },
+/*   5: 0,    2,                 */  {  3,  0 },
+/*   6:    1, 2,                 */  {  2,  3 },
+/*   7: 0, 1, 2,                 */  {  5,  0 },
+/*   8:          3,              */  {  1,  3 },
+/*   9: 0,       3,              */  {  2,  1 },
+/*  10:    1,    3,              */  {  3,  3 },
+/*  11: 0, 1,    3,              */  {  5,  1 },
+/*  12:       2, 3,              */  {  2,  5 },
+/*  13: 0,    2, 3,              */  {  5,  4 },
+/*  14:    1, 2, 3,              */  {  5,  9 },
+/*  15: 0, 1, 2, 3,              */  {  8,  0 },
+/*  16:             4,           */  {  1,  4 },
+/*  17: 0,          4,           */  {  2,  2 },
+/*  18:    1,       4,           */  {  3,  4 },
+/*  19: 0, 1,       4,           */  {  5,  2 },
+/*  20:       2,    4,           */  {  4,  2 },
+/*  21: 0,    2,    4,           */  {  6,  2 },
+/*  22:    1, 2,    4,           */  {  6,  9 },
+/*  23: 0, 1, 2,    4,           */  { 11,  0 },
+/*  24:          3, 4,           */  {  3,  8 },
+/*  25: 0,       3, 4,           */  {  5,  5 },
+/*  26:    1,    3, 4,           */  {  7,  3 },
+/*  27: 0, 1,    3, 4,           */  {  9,  1 },
+/*  28:       2, 3, 4,           */  {  6, 16 },
+/*  29: 0,    2, 3, 4,           */  { 14,  3 },
+/*  30:    1, 2, 3, 4,           */  { 12, 12 },
+/*  31: 0, 1, 2, 3, 4,           */  {  5, 24 },
+/*  32:                5,        */  {  1,  5 },
+/*  33: 0,             5,        */  {  3,  1 },
+/*  34:    1,          5,        */  {  2,  4 },
+/*  35: 0, 1,          5,        */  {  5,  3 },
+/*  36:       2,       5,        */  {  3,  6 },
+/*  37: 0,    2,       5,        */  {  7,  0 },
+/*  38:    1, 2,       5,        */  {  5, 10 },
+/*  39: 0, 1, 2,       5,        */  {  9,  0 },
+/*  40:          3,    5,        */  {  4,  3 },
+/*  41: 0,       3,    5,        */  {  6,  4 },
+/*  42:    1,    3,    5,        */  {  6, 11 },
+/*  43: 0, 1,    3,    5,        */  { 14,  1 },
+/*  44:       2, 3,    5,        */  {  6, 17 },
+/*  45: 0,    2, 3,    5,        */  { 12,  4 },
+/*  46:    1, 2, 3,    5,        */  { 11,  6 },
+/*  47: 0, 1, 2, 3,    5,        */  {  5, 25 },
+/*  48:             4, 5,        */  {  2,  8 },
+/*  49: 0,          4, 5,        */  {  5,  7 },
+/*  50:    1,       4, 5,        */  {  5, 12 },
+/*  51: 0, 1,       4, 5,        */  {  8,  1 },
+/*  52:       2,    4, 5,        */  {  6, 18 },
+/*  53: 0,    2,    4, 5,        */  { 12,  5 },
+/*  54:    1, 2,    4, 5,        */  { 14,  7 },
+/*  55: 0, 1, 2,    4, 5,        */  {  5, 28 },
+/*  56:          3, 4, 5,        */  {  6, 21 },
+/*  57: 0,       3, 4, 5,        */  { 11,  4 },
+/*  58:    1,    3, 4, 5,        */  { 12, 15 },
+/*  59: 0, 1,    3, 4, 5,        */  {  5, 30 },
+/*  60:       2, 3, 4, 5,        */  { 10,  5 },
+/*  61: 0,    2, 3, 4, 5,        */  {  6, 32 },
+/*  62:    1, 2, 3, 4, 5,        */  {  6, 39 },
+/*  63: 0, 1, 2, 3, 4, 5,        */  {  2, 12 },
+/*  64:                   6,     */  {  1,  6 },
+/*  65: 0,                6,     */  {  4,  0 },
+/*  66:    1,             6,     */  {  3,  5 },
+/*  67: 0, 1,             6,     */  {  6,  0 },
+/*  68:       2,          6,     */  {  2,  6 },
+/*  69: 0,    2,          6,     */  {  6,  3 },
+/*  70:    1, 2,          6,     */  {  5, 11 },
+/*  71: 0, 1, 2,          6,     */  { 14,  0 },
+/*  72:          3,       6,     */  {  3,  9 },
+/*  73: 0,       3,       6,     */  {  6,  5 },
+/*  74:    1,    3,       6,     */  {  7,  4 },
+/*  75: 0, 1,    3,       6,     */  { 12,  1 },
+/*  76:       2, 3,       6,     */  {  5, 14 },
+/*  77: 0,    2, 3,       6,     */  { 11,  3 },
+/*  78:    1, 2, 3,       6,     */  {  9,  4 },
+/*  79: 0, 1, 2, 3,       6,     */  {  5, 26 },
+/*  80:             4,    6,     */  {  3, 10 },
+/*  81: 0,          4,    6,     */  {  6,  6 },
+/*  82:    1,       4,    6,     */  {  7,  5 },
+/*  83: 0, 1,       4,    6,     */  { 12,  2 },
+/*  84:       2,    4,    6,     */  {  6, 19 },
+/*  85: 0,    2,    4,    6,     */  { 10,  1 },
+/*  86:    1, 2,    4,    6,     */  { 12, 13 },
+/*  87: 0, 1, 2,    4,    6,     */  {  6, 24 },
+/*  88:          3, 4,    6,     */  {  7,  7 },
+/*  89: 0,       3, 4,    6,     */  { 12,  9 },
+/*  90:    1,    3, 4,    6,     */  { 13,  1 },
+/*  91: 0, 1,    3, 4,    6,     */  {  7,  9 },
+/*  92:       2, 3, 4,    6,     */  { 12, 20 },
+/*  93: 0,    2, 3, 4,    6,     */  {  6, 33 },
+/*  94:    1, 2, 3, 4,    6,     */  {  7, 13 },
+/*  95: 0, 1, 2, 3, 4,    6,     */  {  3, 12 },
+/*  96:                5, 6,     */  {  2, 10 },
+/*  97: 0,             5, 6,     */  {  6,  7 },
+/*  98:    1,          5, 6,     */  {  5, 13 },
+/*  99: 0, 1,          5, 6,     */  { 11,  2 },
+/* 100:       2,       5, 6,     */  {  5, 16 },
+/* 101: 0,    2,       5, 6,     */  { 12,  7 },
+/* 102:    1, 2,       5, 6,     */  {  8,  3 },
+/* 103: 0, 1, 2,       5, 6,     */  {  5, 29 },
+/* 104:          3,    5, 6,     */  {  6, 22 },
+/* 105: 0,       3,    5, 6,     */  { 10,  2 },
+/* 106:    1,    3,    5, 6,     */  { 12, 17 },
+/* 107: 0, 1,    3,    5, 6,     */  {  6, 27 },
+/* 108:       2, 3,    5, 6,     */  { 14,  9 },
+/* 109: 0,    2, 3,    5, 6,     */  {  6, 34 },
+/* 110:    1, 2, 3,    5, 6,     */  {  5, 39 },
+/* 111: 0, 1, 2, 3,    5, 6,     */  {  2, 14 },
+/* 112:             4, 5, 6,     */  {  5, 20 },
+/* 113: 0,          4, 5, 6,     */  { 14,  5 },
+/* 114:    1,       4, 5, 6,     */  {  9,  5 },
+/* 115: 0, 1,       4, 5, 6,     */  {  5, 32 },
+/* 116:       2,    4, 5, 6,     */  { 11, 10 },
+/* 117: 0,    2,    4, 5, 6,     */  {  6, 35 },
+/* 118:    1, 2,    4, 5, 6,     */  {  5, 41 },
+/* 119: 0, 1, 2,    4, 5, 6,     */  {  2, 16 },
+/* 120:          3, 4, 5, 6,     */  { 12, 23 },
+/* 121: 0,       3, 4, 5, 6,     */  {  6, 37 },
+/* 122:    1,    3, 4, 5, 6,     */  {  7, 14 },
+/* 123: 0, 1,    3, 4, 5, 6,     */  {  3, 16 },
+/* 124:       2, 3, 4, 5, 6,     */  {  6, 46 },
+/* 125: 0,    2, 3, 4, 5, 6,     */  {  4,  6 },
+/* 126:    1, 2, 3, 4, 5, 6,     */  {  3, 21 },
+/* 127: 0, 1, 2, 3, 4, 5, 6,     */  {  1,  8 },
+/* 128:                      7,  */  {  1,  7 },
+/* 129: 0,                   7,  */  {  3,  2 },
+/* 130:    1,                7,  */  {  4,  1 },
+/* 131: 0, 1,                7,  */  {  6,  1 },
+/* 132:       2,             7,  */  {  3,  7 },
+/* 133: 0,    2,             7,  */  {  7,  1 },
+/* 134:    1, 2,             7,  */  {  6, 10 },
+/* 135: 0, 1, 2,             7,  */  { 12,  0 },
+/* 136:          3,          7,  */  {  2,  7 },
+/* 137: 0,       3,          7,  */  {  5,  6 },
+/* 138:    1,    3,          7,  */  {  6, 12 },
+/* 139: 0, 1,    3,          7,  */  { 11,  1 },
+/* 140:       2, 3,          7,  */  {  5, 15 },
+/* 141: 0,    2, 3,          7,  */  {  9,  2 },
+/* 142:    1, 2, 3,          7,  */  { 14,  6 },
+/* 143: 0, 1, 2, 3,          7,  */  {  5, 27 },
+/* 144:             4,       7,  */  {  2,  9 },
+/* 145: 0,          4,       7,  */  {  5,  8 },
+/* 146:    1,       4,       7,  */  {  6, 13 },
+/* 147: 0, 1,       4,       7,  */  { 14,  2 },
+/* 148:       2,    4,       7,  */  {  6, 20 },
+/* 149: 0,    2,    4,       7,  */  { 12,  6 },
+/* 150:    1, 2,    4,       7,  */  { 10,  3 },
+/* 151: 0, 1, 2,    4,       7,  */  {  6, 25 },
+/* 152:          3, 4,       7,  */  {  5, 18 },
+/* 153: 0,       3, 4,       7,  */  {  8,  2 },
+/* 154:    1,    3, 4,       7,  */  { 12, 16 },
+/* 155: 0, 1,    3, 4,       7,  */  {  5, 31 },
+/* 156:       2, 3, 4,       7,  */  { 11,  9 },
+/* 157: 0,    2, 3, 4,       7,  */  {  5, 34 },
+/* 158:    1, 2, 3, 4,       7,  */  {  6, 40 },
+/* 159: 0, 1, 2, 3, 4,       7,  */  {  2, 13 },
+/* 160:                5,    7,  */  {  3, 11 },
+/* 161: 0,             5,    7,  */  {  7,  2 },
+/* 162:    1,          5,    7,  */  {  6, 14 },
+/* 163: 0, 1,          5,    7,  */  { 12,  3 },
+/* 164:       2,       5,    7,  */  {  7,  6 },
+/* 165: 0,    2,       5,    7,  */  { 13,  0 },
+/* 166:    1, 2,       5,    7,  */  { 12, 14 },
+/* 167: 0, 1, 2,       5,    7,  */  {  7,  8 },
+/* 168:          3,    5,    7,  */  {  6, 23 },
+/* 169: 0,       3,    5,    7,  */  { 12, 10 },
+/* 170:    1,    3,    5,    7,  */  { 10,  4 },
+/* 171: 0, 1,    3,    5,    7,  */  {  6, 28 },
+/* 172:       2, 3,    5,    7,  */  { 12, 21 },
+/* 173: 0,    2, 3,    5,    7,  */  {  7, 10 },
+/* 174:    1, 2, 3,    5,    7,  */  {  6, 41 },
+/* 175: 0, 1, 2, 3,    5,    7,  */  {  3, 13 },
+/* 176:             4, 5,    7,  */  {  5, 21 },
+/* 177: 0,          4, 5,    7,  */  {  9,  3 },
+/* 178:    1,       4, 5,    7,  */  { 11,  8 },
+/* 179: 0, 1,       4, 5,    7,  */  {  5, 33 },
+/* 180:       2,    4, 5,    7,  */  { 12, 22 },
+/* 181: 0,    2,    4, 5,    7,  */  {  7, 11 },
+/* 182:    1, 2,    4, 5,    7,  */  {  6, 42 },
+/* 183: 0, 1, 2,    4, 5,    7,  */  {  3, 14 },
+/* 184:          3, 4, 5,    7,  */  { 14, 11 },
+/* 185: 0,       3, 4, 5,    7,  */  {  5, 36 },
+/* 186:    1,    3, 4, 5,    7,  */  {  6, 44 },
+/* 187: 0, 1,    3, 4, 5,    7,  */  {  2, 17 },
+/* 188:       2, 3, 4, 5,    7,  */  {  6, 47 },
+/* 189: 0,    2, 3, 4, 5,    7,  */  {  3, 18 },
+/* 190:    1, 2, 3, 4, 5,    7,  */  {  4,  7 },
+/* 191: 0, 1, 2, 3, 4, 5,    7,  */  {  1,  9 },
+/* 192:                   6, 7,  */  {  2, 11 },
+/* 193: 0,                6, 7,  */  {  6,  8 },
+/* 194:    1,             6, 7,  */  {  6, 15 },
+/* 195: 0, 1,             6, 7,  */  { 10,  0 },
+/* 196:       2,          6, 7,  */  {  5, 17 },
+/* 197: 0,    2,          6, 7,  */  { 12,  8 },
+/* 198:    1, 2,          6, 7,  */  { 11,  7 },
+/* 199: 0, 1, 2,          6, 7,  */  {  6, 26 },
+/* 200:          3,       6, 7,  */  {  5, 19 },
+/* 201: 0,       3,       6, 7,  */  { 14,  4 },
+/* 202:    1,    3,       6, 7,  */  { 12, 18 },
+/* 203: 0, 1,    3,       6, 7,  */  {  6, 29 },
+/* 204:       2, 3,       6, 7,  */  {  8,  4 },
+/* 205: 0,    2, 3,       6, 7,  */  {  5, 35 },
+/* 206:    1, 2, 3,       6, 7,  */  {  5, 40 },
+/* 207: 0, 1, 2, 3,       6, 7,  */  {  2, 15 },
+/* 208:             4,    6, 7,  */  {  5, 22 },
+/* 209: 0,          4,    6, 7,  */  { 11,  5 },
+/* 210:    1,       4,    6, 7,  */  { 12, 19 },
+/* 211: 0, 1,       4,    6, 7,  */  {  6, 30 },
+/* 212:       2,    4,    6, 7,  */  { 14, 10 },
+/* 213: 0,    2,    4,    6, 7,  */  {  6, 36 },
+/* 214:    1, 2,    4,    6, 7,  */  {  6, 43 },
+/* 215: 0, 1, 2,    4,    6, 7,  */  {  4,  4 },
+/* 216:          3, 4,    6, 7,  */  {  9,  7 },
+/* 217: 0,       3, 4,    6, 7,  */  {  5, 37 },
+/* 218:    1,    3, 4,    6, 7,  */  {  7, 15 },
+/* 219: 0, 1,    3, 4,    6, 7,  */  {  3, 17 },
+/* 220:       2, 3, 4,    6, 7,  */  {  5, 44 },
+/* 221: 0,    2, 3, 4,    6, 7,  */  {  2, 19 },
+/* 222:    1, 2, 3, 4,    6, 7,  */  {  3, 22 },
+/* 223: 0, 1, 2, 3, 4,    6, 7,  */  {  1, 10 },
+/* 224:                5, 6, 7,  */  {  5, 23 },
+/* 225: 0,             5, 6, 7,  */  { 12, 11 },
+/* 226:    1,          5, 6, 7,  */  { 14,  8 },
+/* 227: 0, 1,          5, 6, 7,  */  {  6, 31 },
+/* 228:       2,       5, 6, 7,  */  {  9,  6 },
+/* 229: 0,    2,       5, 6, 7,  */  {  7, 12 },
+/* 230:    1, 2,       5, 6, 7,  */  {  5, 42 },
+/* 231: 0, 1, 2,       5, 6, 7,  */  {  3, 15 },
+/* 232:          3,    5, 6, 7,  */  { 11, 11 },
+/* 233: 0,       3,    5, 6, 7,  */  {  6, 38 },
+/* 234:    1,    3,    5, 6, 7,  */  {  6, 45 },
+/* 235: 0, 1,    3,    5, 6, 7,  */  {  4,  5 },
+/* 236:       2, 3,    5, 6, 7,  */  {  5, 45 },
+/* 237: 0,    2, 3,    5, 6, 7,  */  {  3, 19 },
+/* 238:    1, 2, 3,    5, 6, 7,  */  {  2, 21 },
+/* 239: 0, 1, 2, 3,    5, 6, 7,  */  {  1, 11 },
+/* 240:             4, 5, 6, 7,  */  {  8,  5 },
+/* 241: 0,          4, 5, 6, 7,  */  {  5, 38 },
+/* 242:    1,       4, 5, 6, 7,  */  {  5, 43 },
+/* 243: 0, 1,       4, 5, 6, 7,  */  {  2, 18 },
+/* 244:       2,    4, 5, 6, 7,  */  {  5, 46 },
+/* 245: 0,    2,    4, 5, 6, 7,  */  {  3, 20 },
+/* 246:    1, 2,    4, 5, 6, 7,  */  {  2, 22 },
+/* 247: 0, 1, 2,    4, 5, 6, 7,  */  {  1, 12 },
+/* 248:          3, 4, 5, 6, 7,  */  {  5, 47 },
+/* 249: 0,       3, 4, 5, 6, 7,  */  {  2, 20 },
+/* 250:    1,    3, 4, 5, 6, 7,  */  {  3, 23 },
+/* 251: 0, 1,    3, 4, 5, 6, 7,  */  {  1, 13 },
+/* 252:       2, 3, 4, 5, 6, 7,  */  {  2, 23 },
+/* 253: 0,    2, 3, 4, 5, 6, 7,  */  {  1, 14 },
+/* 254:    1, 2, 3, 4, 5, 6, 7,  */  {  1, 15 },
+/* 255: 0, 1, 2, 3, 4, 5, 6, 7,  */  {  0, -1 }
+};
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 1
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling1[16][3] = {
+/*   1: 0,                       */  {  0,  8,  3 },
+/*   2:    1,                    */  {  0,  1,  9 },
+/*   4:       2,                 */  {  1,  2, 10 },
+/*   8:          3,              */  {  3, 11,  2 },
+/*  16:             4,           */  {  4,  7,  8 },
+/*  32:                5,        */  {  9,  5,  4 },
+/*  64:                   6,     */  { 10,  6,  5 },
+/* 128:                      7,  */  {  7,  6, 11 },
+/* 127: 0, 1, 2, 3, 4, 5, 6,     */  {  7, 11,  6 },
+/* 191: 0, 1, 2, 3, 4, 5,    7,  */  { 10,  5,  6 },
+/* 223: 0, 1, 2, 3, 4,    6, 7,  */  {  9,  4,  5 },
+/* 239: 0, 1, 2, 3,    5, 6, 7,  */  {  4,  8,  7 },
+/* 247: 0, 1, 2,    4, 5, 6, 7,  */  {  3,  2, 11 },
+/* 251: 0, 1,    3, 4, 5, 6, 7,  */  {  1, 10,  2 },
+/* 253: 0,    2, 3, 4, 5, 6, 7,  */  {  0,  9,  1 },
+/* 254:    1, 2, 3, 4, 5, 6, 7,  */  {  0,  3,  8 }
+};
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 2
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling2[24][6] = {
+/*   3: 0, 1,                    */  {  1,  8,  3,  9,  8,  1 },
+/*   9: 0,       3,              */  {  0, 11,  2,  8, 11,  0 },
+/*  17: 0,          4,           */  {  4,  3,  0,  7,  3,  4 },
+/*   6:    1, 2,                 */  {  9,  2, 10,  0,  2,  9 },
+/*  34:    1,          5,        */  {  0,  5,  4,  1,  5,  0 },
+/*  12:       2, 3,              */  {  3, 10,  1, 11, 10,  3 },
+/*  68:       2,          6,     */  {  1,  6,  5,  2,  6,  1 },
+/* 136:          3,          7,  */  {  7,  2,  3,  6,  2,  7 },
+/*  48:             4, 5,        */  {  9,  7,  8,  5,  7,  9 },
+/* 144:             4,       7,  */  {  6,  8,  4, 11,  8,  6 },
+/*  96:                5, 6,     */  { 10,  4,  9,  6,  4, 10 },
+/* 192:                   6, 7,  */  { 11,  5, 10,  7,  5, 11 },
+/*  63: 0, 1, 2, 3, 4, 5,        */  { 11, 10,  5,  7, 11,  5 },
+/* 159: 0, 1, 2, 3, 4,       7,  */  { 10,  9,  4,  6, 10,  4 },
+/* 111: 0, 1, 2, 3,    5, 6,     */  {  6,  4,  8, 11,  6,  8 },
+/* 207: 0, 1, 2, 3,       6, 7,  */  {  9,  8,  7,  5,  9,  7 },
+/* 119: 0, 1, 2,    4, 5, 6,     */  {  7,  3,  2,  6,  7,  2 },
+/* 187: 0, 1,    3, 4, 5,    7,  */  {  1,  5,  6,  2,  1,  6 },
+/* 243: 0, 1,       4, 5, 6, 7,  */  {  3,  1, 10, 11,  3, 10 },
+/* 221: 0,    2, 3, 4,    6, 7,  */  {  0,  4,  5,  1,  0,  5 },
+/* 249: 0,       3, 4, 5, 6, 7,  */  {  9, 10,  2,  0,  9,  2 },
+/* 238:    1, 2, 3,    5, 6, 7,  */  {  4,  0,  3,  7,  4,  3 },
+/* 246:    1, 2,    4, 5, 6, 7,  */  {  0,  2, 11,  8,  0, 11 },
+/* 252:       2, 3, 4, 5, 6, 7,  */  {  1,  3,  8,  9,  1,  8 }
+};
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+/**
+ * \brief test table for case 3
+ * One face to test
+ * When the test on the specified face is positive : 4 first triangles
+ * When the test on the specified face is negative : 2 last triangles
+ *
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int test3[24] = {
+/*   5: 0,    2,                 */    5,
+/*  33: 0,             5,        */    1,
+/* 129: 0,                   7,  */    4,
+/*  10:    1,    3,              */    5,
+/*  18:    1,       4,           */    1,
+/*  66:    1,             6,     */    2,
+/*  36:       2,       5,        */    2,
+/* 132:       2,             7,  */    3,
+/*  24:          3, 4,           */    4,
+/*  72:          3,       6,     */    3,
+/*  80:             4,    6,     */    6,
+/* 160:                5,    7,  */    6,
+/*  95: 0, 1, 2, 3, 4,    6,     */   -6,
+/* 175: 0, 1, 2, 3,    5,    7,  */   -6,
+/* 183: 0, 1, 2,    4, 5,    7,  */   -3,
+/* 231: 0, 1, 2,       5, 6, 7,  */   -4,
+/* 123: 0, 1,    3, 4, 5, 6,     */   -3,
+/* 219: 0, 1,    3, 4,    6, 7,  */   -2,
+/* 189: 0,    2, 3, 4, 5,    7,  */   -2,
+/* 237: 0,    2, 3,    5, 6, 7,  */   -1,
+/* 245: 0,    2,    4, 5, 6, 7,  */   -5,
+/* 126:    1, 2, 3, 4, 5, 6,     */   -4,
+/* 222:    1, 2, 3, 4,    6, 7,  */   -1,
+/* 250:    1,    3, 4, 5, 6, 7,  */   -5
+};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 3.1
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling3_1[24][6] = {
+/*   5: 0,    2,                 */  {  0,  8,  3,  1,  2, 10 },
+/*  33: 0,             5,        */  {  9,  5,  4,  0,  8,  3 },
+/* 129: 0,                   7,  */  {  3,  0,  8, 11,  7,  6 },
+/*  10:    1,    3,              */  {  1,  9,  0,  2,  3, 11 },
+/*  18:    1,       4,           */  {  0,  1,  9,  8,  4,  7 },
+/*  66:    1,             6,     */  {  9,  0,  1,  5, 10,  6 },
+/*  36:       2,       5,        */  {  1,  2, 10,  9,  5,  4 },
+/* 132:       2,             7,  */  { 10,  1,  2,  6, 11,  7 },
+/*  24:          3, 4,           */  {  8,  4,  7,  3, 11,  2 },
+/*  72:          3,       6,     */  {  2,  3, 11, 10,  6,  5 },
+/*  80:             4,    6,     */  {  5, 10,  6,  4,  7,  8 },
+/* 160:                5,    7,  */  {  4,  9,  5,  7,  6, 11 },
+/*  95: 0, 1, 2, 3, 4,    6,     */  {  5,  9,  4, 11,  6,  7 },
+/* 175: 0, 1, 2, 3,    5,    7,  */  {  6, 10,  5,  8,  7,  4 },
+/* 183: 0, 1, 2,    4, 5,    7,  */  { 11,  3,  2,  5,  6, 10 },
+/* 231: 0, 1, 2,       5, 6, 7,  */  {  7,  4,  8,  2, 11,  3 },
+/* 123: 0, 1,    3, 4, 5, 6,     */  {  2,  1, 10,  7, 11,  6 },
+/* 219: 0, 1,    3, 4,    6, 7,  */  { 10,  2,  1,  4,  5,  9 },
+/* 189: 0,    2, 3, 4, 5,    7,  */  {  1,  0,  9,  6, 10,  5 },
+/* 237: 0,    2, 3,    5, 6, 7,  */  {  9,  1,  0,  7,  4,  8 },
+/* 245: 0,    2,    4, 5, 6, 7,  */  {  0,  9,  1, 11,  3,  2 },
+/* 126:    1, 2, 3, 4, 5, 6,     */  {  8,  0,  3,  6,  7, 11 },
+/* 222:    1, 2, 3, 4,    6, 7,  */  {  4,  5,  9,  3,  8,  0 },
+/* 250:    1,    3, 4, 5, 6, 7,  */  {  3,  8,  0, 10,  2,  1 }
+};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 3.2
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling3_2[24][12] = {
+/*   5: 0,    2,                 */  { 10,  3,  2, 10,  8,  3, 10,  1,  0,  8, 10,  \
0 }, +/*  33: 0,             5,        */  {  3,  4,  8,  3,  5,  4,  3,  0,  9,  5,  \
3,  9 }, +/* 129: 0,                   7,  */  {  6,  8,  7,  6,  0,  8,  6, 11,  3,  \
0,  6,  3 }, +/*  10:    1,    3,              */  { 11,  0,  3, 11,  9,  0, 11,  2,  \
1,  9, 11,  1 }, +/*  18:    1,       4,           */  {  7,  9,  4,  7,  1,  9,  7,  \
8,  0,  1,  7,  0 }, +/*  66:    1,             6,     */  {  6,  1, 10,  6,  0,  1,  \
9,  0,  6,  9,  6,  5 }, +/*  36:       2,       5,        */  {  4, 10,  5,  4,  2, \
10,  4,  9,  1,  2,  4,  1 }, +/* 132:       2,             7,  */  {  7,  2, 11,  7, \
1,  2,  7,  6, 10,  1,  7, 10 }, +/*  24:          3, 4,           */  {  2,  7, 11,  \
2,  4,  7,  2,  3,  8,  4,  2,  8 }, +/*  72:          3,       6,     */  {  5, 11,  \
6,  5,  3, 11,  5, 10,  2,  3,  5,  2 }, +/*  80:             4,    6,     */  {  8,  \
6,  7,  8, 10,  6,  8,  4,  5, 10,  8,  5 }, +/* 160:                5,    7,  */  { \
11,  5,  6, 11,  9,  5, 11,  7,  4,  9, 11,  4 }, +/*  95: 0, 1, 2, 3, 4,    6,     \
*/  {  6,  5, 11,  5,  9, 11,  4,  7, 11,  4, 11,  9 }, +/* 175: 0, 1, 2, 3,    5,    \
7,  */  {  7,  6,  8,  6, 10,  8,  5,  4,  8,  5,  8, 10 }, +/* 183: 0, 1, 2,    4, \
5,    7,  */  {  6, 11,  5, 11,  3,  5,  2, 10,  5,  2,  5,  3 }, +/* 231: 0, 1, 2,   \
5, 6, 7,  */  { 11,  7,  2,  7,  4,  2,  8,  3,  2,  8,  2,  4 }, +/* 123: 0, 1,    \
3, 4, 5, 6,     */  { 11,  2,  7,  2,  1,  7, 10,  6,  7, 10,  7,  1 }, +/* 219: 0, \
1,    3, 4,    6, 7,  */  {  5, 10,  4, 10,  2,  4,  1,  9,  4,  1,  4,  2 }, +/* \
189: 0,    2, 3, 4, 5,    7,  */  { 10,  1,  6,  1,  0,  6,  6,  0,  9,  5,  6,  9 }, \
+/* 237: 0,    2, 3,    5, 6, 7,  */  {  4,  9,  7,  9,  1,  7,  0,  8,  7,  0,  7,  \
1 }, +/* 245: 0,    2,    4, 5, 6, 7,  */  {  3,  0, 11,  0,  9, 11,  1,  2, 11,  1, \
11,  9 }, +/* 126:    1, 2, 3, 4, 5, 6,     */  {  7,  8,  6,  8,  0,  6,  3, 11,  6, \
3,  6,  0 }, +/* 222:    1, 2, 3, 4,    6, 7,  */  {  8,  4,  3,  4,  5,  3,  9,  0,  \
3,  9,  3,  5 }, +/* 250:    1,    3, 4, 5, 6, 7,  */  {  2,  3, 10,  3,  8, 10,  0,  \
1, 10,  0, 10,  8 } +};
+//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+/**
+ * \brief test table for case 4
+ * Interior to test
+ * When the test on the interior is negative : 2 first triangles
+ * When the test on the interior is positive : 6 last triangles
+ *
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int test4[8] = {
+/*  65: 0,                6,     */   7,
+/* 130:    1,                7,  */   7,
+/*  20:       2,    4,           */   7,
+/*  40:          3,    5,        */   7,
+/* 215: 0, 1, 2,    4,    6, 7,  */  -7,
+/* 235: 0, 1,    3,    5, 6, 7,  */  -7,
+/* 125: 0,    2, 3, 4, 5, 6,     */  -7,
+/* 190:    1, 2, 3, 4, 5,    7,  */  -7
+};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 4.1
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling4_1[8][6] = {
+/*  65: 0,                6,     */  {  0,  8,  3,  5, 10,  6 },
+/* 130:    1,                7,  */  {  0,  1,  9, 11,  7,  6 },
+/*  20:       2,    4,           */  {  1,  2, 10,  8,  4,  7 },
+/*  40:          3,    5,        */  {  9,  5,  4,  2,  3, 11 },
+/* 215: 0, 1, 2,    4,    6, 7,  */  {  4,  5,  9, 11,  3,  2 },
+/* 235: 0, 1,    3,    5, 6, 7,  */  { 10,  2,  1,  7,  4,  8 },
+/* 125: 0,    2, 3, 4, 5, 6,     */  {  9,  1,  0,  6,  7, 11 },
+/* 190:    1, 2, 3, 4, 5,    7,  */  {  3,  8,  0,  6, 10,  5 }
+};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 4.2
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling4_2[8][18] = {
+/*  65: 0,                6,     */  {  8,  5,  0,  5,  8,  6,  3,  6,  8,  6,  3, \
10,  0, 10,  3, 10,  0,  5 }, +/* 130:    1,                7,  */  {  9,  6,  1,  6, \
9,  7,  0,  7,  9,  7,  0, 11,  1, 11,  0, 11,  1,  6 }, +/*  20:       2,    4,      \
*/  { 10,  7,  2,  7, 10,  4,  1,  4, 10,  4,  1,  8,  2,  8,  1,  8,  2,  7 }, +/*  \
40:          3,    5,        */  { 11,  4,  3,  4, 11,  5,  2,  5, 11,  5,  2,  9,  \
3,  9,  2,  9,  3,  4 }, +/* 215: 0, 1, 2,    4,    6, 7,  */  {  3,  4, 11,  5, 11,  \
4, 11,  5,  2,  9,  2,  5,  2,  9,  3,  4,  3,  9 }, +/* 235: 0, 1,    3,    5, 6, 7, \
*/  {  2,  7, 10,  4, 10,  7, 10,  4,  1,  8,  1,  4,  1,  8,  2,  7,  2,  8 }, +/* \
125: 0,    2, 3, 4, 5, 6,     */  {  1,  6,  9,  7,  9,  6,  9,  7,  0, 11,  0,  7,  \
0, 11,  1,  6,  1, 11 }, +/* 190:    1, 2, 3, 4, 5,    7,  */  {  0,  5,  8,  6,  8,  \
5,  8,  6,  3, 10,  3,  6,  3, 10,  0,  5,  0, 10 } +};
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 5
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling5[48][9] = {
+/*   7: 0, 1, 2,                 */  {  2,  8,  3,  2, 10,  8, 10,  9,  8 },
+/*  11: 0, 1,    3,              */  {  1, 11,  2,  1,  9, 11,  9,  8, 11 },
+/*  19: 0, 1,       4,           */  {  4,  1,  9,  4,  7,  1,  7,  3,  1 },
+/*  35: 0, 1,          5,        */  {  8,  5,  4,  8,  3,  5,  3,  1,  5 },
+/*  13: 0,    2, 3,              */  {  0, 10,  1,  0,  8, 10,  8, 11, 10 },
+/*  25: 0,       3, 4,           */  { 11,  4,  7, 11,  2,  4,  2,  0,  4 },
+/* 137: 0,       3,          7,  */  {  7,  0,  8,  7,  6,  0,  6,  2,  0 },
+/*  49: 0,          4, 5,        */  {  9,  3,  0,  9,  5,  3,  5,  7,  3 },
+/* 145: 0,          4,       7,  */  {  3,  6, 11,  3,  0,  6,  0,  4,  6 },
+/*  14:    1, 2, 3,              */  {  3,  9,  0,  3, 11,  9, 11, 10,  9 },
+/*  38:    1, 2,       5,        */  {  5,  2, 10,  5,  4,  2,  4,  0,  2 },
+/*  70:    1, 2,          6,     */  {  9,  6,  5,  9,  0,  6,  0,  2,  6 },
+/*  50:    1,       4, 5,        */  {  0,  7,  8,  0,  1,  7,  1,  5,  7 },
+/*  98:    1,          5, 6,     */  { 10,  0,  1, 10,  6,  0,  6,  4,  0 },
+/*  76:       2, 3,       6,     */  {  6,  3, 11,  6,  5,  3,  5,  1,  3 },
+/* 140:       2, 3,          7,  */  { 10,  7,  6, 10,  1,  7,  1,  3,  7 },
+/* 100:       2,       5, 6,     */  {  1,  4,  9,  1,  2,  4,  2,  6,  4 },
+/* 196:       2,          6, 7,  */  { 11,  1,  2, 11,  7,  1,  7,  5,  1 },
+/* 152:          3, 4,       7,  */  {  8,  2,  3,  8,  4,  2,  4,  6,  2 },
+/* 200:          3,       6, 7,  */  {  2,  5, 10,  2,  3,  5,  3,  7,  5 },
+/* 112:             4, 5, 6,     */  {  7, 10,  6,  7,  8, 10,  8,  9, 10 },
+/* 176:             4, 5,    7,  */  {  6,  9,  5,  6, 11,  9, 11,  8,  9 },
+/* 208:             4,    6, 7,  */  {  5,  8,  4,  5, 10,  8, 10, 11,  8 },
+/* 224:                5, 6, 7,  */  {  4, 11,  7,  4,  9, 11,  9, 10, 11 },
+/*  31: 0, 1, 2, 3, 4,           */  {  4,  7, 11,  4, 11,  9,  9, 11, 10 },
+/*  47: 0, 1, 2, 3,    5,        */  {  5,  4,  8,  5,  8, 10, 10,  8, 11 },
+/*  79: 0, 1, 2, 3,       6,     */  {  6,  5,  9,  6,  9, 11, 11,  9,  8 },
+/* 143: 0, 1, 2, 3,          7,  */  {  7,  6, 10,  7, 10,  8,  8, 10,  9 },
+/*  55: 0, 1, 2,    4, 5,        */  {  2, 10,  5,  2,  5,  3,  3,  5,  7 },
+/* 103: 0, 1, 2,       5, 6,     */  {  8,  3,  2,  8,  2,  4,  4,  2,  6 },
+/*  59: 0, 1,    3, 4, 5,        */  { 11,  2,  1, 11,  1,  7,  7,  1,  5 },
+/* 155: 0, 1,    3, 4,       7,  */  {  1,  9,  4,  1,  4,  2,  2,  4,  6 },
+/* 115: 0, 1,       4, 5, 6,     */  { 10,  6,  7, 10,  7,  1,  1,  7,  3 },
+/* 179: 0, 1,       4, 5,    7,  */  {  6, 11,  3,  6,  3,  5,  5,  3,  1 },
+/* 157: 0,    2, 3, 4,       7,  */  { 10,  1,  0, 10,  0,  6,  6,  0,  4 },
+/* 205: 0,    2, 3,       6, 7,  */  {  0,  8,  7,  0,  7,  1,  1,  7,  5 },
+/* 185: 0,       3, 4, 5,    7,  */  {  9,  5,  6,  9,  6,  0,  0,  6,  2 },
+/* 217: 0,       3, 4,    6, 7,  */  {  5, 10,  2,  5,  2,  4,  4,  2,  0 },
+/* 241: 0,          4, 5, 6, 7,  */  {  3,  0,  9,  3,  9, 11, 11,  9, 10 },
+/* 110:    1, 2, 3,    5, 6,     */  {  3, 11,  6,  3,  6,  0,  0,  6,  4 },
+/* 206:    1, 2, 3,       6, 7,  */  {  9,  0,  3,  9,  3,  5,  5,  3,  7 },
+/* 118:    1, 2,    4, 5, 6,     */  {  7,  8,  0,  7,  0,  6,  6,  0,  2 },
+/* 230:    1, 2,       5, 6, 7,  */  { 11,  7,  4, 11,  4,  2,  2,  4,  0 },
+/* 242:    1,       4, 5, 6, 7,  */  {  0,  1, 10,  0, 10,  8,  8, 10, 11 },
+/* 220:       2, 3, 4,    6, 7,  */  {  8,  4,  5,  8,  5,  3,  3,  5,  1 },
+/* 236:       2, 3,    5, 6, 7,  */  {  4,  9,  1,  4,  1,  7,  7,  1,  3 },
+/* 244:       2,    4, 5, 6, 7,  */  {  1,  2, 11,  1, 11,  9,  9, 11,  8 },
+/* 248:          3, 4, 5, 6, 7,  */  {  2,  3,  8,  2,  8, 10, 10,  8,  9 }
+};
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+/**
+ * \brief test table for case 6
+ * 1 face to test + eventually the interior
+ * When the test on the specified face is positive : 5 first triangles
+ * When the test on the specified face is negative :
+ * - if the test on the interior is negative : 3 middle triangles
+ * - if the test on the interior is positive : 8 last triangles
+ * The support edge for the interior test is marked as the 3rd column.
+ *
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int test6[48][3] = {
+/*  67: 0, 1,             6,     */  {  2,  7,  10  },
+/* 131: 0, 1,                7,  */  {  4,  7,  11  },
+/*  21: 0,    2,    4,           */  {  5,  7,   1  },
+/*  69: 0,    2,          6,     */  {  5,  7,   3  },
+/*  41: 0,       3,    5,        */  {  1,  7,   9  },
+/*  73: 0,       3,       6,     */  {  3,  7,  10  },
+/*  81: 0,          4,    6,     */  {  6,  7,   5  },
+/*  97: 0,             5, 6,     */  {  1,  7,   8  },
+/* 193: 0,                6, 7,  */  {  4,  7,   8  },
+/*  22:    1, 2,    4,           */  {  1,  7,   8  },
+/* 134:    1, 2,             7,  */  {  3,  7,  11  },
+/*  42:    1,    3,    5,        */  {  5,  7,   2  },
+/* 138:    1,    3,          7,  */  {  5,  7,   0  },
+/* 146:    1,       4,       7,  */  {  1,  7,   9  },
+/* 162:    1,          5,    7,  */  {  6,  7,   6  },
+/* 194:    1,             6, 7,  */  {  2,  7,   9  },
+/*  28:       2, 3, 4,           */  {  4,  7,   8  },
+/*  44:       2, 3,    5,        */  {  2,  7,   9  },
+/*  52:       2,    4, 5,        */  {  2,  7,  10  },
+/*  84:       2,    4,    6,     */  {  6,  7,   7  },
+/* 148:       2,    4,       7,  */  {  3,  7,  10  },
+/*  56:          3, 4, 5,        */  {  4,  7,  11  },
+/* 104:          3,    5, 6,     */  {  3,  7,  11  },
+/* 168:          3,    5,    7,  */  {  6,  7,   4  },
+/*  87: 0, 1, 2,    4,    6,     */  { -6, -7,   4  },
+/* 151: 0, 1, 2,    4,       7,  */  { -3, -7,  11  },
+/* 199: 0, 1, 2,          6, 7,  */  { -4, -7,  11  },
+/* 107: 0, 1,    3,    5, 6,     */  { -3, -7,  10  },
+/* 171: 0, 1,    3,    5,    7,  */  { -6, -7,   7  },
+/* 203: 0, 1,    3,       6, 7,  */  { -2, -7,  10  },
+/* 211: 0, 1,       4,    6, 7,  */  { -2, -7,   9  },
+/* 227: 0, 1,          5, 6, 7,  */  { -4, -7,   8  },
+/*  61: 0,    2, 3, 4, 5,        */  { -2, -7,   9  },
+/*  93: 0,    2, 3, 4,    6,     */  { -6, -7,   6  },
+/* 109: 0,    2, 3,    5, 6,     */  { -1, -7,   9  },
+/* 117: 0,    2,    4, 5, 6,     */  { -5, -7,   0  },
+/* 213: 0,    2,    4,    6, 7,  */  { -5, -7,   2  },
+/* 121: 0,       3, 4, 5, 6,     */  { -3, -7,  11  },
+/* 233: 0,       3,    5, 6, 7,  */  { -1, -7,   8  },
+/*  62:    1, 2, 3, 4, 5,        */  { -4, -7,   8  },
+/* 158:    1, 2, 3, 4,       7,  */  { -1, -7,   8  },
+/* 174:    1, 2, 3,    5,    7,  */  { -6, -7,   5  },
+/* 182:    1, 2,    4, 5,    7,  */  { -3, -7,  10  },
+/* 214:    1, 2,    4,    6, 7,  */  { -1, -7,   9  },
+/* 186:    1,    3, 4, 5,    7,  */  { -5, -7,   3  },
+/* 234:    1,    3,    5, 6, 7,  */  { -5, -7,   1  },
+/* 124:       2, 3, 4, 5, 6,     */  { -4, -7,  11  },
+/* 188:       2, 3, 4, 5,    7,  */  { -2, -7,  10  }
+};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 6.1.1
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling6_1_1[48][9] = {
+/*  67: 0, 1,             6,     */  {  6,  5, 10,  3,  1,  8,  9,  8,  1 },
+/* 131: 0, 1,                7,  */  { 11,  7,  6,  9,  3,  1,  3,  9,  8 },
+/*  21: 0,    2,    4,           */  {  1,  2, 10,  7,  0,  4,  0,  7,  3 },
+/*  69: 0,    2,          6,     */  {  3,  0,  8,  5,  2,  6,  2,  5,  1 },
+/*  41: 0,       3,    5,        */  {  5,  4,  9,  2,  0, 11,  8, 11,  0 },
+/*  73: 0,       3,       6,     */  { 10,  6,  5,  8,  2,  0,  2,  8, 11 },
+/*  81: 0,          4,    6,     */  { 10,  6,  5,  0,  4,  3,  7,  3,  4 },
+/*  97: 0,             5, 6,     */  {  3,  0,  8,  6,  4, 10,  9, 10,  4 },
+/* 193: 0,                6, 7,  */  {  8,  3,  0, 10,  7,  5,  7, 10, 11 },
+/*  22:    1, 2,    4,           */  {  8,  4,  7, 10,  0,  2,  0, 10,  9 },
+/* 134:    1, 2,             7,  */  {  7,  6, 11,  0,  2,  9, 10,  9,  2 },
+/*  42:    1,    3,    5,        */  {  2,  3, 11,  4,  1,  5,  1,  4,  0 },
+/* 138:    1,    3,          7,  */  {  0,  1,  9,  6,  3,  7,  3,  6,  2 },
+/* 146:    1,       4,       7,  */  {  9,  0,  1, 11,  4,  6,  4, 11,  8 },
+/* 162:    1,          5,    7,  */  { 11,  7,  6,  1,  5,  0,  4,  0,  5 },
+/* 194:    1,             6, 7,  */  {  0,  1,  9,  7,  5, 11, 10, 11,  5 },
+/*  28:       2, 3, 4,           */  {  4,  7,  8,  1,  3, 10, 11, 10,  3 },
+/*  44:       2, 3,    5,        */  {  9,  5,  4, 11,  1,  3,  1, 11, 10 },
+/*  52:       2,    4, 5,        */  { 10,  1,  2,  8,  5,  7,  5,  8,  9 },
+/*  84:       2,    4,    6,     */  {  8,  4,  7,  2,  6,  1,  5,  1,  6 },
+/* 148:       2,    4,       7,  */  {  1,  2, 10,  4,  6,  8, 11,  8,  6 },
+/*  56:          3, 4, 5,        */  {  2,  3, 11,  5,  7,  9,  8,  9,  7 },
+/* 104:          3,    5, 6,     */  { 11,  2,  3,  9,  6,  4,  6,  9, 10 },
+/* 168:          3,    5,    7,  */  {  9,  5,  4,  3,  7,  2,  6,  2,  7 },
+/*  87: 0, 1, 2,    4,    6,     */  {  4,  5,  9,  2,  7,  3,  7,  2,  6 },
+/* 151: 0, 1, 2,    4,       7,  */  {  3,  2, 11,  4,  6,  9, 10,  9,  6 },
+/* 199: 0, 1, 2,          6, 7,  */  { 11,  3,  2,  9,  7,  5,  7,  9,  8 },
+/* 107: 0, 1,    3,    5, 6,     */  { 10,  2,  1,  8,  6,  4,  6,  8, 11 },
+/* 171: 0, 1,    3,    5,    7,  */  {  7,  4,  8,  1,  6,  2,  6,  1,  5 },
+/* 203: 0, 1,    3,       6, 7,  */  {  2,  1, 10,  7,  5,  8,  9,  8,  5 },
+/* 211: 0, 1,       4,    6, 7,  */  {  4,  5,  9,  3,  1, 11, 10, 11,  1 },
+/* 227: 0, 1,          5, 6, 7,  */  {  8,  7,  4, 10,  3,  1,  3, 10, 11 },
+/*  61: 0,    2, 3, 4, 5,        */  {  9,  1,  0, 11,  5,  7,  5, 11, 10 },
+/*  93: 0,    2, 3, 4,    6,     */  {  6,  7, 11,  0,  5,  1,  5,  0,  4 },
+/* 109: 0,    2, 3,    5, 6,     */  {  1,  0,  9,  6,  4, 11,  8, 11,  4 },
+/* 117: 0,    2,    4, 5, 6,     */  {  9,  1,  0,  7,  3,  6,  2,  6,  3 },
+/* 213: 0,    2,    4,    6, 7,  */  { 11,  3,  2,  5,  1,  4,  0,  4,  1 },
+/* 121: 0,       3, 4, 5, 6,     */  { 11,  6,  7,  9,  2,  0,  2,  9, 10 },
+/* 233: 0,       3,    5, 6, 7,  */  {  7,  4,  8,  2,  0, 10,  9, 10,  0 },
+/*  62:    1, 2, 3, 4, 5,        */  {  0,  3,  8,  5,  7, 10, 11, 10,  7 },
+/* 158:    1, 2, 3, 4,       7,  */  {  8,  0,  3, 10,  4,  6,  4, 10,  9 },
+/* 174:    1, 2, 3,    5,    7,  */  {  5,  6, 10,  3,  4,  0,  4,  3,  7 },
+/* 182:    1, 2,    4, 5,    7,  */  {  5,  6, 10,  0,  2,  8, 11,  8,  2 },
+/* 214:    1, 2,    4,    6, 7,  */  {  9,  4,  5, 11,  0,  2,  0, 11,  8 },
+/* 186:    1,    3, 4, 5,    7,  */  {  8,  0,  3,  6,  2,  5,  1,  5,  2 },
+/* 234:    1,    3,    5, 6, 7,  */  { 10,  2,  1,  4,  0,  7,  3,  7,  0 },
+/* 124:       2, 3, 4, 5, 6,     */  {  6,  7, 11,  1,  3,  9,  8,  9,  3 },
+/* 188:       2, 3, 4, 5,    7,  */  { 10,  5,  6,  8,  1,  3,  1,  8,  9 }
+};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 6.1.2
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling6_1_2[48][21] = {
+/*  67: 0, 1,             6,     */  {  1, 10,  3,  6,  3, 10,  3,  6,  8,  5,  8,  \
6,  8,  5,  9,  1,  9,  5, 10,  1,  5 }, +/* 131: 0, 1,                7,  */  {  1, \
11,  3, 11,  1,  6,  9,  6,  1,  6,  9,  7,  8,  7,  9,  7,  8,  3,  7,  3, 11 }, +/* \
21: 0,    2,    4,           */  {  4,  1,  0,  1,  4, 10,  7, 10,  4, 10,  7,  2,  \
3,  2,  7,  2,  3,  0,  2,  0,  1 }, +/*  69: 0,    2,          6,     */  {  6,  3,  \
2,  3,  6,  8,  5,  8,  6,  8,  5,  0,  1,  0,  5,  0,  1,  2,  0,  2,  3 }, +/*  41: \
0,       3,    5,        */  {  0,  9,  2,  5,  2,  9,  2,  5, 11,  4, 11,  5, 11,  \
4,  8,  0,  8,  4,  9,  0,  4 }, +/*  73: 0,       3,       6,     */  {  0, 10,  2, \
10,  0,  5,  8,  5,  0,  5,  8,  6, 11,  6,  8,  6, 11,  2,  6,  2, 10 }, +/*  81: 0, \
4,    6,     */  {  4,  5,  0, 10,  0,  5,  0, 10,  3,  6,  3, 10,  3,  6,  7,  4,  \
7,  6,  5,  4,  6 }, +/*  97: 0,             5, 6,     */  {  4,  8,  6,  3,  6,  8,  \
6,  3, 10,  0, 10,  3, 10,  0,  9,  4,  9,  0,  8,  4,  0 }, +/* 193: 0,              \
6, 7,  */  {  5,  8,  7,  8,  5,  0, 10,  0,  5,  0, 10,  3, 11,  3, 10,  3, 11,  7,  \
3,  7,  8 }, +/*  22:    1, 2,    4,           */  {  2,  8,  0,  8,  2,  7, 10,  7,  \
2,  7, 10,  4,  9,  4, 10,  4,  9,  0,  4,  0,  8 }, +/* 134:    1, 2,             7, \
*/  {  2, 11,  0,  7,  0, 11,  0,  7,  9,  6,  9,  7,  9,  6, 10,  2, 10,  6, 11,  2, \
6 }, +/*  42:    1,    3,    5,        */  {  5,  2,  1,  2,  5, 11,  4, 11,  5, 11,  \
4,  3,  0,  3,  4,  3,  0,  1,  3,  1,  2 }, +/* 138:    1,    3,          7,  */  {  \
7,  0,  3,  0,  7,  9,  6,  9,  7,  9,  6,  1,  2,  1,  6,  1,  2,  3,  1,  3,  0 }, \
+/* 146:    1,       4,       7,  */  {  6,  9,  4,  9,  6,  1, 11,  1,  6,  1, 11,  \
0,  8,  0, 11,  0,  8,  4,  0,  4,  9 }, +/* 162:    1,          5,    7,  */  {  5,  \
6,  1, 11,  1,  6,  1, 11,  0,  7,  0, 11,  0,  7,  4,  5,  4,  7,  6,  5,  7 }, +/* \
194:    1,             6, 7,  */  {  5,  9,  7,  0,  7,  9,  7,  0, 11,  1, 11,  0, \
11,  1, 10,  5, 10,  1,  9,  5,  1 }, +/*  28:       2, 3, 4,           */  {  3,  8, \
1,  4,  1,  8,  1,  4, 10,  7, 10,  4, 10,  7, 11,  3, 11,  7,  8,  3,  7 }, +/*  44: \
2, 3,    5,        */  {  3,  9,  1,  9,  3,  4, 11,  4,  3,  4, 11,  5, 10,  5, 11,  \
5, 10,  1,  5,  1,  9 }, +/*  52:       2,    4, 5,        */  {  7, 10,  5, 10,  7,  \
2,  8,  2,  7,  2,  8,  1,  9,  1,  8,  1,  9,  5,  1,  5, 10 }, +/*  84:       2,    \
4,    6,     */  {  6,  7,  2,  8,  2,  7,  2,  8,  1,  4,  1,  8,  1,  4,  5,  6,  \
5,  4,  7,  6,  4 }, +/* 148:       2,    4,       7,  */  {  6, 10,  4,  1,  4, 10,  \
4,  1,  8,  2,  8,  1,  8,  2, 11,  6, 11,  2, 10,  6,  2 }, +/*  56:          3, 4, \
5,        */  {  7, 11,  5,  2,  5, 11,  5,  2,  9,  3,  9,  2,  9,  3,  8,  7,  8,  \
3, 11,  7,  3 }, +/* 104:          3,    5, 6,     */  {  4, 11,  6, 11,  4,  3,  9,  \
3,  4,  3,  9,  2, 10,  2,  9,  2, 10,  6,  2,  6, 11 }, +/* 168:          3,    5,   \
7,  */  {  7,  4,  3,  9,  3,  4,  3,  9,  2,  5,  2,  9,  2,  5,  6,  7,  6,  5,  4, \
7,  5 }, +/*  87: 0, 1, 2,    4,    6,     */  {  3,  4,  7,  4,  3,  9,  2,  9,  3,  \
9,  2,  5,  6,  5,  2,  5,  6,  7,  5,  7,  4 }, +/* 151: 0, 1, 2,    4,       7,  */ \
{  6, 11,  4,  3,  4, 11,  4,  3,  9,  2,  9,  3,  9,  2, 10,  6, 10,  2, 11,  6,  2 \
}, +/* 199: 0, 1, 2,          6, 7,  */  {  5, 11,  7, 11,  5,  2,  9,  2,  5,  2,  \
9,  3,  8,  3,  9,  3,  8,  7,  3,  7, 11 }, +/* 107: 0, 1,    3,    5, 6,     */  {  \
4, 10,  6, 10,  4,  1,  8,  1,  4,  1,  8,  2, 11,  2,  8,  2, 11,  6,  2,  6, 10 }, \
+/* 171: 0, 1,    3,    5,    7,  */  {  2,  7,  6,  7,  2,  8,  1,  8,  2,  8,  1,  \
4,  5,  4,  1,  4,  5,  6,  4,  6,  7 }, +/* 203: 0, 1,    3,       6, 7,  */  {  5, \
10,  7,  2,  7, 10,  7,  2,  8,  1,  8,  2,  8,  1,  9,  5,  9,  1, 10,  5,  1 }, +/* \
211: 0, 1,       4,    6, 7,  */  {  1,  9,  3,  4,  3,  9,  3,  4, 11,  5, 11,  4, \
11,  5, 10,  1, 10,  5,  9,  1,  5 }, +/* 227: 0, 1,          5, 6, 7,  */  {  1,  8, \
3,  8,  1,  4, 10,  4,  1,  4, 10,  7, 11,  7, 10,  7, 11,  3,  7,  3,  8 }, +/*  61: \
0,    2, 3, 4, 5,        */  {  7,  9,  5,  9,  7,  0, 11,  0,  7,  0, 11,  1, 10,  \
1, 11,  1, 10,  5,  1,  5,  9 }, +/*  93: 0,    2, 3, 4,    6,     */  {  1,  6,  5,  \
6,  1, 11,  0, 11,  1, 11,  0,  7,  4,  7,  0,  7,  4,  5,  7,  5,  6 }, +/* 109: 0,  \
2, 3,    5, 6,     */  {  4,  9,  6,  1,  6,  9,  6,  1, 11,  0, 11,  1, 11,  0,  8,  \
4,  8,  0,  9,  4,  0 }, +/* 117: 0,    2,    4, 5, 6,     */  {  3,  0,  7,  9,  7,  \
0,  7,  9,  6,  1,  6,  9,  6,  1,  2,  3,  2,  1,  0,  3,  1 }, +/* 213: 0,    2,    \
4,    6, 7,  */  {  1,  2,  5, 11,  5,  2,  5, 11,  4,  3,  4, 11,  4,  3,  0,  1,  \
0,  3,  2,  1,  3 }, +/* 121: 0,       3, 4, 5, 6,     */  {  0, 11,  2, 11,  0,  7,  \
9,  7,  0,  7,  9,  6, 10,  6,  9,  6, 10,  2,  6,  2, 11 }, +/* 233: 0,       3,    \
5, 6, 7,  */  {  0,  8,  2,  7,  2,  8,  2,  7, 10,  4, 10,  7, 10,  4,  9,  0,  9,  \
4,  8,  0,  4 }, +/*  62:    1, 2, 3, 4, 5,        */  {  7,  8,  5,  0,  5,  8,  5,  \
0, 10,  3, 10,  0, 10,  3, 11,  7, 11,  3,  8,  7,  3 }, +/* 158:    1, 2, 3, 4,      \
7,  */  {  6,  8,  4,  8,  6,  3, 10,  3,  6,  3, 10,  0,  9,  0, 10,  0,  9,  4,  0, \
4,  8 }, +/* 174:    1, 2, 3,    5,    7,  */  {  0,  5,  4,  5,  0, 10,  3, 10,  0, \
10,  3,  6,  7,  6,  3,  6,  7,  4,  6,  4,  5 }, +/* 182:    1, 2,    4, 5,    7,  \
*/  {  2, 10,  0,  5,  0, 10,  0,  5,  8,  6,  8,  5,  8,  6, 11,  2, 11,  6, 10,  2, \
6 }, +/* 214:    1, 2,    4,    6, 7,  */  {  2,  9,  0,  9,  2,  5, 11,  5,  2,  5, \
11,  4,  8,  4, 11,  4,  8,  0,  4,  0,  9 }, +/* 186:    1,    3, 4, 5,    7,  */  { \
2,  3,  6,  8,  6,  3,  6,  8,  5,  0,  5,  8,  5,  0,  1,  2,  1,  0,  3,  2,  0 }, \
+/* 234:    1,    3,    5, 6, 7,  */  {  0,  1,  4, 10,  4,  1,  4, 10,  7,  2,  7, \
10,  7,  2,  3,  0,  3,  2,  1,  0,  2 }, +/* 124:       2, 3, 4, 5, 6,     */  {  3, \
11,  1,  6,  1, 11,  1,  6,  9,  7,  9,  6,  9,  7,  8,  3,  8,  7, 11,  3,  7 }, +/* \
188:       2, 3, 4, 5,    7,  */  {  3, 10,  1, 10,  3,  6,  8,  6,  3,  6,  8,  5,  \
9,  5,  8,  5,  9,  1,  5,  1, 10 } +};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 6.2
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling6_2[48][15] = {
+/*  67: 0, 1,             6,     */  {  1, 10,  3,  6,  3, 10,  3,  6,  8,  5,  8,  \
6,  8,  5,  9 }, +/* 131: 0, 1,                7,  */  {  1, 11,  3, 11,  1,  6,  9,  \
6,  1,  6,  9,  7,  8,  7,  9 }, +/*  21: 0,    2,    4,           */  {  4,  1,  0,  \
1,  4, 10,  7, 10,  4, 10,  7,  2,  3,  2,  7 }, +/*  69: 0,    2,          6,     */ \
{  6,  3,  2,  3,  6,  8,  5,  8,  6,  8,  5,  0,  1,  0,  5 }, +/*  41: 0,       3,  \
5,        */  {  0,  9,  2,  5,  2,  9,  2,  5, 11,  4, 11,  5, 11,  4,  8 }, +/*  \
73: 0,       3,       6,     */  {  0, 10,  2, 10,  0,  5,  8,  5,  0,  5,  8,  6, \
11,  6,  8 }, +/*  81: 0,          4,    6,     */  {  4,  5,  0, 10,  0,  5,  0, 10, \
3,  6,  3, 10,  3,  6,  7 }, +/*  97: 0,             5, 6,     */  {  4,  8,  6,  3,  \
6,  8,  6,  3, 10,  0, 10,  3, 10,  0,  9 }, +/* 193: 0,                6, 7,  */  {  \
5,  8,  7,  8,  5,  0, 10,  0,  5,  0, 10,  3, 11,  3, 10 }, +/*  22:    1, 2,    4,  \
*/  {  2,  8,  0,  8,  2,  7, 10,  7,  2,  7, 10,  4,  9,  4, 10 }, +/* 134:    1, 2, \
7,  */  {  2, 11,  0,  7,  0, 11,  0,  7,  9,  6,  9,  7,  9,  6, 10 }, +/*  42:    \
1,    3,    5,        */  {  5,  2,  1,  2,  5, 11,  4, 11,  5, 11,  4,  3,  0,  3,  \
4 }, +/* 138:    1,    3,          7,  */  {  7,  0,  3,  0,  7,  9,  6,  9,  7,  9,  \
6,  1,  2,  1,  6 }, +/* 146:    1,       4,       7,  */  {  6,  9,  4,  9,  6,  1, \
11,  1,  6,  1, 11,  0,  8,  0, 11 }, +/* 162:    1,          5,    7,  */  {  5,  6, \
1, 11,  1,  6,  1, 11,  0,  7,  0, 11,  0,  7,  4 }, +/* 194:    1,             6, 7, \
*/  {  5,  9,  7,  0,  7,  9,  7,  0, 11,  1, 11,  0, 11,  1, 10 }, +/*  28:       2, \
3, 4,           */  {  3,  8,  1,  4,  1,  8,  1,  4, 10,  7, 10,  4, 10,  7, 11 }, \
+/*  44:       2, 3,    5,        */  {  3,  9,  1,  9,  3,  4, 11,  4,  3,  4, 11,  \
5, 10,  5, 11 }, +/*  52:       2,    4, 5,        */  {  7, 10,  5, 10,  7,  2,  8,  \
2,  7,  2,  8,  1,  9,  1,  8 }, +/*  84:       2,    4,    6,     */  {  6,  7,  2,  \
8,  2,  7,  2,  8,  1,  4,  1,  8,  1,  4,  5 }, +/* 148:       2,    4,       7,  */ \
{  6, 10,  4,  1,  4, 10,  4,  1,  8,  2,  8,  1,  8,  2, 11 }, +/*  56:          3, \
4, 5,        */  {  7, 11,  5,  2,  5, 11,  5,  2,  9,  3,  9,  2,  9,  3,  8 }, +/* \
104:          3,    5, 6,     */  {  4, 11,  6, 11,  4,  3,  9,  3,  4,  3,  9,  2, \
10,  2,  9 }, +/* 168:          3,    5,    7,  */  {  7,  4,  3,  9,  3,  4,  3,  9, \
2,  5,  2,  9,  2,  5,  6 }, +/*  87: 0, 1, 2,    4,    6,     */  {  3,  4,  7,  4,  \
3,  9,  2,  9,  3,  9,  2,  5,  6,  5,  2 }, +/* 151: 0, 1, 2,    4,       7,  */  {  \
6, 11,  4,  3,  4, 11,  4,  3,  9,  2,  9,  3,  9,  2, 10 }, +/* 199: 0, 1, 2,        \
6, 7,  */  {  5, 11,  7, 11,  5,  2,  9,  2,  5,  2,  9,  3,  8,  3,  9 }, +/* 107: \
0, 1,    3,    5, 6,     */  {  4, 10,  6, 10,  4,  1,  8,  1,  4,  1,  8,  2, 11,  \
2,  8 }, +/* 171: 0, 1,    3,    5,    7,  */  {  2,  7,  6,  7,  2,  8,  1,  8,  2,  \
8,  1,  4,  5,  4,  1 }, +/* 203: 0, 1,    3,       6, 7,  */  {  5, 10,  7,  2,  7, \
10,  7,  2,  8,  1,  8,  2,  8,  1,  9 }, +/* 211: 0, 1,       4,    6, 7,  */  {  1, \
9,  3,  4,  3,  9,  3,  4, 11,  5, 11,  4, 11,  5, 10 }, +/* 227: 0, 1,          5, \
6, 7,  */  {  1,  8,  3,  8,  1,  4, 10,  4,  1,  4, 10,  7, 11,  7, 10 }, +/*  61: \
0,    2, 3, 4, 5,        */  {  7,  9,  5,  9,  7,  0, 11,  0,  7,  0, 11,  1, 10,  \
1, 11 }, +/*  93: 0,    2, 3, 4,    6,     */  {  1,  6,  5,  6,  1, 11,  0, 11,  1, \
11,  0,  7,  4,  7,  0 }, +/* 109: 0,    2, 3,    5, 6,     */  {  4,  9,  6,  1,  6, \
9,  6,  1, 11,  0, 11,  1, 11,  0,  8 }, +/* 117: 0,    2,    4, 5, 6,     */  {  3,  \
0,  7,  9,  7,  0,  7,  9,  6,  1,  6,  9,  6,  1,  2 }, +/* 213: 0,    2,    4,    \
6, 7,  */  {  1,  2,  5, 11,  5,  2,  5, 11,  4,  3,  4, 11,  4,  3,  0 }, +/* 121: \
0,       3, 4, 5, 6,     */  {  0, 11,  2, 11,  0,  7,  9,  7,  0,  7,  9,  6, 10,  \
6,  9 }, +/* 233: 0,       3,    5, 6, 7,  */  {  0,  8,  2,  7,  2,  8,  2,  7, 10,  \
4, 10,  7, 10,  4,  9 }, +/*  62:    1, 2, 3, 4, 5,        */  {  7,  8,  5,  0,  5,  \
8,  5,  0, 10,  3, 10,  0, 10,  3, 11 }, +/* 158:    1, 2, 3, 4,       7,  */  {  6,  \
8,  4,  8,  6,  3, 10,  3,  6,  3, 10,  0,  9,  0, 10 }, +/* 174:    1, 2, 3,    5,   \
7,  */  {  0,  5,  4,  5,  0, 10,  3, 10,  0, 10,  3,  6,  7,  6,  3 }, +/* 182:    \
1, 2,    4, 5,    7,  */  {  2, 10,  0,  5,  0, 10,  0,  5,  8,  6,  8,  5,  8,  6, \
11 }, +/* 214:    1, 2,    4,    6, 7,  */  {  2,  9,  0,  9,  2,  5, 11,  5,  2,  5, \
11,  4,  8,  4, 11 }, +/* 186:    1,    3, 4, 5,    7,  */  {  2,  3,  6,  8,  6,  3, \
6,  8,  5,  0,  5,  8,  5,  0,  1 }, +/* 234:    1,    3,    5, 6, 7,  */  {  0,  1,  \
4, 10,  4,  1,  4, 10,  7,  2,  7, 10,  7,  2,  3 }, +/* 124:       2, 3, 4, 5, 6,    \
*/  {  3, 11,  1,  6,  1, 11,  1,  6,  9,  7,  9,  6,  9,  7,  8 }, +/* 188:       2, \
3, 4, 5,    7,  */  {  3, 10,  1, 10,  3,  6,  8,  6,  3,  6,  8,  5,  9,  5,  8 } \
+}; +//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+/**
+ * \brief test table for case 7
+ * 3 faces to test + eventually the interior
+ * When the tests on the 3 specified faces are positive :
+ * - if the test on the interior is positive : 5 first triangles
+ * - if the test on the interior is negative : 9 next triangles
+ * When the tests on the first  and the second specified faces are positive : 9 next \
triangles + * When the tests on the first  and the third  specified faces are \
positive : 9 next triangles + * When the tests on the second and the third  specified \
faces are positive : 9 next triangles + * When the test on the first  specified face \
is positive : 5 next triangles + * When the test on the second specified face is \
positive : 5 next triangles + * When the test on the third  specified face is \
positive : 5 next triangles + * When the tests on the 3 specified faces are negative \
: 3 last triangles + * The support edge for the interior test is marked as the 5th \
column. + *
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int test7[16][5] = {
+/*  37: 0,    2,       5,        */  {  1,  2,  5,  7,   1 },
+/* 133: 0,    2,             7,  */  {  3,  4,  5,  7,   3 },
+/* 161: 0,             5,    7,  */  {  4,  1,  6,  7,   4 },
+/*  26:    1,    3, 4,           */  {  4,  1,  5,  7,   0 },
+/*  74:    1,    3,       6,     */  {  2,  3,  5,  7,   2 },
+/*  82:    1,       4,    6,     */  {  1,  2,  6,  7,   5 },
+/* 164:       2,       5,    7,  */  {  2,  3,  6,  7,   6 },
+/*  88:          3, 4,    6,     */  {  3,  4,  6,  7,   7 },
+/* 167: 0, 1, 2,       5,    7,  */  { -3, -4, -6, -7,   7 },
+/*  91: 0, 1,    3, 4,    6,     */  { -2, -3, -6, -7,   6 },
+/* 173: 0,    2, 3,    5,    7,  */  { -1, -2, -6, -7,   5 },
+/* 181: 0,    2,    4, 5,    7,  */  { -2, -3, -5, -7,   2 },
+/* 229: 0,    2,       5, 6, 7,  */  { -4, -1, -5, -7,   0 },
+/*  94:    1, 2, 3, 4,    6,     */  { -4, -1, -6, -7,   4 },
+/* 122:    1,    3, 4, 5, 6,     */  { -3, -4, -5, -7,   3 },
+/* 218:    1,    3, 4,    6, 7,  */  { -1, -2, -5, -7,   1 }
+};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 7.1
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling7_1[16][9] = {
+/*  37: 0,    2,       5,        */  {  9,  5,  4, 10,  1,  2,  8,  3,  0 },
+/* 133: 0,    2,             7,  */  { 11,  7,  6,  8,  3,  0, 10,  1,  2 },
+/* 161: 0,             5,    7,  */  {  3,  0,  8,  5,  4,  9,  7,  6, 11 },
+/*  26:    1,    3, 4,           */  {  8,  4,  7,  9,  0,  1, 11,  2,  3 },
+/*  74:    1,    3,       6,     */  { 10,  6,  5, 11,  2,  3,  9,  0,  1 },
+/*  82:    1,       4,    6,     */  {  0,  1,  9,  6,  5, 10,  4,  7,  8 },
+/* 164:       2,       5,    7,  */  {  1,  2, 10,  7,  6, 11,  5,  4,  9 },
+/*  88:          3, 4,    6,     */  {  2,  3, 11,  4,  7,  8,  6,  5, 10 },
+/* 167: 0, 1, 2,       5,    7,  */  { 11,  3,  2,  8,  7,  4, 10,  5,  6 },
+/*  91: 0, 1,    3, 4,    6,     */  { 10,  2,  1, 11,  6,  7,  9,  4,  5 },
+/* 173: 0,    2, 3,    5,    7,  */  {  9,  1,  0, 10,  5,  6,  8,  7,  4 },
+/* 181: 0,    2,    4, 5,    7,  */  {  5,  6, 10,  3,  2, 11,  1,  0,  9 },
+/* 229: 0,    2,       5, 6, 7,  */  {  7,  4,  8,  1,  0,  9,  3,  2, 11 },
+/*  94:    1, 2, 3, 4,    6,     */  {  8,  0,  3,  9,  4,  5, 11,  6,  7 },
+/* 122:    1,    3, 4, 5, 6,     */  {  6,  7, 11,  0,  3,  8,  2,  1, 10 },
+/* 218:    1,    3, 4,    6, 7,  */  {  4,  5,  9,  2,  1, 10,  0,  3,  8 }
+};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 7.2
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling7_2[16][3][15] = {
+/*  37: 0,    2,       5,        */  {
+ /* 1,0 */ {  1,  2, 10,  3,  4,  8,  4,  3,  5,  0,  5,  3,  5,  0,  9 },
+ /* 0,1 */ {  3,  0,  8,  9,  1,  4,  2,  4,  1,  4,  2,  5, 10,  5,  2 },
+ /* 1,1 */ {  9,  5,  4,  0, 10,  1, 10,  0,  8, 10,  8,  2,  3,  2,  8 }
+},
+/* 133: 0,    2,             7,  */  {
+ /* 1,0 */ {  3,  0,  8,  1,  6, 10,  6,  1,  7,  2,  7,  1,  7,  2, 11 },
+ /* 0,1 */ {  1,  2, 10, 11,  3,  6,  0,  6,  3,  6,  0,  7,  8,  7,  0 },
+ /* 1,1 */ { 11,  7,  6,  2,  8,  3,  8,  2, 10,  8, 10,  0,  1,  0, 10 }
+},
+/* 161: 0,             5,    7,  */  {
+ /* 1,0 */ {  9,  5,  4, 11,  3,  6,  0,  6,  3,  6,  0,  7,  8,  7,  0 },
+ /* 0,1 */ { 11,  7,  6,  3,  4,  8,  4,  3,  5,  0,  5,  3,  5,  0,  9 },
+ /* 1,1 */ {  3,  0,  8,  4,  9,  7, 11,  7,  9,  5, 11,  9, 11,  5,  6 }
+},
+/*  26:    1,    3, 4,           */  {
+ /* 1,0 */ {  0,  1,  9,  2,  7, 11,  7,  2,  4,  3,  4,  2,  4,  3,  8 },
+ /* 0,1 */ {  2,  3, 11,  8,  0,  7,  1,  7,  0,  7,  1,  4,  9,  4,  1 },
+ /* 1,1 */ {  8,  4,  7,  3,  9,  0,  9,  3, 11,  9, 11,  1,  2,  1, 11 }
+},
+/*  74:    1,    3,       6,     */  {
+ /* 1,0 */ {  2,  3, 11,  0,  5,  9,  5,  0,  6,  1,  6,  0,  6,  1, 10 },
+ /* 0,1 */ {  0,  1,  9, 10,  2,  5,  3,  5,  2,  5,  3,  6, 11,  6,  3 },
+ /* 1,1 */ {  6,  5, 10,  1, 11,  2, 11,  1,  9, 11,  9,  3,  0,  3,  9 }
+},
+/*  82:    1,       4,    6,     */  {
+ /* 1,0 */ {  6,  5, 10,  8,  0,  7,  1,  7,  0,  7,  1,  4,  9,  4,  1 },
+ /* 0,1 */ {  8,  4,  7,  0,  5,  9,  5,  0,  6,  1,  6,  0,  6,  1, 10 },
+ /* 1,1 */ {  0,  1,  9,  5, 10,  4,  8,  4, 10,  6,  8, 10,  8,  6,  7 }
+},
+/* 164:       2,       5,    7,  */  {
+ /* 1,0 */ { 11,  7,  6,  9,  1,  4,  2,  4,  1,  4,  2,  5, 10,  5,  2 },
+ /* 0,1 */ {  9,  5,  4,  1,  6, 10,  6,  1,  7,  2,  7,  1,  7,  2, 11 },
+ /* 1,1 */ {  1,  2, 10,  6, 11,  5,  9,  5, 11,  7,  9, 11,  9,  7,  4 }
+},
+/*  88:          3, 4,    6,     */  {
+ /* 1,0 */ {  8,  4,  7, 10,  2,  5,  3,  5,  2,  5,  3,  6, 11,  6,  3 },
+ /* 0,1 */ {  6,  5, 10,  2,  7, 11,  7,  2,  4,  3,  4,  2,  4,  3,  8 },
+ /* 1,1 */ {  2,  3, 11,  7,  8,  6, 10,  6,  8,  4, 10,  8, 10,  4,  5 }
+},
+/* 167: 0, 1, 2,       5,    7,  */  {
+ /* 1,0 */ {  7,  4,  8,  5,  2, 10,  2,  5,  3,  6,  3,  5,  3,  6, 11 },
+ /* 0,1 */ { 10,  5,  6, 11,  7,  2,  4,  2,  7,  2,  4,  3,  8,  3,  4 },
+ /* 1,1 */ { 11,  3,  2,  6,  8,  7,  8,  6, 10,  8, 10,  4,  5,  4, 10 }
+},
+/*  91: 0, 1,    3, 4,    6,     */  {
+ /* 1,0 */ {  6,  7, 11,  4,  1,  9,  1,  4,  2,  5,  2,  4,  2,  5, 10 },
+ /* 0,1 */ {  4,  5,  9, 10,  6,  1,  7,  1,  6,  1,  7,  2, 11,  2,  7 },
+ /* 1,1 */ { 10,  2,  1,  5, 11,  6, 11,  5,  9, 11,  9,  7,  4,  7,  9 }
+},
+/* 173: 0,    2, 3,    5,    7,  */  {
+ /* 1,0 */ { 10,  5,  6,  7,  0,  8,  0,  7,  1,  4,  1,  7,  1,  4,  9 },
+ /* 0,1 */ {  7,  4,  8,  9,  5,  0,  6,  0,  5,  0,  6,  1, 10,  1,  6 },
+ /* 1,1 */ {  9,  1,  0,  4, 10,  5, 10,  4,  8, 10,  8,  6,  7,  6,  8 }
+},
+/* 181: 0,    2,    4, 5,    7,  */  {
+ /* 1,0 */ { 11,  3,  2,  9,  5,  0,  6,  0,  5,  0,  6,  1, 10,  1,  6 },
+ /* 0,1 */ {  9,  1,  0,  5,  2, 10,  2,  5,  3,  6,  3,  5,  3,  6, 11 },
+ /* 1,1 */ { 10,  5,  6,  2, 11,  1,  9,  1, 11,  3,  9, 11,  9,  3,  0 }
+},
+/* 229: 0,    2,       5, 6, 7,  */  {
+ /* 1,0 */ {  9,  1,  0, 11,  7,  2,  4,  2,  7,  2,  4,  3,  8,  3,  4 },
+ /* 0,1 */ { 11,  3,  2,  7,  0,  8,  0,  7,  1,  4,  1,  7,  1,  4,  9 },
+ /* 1,1 */ {  7,  4,  8,  0,  9,  3, 11,  3,  9,  1, 11,  9, 11,  1,  2 }
+},
+/*  94:    1, 2, 3, 4,    6,     */  {
+ /* 1,0 */ {  4,  5,  9,  6,  3, 11,  3,  6,  0,  7,  0,  6,  0,  7,  8 },
+ /* 0,1 */ {  6,  7, 11,  8,  4,  3,  5,  3,  4,  3,  5,  0,  9,  0,  5 },
+ /* 1,1 */ {  8,  0,  3,  7,  9,  4,  9,  7, 11,  9, 11,  5,  6,  5, 11 }
+},
+/* 122:    1,    3, 4, 5, 6,     */  {
+ /* 1,0 */ {  8,  0,  3, 10,  6,  1,  7,  1,  6,  1,  7,  2, 11,  2,  7 },
+ /* 0,1 */ { 10,  2,  1,  6,  3, 11,  3,  6,  0,  7,  0,  6,  0,  7,  8 },
+ /* 1,1 */ {  6,  7, 11,  3,  8,  2, 10,  2,  8,  0, 10,  8, 10,  0,  1 }
+},
+/* 218:    1,    3, 4,    6, 7,  */  {
+ /* 1,0 */ { 10,  2,  1,  8,  4,  3,  5,  3,  4,  3,  5,  0,  9,  0,  5 },
+ /* 0,1 */ {  8,  0,  3,  4,  1,  9,  1,  4,  2,  5,  2,  4,  2,  5, 10 },
+ /* 1,1 */ {  4,  5,  9,  1, 10,  0,  8,  0, 10,  2,  8, 10,  8,  2,  3 } }
+};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 7.3
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling7_3[16][3][27] = {
+/*  37: 0,    2,       5,        */  {
+ /* 1,0 */ { 12,  2, 10, 12, 10,  5, 12,  5,  4, 12,  4,  8, 12,  8,  3, 12,  3,  0, \
12,  0,  9, 12,  9,  1, 12,  1,  2 }, + /* 0,1 */ { 12,  5,  4, 12,  4,  8, 12,  8,  \
3, 12,  3,  2, 12,  2, 10, 12, 10,  1, 12,  1,  0, 12,  0,  9, 12,  9,  5 }, + /* 1,1 \
*/ {  5,  4, 12, 10,  5, 12,  2, 10, 12,  3,  2, 12,  8,  3, 12,  0,  8, 12,  1,  0, \
12,  9,  1, 12,  4,  9, 12 } +},
+/* 133: 0,    2,             7,  */  {
+ /* 1,0 */ { 12,  0,  8, 12,  8,  7, 12,  7,  6, 12,  6, 10, 12, 10,  1, 12,  1,  2, \
12,  2, 11, 12, 11,  3, 12,  3,  0 }, + /* 0,1 */ { 12,  7,  6, 12,  6, 10, 12, 10,  \
1, 12,  1,  0, 12,  0,  8, 12,  8,  3, 12,  3,  2, 12,  2, 11, 12, 11,  7 }, + /* 1,1 \
*/ {  7,  6, 12,  8,  7, 12,  0,  8, 12,  1,  0, 12, 10,  1, 12,  2, 10, 12,  3,  2, \
12, 11,  3, 12,  6, 11, 12 } +},
+/* 161: 0,             5,    7,  */  {
+ /* 1,0 */ {  9,  5, 12,  0,  9, 12,  3,  0, 12, 11,  3, 12,  6, 11, 12,  7,  6, 12, \
8,  7, 12,  4,  8, 12,  5,  4, 12 }, + /* 0,1 */ {  3,  0, 12, 11,  3, 12,  6, 11, \
12,  5,  6, 12,  9,  5, 12,  4,  9, 12,  7,  4, 12,  8,  7, 12,  0,  8, 12 }, + /* \
1,1 */ { 12,  3,  0, 12,  0,  9, 12,  9,  5, 12,  5,  6, 12,  6, 11, 12, 11,  7, 12,  \
7,  4, 12,  4,  8, 12,  8,  3 } +},
+/*  26:    1,    3, 4,           */  {
+ /* 1,0 */ { 12,  1,  9, 12,  9,  4, 12,  4,  7, 12,  7, 11, 12, 11,  2, 12,  2,  3, \
12,  3,  8, 12,  8,  0, 12,  0,  1 }, + /* 0,1 */ { 12,  4,  7, 12,  7, 11, 12, 11,  \
2, 12,  2,  1, 12,  1,  9, 12,  9,  0, 12,  0,  3, 12,  3,  8, 12,  8,  4 }, + /* 1,1 \
*/ {  4,  7, 12,  9,  4, 12,  1,  9, 12,  2,  1, 12, 11,  2, 12,  3, 11, 12,  0,  3, \
12,  8,  0, 12,  7,  8, 12 } +},
+/*  74:    1,    3,       6,     */  {
+ /* 1,0 */ { 12,  3, 11, 12, 11,  6, 12,  6,  5, 12,  5,  9, 12,  9,  0, 12,  0,  1, \
12,  1, 10, 12, 10,  2, 12,  2,  3 }, + /* 0,1 */ { 12,  6,  5, 12,  5,  9, 12,  9,  \
0, 12,  0,  3, 12,  3, 11, 12, 11,  2, 12,  2,  1, 12,  1, 10, 12, 10,  6 }, + /* 1,1 \
*/ {  6,  5, 12, 11,  6, 12,  3, 11, 12,  0,  3, 12,  9,  0, 12,  1,  9, 12,  2,  1, \
12, 10,  2, 12,  5, 10, 12 } +},
+/*  82:    1,       4,    6,     */  {
+ /* 1,0 */ { 10,  6, 12,  1, 10, 12,  0,  1, 12,  8,  0, 12,  7,  8, 12,  4,  7, 12, \
9,  4, 12,  5,  9, 12,  6,  5, 12 }, + /* 0,1 */ {  0,  1, 12,  8,  0, 12,  7,  8, \
12,  6,  7, 12, 10,  6, 12,  5, 10, 12,  4,  5, 12,  9,  4, 12,  1,  9, 12 }, + /* \
1,1 */ { 12,  0,  1, 12,  1, 10, 12, 10,  6, 12,  6,  7, 12,  7,  8, 12,  8,  4, 12,  \
4,  5, 12,  5,  9, 12,  9,  0 } +},
+/* 164:       2,       5,    7,  */  {
+ /* 1,0 */ { 11,  7, 12,  2, 11, 12,  1,  2, 12,  9,  1, 12,  4,  9, 12,  5,  4, 12, \
10,  5, 12,  6, 10, 12,  7,  6, 12 }, + /* 0,1 */ {  1,  2, 12,  9,  1, 12,  4,  9, \
12,  7,  4, 12, 11,  7, 12,  6, 11, 12,  5,  6, 12, 10,  5, 12,  2, 10, 12 }, + /* \
1,1 */ { 12,  1,  2, 12,  2, 11, 12, 11,  7, 12,  7,  4, 12,  4,  9, 12,  9,  5, 12,  \
5,  6, 12,  6, 10, 12, 10,  1 } +},
+/*  88:          3, 4,    6,     */  {
+ /* 1,0 */ {  8,  4, 12,  3,  8, 12,  2,  3, 12, 10,  2, 12,  5, 10, 12,  6,  5, 12, \
11,  6, 12,  7, 11, 12,  4,  7, 12 }, + /* 0,1 */ {  2,  3, 12, 10,  2, 12,  5, 10, \
12,  4,  5, 12,  8,  4, 12,  7,  8, 12,  6,  7, 12, 11,  6, 12,  3, 11, 12 }, + /* \
1,1 */ { 12,  2,  3, 12,  3,  8, 12,  8,  4, 12,  4,  5, 12,  5, 10, 12, 10,  6, 12,  \
6,  7, 12,  7, 11, 12, 11,  2 } +},
+/* 167: 0, 1, 2,       5,    7,  */  {
+ /* 1,0 */ { 12,  4,  8, 12,  8,  3, 12,  3,  2, 12,  2, 10, 12, 10,  5, 12,  5,  6, \
12,  6, 11, 12, 11,  7, 12,  7,  4 }, + /* 0,1 */ { 12,  3,  2, 12,  2, 10, 12, 10,  \
5, 12,  5,  4, 12,  4,  8, 12,  8,  7, 12,  7,  6, 12,  6, 11, 12, 11,  3 }, + /* 1,1 \
*/ {  3,  2, 12,  8,  3, 12,  4,  8, 12,  5,  4, 12, 10,  5, 12,  6, 10, 12,  7,  6, \
12, 11,  7, 12,  2, 11, 12 } +},
+/*  91: 0, 1,    3, 4,    6,     */  {
+ /* 1,0 */ { 12,  7, 11, 12, 11,  2, 12,  2,  1, 12,  1,  9, 12,  9,  4, 12,  4,  5, \
12,  5, 10, 12, 10,  6, 12,  6,  7 }, + /* 0,1 */ { 12,  2,  1, 12,  1,  9, 12,  9,  \
4, 12,  4,  7, 12,  7, 11, 12, 11,  6, 12,  6,  5, 12,  5, 10, 12, 10,  2 }, + /* 1,1 \
*/ {  2,  1, 12, 11,  2, 12,  7, 11, 12,  4,  7, 12,  9,  4, 12,  5,  9, 12,  6,  5, \
12, 10,  6, 12,  1, 10, 12 } +},
+/* 173: 0,    2, 3,    5,    7,  */  {
+ /* 1,0 */ { 12,  6, 10, 12, 10,  1, 12,  1,  0, 12,  0,  8, 12,  8,  7, 12,  7,  4, \
12,  4,  9, 12,  9,  5, 12,  5,  6 }, + /* 0,1 */ { 12,  1,  0, 12,  0,  8, 12,  8,  \
7, 12,  7,  6, 12,  6, 10, 12, 10,  5, 12,  5,  4, 12,  4,  9, 12,  9,  1 }, + /* 1,1 \
*/ {  1,  0, 12, 10,  1, 12,  6, 10, 12,  7,  6, 12,  8,  7, 12,  4,  8, 12,  5,  4, \
12,  9,  5, 12,  0,  9, 12 } +},
+/* 181: 0,    2,    4, 5,    7,  */  {
+ /* 1,0 */ { 11,  3, 12,  6, 11, 12,  5,  6, 12,  9,  5, 12,  0,  9, 12,  1,  0, 12, \
10,  1, 12,  2, 10, 12,  3,  2, 12 }, + /* 0,1 */ {  5,  6, 12,  9,  5, 12,  0,  9, \
12,  3,  0, 12, 11,  3, 12,  2, 11, 12,  1,  2, 12, 10,  1, 12,  6, 10, 12 }, + /* \
1,1 */ { 12,  5,  6, 12,  6, 11, 12, 11,  3, 12,  3,  0, 12,  0,  9, 12,  9,  1, 12,  \
1,  2, 12,  2, 10, 12, 10,  5 } +},
+/* 229: 0,    2,       5, 6, 7,  */  {
+ /* 1,0 */ {  9,  1, 12,  4,  9, 12,  7,  4, 12, 11,  7, 12,  2, 11, 12,  3,  2, 12, \
8,  3, 12,  0,  8, 12,  1,  0, 12 }, + /* 0,1 */ {  7,  4, 12, 11,  7, 12,  2, 11, \
12,  1,  2, 12,  9,  1, 12,  0,  9, 12,  3,  0, 12,  8,  3, 12,  4,  8, 12 }, + /* \
1,1 */ { 12,  7,  4, 12,  4,  9, 12,  9,  1, 12,  1,  2, 12,  2, 11, 12, 11,  3, 12,  \
3,  0, 12,  0,  8, 12,  8,  7 } +},
+/*  94:    1, 2, 3, 4,    6,     */  {
+ /* 1,0 */ { 12,  5,  9, 12,  9,  0, 12,  0,  3, 12,  3, 11, 12, 11,  6, 12,  6,  7, \
12,  7,  8, 12,  8,  4, 12,  4,  5 }, + /* 0,1 */ { 12,  0,  3, 12,  3, 11, 12, 11,  \
6, 12,  6,  5, 12,  5,  9, 12,  9,  4, 12,  4,  7, 12,  7,  8, 12,  8,  0 }, + /* 1,1 \
*/ {  0,  3, 12,  9,  0, 12,  5,  9, 12,  6,  5, 12, 11,  6, 12,  7, 11, 12,  4,  7, \
12,  8,  4, 12,  3,  8, 12 } +},
+/* 122:    1,    3, 4, 5, 6,     */  {
+ /* 1,0 */ {  8,  0, 12,  7,  8, 12,  6,  7, 12, 10,  6, 12,  1, 10, 12,  2,  1, 12, \
11,  2, 12,  3, 11, 12,  0,  3, 12 }, + /* 0,1 */ {  6,  7, 12, 10,  6, 12,  1, 10, \
12,  0,  1, 12,  8,  0, 12,  3,  8, 12,  2,  3, 12, 11,  2, 12,  7, 11, 12 }, + /* \
1,1 */ { 12,  6,  7, 12,  7,  8, 12,  8,  0, 12,  0,  1, 12,  1, 10, 12, 10,  2, 12,  \
2,  3, 12,  3, 11, 12, 11,  6 } +},
+/* 218:    1,    3, 4,    6, 7,  */  {
+ /* 1,0 */ { 10,  2, 12,  5, 10, 12,  4,  5, 12,  8,  4, 12,  3,  8, 12,  0,  3, 12, \
9,  0, 12,  1,  9, 12,  2,  1, 12 }, + /* 0,1 */ {  4,  5, 12,  8,  4, 12,  3,  8, \
12,  2,  3, 12, 10,  2, 12,  1, 10, 12,  0,  1, 12,  9,  0, 12,  5,  9, 12 }, + /* \
1,1 */ { 12,  4,  5, 12,  5, 10, 12, 10,  2, 12,  2,  3, 12,  3,  8, 12,  8,  0, 12,  \
0,  1, 12,  1,  9, 12,  9,  4 } } +};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 7.4.1
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling7_4_1[16][15] = {
+/*  37: 0,    2,       5,        */  {  3,  4,  8,  4,  3, 10,  2, 10,  3,  4, 10,  \
5,  9,  1,  0 }, +/* 133: 0,    2,             7,  */  {  1,  6, 10,  6,  1,  8,  0,  \
8,  1,  6,  8,  7, 11,  3,  2 }, +/* 161: 0,             5,    7,  */  { 11,  3,  6,  \
9,  6,  3,  6,  9,  5,  0,  9,  3,  7,  4,  8 }, +/*  26:    1,    3, 4,           */ \
{  2,  7, 11,  7,  2,  9,  1,  9,  2,  7,  9,  4,  8,  0,  3 }, +/*  74:    1,    3,  \
6,     */  {  0,  5,  9,  5,  0, 11,  3, 11,  0,  5, 11,  6, 10,  2,  1 }, +/*  82:   \
1,       4,    6,     */  {  8,  0,  7, 10,  7,  0,  7, 10,  6,  1, 10,  0,  4,  5,  \
9 }, +/* 164:       2,       5,    7,  */  {  9,  1,  4, 11,  4,  1,  4, 11,  7,  2, \
11,  1,  5,  6, 10 }, +/*  88:          3, 4,    6,     */  { 10,  2,  5,  8,  5,  2, \
5,  8,  4,  3,  8,  2,  6,  7, 11 }, +/* 167: 0, 1, 2,       5,    7,  */  {  5,  2, \
10,  2,  5,  8,  4,  8,  5,  2,  8,  3, 11,  7,  6 }, +/*  91: 0, 1,    3, 4,    6,   \
*/  {  4,  1,  9,  1,  4, 11,  7, 11,  4,  1, 11,  2, 10,  6,  5 }, +/* 173: 0,    2, \
3,    5,    7,  */  {  7,  0,  8,  0,  7, 10,  6, 10,  7,  0, 10,  1,  9,  5,  4 }, \
+/* 181: 0,    2,    4, 5,    7,  */  {  9,  5,  0, 11,  0,  5,  0, 11,  3,  6, 11,  \
5,  1,  2, 10 }, +/* 229: 0,    2,       5, 6, 7,  */  { 11,  7,  2,  9,  2,  7,  2,  \
9,  1,  4,  9,  7,  3,  0,  8 }, +/*  94:    1, 2, 3, 4,    6,     */  {  6,  3, 11,  \
3,  6,  9,  5,  9,  6,  3,  9,  0,  8,  4,  7 }, +/* 122:    1,    3, 4, 5, 6,     */ \
{ 10,  6,  1,  8,  1,  6,  1,  8,  0,  7,  8,  6,  2,  3, 11 }, +/* 218:    1,    3, \
4,    6, 7,  */  {  8,  4,  3, 10,  3,  4,  3, 10,  2,  5, 10,  4,  0,  1,  9 } +};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 7.4.2
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling7_4_2[16][27] = {
+/*  37: 0,    2,       5,        */  {   9,  4,  8,  4,  9,  5, 10,  5,  9,  1, 10,  \
9, 10,  1,  2,  0,  2,  1,  2,  0,  3,  8,  3,  0,  9,  8,  0 }, +/* 133: 0,    2,    \
7,  */  {  11,  6, 10,  6, 11,  7,  8,  7, 11,  3,  8, 11,  8,  3,  0,  2,  0,  3,  \
0,  2,  1, 10,  1,  2, 11, 10,  2 }, +/* 161: 0,             5,    7,  */  {  11,  3, \
8,  0,  8,  3,  8,  0,  9,  8,  9,  4,  5,  4,  9,  4,  5,  7,  6,  7,  5,  7,  6, \
11,  7, 11,  8 }, +/*  26:    1,    3, 4,           */  {   8,  7, 11,  7,  8,  4,  \
9,  4,  8,  0,  9,  8,  9,  0,  1,  3,  1,  0,  1,  3,  2, 11,  2,  3,  8, 11,  3 }, \
+/*  74:    1,    3,       6,     */  {  10,  5,  9,  5, 10,  6, 11,  6, 10,  2, 11, \
10, 11,  2,  3,  1,  3,  2,  3,  1,  0,  9,  0,  1, 10,  9,  1 }, +/*  82:    1,      \
4,    6,     */  {   8,  0,  9,  1,  9,  0,  9,  1, 10,  9, 10,  5,  6,  5, 10,  5,  \
6,  4,  7,  4,  6,  4,  7,  8,  4,  8,  9 }, +/* 164:       2,       5,    7,  */  {  \
9,  1, 10,  2, 10,  1, 10,  2, 11, 10, 11,  6,  7,  6, 11,  6,  7,  5,  4,  5,  7,  \
5,  4,  9,  5,  9, 10 }, +/*  88:          3, 4,    6,     */  {  10,  2, 11,  3, 11, \
2, 11,  3,  8, 11,  8,  7,  4,  7,  8,  7,  4,  6,  5,  6,  4,  6,  5, 10,  6, 10, 11 \
}, +/* 167: 0, 1, 2,       5,    7,  */  {  11,  2, 10,  2, 11,  3,  8,  3, 11,  7,  \
8, 11,  8,  7,  4,  6,  4,  7,  4,  6,  5, 10,  5,  6, 11, 10,  6 }, +/*  91: 0, 1,   \
3, 4,    6,     */  {  10,  1,  9,  1, 10,  2, 11,  2, 10,  6, 11, 10, 11,  6,  7,  \
5,  7,  6,  7,  5,  4,  9,  4,  5, 10,  9,  5 }, +/* 173: 0,    2, 3,    5,    7,  */ \
{   9,  0,  8,  0,  9,  1, 10,  1,  9,  5, 10,  9, 10,  5,  6,  4,  6,  5,  6,  4,  \
7,  8,  7,  4,  9,  8,  4 }, +/* 181: 0,    2,    4, 5,    7,  */  {   9,  5, 10,  6, \
10,  5, 10,  6, 11, 10, 11,  2,  3,  2, 11,  2,  3,  1,  0,  1,  3,  1,  0,  9,  1,  \
9, 10 }, +/* 229: 0,    2,       5, 6, 7,  */  {  11,  7,  8,  4,  8,  7,  8,  4,  9, \
8,  9,  0,  1,  0,  9,  0,  1,  3,  2,  3,  1,  3,  2, 11,  3, 11,  8 }, +/*  94:    \
1, 2, 3, 4,    6,     */  {   8,  3, 11,  3,  8,  0,  9,  0,  8,  4,  9,  8,  9,  4,  \
5,  7,  5,  4,  5,  7,  6, 11,  6,  7,  8, 11,  7 }, +/* 122:    1,    3, 4, 5, 6,    \
*/  {  10,  6, 11,  7, 11,  6, 11,  7,  8, 11,  8,  3,  0,  3,  8,  3,  0,  2,  1,  \
2,  0,  2,  1, 10,  2, 10, 11 }, +/* 218:    1,    3, 4,    6, 7,  */  {   8,  4,  9, \
5,  9,  4,  9,  5, 10,  9, 10,  1,  2,  1, 10,  1,  2,  0,  3,  0,  2,  0,  3,  8,  \
0,  8,  9 } +};
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 8
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling8[6][6] = {
+/*  15: 0, 1, 2, 3,              */  { 9,  8, 10, 10,  8, 11 },
+/*  51: 0, 1,       4, 5,        */  { 1,  5,  3,  3,  5,  7 },
+/* 153: 0,       3, 4,       7,  */  { 0,  4,  2,  4,  6,  2 },
+/* 102:    1, 2,       5, 6,     */  { 0,  2,  4,  4,  2,  6 },
+/* 204:       2, 3,       6, 7,  */  { 1,  3,  5,  3,  7,  5 },
+/* 240:             4, 5, 6, 7,  */  { 9, 10,  8, 10, 11,  8 }
+};
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 9
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling9[8][12] = {
+/*  39: 0, 1, 2,       5,        */  {  2, 10,  5,  3,  2,  5,  3,  5,  4,  3,  4,  \
8 }, +/*  27: 0, 1,    3, 4,           */  {  4,  7, 11,  9,  4, 11,  9, 11,  2,  9,  \
2,  1 }, +/* 141: 0,    2, 3,          7,  */  { 10,  7,  6,  1,  7, 10,  1,  8,  7,  \
1,  0,  8 }, +/* 177: 0,          4, 5,    7,  */  {  3,  6, 11,  0,  6,  3,  0,  5,  \
6,  0,  9,  5 }, +/*  78:    1, 2, 3,       6,     */  {  3, 11,  6,  0,  3,  6,  0,  \
6,  5,  0,  5,  9 }, +/* 114:    1,       4, 5, 6,     */  { 10,  6,  7,  1, 10,  7,  \
1,  7,  8,  1,  8,  0 }, +/* 228:       2,       5, 6, 7,  */  {  4, 11,  7,  9, 11,  \
4,  9,  2, 11,  9,  1,  2 }, +/* 216:          3, 4,    6, 7,  */  {  2,  5, 10,  3,  \
5,  2,  3,  4,  5,  3,  8,  4 } +};
+//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+/**
+ * \brief test table for case 10
+ * 2 faces to test + eventually the interior
+ * When the tests on both specified faces are positive : 4 middle triangles (1)
+ * When the test on the first  specified face is positive : 8 first triangles
+ * When the test on the second specified face is positive : 8 next triangles
+ * When the tests on both specified faces are negative :
+ * - if the test on the interior is negative : 4 middle triangles
+ * - if the test on the interior is positive : 8 last triangles
+ *
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int test10[6][3] = {
+/* 195: 0, 1,             6, 7,  */  {  2,  4,  7 },
+/*  85: 0,    2,    4,    6,     */  {  5,  6,  7 },
+/* 105: 0,       3,    5, 6,     */  {  1,  3,  7 },
+/* 150:    1, 2,    4,       7,  */  {  1,  3,  7 },
+/* 170:    1,    3,    5,    7,  */  {  5,  6,  7 },
+/*  60:       2, 3, 4, 5,        */  {  2,  4,  7 }
+};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 10.1.1
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling10_1_1[6][12] = {
+/* 195: 0, 1,             6, 7,  */  {  5, 10,  7, 11,  7, 10,  8,  1,  9,  1,  8,  \
3 }, +/*  85: 0,    2,    4,    6,     */  {  1,  2,  5,  6,  5,  2,  4,  3,  0,  3,  \
4,  7 }, +/* 105: 0,       3,    5, 6,     */  { 11,  0,  8,  0, 11,  2,  4,  9,  6, \
10,  6,  9 }, +/* 150:    1, 2,    4,       7,  */  {  9,  0, 10,  2, 10,  0,  6,  8, \
4,  8,  6, 11 }, +/* 170:    1,    3,    5,    7,  */  {  7,  2,  3,  2,  7,  6,  0,  \
1,  4,  5,  4,  1 }, +/*  60:       2, 3, 4, 5,        */  {  7,  9,  5,  9,  7,  8, \
10,  1, 11,  3, 11,  1 } +};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 10.1.1 inverted
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling10_1_1_[6][12] = {
+/* 195: 0, 1,             6, 7,  */  {  5,  9,  7,  8,  7,  9, 11,  1, 10,  1, 11,  \
3 }, +/*  85: 0,    2,    4,    6,     */  {  3,  2,  7,  6,  7,  2,  4,  1,  0,  1,  \
4,  5 }, +/* 105: 0,       3,    5, 6,     */  { 10,  0,  9,  0, 10,  2,  4,  8,  6, \
11,  6,  8 }, +/* 150:    1, 2,    4,       7,  */  {  8,  0, 11,  2, 11,  0,  6,  9, \
4,  9,  6, 10 }, +/* 170:    1,    3,    5,    7,  */  {  5,  2,  1,  2,  5,  6,  0,  \
3,  4,  7,  4,  3 }, +/*  60:       2, 3, 4, 5,        */  {  7, 10,  5, 10,  7, 11,  \
9,  1,  8,  3,  8,  1 } +};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 10.1.2
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling10_1_2[6][24] = {
+/* 195: 0, 1,             6, 7,  */  {  3, 11,  7,  3,  7,  8,  9,  8,  7,  5,  9,  \
7,  9,  5, 10,  9, 10,  1,  3,  1, 10, 11,  3, 10 }, +/*  85: 0,    2,    4,    6,    \
*/  {  7,  6,  5,  7,  5,  4,  0,  4,  5,  1,  0,  5,  0,  1,  2,  0,  2,  3,  7,  3, \
2,  6,  7,  2 }, +/* 105: 0,       3,    5, 6,     */  { 11,  2, 10,  6, 11, 10, 11,  \
6,  4, 11,  4,  8,  0,  8,  4,  9,  0,  4,  0,  9, 10,  0, 10,  2 }, +/* 150:    1, \
2,    4,       7,  */  { 11,  2, 10, 11, 10,  6,  4,  6, 10,  9,  4, 10,  4,  9,  0,  \
4,  0,  8, 11,  8,  0,  2, 11,  0 }, +/* 170:    1,    3,    5,    7,  */  {  7,  6,  \
5,  4,  7,  5,  7,  4,  0,  7,  0,  3,  2,  3,  0,  1,  2,  0,  2,  1,  5,  2,  5,  6 \
}, +/*  60:       2, 3, 4, 5,        */  {  7,  8,  3, 11,  7,  3,  7, 11, 10,  7, \
10,  5,  9,  5, 10,  1,  9, 10,  9,  1,  3,  9,  3,  8 } +};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 10.2
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling10_2[6][24] = {
+/* 195: 0, 1,             6, 7,  */  { 12,  5,  9, 12,  9,  8, 12,  8,  3, 12,  3,  \
1, 12,  1, 10, 12, 10, 11, 12, 11,  7, 12,  7,  5 }, +/*  85: 0,    2,    4,    6,    \
*/  { 12,  1,  0, 12,  0,  4, 12,  4,  7, 12,  7,  3, 12,  3,  2, 12,  2,  6, 12,  6, \
5, 12,  5,  1 }, +/* 105: 0,       3,    5, 6,     */  {  4,  8, 12,  6,  4, 12, 10,  \
6, 12,  9, 10, 12,  0,  9, 12,  2,  0, 12, 11,  2, 12,  8, 11, 12 }, +/* 150:    1, \
2,    4,       7,  */  { 12,  9,  4, 12,  4,  6, 12,  6, 11, 12, 11,  8, 12,  8,  0, \
12,  0,  2, 12,  2, 10, 12, 10,  9 }, +/* 170:    1,    3,    5,    7,  */  {  0,  3, \
12,  4,  0, 12,  5,  4, 12,  1,  5, 12,  2,  1, 12,  6,  2, 12,  7,  6, 12,  3,  7, \
12 }, +/*  60:       2, 3, 4, 5,        */  { 10,  5, 12, 11, 10, 12,  3, 11, 12,  1, \
3, 12,  9,  1, 12,  8,  9, 12,  7,  8, 12,  5,  7, 12 } +};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 10.2 inverted
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling10_2_[6][24] = {
+/* 195: 0, 1,             6, 7,  */  {  8,  7, 12,  9,  8, 12,  1,  9, 12,  3,  1, \
12, 11,  3, 12, 10, 11, 12,  5, 10, 12,  7,  5, 12 }, +/*  85: 0,    2,    4,    6,   \
*/  {  4,  5, 12,  0,  4, 12,  3,  0, 12,  7,  3, 12,  6,  7, 12,  2,  6, 12,  1,  2, \
12,  5,  1, 12 }, +/* 105: 0,       3,    5, 6,     */  { 12, 11,  6, 12,  6,  4, 12, \
4,  9, 12,  9, 10, 12, 10,  2, 12,  2,  0, 12,  0,  8, 12,  8, 11 }, +/* 150:    1, \
2,    4,       7,  */  {  6, 10, 12,  4,  6, 12,  8,  4, 12, 11,  8, 12,  2, 11, 12,  \
0,  2, 12,  9,  0, 12, 10,  9, 12 }, +/* 170:    1,    3,    5,    7,  */  { 12,  7,  \
4, 12,  4,  0, 12,  0,  1, 12,  1,  5, 12,  5,  6, 12,  6,  2, 12,  2,  3, 12,  3,  7 \
}, +/*  60:       2, 3, 4, 5,        */  { 12,  7, 11, 12, 11, 10, 12, 10,  1, 12,  \
1,  3, 12,  3,  8, 12,  8,  9, 12,  9,  5, 12,  5,  7 } +};
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 11
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling11[12][12] = {
+/*  23: 0, 1, 2,    4,           */  { 2, 10,  9,  2,  9,  7,  2,  7,  3,  7,  9,  4 \
}, +/* 139: 0, 1,    3,          7,  */  { 1,  6,  2,  1,  8,  6,  1,  9,  8,  8,  7, \
6 }, +/*  99: 0, 1,          5, 6,     */  { 8,  3,  1,  8,  1,  6,  8,  6,  4,  6,  \
1, 10 }, +/*  77: 0,    2, 3,       6,     */  { 0,  8, 11,  0, 11,  5,  0,  5,  1,  \
5, 11,  6 }, +/*  57: 0,       3, 4, 5,        */  { 9,  5,  7,  9,  7,  2,  9,  2,  \
0,  2,  7, 11 }, +/* 209: 0,          4,    6, 7,  */  { 5,  0,  4,  5, 11,  0,  5, \
10, 11, 11,  3,  0 }, +/*  46:    1, 2, 3,    5,        */  { 5,  4,  0,  5,  0, 11,  \
5, 11, 10, 11,  0,  3 }, +/* 198:    1, 2,          6, 7,  */  { 9,  7,  5,  9,  2,  \
7,  9,  0,  2,  2, 11,  7 }, +/* 178:    1,       4, 5,    7,  */  { 0, 11,  8,  0,  \
5, 11,  0,  1,  5,  5,  6, 11 }, +/* 156:       2, 3, 4,       7,  */  { 8,  1,  3,  \
8,  6,  1,  8,  4,  6,  6, 10,  1 }, +/* 116:       2,    4, 5, 6,     */  { 1,  2,  \
6,  1,  6,  8,  1,  8,  9,  8,  6,  7 }, +/* 232:          3,    5, 6, 7,  */  { 2,  \
9, 10,  2,  7,  9,  2,  3,  7,  7,  4,  9 } +};
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+/**
+ * \brief test table for case 12
+ * 2 faces to test + eventually the interior
+ * When the tests on both specified faces are positive : 4 middle triangles (1)
+ * When the test on the first  specified face is positive : 8 first triangles
+ * When the test on the second specified face is positive : 8 next triangles
+ * When the tests on both specified faces are negative :
+ * - if the test on the interior is negative : 4 middle triangles
+ * - if the test on the interior is positive : 8 last triangles
+ * The support edge for the interior test is marked as the 4th column.
+ *
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int test12[24][4] = {
+/* 135: 0, 1, 2,             7,  */  {  4,  3,  7,  11 },
+/*  75: 0, 1,    3,       6,     */  {  3,  2,  7,  10 },
+/*  83: 0, 1,       4,    6,     */  {  2,  6,  7,   5 },
+/* 163: 0, 1,          5,    7,  */  {  6,  4,  7,   7 },
+/*  45: 0,    2, 3,    5,        */  {  2,  1,  7,   9 },
+/*  53: 0,    2,    4, 5,        */  {  5,  2,  7,   1 },
+/* 149: 0,    2,    4,       7,  */  {  5,  3,  7,   2 },
+/* 101: 0,    2,       5, 6,     */  {  5,  1,  7,   0 },
+/* 197: 0,    2,          6, 7,  */  {  5,  4,  7,   3 },
+/*  89: 0,       3, 4,    6,     */  {  6,  3,  7,   6 },
+/* 169: 0,       3,    5,    7,  */  {  1,  6,  7,   4 },
+/* 225: 0,             5, 6, 7,  */  {  1,  4,  7,   8 },
+/*  30:    1, 2, 3, 4,           */  {  4,  1,  7,   8 },
+/*  86:    1, 2,    4,    6,     */  {  6,  1,  7,   4 },
+/* 166:    1, 2,       5,    7,  */  {  3,  6,  7,   6 },
+/*  58:    1,    3, 4, 5,        */  {  4,  5,  7,   3 },
+/* 154:    1,    3, 4,       7,  */  {  1,  5,  7,   0 },
+/* 106:    1,    3,    5, 6,     */  {  3,  5,  7,   2 },
+/* 202:    1,    3,       6, 7,  */  {  2,  5,  7,   1 },
+/* 210:    1,       4,    6, 7,  */  {  1,  2,  7,   9 },
+/*  92:       2, 3, 4,    6,     */  {  4,  6,  7,   7 },
+/* 172:       2, 3,    5,    7,  */  {  6,  2,  7,   5 },
+/* 180:       2,    4, 5,    7,  */  {  2,  3,  7,  10 },
+/* 120:          3, 4, 5, 6,     */  {  3,  4,  7,  11 }
+};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 12.1.1
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling12_1_1[24][12] = {
+/* 135: 0, 1, 2,             7,  */  {  7,  6, 11, 10,  3,  2,  3, 10,  8,  9,  8, \
10 }, +/*  75: 0, 1,    3,       6,     */  {  6,  5, 10,  9,  2,  1,  2,  9, 11,  8, \
11,  9 }, +/*  83: 0, 1,       4,    6,     */  { 10,  6,  5,  7,  9,  4,  9,  7,  1, \
3,  1,  7 }, +/* 163: 0, 1,          5,    7,  */  {  7,  6, 11,  4,  8,  5,  3,  5,  \
8,  5,  3,  1 }, +/*  45: 0,    2, 3,    5,        */  {  5,  4,  9,  8,  1,  0,  1,  \
8, 10, 11, 10,  8 }, +/*  53: 0,    2,    4, 5,        */  {  1,  2, 10,  0,  9,  3,  \
5,  3,  9,  3,  5,  7 }, +/* 149: 0,    2,    4,       7,  */  { 10,  1,  2,  0, 11,  \
3, 11,  0,  6,  4,  6,  0 }, +/* 101: 0,    2,       5, 6,     */  {  8,  3,  0,  2,  \
9,  1,  9,  2,  4,  6,  4,  2 }, +/* 197: 0,    2,          6, 7,  */  {  3,  0,  8,  \
2, 11,  1,  7,  1, 11,  1,  7,  5 }, +/*  89: 0,       3, 4,    6,     */  {  6,  5, \
10,  7, 11,  4,  2,  4, 11,  4,  2,  0 }, +/* 169: 0,       3,    5,    7,  */  {  9, \
5,  4,  6,  8,  7,  8,  6,  0,  2,  0,  6 }, +/* 225: 0,             5, 6, 7,  */  {  \
8,  3,  0,  7,  4, 11,  9, 11,  4, 11,  9, 10 }, +/*  30:    1, 2, 3, 4,           */ \
{  4,  7,  8, 11,  0,  3,  0, 11,  9, 10,  9, 11 }, +/*  86:    1, 2,    4,    6,     \
*/  {  4,  7,  8,  5,  9,  6,  0,  6,  9,  6,  0,  2 }, +/* 166:    1, 2,       5,    \
7,  */  { 11,  7,  6,  4, 10,  5, 10,  4,  2,  0,  2,  4 }, +/*  58:    1,    3, 4, \
5,        */  { 11,  2,  3,  1,  8,  0,  8,  1,  7,  5,  7,  1 }, +/* 154:    1,    \
3, 4,       7,  */  {  0,  1,  9,  3,  8,  2,  4,  2,  8,  2,  4,  6 }, +/* 106:    \
1,    3,    5, 6,     */  {  2,  3, 11,  1, 10,  0,  6,  0, 10,  0,  6,  4 }, +/* \
202:    1,    3,       6, 7,  */  {  9,  0,  1,  3, 10,  2, 10,  3,  5,  7,  5,  3 }, \
+/* 210:    1,       4,    6, 7,  */  {  9,  0,  1,  4,  5,  8, 10,  8,  5,  8, 10, \
11 }, +/*  92:       2, 3, 4,    6,     */  {  8,  4,  7,  5, 11,  6, 11,  5,  3,  1, \
3,  5 }, +/* 172:       2, 3,    5,    7,  */  {  5,  4,  9,  6, 10,  7,  1,  7, 10,  \
7,  1,  3 }, +/* 180:       2,    4, 5,    7,  */  { 10,  1,  2,  5,  6,  9, 11,  9,  \
6,  9, 11,  8 }, +/* 120:          3, 4, 5, 6,     */  { 11,  2,  3,  6,  7, 10,  8, \
10,  7, 10,  8,  9 } +};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 12.1.1 inverted
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling12_1_1_[24][12] = {
+/* 135: 0, 1, 2,             7,  */  {  3,  2, 11, 10,  7,  6,  7, 10,  8,  9,  8, \
10 }, +/*  75: 0, 1,    3,       6,     */  {  2,  1, 10,  9,  6,  5,  6,  9, 11,  8, \
11,  9 }, +/*  83: 0, 1,       4,    6,     */  {  9,  4,  5,  7, 10,  6, 10,  7,  1, \
3,  1,  7 }, +/* 163: 0, 1,          5,    7,  */  {  7,  4,  8,  6, 11,  5,  3,  5, \
11,  5,  3,  1 }, +/*  45: 0,    2, 3,    5,        */  {  1,  0,  9,  8,  5,  4,  5, \
8, 10, 11, 10,  8 }, +/*  53: 0,    2,    4, 5,        */  {  1,  0,  9,  2, 10,  3,  \
5,  3, 10,  3,  5,  7 }, +/* 149: 0,    2,    4,       7,  */  { 11,  3,  2,  0, 10,  \
1, 10,  0,  6,  4,  6,  0 }, +/* 101: 0,    2,       5, 6,     */  {  9,  1,  0,  2,  \
8,  3,  8,  2,  4,  6,  4,  2 }, +/* 197: 0,    2,          6, 7,  */  {  3,  2, 11,  \
0,  8,  1,  7,  1,  8,  1,  7,  5 }, +/*  89: 0,       3, 4,    6,     */  {  6,  7, \
11,  5, 10,  4,  2,  4, 10,  4,  2,  0 }, +/* 169: 0,       3,    5,    7,  */  {  8, \
7,  4,  6,  9,  5,  9,  6,  0,  2,  0,  6 }, +/* 225: 0,             5, 6, 7,  */  {  \
8,  7,  4,  3,  0, 11,  9, 11,  0, 11,  9, 10 }, +/*  30:    1, 2, 3, 4,           */ \
{  0,  3,  8, 11,  4,  7,  4, 11,  9, 10,  9, 11 }, +/*  86:    1, 2,    4,    6,     \
*/  {  4,  5,  9,  7,  8,  6,  0,  6,  8,  6,  0,  2 }, +/* 166:    1, 2,       5,    \
7,  */  { 10,  5,  6,  4, 11,  7, 11,  4,  2,  0,  2,  4 }, +/*  58:    1,    3, 4, \
5,        */  {  8,  0,  3,  1, 11,  2, 11,  1,  7,  5,  7,  1 }, +/* 154:    1,    \
3, 4,       7,  */  {  0,  3,  8,  1,  9,  2,  4,  2,  9,  2,  4,  6 }, +/* 106:    \
1,    3,    5, 6,     */  {  2,  1, 10,  3, 11,  0,  6,  0, 11,  0,  6,  4 }, +/* \
202:    1,    3,       6, 7,  */  { 10,  2,  1,  3,  9,  0,  9,  3,  5,  7,  5,  3 }, \
+/* 210:    1,       4,    6, 7,  */  {  9,  4,  5,  0,  1,  8, 10,  8,  1,  8, 10, \
11 }, +/*  92:       2, 3, 4,    6,     */  { 11,  6,  7,  5,  8,  4,  8,  5,  3,  1, \
3,  5 }, +/* 172:       2, 3,    5,    7,  */  {  5,  6, 10,  4,  9,  7,  1,  7,  9,  \
7,  1,  3 }, +/* 180:       2,    4, 5,    7,  */  { 10,  5,  6,  1,  2,  9, 11,  9,  \
2,  9, 11,  8 }, +/* 120:          3, 4, 5, 6,     */  { 11,  6,  7,  2,  3, 10,  8, \
10,  3, 10,  8,  9 } +};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 12.1.2
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling12_1_2[24][24] = {
+/* 135: 0, 1, 2,             7,  */  {  7,  3, 11,  3,  7,  8,  9,  8,  7,  6,  9,  \
7,  9,  6, 10,  2, 10,  6, 11,  2,  6,  2, 11,  3 }, +/*  75: 0, 1,    3,       6,    \
*/  {  6,  2, 10,  2,  6, 11,  8, 11,  6,  5,  8,  6,  8,  5,  9,  1,  9,  5, 10,  1, \
5,  1, 10,  2 }, +/*  83: 0, 1,       4,    6,     */  { 10,  9,  5,  9, 10,  1,  3,  \
1, 10,  6,  3, 10,  3,  6,  7,  4,  7,  6,  5,  4,  6,  4,  5,  9 }, +/* 163: 0, 1,   \
5,    7,  */  {  7,  8, 11,  3, 11,  8, 11,  3,  1, 11,  1,  6,  5,  6,  1,  6,  5,  \
4,  6,  4,  7,  8,  7,  4 }, +/*  45: 0,    2, 3,    5,        */  {  5,  1,  9,  1,  \
5, 10, 11, 10,  5,  4, 11,  5, 11,  4,  8,  0,  8,  4,  9,  0,  4,  0,  9,  1 }, +/*  \
53: 0,    2,    4, 5,        */  {  1,  9, 10,  5, 10,  9, 10,  5,  7, 10,  7,  2,  \
3,  2,  7,  2,  3,  0,  2,  0,  1,  9,  1,  0 }, +/* 149: 0,    2,    4,       7,  */ \
{ 10, 11,  2, 11, 10,  6,  4,  6, 10,  1,  4, 10,  4,  1,  0,  3,  0,  1,  2,  3,  1, \
3,  2, 11 }, +/* 101: 0,    2,       5, 6,     */  {  8,  9,  0,  9,  8,  4,  6,  4,  \
8,  3,  6,  8,  6,  3,  2,  1,  2,  3,  0,  1,  3,  1,  0,  9 }, +/* 197: 0,    2,    \
6, 7,  */  {  3, 11,  8,  7,  8, 11,  8,  7,  5,  8,  5,  0,  1,  0,  5,  0,  1,  2,  \
0,  2,  3, 11,  3,  2 }, +/*  89: 0,       3, 4,    6,     */  {  6, 11, 10,  2, 10, \
11, 10,  2,  0, 10,  0,  5,  4,  5,  0,  5,  4,  7,  5,  7,  6, 11,  6,  7 }, +/* \
169: 0,       3,    5,    7,  */  {  9,  8,  4,  8,  9,  0,  2,  0,  9,  5,  2,  9,  \
2,  5,  6,  7,  6,  5,  4,  7,  5,  7,  4,  8 }, +/* 225: 0,             5, 6, 7,  */ \
{  8,  4,  0,  9,  0,  4,  0,  9, 10,  0, 10,  3, 11,  3, 10,  3, 11,  7,  3,  7,  8, \
4,  8,  7 }, +/*  30:    1, 2, 3, 4,           */  {  4,  0,  8,  0,  4,  9, 10,  9,  \
4,  7, 10,  4, 10,  7, 11,  3, 11,  7,  8,  3,  7,  3,  8,  0 }, +/*  86:    1, 2,    \
4,    6,     */  {  4,  9,  8,  0,  8,  9,  8,  0,  2,  8,  2,  7,  6,  7,  2,  7,  \
6,  5,  7,  5,  4,  9,  4,  5 }, +/* 166:    1, 2,       5,    7,  */  { 11, 10,  6, \
10, 11,  2,  0,  2, 11,  7,  0, 11,  0,  7,  4,  5,  4,  7,  6,  5,  7,  5,  6, 10 }, \
+/*  58:    1,    3, 4, 5,        */  { 11,  8,  3,  8, 11,  7,  5,  7, 11,  2,  5, \
11,  5,  2,  1,  0,  1,  2,  3,  0,  2,  0,  3,  8 }, +/* 154:    1,    3, 4,       \
7,  */  {  0,  8,  9,  4,  9,  8,  9,  4,  6,  9,  6,  1,  2,  1,  6,  1,  2,  3,  1, \
3,  0,  8,  0,  3 }, +/* 106:    1,    3,    5, 6,     */  {  2, 10, 11,  6, 11, 10, \
11,  6,  4, 11,  4,  3,  0,  3,  4,  3,  0,  1,  3,  1,  2, 10,  2,  1 }, +/* 202:    \
1,    3,       6, 7,  */  {  9, 10,  1, 10,  9,  5,  7,  5,  9,  0,  7,  9,  7,  0,  \
3,  2,  3,  0,  1,  2,  0,  2,  1, 10 }, +/* 210:    1,       4,    6, 7,  */  {  9,  \
5,  1, 10,  1,  5,  1, 10, 11,  1, 11,  0,  8,  0, 11,  0,  8,  4,  0,  4,  9,  5,  \
9,  4 }, +/*  92:       2, 3, 4,    6,     */  {  8, 11,  7, 11,  8,  3,  1,  3,  8,  \
4,  1,  8,  1,  4,  5,  6,  5,  4,  7,  6,  4,  6,  7, 11 }, +/* 172:       2, 3,    \
5,    7,  */  {  5, 10,  9,  1,  9, 10,  9,  1,  3,  9,  3,  4,  7,  4,  3,  4,  7,  \
6,  4,  6,  5, 10,  5,  6 }, +/* 180:       2,    4, 5,    7,  */  { 10,  6,  2, 11,  \
2,  6,  2, 11,  8,  2,  8,  1,  9,  1,  8,  1,  9,  5,  1,  5, 10,  6, 10,  5 }, +/* \
120:          3, 4, 5, 6,     */  { 11,  7,  3,  8,  3,  7,  3,  8,  9,  3,  9,  2, \
10,  2,  9,  2, 10,  6,  2,  6, 11,  7, 11,  6 } +};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 12.2
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling12_2[24][24] = {
+/* 135: 0, 1, 2,             7,  */  {   9,  8, 12, 10,  9, 12,  2, 10, 12,  3,  2, \
12, 11,  3, 12,  6, 11, 12,  7,  6, 12,  8,  7, 12 }, +/*  75: 0, 1,    3,       6,   \
*/  {   8, 11, 12,  9,  8, 12,  1,  9, 12,  2,  1, 12, 10,  2, 12,  5, 10, 12,  6,  \
5, 12, 11,  6, 12 }, +/*  83: 0, 1,       4,    6,     */  {   3,  1, 12,  7,  3, 12, \
4,  7, 12,  9,  4, 12,  5,  9, 12,  6,  5, 12, 10,  6, 12,  1, 10, 12 }, +/* 163: 0, \
1,          5,    7,  */  {  12,  3,  1, 12,  1,  5, 12,  5,  6, 12,  6, 11, 12, 11,  \
7, 12,  7,  4, 12,  4,  8, 12,  8,  3 }, +/*  45: 0,    2, 3,    5,        */  {  11, \
10, 12,  8, 11, 12,  0,  8, 12,  1,  0, 12,  9,  1, 12,  4,  9, 12,  5,  4, 12, 10,  \
5, 12 }, +/*  53: 0,    2,    4, 5,        */  {  12,  5,  7, 12,  7,  3, 12,  3,  2, \
12,  2, 10, 12, 10,  1, 12,  1,  0, 12,  0,  9, 12,  9,  5 }, +/* 149: 0,    2,    4, \
7,  */  {   4,  6, 12,  0,  4, 12,  1,  0, 12, 10,  1, 12,  2, 10, 12,  3,  2, 12, \
11,  3, 12,  6, 11, 12 }, +/* 101: 0,    2,       5, 6,     */  {   6,  4, 12,  2,  \
6, 12,  3,  2, 12,  8,  3, 12,  0,  8, 12,  1,  0, 12,  9,  1, 12,  4,  9, 12 }, +/* \
197: 0,    2,          6, 7,  */  {  12,  7,  5, 12,  5,  1, 12,  1,  0, 12,  0,  8, \
12,  8,  3, 12,  3,  2, 12,  2, 11, 12, 11,  7 }, +/*  89: 0,       3, 4,    6,     \
*/  {  12,  2,  0, 12,  0,  4, 12,  4,  5, 12,  5, 10, 12, 10,  6, 12,  6,  7, 12,  \
7, 11, 12, 11,  2 }, +/* 169: 0,       3,    5,    7,  */  {   2,  0, 12,  6,  2, 12, \
7,  6, 12,  8,  7, 12,  4,  8, 12,  5,  4, 12,  9,  5, 12,  0,  9, 12 }, +/* 225: 0,  \
5, 6, 7,  */  {  12,  9, 10, 12, 10, 11, 12, 11,  7, 12,  7,  4, 12,  4,  8, 12,  8,  \
3, 12,  3,  0, 12,  0,  9 }, +/*  30:    1, 2, 3, 4,           */  {  10,  9, 12, 11, \
10, 12,  7, 11, 12,  4,  7, 12,  8,  4, 12,  3,  8, 12,  0,  3, 12,  9,  0, 12 }, +/* \
86:    1, 2,    4,    6,     */  {  12,  0,  2, 12,  2,  6, 12,  6,  7, 12,  7,  8, \
12,  8,  4, 12,  4,  5, 12,  5,  9, 12,  9,  0 }, +/* 166:    1, 2,       5,    7,  \
*/  {   0,  2, 12,  4,  0, 12,  5,  4, 12, 10,  5, 12,  6, 10, 12,  7,  6, 12, 11,  \
7, 12,  2, 11, 12 }, +/*  58:    1,    3, 4, 5,        */  {   5,  7, 12,  1,  5, 12, \
0,  1, 12,  8,  0, 12,  3,  8, 12,  2,  3, 12, 11,  2, 12,  7, 11, 12 }, +/* 154:    \
1,    3, 4,       7,  */  {  12,  4,  6, 12,  6,  2, 12,  2,  3, 12,  3,  8, 12,  8,  \
0, 12,  0,  1, 12,  1,  9, 12,  9,  4 }, +/* 106:    1,    3,    5, 6,     */  {  12, \
6,  4, 12,  4,  0, 12,  0,  1, 12,  1, 10, 12, 10,  2, 12,  2,  3, 12,  3, 11, 12, \
11,  6 }, +/* 202:    1,    3,       6, 7,  */  {   7,  5, 12,  3,  7, 12,  2,  3, \
12, 10,  2, 12,  1, 10, 12,  0,  1, 12,  9,  0, 12,  5,  9, 12 }, +/* 210:    1,      \
4,    6, 7,  */  {  12, 10, 11, 12, 11,  8, 12,  8,  0, 12,  0,  1, 12,  1,  9, 12,  \
9,  4, 12,  4,  5, 12,  5, 10 }, +/*  92:       2, 3, 4,    6,     */  {   1,  3, 12, \
5,  1, 12,  6,  5, 12, 11,  6, 12,  7, 11, 12,  4,  7, 12,  8,  4, 12,  3,  8, 12 }, \
+/* 172:       2, 3,    5,    7,  */  {  12,  1,  3, 12,  3,  7, 12,  7,  4, 12,  4,  \
9, 12,  9,  5, 12,  5,  6, 12,  6, 10, 12, 10,  1 }, +/* 180:       2,    4, 5,    7, \
*/  {  12, 11,  8, 12,  8,  9, 12,  9,  1, 12,  1,  2, 12,  2, 10, 12, 10,  5, 12,  \
5,  6, 12,  6, 11 }, +/* 120:          3, 4, 5, 6,     */  {  12,  8,  9, 12,  9, 10, \
12, 10,  2, 12,  2,  3, 12,  3, 11, 12, 11,  6, 12,  6,  7, 12,  7,  8 } +};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 12.2 inverted
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling12_2_[24][24] = {
+/* 135: 0, 1, 2,             7,  */  { 12,  2, 11, 12, 11,  7, 12,  7,  6, 12,  6, \
10, 12, 10,  9, 12,  9,  8, 12,  8,  3, 12,  3,  2 }, +/*  75: 0, 1,    3,       6,   \
*/  { 12,  1, 10, 12, 10,  6, 12,  6,  5, 12,  5,  9, 12,  9,  8, 12,  8, 11, 12, 11, \
2, 12,  2,  1 }, +/*  83: 0, 1,       4,    6,     */  { 12,  4,  5, 12,  5, 10, 12, \
10,  6, 12,  6,  7, 12,  7,  3, 12,  3,  1, 12,  1,  9, 12,  9,  4 }, +/* 163: 0, 1,  \
5,    7,  */  {  7,  6, 12,  8,  7, 12,  4,  8, 12,  5,  4, 12,  1,  5, 12,  3,  1, \
12, 11,  3, 12,  6, 11, 12 }, +/*  45: 0,    2, 3,    5,        */  { 12,  0,  9, 12, \
9,  5, 12,  5,  4, 12,  4,  8, 12,  8, 11, 12, 11, 10, 12, 10,  1, 12,  1,  0 }, +/*  \
53: 0,    2,    4, 5,        */  {  1,  2, 12,  9,  1, 12,  0,  9, 12,  3,  0, 12,  \
7,  3, 12,  5,  7, 12, 10,  5, 12,  2, 10, 12 }, +/* 149: 0,    2,    4,       7,  */ \
{ 12,  1,  2, 12,  2, 11, 12, 11,  3, 12,  3,  0, 12,  0,  4, 12,  4,  6, 12,  6, 10, \
12, 10,  1 }, +/* 101: 0,    2,       5, 6,     */  { 12,  3,  0, 12,  0,  9, 12,  9, \
1, 12,  1,  2, 12,  2,  6, 12,  6,  4, 12,  4,  8, 12,  8,  3 }, +/* 197: 0,    2,    \
6, 7,  */  {  3,  0, 12, 11,  3, 12,  2, 11, 12,  1,  2, 12,  5,  1, 12,  7,  5, 12,  \
8,  7, 12,  0,  8, 12 }, +/*  89: 0,       3, 4,    6,     */  {  6,  5, 12, 11,  6, \
12,  7, 11, 12,  4,  7, 12,  0,  4, 12,  2,  0, 12, 10,  2, 12,  5, 10, 12 }, +/* \
169: 0,       3,    5,    7,  */  { 12,  7,  4, 12,  4,  9, 12,  9,  5, 12,  5,  6, \
12,  6,  2, 12,  2,  0, 12,  0,  8, 12,  8,  7 }, +/* 225: 0,             5, 6, 7,  \
*/  {  8,  7, 12,  0,  8, 12,  3,  0, 12, 11,  3, 12, 10, 11, 12,  9, 10, 12,  4,  9, \
12,  7,  4, 12 }, +/*  30:    1, 2, 3, 4,           */  { 12,  7,  8, 12,  8,  0, 12, \
0,  3, 12,  3, 11, 12, 11, 10, 12, 10,  9, 12,  9,  4, 12,  4,  7 }, +/*  86:    1, \
2,    4,    6,     */  {  4,  7, 12,  9,  4, 12,  5,  9, 12,  6,  5, 12,  2,  6, 12,  \
0,  2, 12,  8,  0, 12,  7,  8, 12 }, +/* 166:    1, 2,       5,    7,  */  { 12,  5,  \
6, 12,  6, 11, 12, 11,  7, 12,  7,  4, 12,  4,  0, 12,  0,  2, 12,  2, 10, 12, 10,  5 \
}, +/*  58:    1,    3, 4, 5,        */  { 12,  0,  3, 12,  3, 11, 12, 11,  2, 12,  \
2,  1, 12,  1,  5, 12,  5,  7, 12,  7,  8, 12,  8,  0 }, +/* 154:    1,    3, 4,      \
7,  */  {  0,  3, 12,  9,  0, 12,  1,  9, 12,  2,  1, 12,  6,  2, 12,  4,  6, 12,  8, \
4, 12,  3,  8, 12 }, +/* 106:    1,    3,    5, 6,     */  {  2,  1, 12, 11,  2, 12,  \
3, 11, 12,  0,  3, 12,  4,  0, 12,  6,  4, 12, 10,  6, 12,  1, 10, 12 }, +/* 202:    \
1,    3,       6, 7,  */  { 12,  2,  1, 12,  1,  9, 12,  9,  0, 12,  0,  3, 12,  3,  \
7, 12,  7,  5, 12,  5, 10, 12, 10,  2 }, +/* 210:    1,       4,    6, 7,  */  {  9,  \
0, 12,  5,  9, 12,  4,  5, 12,  8,  4, 12, 11,  8, 12, 10, 11, 12,  1, 10, 12,  0,  \
1, 12 }, +/*  92:       2, 3, 4,    6,     */  { 12,  6,  7, 12,  7,  8, 12,  8,  4, \
12,  4,  5, 12,  5,  1, 12,  1,  3, 12,  3, 11, 12, 11,  6 }, +/* 172:       2, 3,    \
5,    7,  */  {  5,  4, 12, 10,  5, 12,  6, 10, 12,  7,  6, 12,  3,  7, 12,  1,  3, \
12,  9,  1, 12,  4,  9, 12 }, +/* 180:       2,    4, 5,    7,  */  { 10,  1, 12,  6, \
10, 12,  5,  6, 12,  9,  5, 12,  8,  9, 12, 11,  8, 12,  2, 11, 12,  1,  2, 12 }, +/* \
120:          3, 4, 5, 6,     */  { 11,  2, 12,  7, 11, 12,  6,  7, 12, 10,  6, 12,  \
9, 10, 12,  8,  9, 12,  3,  8, 12,  2,  3, 12 } +};
+//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+/**
+ * \brief test table for case 13
+ * All faces are to be tested
+ *
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+/* 13: face test */
+static const int test13[2][7] = {
+/* 165: 0,    2,       5,    7,  */  { 1,2,3,4,5,6,7 },
+/*  90:    1,    3, 4,    6,     */  { 2,3,4,1,5,6,7 },
+};
+
+
+
+//_____________________________________________________________________________
+/**
+ * \brief subconfiguration table for case 13
+ * Hard-coded tests for the subconfiguration determination
+ *
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+/* 13: sub configs */
+static const int subconfig13[64] = {
+/*  0: 0,0,0,0,0,0 */   0,
+/*  1: 1,0,0,0,0,0 */   1,
+/*  2: 0,1,0,0,0,0 */   2,
+/*  3: 1,1,0,0,0,0 */   7,
+/*  4: 0,0,1,0,0,0 */   3,
+/*  5: 1,0,1,0,0,0 */  -1,
+/*  6: 0,1,1,0,0,0 */  11,
+/*  7: 1,1,1,0,0,0 */  -1,
+/*  8: 0,0,0,1,0,0 */   4,
+/*  9: 1,0,0,1,0,0 */   8,
+/* 10: 0,1,0,1,0,0 */  -1,
+/* 11: 1,1,0,1,0,0 */  -1,
+/* 12: 0,0,1,1,0,0 */  14,
+/* 13: 1,0,1,1,0,0 */  -1,
+/* 14: 0,1,1,1,0,0 */  -1,
+/* 15: 1,1,1,1,0,0 */  -1,
+/* 16: 0,0,0,0,1,0 */   5,
+/* 17: 1,0,0,0,1,0 */   9,
+/* 18: 0,1,0,0,1,0 */  12,
+/* 19: 1,1,0,0,1,0 */  23,
+/* 20: 0,0,1,0,1,0 */  15,
+/* 21: 1,0,1,0,1,0 */  -1,
+/* 22: 0,1,1,0,1,0 */  21,
+/* 23: 1,1,1,0,1,0 */  38,
+/* 24: 0,0,0,1,1,0 */  17,
+/* 25: 1,0,0,1,1,0 */  20,
+/* 26: 0,1,0,1,1,0 */  -1,
+/* 27: 1,1,0,1,1,0 */  36,
+/* 28: 0,0,1,1,1,0 */  26,
+/* 29: 1,0,1,1,1,0 */  33,
+/* 30: 0,1,1,1,1,0 */  30,
+/* 31: 1,1,1,1,1,0 */  44,
+/* 32: 0,0,0,0,0,1 */   6,
+/* 33: 1,0,0,0,0,1 */  10,
+/* 34: 0,1,0,0,0,1 */  13,
+/* 35: 1,1,0,0,0,1 */  19,
+/* 36: 0,0,1,0,0,1 */  16,
+/* 37: 1,0,1,0,0,1 */  -1,
+/* 38: 0,1,1,0,0,1 */  25,
+/* 39: 1,1,1,0,0,1 */  37,
+/* 40: 0,0,0,1,0,1 */  18,
+/* 41: 1,0,0,1,0,1 */  24,
+/* 42: 0,1,0,1,0,1 */  -1,
+/* 43: 1,1,0,1,0,1 */  35,
+/* 44: 0,0,1,1,0,1 */  22,
+/* 45: 1,0,1,1,0,1 */  32,
+/* 46: 0,1,1,1,0,1 */  29,
+/* 47: 1,1,1,1,0,1 */  43,
+/* 48: 0,0,0,0,1,1 */  -1,
+/* 49: 1,0,0,0,1,1 */  -1,
+/* 50: 0,1,0,0,1,1 */  -1,
+/* 51: 1,1,0,0,1,1 */  34,
+/* 52: 0,0,1,0,1,1 */  -1,
+/* 53: 1,0,1,0,1,1 */  -1,
+/* 54: 0,1,1,0,1,1 */  28,
+/* 55: 1,1,1,0,1,1 */  42,
+/* 56: 0,0,0,1,1,1 */  -1,
+/* 57: 1,0,0,1,1,1 */  31,
+/* 58: 0,1,0,1,1,1 */  -1,
+/* 59: 1,1,0,1,1,1 */  41,
+/* 60: 0,0,1,1,1,1 */  27,
+/* 61: 1,0,1,1,1,1 */  40,
+/* 62: 0,1,1,1,1,1 */  39,
+/* 63: 1,1,1,1,1,1 */  45,
+};
+
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 13.1
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+/* 13.1 */
+static const int tiling13_1[2][12] = {
+/* 165: 0,    2,       5,    7,  */  { 11,  7,  6,  1,  2, 10,  8,  3,  0,  9,  5, 4 \
}, +/*  90:    1,    3, 4,    6,     */  {  8,  4,  7,  2,  3, 11,  9,  0,  1, 10,  \
6, 5 } +};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 13.1 inverted
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+/* 13.1 */
+static const int tiling13_1_[2][12] = {
+/* 165: 0,    2,       5,    7,  */  { 7,  4,  8, 11,  3,  2,  1,  0,  9,  5,  6, 10 \
}, +/*  90:    1,    3, 4,    6,     */  { 6,  7, 11, 10,  2,  1,  0,  3,  8,  4,  5, \
9 } +};
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 13.2
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+/* 13.2 */
+static const int tiling13_2[2][6][18] = {
+/* 165: 0,    2,       5,    7,  */  {
+ /* 1 */ { 1,  2, 10, 11,  7,  6,  3,  4,  8,  4,  3,  5,  0,  5,  3,  5,  0,  9 },
+ /* 2 */ { 8,  3,  0, 11,  7,  6,  9,  1,  4,  2,  4,  1,  4,  2,  5, 10,  5,  2 },
+ /* 3 */ { 9,  5,  4,  8,  3,  0,  1,  6, 10,  6,  1,  7,  2,  7,  1,  7,  2, 11 },
+ /* 4 */ { 9,  5,  4,  1,  2, 10, 11,  3,  6,  0,  6,  3,  6,  0,  7,  8,  7,  0 },
+ /* 5 */ { 9,  5,  4, 11,  7,  6,  0, 10,  1, 10,  0,  8, 10,  8,  2,  3,  2,  8 },
+ /* 6 */ { 1,  2, 10,  3,  0,  8,  4,  9,  7, 11,  7,  9,  5, 11,  9, 11,  5,  6 }
+},
+/*  90:    1,    3, 4,    6,     */  {
+ /* 1 */ { 2,  3, 11,  8,  4,  7,  0,  5,  9,  5,  0,  6,  1,  6,  0,  6,  1, 10 },
+ /* 2 */ { 9,  0,  1,  8,  4,  7, 10,  2,  5,  3,  5,  2,  5,  3,  6, 11,  6,  3 },
+ /* 3 */ { 6,  5, 10,  9,  0,  1,  2,  7, 11,  7,  2,  4,  3,  4,  2,  4,  3,  8 },
+ /* 4 */ { 6,  5, 10,  2,  3, 11,  8,  0,  7,  1,  7,  0,  7,  1,  4,  9,  4,  1 },
+ /* 5 */ { 6,  5, 10,  8,  4,  7,  1, 11,  2, 11,  1,  9, 11,  9,  3,  0,  3,  9 },
+ /* 6 */ { 2,  3, 11,  0,  1,  9,  5, 10,  4,  8,  4, 10,  6,  8, 10,  8,  6,  7 }
+} };
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 13.2 inverted
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+/* 13.2 */
+static const int tiling13_2_[2][6][18] = {
+/* 165: 0,    2,       5,    7,  */  {
+ /* 1 */ { 10,  5,  6, 11,  3,  2,  7,  0,  8,  0,  7,  1,  4,  1,  7,  1,  4,  9 },
+ /* 2 */ { 11,  3,  2,  7,  4,  8,  9,  5,  0,  6,  0,  5,  0,  6,  1, 10,  1,  6 },
+ /* 3 */ {  1,  0,  9,  7,  4,  8,  5,  2, 10,  2,  5,  3,  6,  3,  5,  3,  6, 11 },
+ /* 4 */ { 10,  5,  6,  1,  0,  9, 11,  7,  2,  4,  2,  7,  2,  4,  3,  8,  3,  4 },
+ /* 5 */ { 10,  5,  6,  7,  4,  8,  2, 11,  1,  9,  1, 11,  3,  9, 11,  9,  3,  0 },
+ /* 6 */ { 11,  3,  2,  9,  1,  0,  4, 10,  5, 10,  4,  8, 10,  8,  6,  7,  6,  8 }
+},
+/*  90:    1,    3, 4,    6,     */  {
+ /* 1 */ {  6,  7, 11,  8,  0,  3,  4,  1,  9,  1,  4,  2,  5,  2,  4,  2,  5, 10 },
+ /* 2 */ {  8,  0,  3,  4,  5,  9, 10,  6,  1,  7,  1,  6,  1,  7,  2, 11,  2,  7 },
+ /* 3 */ {  2,  1, 10,  4,  5,  9,  6,  3, 11,  3,  6,  0,  7,  0,  6,  0,  7,  8 },
+ /* 4 */ {  6,  7, 11,  2,  1, 10,  8,  4,  3,  5,  3,  4,  3,  5,  0,  9,  0,  5 },
+ /* 5 */ {  6,  7, 11,  4,  5,  9,  3,  8,  2, 10,  2,  8,  0, 10,  8, 10,  0,  1 },
+ /* 6 */ {  8,  0,  3, 10,  2,  1,  5, 11,  6, 11,  5,  9, 11,  9,  7,  4,  7,  9 }
+} };
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 13.3
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+/* 13.3 */
+static const int tiling13_3[2][12][30] = {
+/* 165: 0,    2,       5,    7,  */  {
+ /* 1,2 */ { 11,  7,  6, 12,  2, 10, 12, 10,  5, 12,  5,  4, 12,  4,  8, 12,  8,  3, \
12,  3,  0, 12,  0,  9, 12,  9,  1, 12,  1,  2 }, + /* 1,4 */ {  1,  2, 10,  9,  5, \
12,  0,  9, 12,  3,  0, 12, 11,  3, 12,  6, 11, 12,  7,  6, 12,  8,  7, 12,  4,  8, \
12,  5,  4, 12 }, + /* 1,5 */ { 11,  7,  6, 12,  5,  4, 12,  4,  8, 12,  8,  3, 12,  \
3,  2, 12,  2, 10, 12, 10,  1, 12,  1,  0, 12,  0,  9, 12,  9,  5 }, + /* 1,6 */ {  \
1,  2, 10, 12,  3,  0, 12,  0,  9, 12,  9,  5, 12,  5,  6, 12,  6, 11, 12, 11,  7, \
12,  7,  4, 12,  4,  8, 12,  8,  3 }, + /* 2,3 */ {  8,  3,  0, 11,  7, 12,  2, 11, \
12,  1,  2, 12,  9,  1, 12,  4,  9, 12,  5,  4, 12, 10,  5, 12,  6, 10, 12,  7,  6, \
12 }, + /* 2,5 */ { 11,  7,  6,  5,  4, 12, 10,  5, 12,  2, 10, 12,  3,  2, 12,  8,  \
3, 12,  0,  8, 12,  1,  0, 12,  9,  1, 12,  4,  9, 12 }, + /* 2,6 */ {  8,  3,  0,  \
1,  2, 12,  9,  1, 12,  4,  9, 12,  7,  4, 12, 11,  7, 12,  6, 11, 12,  5,  6, 12, \
10,  5, 12,  2, 10, 12 }, + /* 3,4 */ {  9,  5,  4, 12,  0,  8, 12,  8,  7, 12,  7,  \
6, 12,  6, 10, 12, 10,  1, 12,  1,  2, 12,  2, 11, 12, 11,  3, 12,  3,  0 }, + /* 3,5 \
*/ {  9,  5,  4, 12,  7,  6, 12,  6, 10, 12, 10,  1, 12,  1,  0, 12,  0,  8, 12,  8,  \
3, 12,  3,  2, 12,  2, 11, 12, 11,  7 }, + /* 3,6 */ {  8,  3,  0, 12,  1,  2, 12,  \
2, 11, 12, 11,  7, 12,  7,  4, 12,  4,  9, 12,  9,  5, 12,  5,  6, 12,  6, 10, 12, \
10,  1 }, + /* 4,5 */ {  9,  5,  4,  7,  6, 12,  8,  7, 12,  0,  8, 12,  1,  0, 12, \
10,  1, 12,  2, 10, 12,  3,  2, 12, 11,  3, 12,  6, 11, 12 }, + /* 4,6 */ {  1,  2, \
10,  3,  0, 12, 11,  3, 12,  6, 11, 12,  5,  6, 12,  9,  5, 12,  4,  9, 12,  7,  4, \
12,  8,  7, 12,  0,  8, 12 } +},
+/*  90:    1,    3, 4,    6,     */  {
+ /* 1,2 */ {  8,  4,  7, 12,  3, 11, 12, 11,  6, 12,  6,  5, 12,  5,  9, 12,  9,  0, \
12,  0,  1, 12,  1, 10, 12, 10,  2, 12,  2,  3 }, + /* 1,4 */ {  2,  3, 11, 10,  6, \
12,  1, 10, 12,  0,  1, 12,  8,  0, 12,  7,  8, 12,  4,  7, 12,  9,  4, 12,  5,  9, \
12,  6,  5, 12 }, + /* 1,5 */ {  8,  4,  7, 12,  6,  5, 12,  5,  9, 12,  9,  0, 12,  \
0,  3, 12,  3, 11, 12, 11,  2, 12,  2,  1, 12,  1, 10, 12, 10,  6 }, + /* 1,6 */ {  \
2,  3, 11, 12,  0,  1, 12,  1, 10, 12, 10,  6, 12,  6,  7, 12,  7,  8, 12,  8,  4, \
12,  4,  5, 12,  5,  9, 12,  9,  0 }, + /* 2,3 */ {  0,  1,  9,  8,  4, 12,  3,  8, \
12,  2,  3, 12, 10,  2, 12,  5, 10, 12,  6,  5, 12, 11,  6, 12,  7, 11, 12,  4,  7, \
12 }, + /* 2,5 */ {  8,  4,  7,  6,  5, 12, 11,  6, 12,  3, 11, 12,  0,  3, 12,  9,  \
0, 12,  1,  9, 12,  2,  1, 12, 10,  2, 12,  5, 10, 12 }, + /* 2,6 */ {  9,  0,  1,  \
2,  3, 12, 10,  2, 12,  5, 10, 12,  4,  5, 12,  8,  4, 12,  7,  8, 12,  6,  7, 12, \
11,  6, 12,  3, 11, 12 }, + /* 3,4 */ {  6,  5, 10, 12,  1,  9, 12,  9,  4, 12,  4,  \
7, 12,  7, 11, 12, 11,  2, 12,  2,  3, 12,  3,  8, 12,  8,  0, 12,  0,  1 }, + /* 3,5 \
*/ {  6,  5, 10, 12,  4,  7, 12,  7, 11, 12, 11,  2, 12,  2,  1, 12,  1,  9, 12,  9,  \
0, 12,  0,  3, 12,  3,  8, 12,  8,  4 }, + /* 3,6 */ {  9,  0,  1, 12,  2,  3, 12,  \
3,  8, 12,  8,  4, 12,  4,  5, 12,  5, 10, 12, 10,  6, 12,  6,  7, 12,  7, 11, 12, \
11,  2 }, + /* 4,5 */ {  6,  5, 10,  4,  7, 12,  9,  4, 12,  1,  9, 12,  2,  1, 12, \
11,  2, 12,  3, 11, 12,  0,  3, 12,  8,  0, 12,  7,  8, 12 }, + /* 4,6 */ {  2,  3, \
11,  0,  1, 12,  8,  0, 12,  7,  8, 12,  6,  7, 12, 10,  6, 12,  5, 10, 12,  4,  5, \
12,  9,  4, 12,  1,  9, 12 } +} };
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 13.3, inverted
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+/* 13.3 */
+static const int tiling13_3_[2][12][30] = {
+/* 165: 0,    2,       5,    7,  */  {
+ /* 1,2 */ {  3,  2, 11,  8,  7, 12,  0,  8, 12,  1,  0, 12, 10,  1, 12,  6, 10, 12, \
5,  6, 12,  9,  5, 12,  4,  9, 12,  7,  4, 12 }, + /* 1,4 */ {  5,  6, 10, 12,  2, \
11, 12, 11,  7, 12,  7,  4, 12,  4,  9, 12,  9,  1, 12,  1,  0, 12,  0,  8, 12,  8,  \
3, 12,  3,  2 }, + /* 1,5 */ { 10,  5,  6, 12,  7,  4, 12,  4,  9, 12,  9,  1, 12,  \
1,  2, 12,  2, 11, 12, 11,  3, 12,  3,  0, 12,  0,  8, 12,  8,  7 }, + /* 1,6 */ { \
11,  3,  2, 12,  1,  0, 12,  0,  8, 12,  8,  7, 12,  7,  6, 12,  6, 10, 12, 10,  5, \
12,  5,  4, 12,  4,  9, 12,  9,  1 }, + /* 2,3 */ {  7,  4,  8, 11,  3, 12,  6, 11, \
12,  5,  6, 12,  9,  5, 12,  0,  9, 12,  1,  0, 12, 10,  1, 12,  2, 10, 12,  3,  2, \
12 }, + /* 2,5 */ {  7,  4,  8,  5,  6, 12,  9,  5, 12,  0,  9, 12,  3,  0, 12, 11,  \
3, 12,  2, 11, 12,  1,  2, 12, 10,  1, 12,  6, 10, 12 }, + /* 2,6 */ { 11,  3,  2,  \
1,  0, 12, 10,  1, 12,  6, 10, 12,  7,  6, 12,  8,  7, 12,  4,  8, 12,  5,  4, 12,  \
9,  5, 12,  0,  9, 12 }, + /* 3,4 */ {  1,  0,  9, 12,  4,  8, 12,  8,  3, 12,  3,  \
2, 12,  2, 10, 12, 10,  5, 12,  5,  6, 12,  6, 11, 12, 11,  7, 12,  7,  4 }, + /* 3,5 \
*/ {  7,  4,  8, 12,  5,  6, 12,  6, 11, 12, 11,  3, 12,  3,  0, 12,  0,  9, 12,  9,  \
1, 12,  1,  2, 12,  2, 10, 12, 10,  5 }, + /* 3,6 */ {  1,  0,  9, 12,  3,  2, 12,  \
2, 10, 12, 10,  5, 12,  5,  4, 12,  4,  8, 12,  8,  7, 12,  7,  6, 12,  6, 11, 12, \
11,  3 }, + /* 4,5 */ { 10,  5,  6,  7,  4, 12, 11,  7, 12,  2, 11, 12,  1,  2, 12,  \
9,  1, 12,  0,  9, 12,  3,  0, 12,  8,  3, 12,  4,  8, 12 }, + /* 4,6 */ {  9,  1,  \
0,  3,  2, 12,  8,  3, 12,  4,  8, 12,  5,  4, 12, 10,  5, 12,  6, 10, 12,  7,  6, \
12, 11,  7, 12,  2, 11, 12 } +},
+/*  90:    1,    3, 4,    6,     */  {
+ /* 1,2 */ {  0,  3,  8,  9,  4, 12,  1,  9, 12,  2,  1, 12, 11,  2, 12,  7, 11, 12, \
6,  7, 12, 10,  6, 12,  5, 10, 12,  4,  5, 12 }, + /* 1,4 */ { 11,  6,  7, 12,  3,  \
8, 12,  8,  4, 12,  4,  5, 12,  5, 10, 12, 10,  2, 12,  2,  1, 12,  1,  9, 12,  9,  \
0, 12,  0,  3 }, + /* 1,5 */ {  6,  7, 11, 12,  4,  5, 12,  5, 10, 12, 10,  2, 12,  \
2,  3, 12,  3,  8, 12,  8,  0, 12,  0,  1, 12,  1,  9, 12,  9,  4 }, + /* 1,6 */ {  \
8,  0,  3, 12,  2,  1, 12,  1,  9, 12,  9,  4, 12,  4,  7, 12,  7, 11, 12, 11,  6, \
12,  6,  5, 12,  5, 10, 12, 10,  2 }, + /* 2,3 */ {  4,  5,  9,  8,  0, 12,  7,  8, \
12,  6,  7, 12, 10,  6, 12,  1, 10, 12,  2,  1, 12, 11,  2, 12,  3, 11, 12,  0,  3, \
12 }, + /* 2,5 */ {  4,  5,  9,  6,  7, 12, 10,  6, 12,  1, 10, 12,  0,  1, 12,  8,  \
0, 12,  3,  8, 12,  2,  3, 12, 11,  2, 12,  7, 11, 12 }, + /* 2,6 */ {  8,  0,  3,  \
2,  1, 12, 11,  2, 12,  7, 11, 12,  4,  7, 12,  9,  4, 12,  5,  9, 12,  6,  5, 12, \
10,  6, 12,  1, 10, 12 }, + /* 3,4 */ {  2,  1, 10, 12,  5,  9, 12,  9,  0, 12,  0,  \
3, 12,  3, 11, 12, 11,  6, 12,  6,  7, 12,  7,  8, 12,  8,  4, 12,  4,  5 }, + /* 3,5 \
*/ {  4,  5,  9, 12,  6,  7, 12,  7,  8, 12,  8,  0, 12,  0,  1, 12,  1, 10, 12, 10,  \
2, 12,  2,  3, 12,  3, 11, 12, 11,  6 }, + /* 3,6 */ {  2,  1, 10, 12,  0,  3, 12,  \
3, 11, 12, 11,  6, 12,  6,  5, 12,  5,  9, 12,  9,  4, 12,  4,  7, 12,  7,  8, 12,  \
8,  0 }, + /* 4,5 */ {  6,  7, 11,  4,  5, 12,  8,  4, 12,  3,  8, 12,  2,  3, 12, \
10,  2, 12,  1, 10, 12,  0,  1, 12,  9,  0, 12,  5,  9, 12 }, + /* 4,6 */ { 10,  2,  \
1,  0,  3, 12,  9,  0, 12,  5,  9, 12,  6,  5, 12, 11,  6, 12,  7, 11, 12,  4,  7, \
12,  8,  4, 12,  3,  8, 12 } +} };
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 13.4
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+/* 13.4 */
+static const int tiling13_4[2][4][36] = {
+/* 165: 0,    2,       5,    7,  */  {
+/* 1,2,6 */  { 12,  2, 10, 12, 10,  5, 12,  5,  6, 12,  6, 11, 12, 11,  7, 12,  7,  \
4, 12,  4,  8, 12,  8,  3, 12,  3,  0, 12,  0,  9, 12,  9,  1, 12,  1,  2 }, +/* \
1,4,5 */  { 11,  3, 12,  6, 11, 12,  7,  6, 12,  8,  7, 12,  4,  8, 12,  5,  4, 12,  \
9,  5, 12,  0,  9, 12,  1,  0, 12, 10,  1, 12,  2, 10, 12,  3,  2, 12 }, +/* 2,3,5 */ \
{  9,  1, 12,  4,  9, 12,  5,  4, 12, 10,  5, 12,  6, 10, 12,  7,  6, 12, 11,  7, 12, \
2, 11, 12,  3,  2, 12,  8,  3, 12,  0,  8, 12,  1,  0, 12 }, +/* 3,4,6 */  { 12,  0,  \
8, 12,  8,  7, 12,  7,  4, 12,  4,  9, 12,  9,  5, 12,  5,  6, 12,  6, 10, 12, 10,  \
1, 12,  1,  2, 12,  2, 11, 12, 11,  3, 12,  3,  0 } +},
+/*  90:    1,    3, 4,    6,     */  {
+/* 1,2,6 */  { 12,  3, 11, 12, 11,  6, 12,  6,  7, 12,  7,  8, 12,  8,  4, 12,  4,  \
5, 12,  5,  9, 12,  9,  0, 12,  0,  1, 12,  1, 10, 12, 10,  2, 12,  2,  3 }, +/* \
1,4,5 */  {  8,  0, 12,  7,  8, 12,  4,  7, 12,  9,  4, 12,  5,  9, 12,  6,  5, 12, \
10,  6, 12,  1, 10, 12,  2,  1, 12, 11,  2, 12,  3, 11, 12,  0,  3, 12 }, +/* 2,3,5 \
*/  { 10,  2, 12,  5, 10, 12,  6,  5, 12, 11,  6, 12,  7, 11, 12,  4,  7, 12,  8,  4, \
12,  3,  8, 12,  0,  3, 12,  9,  0, 12,  1,  9, 12,  2,  1, 12 }, +/* 3,4,6 */  { 12, \
1,  9, 12,  9,  4, 12,  4,  5, 12,  5, 10, 12, 10,  6, 12,  6,  7, 12,  7, 11, 12, \
11,  2, 12,  2,  3, 12,  3,  8, 12,  8,  0, 12,  0,  1 } +} };
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 13.5.1
+ * The support edge for the interior test is marked as the 1st column.
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+/* 13.5.1 */
+static const int tiling13_5_1[2][4][18] = {
+/* 165: 0,    2,       5,    7,  */  {
+/* 1,2,5 */  {  7,  6, 11,  1,  0,  9, 10,  3,  2,  3, 10,  5,  3,  5,  8,  4,  8, 5 \
}, +/* 1,4,6 */  {  1,  2, 10,  7,  4,  8,  3,  0, 11,  6, 11,  0,  9,  6,  0,  6,  \
9, 5 }, +/* 2,3,6 */  {  3,  0,  8,  5,  6, 10,  1,  2,  9,  4,  9,  2, 11,  4,  2,  \
4, 11, 7 }, +/* 3,4,5 */  {  5,  4,  9,  3,  2, 11,  8,  1,  0,  1,  8,  7,  1,  7, \
10,  6, 10, 7 } +},
+/*  90:    1,    3, 4,    6,     */  {
+/* 1,2,5 */  {  4,  7,  8,  2,  1, 10, 11,  0,  3,  0, 11,  6,  0,  6,  9,  5,  9, 6 \
}, +/* 1,4,6 */  {  2,  3, 11,  4,  5,  9,  0,  1,  8,  7,  8,  1, 10,  7,  1,  7, \
10, 6 }, +/* 2,3,6 */  {  0,  1,  9,  6,  7, 11,  2,  3, 10,  5, 10,  3,  8,  5,  3,  \
5,  8, 4 }, +/* 3,4,5 */  {  6,  5, 10,  0,  3,  8,  9,  2,  1,  2,  9,  4,  2,  4, \
11,  7, 11, 4 } +} };
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 13.5.2
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+/* 13.5.2 */
+static const int tiling13_5_2[2][4][30] = {
+/* 165: 0,    2,       5,    7,  */  {
+/* 1,2,5 */  { 1,  0,  9,  7,  4,  8,  7,  8,  3,  7,  3, 11,  2, 11,  3, 11,  2, \
10, 11, 10,  6,  5,  6, 10,  6,  5,  7,  4,  7, 5 }, +/* 1,4,6 */  { 7,  4,  8, 11,  \
3,  2,  6, 11,  2, 10,  6,  2,  6, 10,  5,  9,  5, 10,  1,  9, 10,  9,  1,  0,  2,  \
0,  1,  0,  2, 3 }, +/* 2,3,6 */  { 5,  6, 10,  9,  1,  0,  4,  9,  0,  8,  4,  0,  \
4,  8,  7, 11,  7,  8,  3, 11,  8, 11,  3,  2,  0,  2,  3,  2,  0, 1 }, +/* 3,4,5 */  \
{ 3,  2, 11,  5,  6, 10,  5, 10,  1,  5,  1,  9,  0,  9,  1,  9,  0,  8,  9,  8,  4,  \
4,  8,  7,  4,  7,  5,  6,  5, 7 } +},
+/*  90:    1,    3, 4,    6,     */  {
+/* 1,2,5 */  { 2,  1, 10,  4,  5,  9,  4,  9,  0,  4,  0,  8,  3,  8,  0,  8,  3, \
11,  8, 11,  7,  6,  7, 11,  7,  6,  4,  5,  4, 6 }, +/* 1,4,6 */  { 4,  5,  9,  8,  \
0,  3,  7,  8,  3, 11,  7,  3,  7, 11,  6, 10,  6, 11,  2, 10, 11, 10,  2,  1,  3,  \
1,  2,  1,  3, 0 }, +/* 2,3,6 */  { 6,  7, 11, 10,  2,  1,  5, 10,  1,  9,  5,  1,  \
5,  9,  4,  8,  4,  9,  0,  8,  9,  8,  0,  3,  1,  3,  0,  3,  1, 2 }, +/* 3,4,5 */  \
{ 0,  3,  8,  6,  7, 11,  6, 11,  2,  6,  2, 10,  1, 10,  2, 10,  1,  9, 10,  9,  5,  \
5,  9,  4,  5,  4,  6,  7,  6, 4 } +} };
+//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+/**
+ * \brief tiling table for case 14
+ * For each of the case above, the specific triangulation of the edge
+ * intersection points is given.
+ * When a case is ambiguous, there is an auxiliary table that contains
+ * the face number to test and the tiling table contains the specific
+ * triangulations depending on the results
+ * A minus sign means to invert the result of the test.
+ */
+//-----------------------------------------------------------------------------
+static const int tiling14[12][12] = {
+/*  71: 0, 1, 2,          6,     */  {  5,  9,  8,  5,  8,  2,  5,  2,  6,  3,  2,  \
8 }, +/*  43: 0, 1,    3,    5,        */  {  2,  1,  5,  2,  5,  8,  2,  8, 11,  4,  \
8,  5 }, +/* 147: 0, 1,       4,       7,  */  {  9,  4,  6,  9,  6,  3,  9,  3,  1, \
11,  3,  6 }, +/*  29: 0,    2, 3, 4,           */  {  1, 11, 10,  1,  4, 11,  1,  0, \
4,  7, 11,  4 }, +/* 201: 0,       3,       6, 7,  */  {  8,  2,  0,  8,  5,  2,  8,  \
7,  5, 10,  2,  5 }, +/* 113: 0,          4, 5, 6,     */  {  0,  7,  3,  0, 10,  7,  \
0,  9, 10,  6,  7, 10 }, +/* 142:    1, 2, 3,          7,  */  {  0,  3,  7,  0,  7, \
10,  0, 10,  9,  6, 10,  7 }, +/*  54:    1, 2,    4, 5,        */  {  8,  0,  2,  8, \
2,  5,  8,  5,  7, 10,  5,  2 }, +/* 226:    1,          5, 6, 7,  */  {  1, 10, 11,  \
1, 11,  4,  1,  4,  0,  7,  4, 11 }, +/* 108:       2, 3,    5, 6,     */  {  9,  6,  \
4,  9,  3,  6,  9,  1,  3, 11,  6,  3 }, +/* 212:       2,    4,    6, 7,  */  {  2,  \
5,  1,  2,  8,  5,  2, 11,  8,  4,  5,  8 }, +/* 184:          3, 4, 5,    7,  */  {  \
5,  8,  9,  5,  2,  8,  5,  6,  2,  3,  8,  2 } +};
+//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+/**
+ * \brief original Marching Cubes implementation
+ * For each of the possible vertex states listed in this table there is a
+ * specific triangulation of the edge intersection points.  The table lists
+ * all of them in the form of 0-5 edge triples with the list terminated by
+ * the invalid value -1.  For example: casesClassic[3] list the 2 triangles
+ * formed when cube[0] and cube[1] are inside of the surface, but the rest of
+ * the cube is not.
+ */
+//-----------------------------------------------------------------------------
+static const int casesClassic[256][16] = {
+/*   0:                          */  { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1, -1 }, +/*   1: 0,                       */  {  0,  8,  3, -1, -1, -1, \
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*   2:    1,                    */  {  0, \
1,  9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*   3: 0, 1,           \
*/  {  1,  8,  3,  9,  8,  1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*   4:      \
2,                 */  {  1,  2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, \
-1 }, +/*   5: 0,    2,                 */  {  0,  8,  3,  1,  2, 10, -1, -1, -1, -1, \
-1, -1, -1, -1, -1, -1 }, +/*   6:    1, 2,                 */  {  9,  2, 10,  0,  2, \
9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*   7: 0, 1, 2,                 */  {  \
2,  8,  3,  2, 10,  8, 10,  9,  8, -1, -1, -1, -1, -1, -1, -1 }, +/*   8:          3, \
*/  {  3, 11,  2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*   9: 0,   \
3,              */  {  0, 11,  2,  8, 11,  0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 \
}, +/*  10:    1,    3,              */  {  1,  9,  0,  2,  3, 11, -1, -1, -1, -1, \
-1, -1, -1, -1, -1, -1 }, +/*  11: 0, 1,    3,              */  {  1, 11,  2,  1,  9, \
11,  9,  8, 11, -1, -1, -1, -1, -1, -1, -1 }, +/*  12:       2, 3,              */  { \
3, 10,  1, 11, 10,  3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  13: 0,    2, 3, \
*/  {  0, 10,  1,  0,  8, 10,  8, 11, 10, -1, -1, -1, -1, -1, -1, -1 }, +/*  14:    \
1, 2, 3,              */  {  3,  9,  0,  3, 11,  9, 11, 10,  9, -1, -1, -1, -1, -1, \
-1, -1 }, +/*  15: 0, 1, 2, 3,              */  {  9,  8, 10, 10,  8, 11, -1, -1, -1, \
-1, -1, -1, -1, -1, -1, -1 }, +/*  16:             4,           */  {  4,  7,  8, -1, \
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  17: 0,          4,           \
*/  {  4,  3,  0,  7,  3,  4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  18:    \
1,       4,           */  {  0,  1,  9,  8,  4,  7, -1, -1, -1, -1, -1, -1, -1, -1, \
-1, -1 }, +/*  19: 0, 1,       4,           */  {  4,  1,  9,  4,  7,  1,  7,  3,  1, \
-1, -1, -1, -1, -1, -1, -1 }, +/*  20:       2,    4,           */  {  1,  2, 10,  8, \
4,  7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  21: 0,    2,    4,           */ \
{  3,  4,  7,  3,  0,  4,  1,  2, 10, -1, -1, -1, -1, -1, -1, -1 }, +/*  22:    1, 2, \
4,           */  {  9,  2, 10,  9,  0,  2,  8,  4,  7, -1, -1, -1, -1, -1, -1, -1 }, \
+/*  23: 0, 1, 2,    4,           */  {  2, 10,  9,  2,  9,  7,  2,  7,  3,  7,  9,  \
4, -1, -1, -1, -1 }, +/*  24:          3, 4,           */  {  8,  4,  7,  3, 11,  2, \
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  25: 0,       3, 4,           */  { 11, \
4,  7, 11,  2,  4,  2,  0,  4, -1, -1, -1, -1, -1, -1, -1 }, +/*  26:    1,    3, 4,  \
*/  {  9,  0,  1,  8,  4,  7,  2,  3, 11, -1, -1, -1, -1, -1, -1, -1 }, +/*  27: 0, \
1,    3, 4,           */  {  4,  7, 11,  9,  4, 11,  9, 11,  2,  9,  2,  1, -1, -1, \
-1, -1 }, +/*  28:       2, 3, 4,           */  {  3, 10,  1,  3, 11, 10,  7,  8,  4, \
-1, -1, -1, -1, -1, -1, -1 }, +/*  29: 0,    2, 3, 4,           */  {  1, 11, 10,  1, \
4, 11,  1,  0,  4,  7, 11,  4, -1, -1, -1, -1 }, +/*  30:    1, 2, 3, 4,           */ \
{  4,  7,  8,  9,  0, 11,  9, 11, 10, 11,  0,  3, -1, -1, -1, -1 }, +/*  31: 0, 1, 2, \
3, 4,           */  {  4,  7, 11,  4, 11,  9,  9, 11, 10, -1, -1, -1, -1, -1, -1, -1 \
}, +/*  32:                5,        */  {  9,  5,  4, -1, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1, -1, -1 }, +/*  33: 0,             5,        */  {  9,  5,  4,  0,  8, \
3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  34:    1,          5,        */  {  \
0,  5,  4,  1,  5,  0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  35: 0, 1,       \
5,        */  {  8,  5,  4,  8,  3,  5,  3,  1,  5, -1, -1, -1, -1, -1, -1, -1 }, +/* \
36:       2,       5,        */  {  1,  2, 10,  9,  5,  4, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1 }, +/*  37: 0,    2,       5,        */  {  3,  0,  8,  1,  2, 10,  4, \
9,  5, -1, -1, -1, -1, -1, -1, -1 }, +/*  38:    1, 2,       5,        */  {  5,  2, \
10,  5,  4,  2,  4,  0,  2, -1, -1, -1, -1, -1, -1, -1 }, +/*  39: 0, 1, 2,       5,  \
*/  {  2, 10,  5,  3,  2,  5,  3,  5,  4,  3,  4,  8, -1, -1, -1, -1 }, +/*  40:      \
3,    5,        */  {  9,  5,  4,  2,  3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 \
}, +/*  41: 0,       3,    5,        */  {  0, 11,  2,  0,  8, 11,  4,  9,  5, -1, \
-1, -1, -1, -1, -1, -1 }, +/*  42:    1,    3,    5,        */  {  0,  5,  4,  0,  1, \
5,  2,  3, 11, -1, -1, -1, -1, -1, -1, -1 }, +/*  43: 0, 1,    3,    5,        */  {  \
2,  1,  5,  2,  5,  8,  2,  8, 11,  4,  8,  5, -1, -1, -1, -1 }, +/*  44:       2, 3, \
5,        */  { 10,  3, 11, 10,  1,  3,  9,  5,  4, -1, -1, -1, -1, -1, -1, -1 }, +/* \
45: 0,    2, 3,    5,        */  {  4,  9,  5,  0,  8,  1,  8, 10,  1,  8, 11, 10, \
-1, -1, -1, -1 }, +/*  46:    1, 2, 3,    5,        */  {  5,  4,  0,  5,  0, 11,  5, \
11, 10, 11,  0,  3, -1, -1, -1, -1 }, +/*  47: 0, 1, 2, 3,    5,        */  {  5,  4, \
8,  5,  8, 10, 10,  8, 11, -1, -1, -1, -1, -1, -1, -1 }, +/*  48:             4, 5,   \
*/  {  9,  7,  8,  5,  7,  9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  49: 0,   \
4, 5,        */  {  9,  3,  0,  9,  5,  3,  5,  7,  3, -1, -1, -1, -1, -1, -1, -1 }, \
+/*  50:    1,       4, 5,        */  {  0,  7,  8,  0,  1,  7,  1,  5,  7, -1, -1, \
-1, -1, -1, -1, -1 }, +/*  51: 0, 1,       4, 5,        */  {  1,  5,  3,  3,  5,  7, \
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  52:       2,    4, 5,        */  {  9, \
7,  8,  9,  5,  7, 10,  1,  2, -1, -1, -1, -1, -1, -1, -1 }, +/*  53: 0,    2,    4, \
5,        */  { 10,  1,  2,  9,  5,  0,  5,  3,  0,  5,  7,  3, -1, -1, -1, -1 }, +/* \
54:    1, 2,    4, 5,        */  {  8,  0,  2,  8,  2,  5,  8,  5,  7, 10,  5,  2, \
-1, -1, -1, -1 }, +/*  55: 0, 1, 2,    4, 5,        */  {  2, 10,  5,  2,  5,  3,  3, \
5,  7, -1, -1, -1, -1, -1, -1, -1 }, +/*  56:          3, 4, 5,        */  {  7,  9,  \
5,  7,  8,  9,  3, 11,  2, -1, -1, -1, -1, -1, -1, -1 }, +/*  57: 0,       3, 4, 5,   \
*/  {  9,  5,  7,  9,  7,  2,  9,  2,  0,  2,  7, 11, -1, -1, -1, -1 }, +/*  58:    \
1,    3, 4, 5,        */  {  2,  3, 11,  0,  1,  8,  1,  7,  8,  1,  5,  7, -1, -1, \
-1, -1 }, +/*  59: 0, 1,    3, 4, 5,        */  { 11,  2,  1, 11,  1,  7,  7,  1,  5, \
-1, -1, -1, -1, -1, -1, -1 }, +/*  60:       2, 3, 4, 5,        */  {  9,  5,  8,  8, \
5,  7, 10,  1,  3, 10,  3, 11, -1, -1, -1, -1 }, +/*  61: 0,    2, 3, 4, 5,        */ \
{  5,  7,  0,  5,  0,  9,  7, 11,  0,  1,  0, 10, 11, 10,  0, -1 }, +/*  62:    1, 2, \
3, 4, 5,        */  { 11, 10,  0, 11,  0,  3, 10,  5,  0,  8,  0,  7,  5,  7,  0, -1 \
}, +/*  63: 0, 1, 2, 3, 4, 5,        */  { 11, 10,  5,  7, 11,  5, -1, -1, -1, -1, \
-1, -1, -1, -1, -1, -1 }, +/*  64:                   6,     */  { 10,  6,  5, -1, -1, \
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  65: 0,                6,     */  { \
0,  8,  3,  5, 10,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  66:    1,       \
6,     */  {  9,  0,  1,  5, 10,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  \
67: 0, 1,             6,     */  {  1,  8,  3,  1,  9,  8,  5, 10,  6, -1, -1, -1, \
-1, -1, -1, -1 }, +/*  68:       2,          6,     */  {  1,  6,  5,  2,  6,  1, -1, \
-1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  69: 0,    2,          6,     */  {  1,  6, \
5,  1,  2,  6,  3,  0,  8, -1, -1, -1, -1, -1, -1, -1 }, +/*  70:    1, 2,          \
6,     */  {  9,  6,  5,  9,  0,  6,  0,  2,  6, -1, -1, -1, -1, -1, -1, -1 }, +/*  \
71: 0, 1, 2,          6,     */  {  5,  9,  8,  5,  8,  2,  5,  2,  6,  3,  2,  8, \
-1, -1, -1, -1 }, +/*  72:          3,       6,     */  {  2,  3, 11, 10,  6,  5, -1, \
-1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  73: 0,       3,       6,     */  { 11,  0, \
8, 11,  2,  0, 10,  6,  5, -1, -1, -1, -1, -1, -1, -1 }, +/*  74:    1,    3,       \
6,     */  {  0,  1,  9,  2,  3, 11,  5, 10,  6, -1, -1, -1, -1, -1, -1, -1 }, +/*  \
75: 0, 1,    3,       6,     */  {  5, 10,  6,  1,  9,  2,  9, 11,  2,  9,  8, 11, \
-1, -1, -1, -1 }, +/*  76:       2, 3,       6,     */  {  6,  3, 11,  6,  5,  3,  5, \
1,  3, -1, -1, -1, -1, -1, -1, -1 }, +/*  77: 0,    2, 3,       6,     */  {  0,  8, \
11,  0, 11,  5,  0,  5,  1,  5, 11,  6, -1, -1, -1, -1 }, +/*  78:    1, 2, 3,       \
6,     */  {  3, 11,  6,  0,  3,  6,  0,  6,  5,  0,  5,  9, -1, -1, -1, -1 }, +/*  \
79: 0, 1, 2, 3,       6,     */  {  6,  5,  9,  6,  9, 11, 11,  9,  8, -1, -1, -1, \
-1, -1, -1, -1 }, +/*  80:             4,    6,     */  {  5, 10,  6,  4,  7,  8, -1, \
-1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  81: 0,          4,    6,     */  {  4,  3, \
0,  4,  7,  3,  6,  5, 10, -1, -1, -1, -1, -1, -1, -1 }, +/*  82:    1,       4,    \
6,     */  {  1,  9,  0,  5, 10,  6,  8,  4,  7, -1, -1, -1, -1, -1, -1, -1 }, +/*  \
83: 0, 1,       4,    6,     */  { 10,  6,  5,  1,  9,  7,  1,  7,  3,  7,  9,  4, \
-1, -1, -1, -1 }, +/*  84:       2,    4,    6,     */  {  6,  1,  2,  6,  5,  1,  4, \
7,  8, -1, -1, -1, -1, -1, -1, -1 }, +/*  85: 0,    2,    4,    6,     */  {  1,  2,  \
5,  5,  2,  6,  3,  0,  4,  3,  4,  7, -1, -1, -1, -1 }, +/*  86:    1, 2,    4,    \
6,     */  {  8,  4,  7,  9,  0,  5,  0,  6,  5,  0,  2,  6, -1, -1, -1, -1 }, +/*  \
87: 0, 1, 2,    4,    6,     */  {  7,  3,  9,  7,  9,  4,  3,  2,  9,  5,  9,  6,  \
2,  6,  9, -1 }, +/*  88:          3, 4,    6,     */  {  3, 11,  2,  7,  8,  4, 10,  \
6,  5, -1, -1, -1, -1, -1, -1, -1 }, +/*  89: 0,       3, 4,    6,     */  {  5, 10,  \
6,  4,  7,  2,  4,  2,  0,  2,  7, 11, -1, -1, -1, -1 }, +/*  90:    1,    3, 4,    \
6,     */  {  0,  1,  9,  4,  7,  8,  2,  3, 11,  5, 10,  6, -1, -1, -1, -1 }, +/*  \
91: 0, 1,    3, 4,    6,     */  {  9,  2,  1,  9, 11,  2,  9,  4, 11,  7, 11,  4,  \
5, 10,  6, -1 }, +/*  92:       2, 3, 4,    6,     */  {  8,  4,  7,  3, 11,  5,  3,  \
5,  1,  5, 11,  6, -1, -1, -1, -1 }, +/*  93: 0,    2, 3, 4,    6,     */  {  5,  1, \
11,  5, 11,  6,  1,  0, 11,  7, 11,  4,  0,  4, 11, -1 }, +/*  94:    1, 2, 3, 4,    \
6,     */  {  0,  5,  9,  0,  6,  5,  0,  3,  6, 11,  6,  3,  8,  4,  7, -1 }, +/*  \
95: 0, 1, 2, 3, 4,    6,     */  {  6,  5,  9,  6,  9, 11,  4,  7,  9,  7, 11,  9, \
-1, -1, -1, -1 }, +/*  96:                5, 6,     */  { 10,  4,  9,  6,  4, 10, -1, \
-1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/*  97: 0,             5, 6,     */  {  4, 10, \
6,  4,  9, 10,  0,  8,  3, -1, -1, -1, -1, -1, -1, -1 }, +/*  98:    1,          5, \
6,     */  { 10,  0,  1, 10,  6,  0,  6,  4,  0, -1, -1, -1, -1, -1, -1, -1 }, +/*  \
99: 0, 1,          5, 6,     */  {  8,  3,  1,  8,  1,  6,  8,  6,  4,  6,  1, 10, \
-1, -1, -1, -1 }, +/* 100:       2,       5, 6,     */  {  1,  4,  9,  1,  2,  4,  2, \
6,  4, -1, -1, -1, -1, -1, -1, -1 }, +/* 101: 0,    2,       5, 6,     */  {  3,  0,  \
8,  1,  2,  9,  2,  4,  9,  2,  6,  4, -1, -1, -1, -1 }, +/* 102:    1, 2,       5, \
6,     */  {  0,  2,  4,  4,  2,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* \
103: 0, 1, 2,       5, 6,     */  {  8,  3,  2,  8,  2,  4,  4,  2,  6, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 104:          3,    5, 6,     */  { 10,  4,  9, 10,  6,  4, 11, \
2,  3, -1, -1, -1, -1, -1, -1, -1 }, +/* 105: 0,       3,    5, 6,     */  {  0,  8,  \
2,  2,  8, 11,  4,  9, 10,  4, 10,  6, -1, -1, -1, -1 }, +/* 106:    1,    3,    5, \
6,     */  {  3, 11,  2,  0,  1,  6,  0,  6,  4,  6,  1, 10, -1, -1, -1, -1 }, +/* \
107: 0, 1,    3,    5, 6,     */  {  6,  4,  1,  6,  1, 10,  4,  8,  1,  2,  1, 11,  \
8, 11,  1, -1 }, +/* 108:       2, 3,    5, 6,     */  {  9,  6,  4,  9,  3,  6,  9,  \
1,  3, 11,  6,  3, -1, -1, -1, -1 }, +/* 109: 0,    2, 3,    5, 6,     */  {  8, 11,  \
1,  8,  1,  0, 11,  6,  1,  9,  1,  4,  6,  4,  1, -1 }, +/* 110:    1, 2, 3,    5, \
6,     */  {  3, 11,  6,  3,  6,  0,  0,  6,  4, -1, -1, -1, -1, -1, -1, -1 }, +/* \
111: 0, 1, 2, 3,    5, 6,     */  {  6,  4,  8, 11,  6,  8, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 112:             4, 5, 6,     */  {  7, 10,  6,  7,  8, 10,  8, \
9, 10, -1, -1, -1, -1, -1, -1, -1 }, +/* 113: 0,          4, 5, 6,     */  {  0,  7,  \
3,  0, 10,  7,  0,  9, 10,  6,  7, 10, -1, -1, -1, -1 }, +/* 114:    1,       4, 5, \
6,     */  { 10,  6,  7,  1, 10,  7,  1,  7,  8,  1,  8,  0, -1, -1, -1, -1 }, +/* \
115: 0, 1,       4, 5, 6,     */  { 10,  6,  7, 10,  7,  1,  1,  7,  3, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 116:       2,    4, 5, 6,     */  {  1,  2,  6,  1,  6,  8,  1, \
8,  9,  8,  6,  7, -1, -1, -1, -1 }, +/* 117: 0,    2,    4, 5, 6,     */  {  2,  6,  \
9,  2,  9,  1,  6,  7,  9,  0,  9,  3,  7,  3,  9, -1 }, +/* 118:    1, 2,    4, 5, \
6,     */  {  7,  8,  0,  7,  0,  6,  6,  0,  2, -1, -1, -1, -1, -1, -1, -1 }, +/* \
119: 0, 1, 2,    4, 5, 6,     */  {  7,  3,  2,  6,  7,  2, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 120:          3, 4, 5, 6,     */  {  2,  3, 11, 10,  6,  8, 10, \
8,  9,  8,  6,  7, -1, -1, -1, -1 }, +/* 121: 0,       3, 4, 5, 6,     */  {  2,  0,  \
7,  2,  7, 11,  0,  9,  7,  6,  7, 10,  9, 10,  7, -1 }, +/* 122:    1,    3, 4, 5, \
6,     */  {  1,  8,  0,  1,  7,  8,  1, 10,  7,  6,  7, 10,  2,  3, 11, -1 }, +/* \
123: 0, 1,    3, 4, 5, 6,     */  { 11,  2,  1, 11,  1,  7, 10,  6,  1,  6,  7,  1, \
-1, -1, -1, -1 }, +/* 124:       2, 3, 4, 5, 6,     */  {  8,  9,  6,  8,  6,  7,  9, \
1,  6, 11,  6,  3,  1,  3,  6, -1 }, +/* 125: 0,    2, 3, 4, 5, 6,     */  {  0,  9,  \
1, 11,  6,  7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* 126:    1, 2, 3, 4, 5, \
6,     */  {  7,  8,  0,  7,  0,  6,  3, 11,  0, 11,  6,  0, -1, -1, -1, -1 }, +/* \
127: 0, 1, 2, 3, 4, 5, 6,     */  {  7, 11,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 128:                      7,  */  {  7,  6, 11, -1, -1, -1, -1, \
-1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* 129: 0,                   7,  */  {  3,  0, \
8, 11,  7,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* 130:    1,               \
7,  */  {  0,  1,  9, 11,  7,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* 131: \
0, 1,                7,  */  {  8,  1,  9,  8,  3,  1, 11,  7,  6, -1, -1, -1, -1, \
-1, -1, -1 }, +/* 132:       2,             7,  */  { 10,  1,  2,  6, 11,  7, -1, -1, \
-1, -1, -1, -1, -1, -1, -1, -1 }, +/* 133: 0,    2,             7,  */  {  1,  2, 10, \
3,  0,  8,  6, 11,  7, -1, -1, -1, -1, -1, -1, -1 }, +/* 134:    1, 2,             7, \
*/  {  2,  9,  0,  2, 10,  9,  6, 11,  7, -1, -1, -1, -1, -1, -1, -1 }, +/* 135: 0, \
1, 2,             7,  */  {  6, 11,  7,  2, 10,  3, 10,  8,  3, 10,  9,  8, -1, -1, \
-1, -1 }, +/* 136:          3,          7,  */  {  7,  2,  3,  6,  2,  7, -1, -1, -1, \
-1, -1, -1, -1, -1, -1, -1 }, +/* 137: 0,       3,          7,  */  {  7,  0,  8,  7, \
6,  0,  6,  2,  0, -1, -1, -1, -1, -1, -1, -1 }, +/* 138:    1,    3,          7,  */ \
{  2,  7,  6,  2,  3,  7,  0,  1,  9, -1, -1, -1, -1, -1, -1, -1 }, +/* 139: 0, 1,    \
3,          7,  */  {  1,  6,  2,  1,  8,  6,  1,  9,  8,  8,  7,  6, -1, -1, -1, -1 \
}, +/* 140:       2, 3,          7,  */  { 10,  7,  6, 10,  1,  7,  1,  3,  7, -1, \
-1, -1, -1, -1, -1, -1 }, +/* 141: 0,    2, 3,          7,  */  { 10,  7,  6,  1,  7, \
10,  1,  8,  7,  1,  0,  8, -1, -1, -1, -1 }, +/* 142:    1, 2, 3,          7,  */  { \
0,  3,  7,  0,  7, 10,  0, 10,  9,  6, 10,  7, -1, -1, -1, -1 }, +/* 143: 0, 1, 2, 3, \
7,  */  {  7,  6, 10,  7, 10,  8,  8, 10,  9, -1, -1, -1, -1, -1, -1, -1 }, +/* 144:  \
4,       7,  */  {  6,  8,  4, 11,  8,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, \
+/* 145: 0,          4,       7,  */  {  3,  6, 11,  3,  0,  6,  0,  4,  6, -1, -1, \
-1, -1, -1, -1, -1 }, +/* 146:    1,       4,       7,  */  {  8,  6, 11,  8,  4,  6, \
9,  0,  1, -1, -1, -1, -1, -1, -1, -1 }, +/* 147: 0, 1,       4,       7,  */  {  9,  \
4,  6,  9,  6,  3,  9,  3,  1, 11,  3,  6, -1, -1, -1, -1 }, +/* 148:       2,    4,  \
7,  */  {  6,  8,  4,  6, 11,  8,  2, 10,  1, -1, -1, -1, -1, -1, -1, -1 }, +/* 149: \
0,    2,    4,       7,  */  {  1,  2, 10,  3,  0, 11,  0,  6, 11,  0,  4,  6, -1, \
-1, -1, -1 }, +/* 150:    1, 2,    4,       7,  */  {  4, 11,  8,  4,  6, 11,  0,  2, \
9,  2, 10,  9, -1, -1, -1, -1 }, +/* 151: 0, 1, 2,    4,       7,  */  { 10,  9,  3, \
10,  3,  2,  9,  4,  3, 11,  3,  6,  4,  6,  3, -1 }, +/* 152:          3, 4,       \
7,  */  {  8,  2,  3,  8,  4,  2,  4,  6,  2, -1, -1, -1, -1, -1, -1, -1 }, +/* 153: \
0,       3, 4,       7,  */  {  0,  4,  2,  4,  6,  2, -1, -1, -1, -1, -1, -1, -1, \
-1, -1, -1 }, +/* 154:    1,    3, 4,       7,  */  {  1,  9,  0,  2,  3,  4,  2,  4, \
6,  4,  3,  8, -1, -1, -1, -1 }, +/* 155: 0, 1,    3, 4,       7,  */  {  1,  9,  4,  \
1,  4,  2,  2,  4,  6, -1, -1, -1, -1, -1, -1, -1 }, +/* 156:       2, 3, 4,       7, \
*/  {  8,  1,  3,  8,  6,  1,  8,  4,  6,  6, 10,  1, -1, -1, -1, -1 }, +/* 157: 0,   \
2, 3, 4,       7,  */  { 10,  1,  0, 10,  0,  6,  6,  0,  4, -1, -1, -1, -1, -1, -1, \
-1 }, +/* 158:    1, 2, 3, 4,       7,  */  {  4,  6,  3,  4,  3,  8,  6, 10,  3,  0, \
3,  9, 10,  9,  3, -1 }, +/* 159: 0, 1, 2, 3, 4,       7,  */  { 10,  9,  4,  6, 10,  \
4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* 160:                5,    7,  */  {  \
4,  9,  5,  7,  6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* 161: 0,          \
5,    7,  */  {  0,  8,  3,  4,  9,  5, 11,  7,  6, -1, -1, -1, -1, -1, -1, -1 }, +/* \
162:    1,          5,    7,  */  {  5,  0,  1,  5,  4,  0,  7,  6, 11, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 163: 0, 1,          5,    7,  */  { 11,  7,  6,  8,  3,  4,  3, \
+/* 165: 0,    2,       5,    7,  */  {  6, 11,  7,  1,  2, 10,  0,  8,  3,  4,  9,  \
5, -1, -1, -1, -1 }, +/* 166:    1, 2,       5,    7,  */  {  7,  6, 11,  5,  4, 10,  \
4,  2, 10,  4,  0,  2, -1, -1, -1, -1 }, +/* 167: 0, 1, 2,       5,    7,  */  {  3,  \
4,  8,  3,  5,  4,  3,  2,  5, 10,  5,  2, 11,  7,  6, -1 }, +/* 168:          3,    \
5,    7,  */  {  7,  2,  3,  7,  6,  2,  5,  4,  9, -1, -1, -1, -1, -1, -1, -1 }, +/* \
169: 0,       3,    5,    7,  */  {  9,  5,  4,  0,  8,  6,  0,  6,  2,  6,  8,  7, \
-1, -1, -1, -1 }, +/* 170:    1,    3,    5,    7,  */  {  3,  6,  2,  3,  7,  6,  1, \
5,  0,  5,  4,  0, -1, -1, -1, -1 }, +/* 171: 0, 1,    3,    5,    7,  */  {  6,  2,  \
8,  6,  8,  7,  2,  1,  8,  4,  8,  5,  1,  5,  8, -1 }, +/* 172:       2, 3,    5,   \
7,  */  {  9,  5,  4, 10,  1,  6,  1,  7,  6,  1,  3,  7, -1, -1, -1, -1 }, +/* 173: \
0,    2, 3,    5,    7,  */  {  1,  6, 10,  1,  7,  6,  1,  0,  7,  8,  7,  0,  9,  \
5,  4, -1 }, +/* 174:    1, 2, 3,    5,    7,  */  {  4,  0, 10,  4, 10,  5,  0,  3, \
10,  6, 10,  7,  3,  7, 10, -1 }, +/* 175: 0, 1, 2, 3,    5,    7,  */  {  7,  6, 10, \
7, 10,  8,  5,  4, 10,  4,  8, 10, -1, -1, -1, -1 }, +/* 176:             4, 5,    7, \
*/  {  6,  9,  5,  6, 11,  9, 11,  8,  9, -1, -1, -1, -1, -1, -1, -1 }, +/* 177: 0,   \
4, 5,    7,  */  {  3,  6, 11,  0,  6,  3,  0,  5,  6,  0,  9,  5, -1, -1, -1, -1 }, \
+/* 178:    1,       4, 5,    7,  */  {  0, 11,  8,  0,  5, 11,  0,  1,  5,  5,  6, \
11, -1, -1, -1, -1 }, +/* 179: 0, 1,       4, 5,    7,  */  {  6, 11,  3,  6,  3,  5, \
5,  3,  1, -1, -1, -1, -1, -1, -1, -1 }, +/* 180:       2,    4, 5,    7,  */  {  1,  \
2, 10,  9,  5, 11,  9, 11,  8, 11,  5,  6, -1, -1, -1, -1 }, +/* 181: 0,    2,    4, \
5,    7,  */  {  0, 11,  3,  0,  6, 11,  0,  9,  6,  5,  6,  9,  1,  2, 10, -1 }, +/* \
182:    1, 2,    4, 5,    7,  */  { 11,  8,  5, 11,  5,  6,  8,  0,  5, 10,  5,  2,  \
0,  2,  5, -1 }, +/* 183: 0, 1, 2,    4, 5,    7,  */  {  6, 11,  3,  6,  3,  5,  2, \
10,  3, 10,  5,  3, -1, -1, -1, -1 }, +/* 184:          3, 4, 5,    7,  */  {  5,  8, \
9,  5,  2,  8,  5,  6,  2,  3,  8,  2, -1, -1, -1, -1 }, +/* 185: 0,       3, 4, 5,   \
7,  */  {  9,  5,  6,  9,  6,  0,  0,  6,  2, -1, -1, -1, -1, -1, -1, -1 }, +/* 186:  \
1,    3, 4, 5,    7,  */  {  1,  5,  8,  1,  8,  0,  5,  6,  8,  3,  8,  2,  6,  2,  \
8, -1 }, +/* 187: 0, 1,    3, 4, 5,    7,  */  {  1,  5,  6,  2,  1,  6, -1, -1, -1, \
-1, -1, -1, -1, -1, -1, -1 }, +/* 188:       2, 3, 4, 5,    7,  */  {  1,  3,  6,  1, \
6, 10,  3,  8,  6,  5,  6,  9,  8,  9,  6, -1 }, +/* 189: 0,    2, 3, 4, 5,    7,  */ \
{ 10,  1,  0, 10,  0,  6,  9,  5,  0,  5,  6,  0, -1, -1, -1, -1 }, +/* 190:    1, 2, \
3, 4, 5,    7,  */  {  0,  3,  8,  5,  6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 \
}, +/* 191: 0, 1, 2, 3, 4, 5,    7,  */  { 10,  5,  6, -1, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1, -1, -1 }, +/* 192:                   6, 7,  */  { 11,  5, 10,  7,  5, \
11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* 193: 0,                6, 7,  */  { \
11,  5, 10, 11,  7,  5,  8,  3,  0, -1, -1, -1, -1, -1, -1, -1 }, +/* 194:    1,      \
6, 7,  */  {  5, 11,  7,  5, 10, 11,  1,  9,  0, -1, -1, -1, -1, -1, -1, -1 }, +/* \
195: 0, 1,             6, 7,  */  { 10,  7,  5, 10, 11,  7,  9,  8,  1,  8,  3,  1, \
-1, -1, -1, -1 }, +/* 196:       2,          6, 7,  */  { 11,  1,  2, 11,  7,  1,  7, \
5,  1, -1, -1, -1, -1, -1, -1, -1 }, +/* 197: 0,    2,          6, 7,  */  {  0,  8,  \
3,  1,  2,  7,  1,  7,  5,  7,  2, 11, -1, -1, -1, -1 }, +/* 198:    1, 2,          \
6, 7,  */  {  9,  7,  5,  9,  2,  7,  9,  0,  2,  2, 11,  7, -1, -1, -1, -1 }, +/* \
199: 0, 1, 2,          6, 7,  */  {  7,  5,  2,  7,  2, 11,  5,  9,  2,  3,  2,  8,  \
9,  8,  2, -1 }, +/* 200:          3,       6, 7,  */  {  2,  5, 10,  2,  3,  5,  3,  \
7,  5, -1, -1, -1, -1, -1, -1, -1 }, +/* 201: 0,       3,       6, 7,  */  {  8,  2,  \
0,  8,  5,  2,  8,  7,  5, 10,  2,  5, -1, -1, -1, -1 }, +/* 202:    1,    3,       \
6, 7,  */  {  9,  0,  1,  5, 10,  3,  5,  3,  7,  3, 10,  2, -1, -1, -1, -1 }, +/* \
203: 0, 1,    3,       6, 7,  */  {  9,  8,  2,  9,  2,  1,  8,  7,  2, 10,  2,  5,  \
7,  5,  2, -1 }, +/* 204:       2, 3,       6, 7,  */  {  1,  3,  5,  3,  7,  5, -1, \
-1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* 205: 0,    2, 3,       6, 7,  */  {  0,  8, \
7,  0,  7,  1,  1,  7,  5, -1, -1, -1, -1, -1, -1, -1 }, +/* 206:    1, 2, 3,       \
6, 7,  */  {  9,  0,  3,  9,  3,  5,  5,  3,  7, -1, -1, -1, -1, -1, -1, -1 }, +/* \
207: 0, 1, 2, 3,       6, 7,  */  {  9,  8,  7,  5,  9,  7, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 208:             4,    6, 7,  */  {  5,  8,  4,  5, 10,  8, 10, \
11,  8, -1, -1, -1, -1, -1, -1, -1 }, +/* 209: 0,          4,    6, 7,  */  {  5,  0, \
4,  5, 11,  0,  5, 10, 11, 11,  3,  0, -1, -1, -1, -1 }, +/* 210:    1,       4,    \
6, 7,  */  {  0,  1,  9,  8,  4, 10,  8, 10, 11, 10,  4,  5, -1, -1, -1, -1 }, +/* \
211: 0, 1,       4,    6, 7,  */  { 10, 11,  4, 10,  4,  5, 11,  3,  4,  9,  4,  1,  \
3,  1,  4, -1 }, +/* 212:       2,    4,    6, 7,  */  {  2,  5,  1,  2,  8,  5,  2, \
11,  8,  4,  5,  8, -1, -1, -1, -1 }, +/* 213: 0,    2,    4,    6, 7,  */  {  0,  4, \
11,  0, 11,  3,  4,  5, 11,  2, 11,  1,  5,  1, 11, -1 }, +/* 214:    1, 2,    4,    \
6, 7,  */  {  0,  2,  5,  0,  5,  9,  2, 11,  5,  4,  5,  8, 11,  8,  5, -1 }, +/* \
215: 0, 1, 2,    4,    6, 7,  */  {  9,  4,  5,  2, 11,  3, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 216:          3, 4,    6, 7,  */  {  2,  5, 10,  3,  5,  2,  3, \
4,  5,  3,  8,  4, -1, -1, -1, -1 }, +/* 217: 0,       3, 4,    6, 7,  */  {  5, 10,  \
2,  5,  2,  4,  4,  2,  0, -1, -1, -1, -1, -1, -1, -1 }, +/* 218:    1,    3, 4,    \
6, 7,  */  {  3, 10,  2,  3,  5, 10,  3,  8,  5,  4,  5,  8,  0,  1,  9, -1 }, +/* \
219: 0, 1,    3, 4,    6, 7,  */  {  5, 10,  2,  5,  2,  4,  1,  9,  2,  9,  4,  2, \
-1, -1, -1, -1 }, +/* 220:       2, 3, 4,    6, 7,  */  {  8,  4,  5,  8,  5,  3,  3, \
5,  1, -1, -1, -1, -1, -1, -1, -1 }, +/* 221: 0,    2, 3, 4,    6, 7,  */  {  0,  4,  \
5,  1,  0,  5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* 222:    1, 2, 3, 4,    \
6, 7,  */  {  8,  4,  5,  8,  5,  3,  9,  0,  5,  0,  3,  5, -1, -1, -1, -1 }, +/* \
223: 0, 1, 2, 3, 4,    6, 7,  */  {  9,  4,  5, -1, -1, -1, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 224:                5, 6, 7,  */  {  4, 11,  7,  4,  9, 11,  9, \
10, 11, -1, -1, -1, -1, -1, -1, -1 }, +/* 225: 0,             5, 6, 7,  */  {  0,  8, \
3,  4,  9,  7,  9, 11,  7,  9, 10, 11, -1, -1, -1, -1 }, +/* 226:    1,          5, \
6, 7,  */  {  1, 10, 11,  1, 11,  4,  1,  4,  0,  7,  4, 11, -1, -1, -1, -1 }, +/* \
227: 0, 1,          5, 6, 7,  */  {  3,  1,  4,  3,  4,  8,  1, 10,  4,  7,  4, 11, \
10, 11,  4, -1 }, +/* 228:       2,       5, 6, 7,  */  {  4, 11,  7,  9, 11,  4,  9, \
2, 11,  9,  1,  2, -1, -1, -1, -1 }, +/* 229: 0,    2,       5, 6, 7,  */  {  9,  7,  \
4,  9, 11,  7,  9,  1, 11,  2, 11,  1,  0,  8,  3, -1 }, +/* 230:    1, 2,       5, \
6, 7,  */  { 11,  7,  4, 11,  4,  2,  2,  4,  0, -1, -1, -1, -1, -1, -1, -1 }, +/* \
231: 0, 1, 2,       5, 6, 7,  */  { 11,  7,  4, 11,  4,  2,  8,  3,  4,  3,  2,  4, \
-1, -1, -1, -1 }, +/* 232:          3,    5, 6, 7,  */  {  2,  9, 10,  2,  7,  9,  2, \
3,  7,  7,  4,  9, -1, -1, -1, -1 }, +/* 233: 0,       3,    5, 6, 7,  */  {  9, 10,  \
7,  9,  7,  4, 10,  2,  7,  8,  7,  0,  2,  0,  7, -1 }, +/* 234:    1,    3,    5, \
6, 7,  */  {  3,  7, 10,  3, 10,  2,  7,  4, 10,  1, 10,  0,  4,  0, 10, -1 }, +/* \
235: 0, 1,    3,    5, 6, 7,  */  {  1, 10,  2,  8,  7,  4, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 236:       2, 3,    5, 6, 7,  */  {  4,  9,  1,  4,  1,  7,  7, \
1,  3, -1, -1, -1, -1, -1, -1, -1 }, +/* 237: 0,    2, 3,    5, 6, 7,  */  {  4,  9,  \
1,  4,  1,  7,  0,  8,  1,  8,  7,  1, -1, -1, -1, -1 }, +/* 238:    1, 2, 3,    5, \
6, 7,  */  {  4,  0,  3,  7,  4,  3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* \
239: 0, 1, 2, 3,    5, 6, 7,  */  {  4,  8,  7, -1, -1, -1, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 240:             4, 5, 6, 7,  */  {  9, 10,  8, 10, 11,  8, -1, \
-1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* 241: 0,          4, 5, 6, 7,  */  {  3,  0, \
9,  3,  9, 11, 11,  9, 10, -1, -1, -1, -1, -1, -1, -1 }, +/* 242:    1,       4, 5, \
6, 7,  */  {  0,  1, 10,  0, 10,  8,  8, 10, 11, -1, -1, -1, -1, -1, -1, -1 }, +/* \
243: 0, 1,       4, 5, 6, 7,  */  {  3,  1, 10, 11,  3, 10, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 244:       2,    4, 5, 6, 7,  */  {  1,  2, 11,  1, 11,  9,  9, \
11,  8, -1, -1, -1, -1, -1, -1, -1 }, +/* 245: 0,    2,    4, 5, 6, 7,  */  {  3,  0, \
9,  3,  9, 11,  1,  2,  9,  2, 11,  9, -1, -1, -1, -1 }, +/* 246:    1, 2,    4, 5, \
6, 7,  */  {  0,  2, 11,  8,  0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* \
247: 0, 1, 2,    4, 5, 6, 7,  */  {  3,  2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 248:          3, 4, 5, 6, 7,  */  {  2,  3,  8,  2,  8, 10, 10, \
8,  9, -1, -1, -1, -1, -1, -1, -1 }, +/* 249: 0,       3, 4, 5, 6, 7,  */  {  9, 10,  \
2,  0,  9,  2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* 250:    1,    3, 4, 5, \
6, 7,  */  {  2,  3,  8,  2,  8, 10,  0,  1,  8,  1, 10,  8, -1, -1, -1, -1 }, +/* \
251: 0, 1,    3, 4, 5, 6, 7,  */  {  1, 10,  2, -1, -1, -1, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1 }, +/* 252:       2, 3, 4, 5, 6, 7,  */  {  1,  3,  8,  9,  1,  8, -1, \
-1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* 253: 0,    2, 3, 4, 5, 6, 7,  */  {  0,  9, \
1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* 254:    1, 2, 3, 4, 5, \
6, 7,  */  {  0,  3,  8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, +/* \
255: 0, 1, 2, 3, 4, 5, 6, 7,  */  { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, \
-1, -1, -1, -1 } +};
+//_____________________________________________________________________________
+
+
+
+#endif // _LOOKUPTABLE_H_
+
diff --git a/analitzaplot/private/utils/marchingcubes.cpp \
b/analitzaplot/private/utils/marchingcubes.cpp index 49331f1..b879761 100644
--- a/analitzaplot/private/utils/marchingcubes.cpp
+++ b/analitzaplot/private/utils/marchingcubes.cpp
@@ -1,867 +1,1490 @@
-/*************************************************************************************
                
- *  Copyright (C) 2012 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com>      \
                *
- *                                                                                   \
                *
- *  This program is free software; you can redistribute it and/or                    \
                *
- *  modify it under the terms of the GNU General Public License                      \
                *
- *  as published by the Free Software Foundation; either version 2                   \
                *
- *  of the License, or (at your option) any later version.                           \
                *
- *                                                                                   \
                *
- *  This program is distributed in the hope that it will be useful,                  \
                *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   \
                *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    \
                *
- *  GNU General Public License for more details.                                     \
                *
- *                                                                                   \
                *
- *  You should have received a copy of the GNU General Public License                \
                *
- *  along with this program; if not, write to the Free Software                      \
                *
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   \
                *
- *************************************************************************************/
 +// Aqsis
+// Copyright (C) 2006, Paul C. Gregory
+//
+// Contact: pgregory@aqsis.org
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+/** \file
+    \brief MarchingCubes Algorithm
+    \author Thomas Lewiner <thomas.lewiner@polytechnique.org>
+    \author Math Dept, PUC-Rio
+    \version 0.2
+    \date    12/08/2002
+*/
+
+// Minor modifications for KDE-Edu/Analitza Library: Copyright (C) 2014 by Percy \
Camilo T. Aucahuasi <percy.camilo.ta@gmail.com> +
 
 #include "marchingcubes.h"
 
-#include <QDebug>
+#include <math.h>
+#include <memory.h>
+#include <float.h>
+#include <stdio.h>
 
-//
-//@percy spec/impl details
-//
-// vertex | moves from center (C)
-// 0 | (-, -, -)
-// 1 | (-, -, +)
-// 2 | (-, +, -)
-// 3 | (-, +, +)
-// 4 | (+, -, -)
-// 5 | (+, -, +)
-// 6 | (+, +, -)
-// 7 | (+, +, +)
-// Notes: moves from center means the offsets (offsetfactor x,offsetfactor \
                y,offsetfactor z) 
-// where offsetfactor is + or - and the factor is the half-edge
-// 
-// edge | vertex from -> vertex to | axis (or paralel axis)
-// 0  | 0 -> 1 | z
-// 1  | 0 -> 2 | y
-// 2  | 0 -> 4 | x
-// 3  | 1 -> 3 | y
-// 4  | 1 -> 5 | x
-// 5  | 2 -> 3 | z
-// 6  | 2 -> 6 | x
-// 7  | 3 -> 7 | x
-// 8  | 4 -> 5 | z
-// 9  | 4 -> 6 | y
-// 10 | 5 -> 7 | y
-// 11 | 6 -> 7 | z
-// 
-// Notes: (->) means to low value from high value (in the direction of its axis)
-// see the next ref system:
-//        
-//            +Z
-//            |
-//            |
-//            |
-//            |
-//    /|      |________>+Y
-// EYE |     /
-//    \|    /
-//         /
-//        -X
-// ... and the ref cube is:
-//
-//             3
-//        1---------3
-//      4/:        /|
-//      / : 10    / |5
-//     5---------7  |
-//     |  :  C   |  |
-//    8|  0......|..2
-//     |2.    1  | /
-//     |.      11|/6
-//     4---------6
-//         9
-
-sMarching_Cube MarchingCubes::evalCube(Cube cubo){
-    sMarching_Cube res;
-    QVector3D punto;
-    unsigned short int val;
-
-
-    //basic data
-    res.center = cubo.center();
-    res.half_size = cubo.halfEdge();
-
-    //fill vertices
-    double x = res.center.x();
-    double y = res.center.y();
-    double z = res.center.z();
-    double hedge = res.half_size;
-    
-    
-    res.vertices[0] = evalScalarField(x-hedge, y-hedge, z-hedge);
-    res.vertices[1] = evalScalarField(x-hedge, y-hedge, z+hedge);
-    res.vertices[2] = evalScalarField(x-hedge, y+hedge, z-hedge);
-    res.vertices[3] = evalScalarField(x-hedge, y+hedge, z+hedge);
-    res.vertices[4] = evalScalarField(x+hedge, y-hedge, z-hedge);
-    res.vertices[5] = evalScalarField(x+hedge, y-hedge, z+hedge);
-    res.vertices[6] = evalScalarField(x+hedge, y+hedge, z-hedge);
-    res.vertices[7] = evalScalarField(x+hedge, y+hedge, z+hedge);
-
-    //define topology type
-    res.type = 0;
-    val=1;
-    
-    //sum each vertex based on position
-    for(unsigned int i=0;i<8;i++){
-        if(res.vertices[i] > 0){
-            res.type += val;
-        }
-        val*=2;
-    }
-    
-    return res;
-}
 
-QList<Cube> MarchingCubes::breadthSearch(int cubos_lado){
-    Cube cubo;
-    sMarching_Cube m_cubo;
-    bool salir = false;
-    QList<Cube> cubos;
-    cubo.setHalfEdge(m_worldLength/(2*cubos_lado));
 
-    double x = 0;
-    double y = 0;
-    double z = 0;
-    
-// static const double iteration_square_val = 0.5;
 
-    for(int i=m_worldLimits.minX;i<=m_worldLimits.maxX;i++){
-//         cubo.centro.x() = (2*i+1)*cubo.medio_lado;
-        x = (2*i+1)*cubo.halfEdge();
-        
-        for(int j=m_worldLimits.minY;j<=m_worldLimits.maxY;j++){
-            y = (2*j+1)*cubo.halfEdge();
-            for(int k=m_worldLimits.minZ;k<=m_worldLimits.maxZ;k++){
-                z = (2*k+1)*cubo.halfEdge();
-                cubo.setCenter(x,y,z);
-                m_cubo = evalCube(cubo);
-                if(m_cubo.type != 0 && m_cubo.type != 255){
-                    //if is inside the cube, stop the search ...
-                    salir = true;
-                    cubos.append(cubo);
-                }
-            }
-        }
-    }
-    if(!salir && 2*cubo.halfEdge() > m_minCubeSize){
-        cubos.append(breadthSearch(cubos_lado*2));
-        //mundo.maxX*=2; mundo.maxY*=2; mundo.maxZ*=2;
-    }
-    return cubos;
-}
+#include "lookuptable.h"
 
-QList<sMarching_Cube> MarchingCubes::depthSearch(Octree *arbol, sNode *nodo){
-    QList<sMarching_Cube> cubos;
-    sMarching_Cube m_cubo;
+// step size of the arrays of vertices and triangles
+#define ALLOC_SIZE 65536
 
-    //test if surface "cut" the cube
-    m_cubo = evalCube(nodo->cube);
 
-    if(m_cubo.type != 0 && m_cubo.type != 255){
-        //if intersection
-        if(m_cubo.half_size*2 > m_minCubeSize){ 
-            //Seguir bajando
-            arbol->downLevel(nodo);
-            for(unsigned int i=0; i<8; i++){
-                cubos.append(depthSearch(arbol,nodo->nodes[i]));
-            }
-        } else {
-            //stop condition
-            cubos.append(m_cubo);
-        }
-    }
-    return cubos;
+//_____________________________________________________________________________
+// print cube for debug
+void MarchingCubes::print_cube()
+{
+    //Aqsis::log() << warning << i_cube[0] << " " <<  i_cube[1] << " " <<  i_cube[2] \
<< " " <<  i_cube[3] << " " <<  i_cube[4] << " " <<  i_cube[5] << " " <<  i_cube[6] \
<< " " <<  i_cube[7]) << std::endl;  }
 
-MarchingCubes::MarchingCubes()
+//_____________________________________________________________________________
+// Constructor
+MarchingCubes::MarchingCubes(  ) :
+        i_originalMC(false),
+        i_data      ((double*)NULL),
+        i_x_verts   (( int *)NULL),
+        i_y_verts   (( int *)NULL),
+        i_z_verts   (( int *)NULL),
+        i_nverts    (0),
+        i_ntrigs    (0),
+        i_Nverts    (0),
+        i_Ntrigs    (0),
+        i_vertices  (( Vertex *)NULL),
+        i_triangles ((Triangle*)NULL)
 {
-
 }
+//_____________________________________________________________________________
 
 void MarchingCubes::setupSpace(const SpaceLimits &spaceLimits)
 {
-    //TODO no magic numbers
-    m_minCubeSize = 0.2;
-    m_worldLength = 1;
-    m_worldLimits = spaceLimits;    
+    ///
+        clean_all();
+
+    ///
+        int x,y,z;
+    int a = 64;// para mas de 10 de radio de mundo 80 para a es un buen valor
+    x = a;
+    y=a;
+    z=a;
+
+i_size_x    =(x);
+i_size_y    =(y);
+i_size_z    =(z);
+
+        xmin = spaceLimits.minX;
+        ymin = spaceLimits.minY;
+        zmin = spaceLimits.minZ;
+        xmax = spaceLimits.maxX;
+        ymax = spaceLimits.maxY;
+        zmax = spaceLimits.maxZ;
+
+//     qDebug() << xmin << xmax << "|" << ymin << ymax << "|" << zmin << zmax;
+        
+    hx = (xmax-xmin)/i_size_x;
+    hy = (ymax-ymin)/i_size_y;
+    hz = (zmax-zmin)/i_size_z;    
+    
+
+    ///
+    init_all();
+
 }
 
+
+//_____________________________________________________________________________
+// Destructor
 MarchingCubes::~MarchingCubes()
+//-----------------------------------------------------------------------------
 {
+    clean_all() ;
 }
+//_____________________________________________________________________________
+
+
 
-QList<sMarching_Cube> MarchingCubes::getCubes()
+//_____________________________________________________________________________
+// main algorithm
+void MarchingCubes::run()
+//-----------------------------------------------------------------------------
 {
-    QList<sMarching_Cube> cubos;
-    QList<Cube> found = breadthSearch(m_worldLength);
+/*
+    long int tick = clock();
+    TqDouble perclocks = 1.0/(double)CLOCKS_PER_SEC;
+*/
+//pareciara que existen mas evialuaciones, pero no es asi ... en realidad
+//teniendo este bucle ahorr evaluaciones pues eval de analitza es muy costoso
+        for( i_k = 0 ; i_k < i_size_z ; i_k++ )
+        for( i_j = 0 ; i_j < i_size_y ; i_j++ )
+            for( i_i = 0 ; i_i < i_size_x ; i_i++ )
+            {
+                set_data (evalScalarField(xmin+hx*i_i, ymin+hy*i_j, zmin+hz*i_k), \
i_i, i_j, i_k); +            }
 
-    foreach(const Cube& iterador, found){
-        Octree* arbol = new Octree(iterador);
-        cubos.append(depthSearch(arbol, arbol->getRoot()));
-        delete arbol;
-    }
+    compute_intersection_points( ) ;
+
+
+            
+    for( i_k = 0 ; i_k < i_size_z-1 ; i_k++ )
+        for( i_j = 0 ; i_j < i_size_y-1 ; i_j++ )
+            for( i_i = 0 ; i_i < i_size_x-1 ; i_i++ )
+            {
+                i_lut_entry = 0 ;
+                for( int p = 0 ; p < 8 ; ++p )
+                {
+                    i_cube[p] = get_data( i_i+((p^(p>>1))&1), i_j+((p>>1)&1), \
i_k+((p>>2)&1) ) ; +                    if( fabs( i_cube[p] ) < FLT_EPSILON )
+                        i_cube[p] = FLT_EPSILON ;
+                    if( i_cube[p] > 0 )
+                        i_lut_entry += 1 << p ;
+                }
+                /*
+                    if( ( i_cube[0] = get_data( i_i , i_j , i_k ) ) > 0 ) \
i_lut_entry +=   1 ; +                    if( ( i_cube[1] = get_data(i_i+1, i_j , i_k \
) ) > 0 ) i_lut_entry +=   2 ; +                    if( ( i_cube[2] = \
get_data(i_i+1,i_j+1, i_k ) ) > 0 ) i_lut_entry +=   4 ; +                    if( ( \
i_cube[3] = get_data( i_i ,i_j+1, i_k ) ) > 0 ) i_lut_entry +=   8 ; +                \
if( ( i_cube[4] = get_data( i_i , i_j ,i_k+1) ) > 0 ) i_lut_entry +=  16 ; +          \
if( ( i_cube[5] = get_data(i_i+1, i_j ,i_k+1) ) > 0 ) i_lut_entry +=  32 ; +          \
if( ( i_cube[6] = get_data(i_i+1,i_j+1,i_k+1) ) > 0 ) i_lut_entry +=  64 ; +          \
if( ( i_cube[7] = get_data(i_i ,i_j+1,i_k+1) ) > 0 ) i_lut_entry += 128 ; +           \
*/ +                process_cube( ) ;
+            }
 
-    return cubos;
+/*
+      Aqsis::log() << info << "the cpu tooks " << perclocks * (TqDouble) (clock() - \
tick ) << " secs." << std::endl; +
+      for( i_i = 0 ; i_i < 15 ; i_i++ )
+      {
+        Aqsis::log() << info << i_N[i_i] << " cases " << i_i << std::endl;
+      }
+*/
 }
+//_____________________________________________________________________________
+
+
 
-void MarchingCubes::apendTriangle(const QVector3D& a, const QVector3D& b, const \
QVector3D& c) +//_____________________________________________________________________________
 +// init temporary structures (must set sizes before call)
+void MarchingCubes::init_temps()
+//-----------------------------------------------------------------------------
 {
-    QVector3D n = QVector3D::crossProduct(b - a, c - b).normalized();
+    long int howmany = i_size_x * i_size_y * i_size_z;
+    
+ i_data    = new double[ howmany ];
+    i_x_verts = new int  [ howmany ];
+    i_y_verts = new int  [ howmany ];
+    i_z_verts = new int  [ howmany ];
 
-    _vertices << a.x() << a.y() << a.z() <<
-                b.x() << b.y() << b.z() <<
-                c.x() << c.y() << c.z();
-                
-    _normals << n.x() << n.y() << n.z(); 
+    while (!i_x_verts || !i_y_verts || !i_z_verts)
+    {
+        clean_temps();
+        i_size_x /= 2;
+        i_size_y /= 2;
+        i_size_z /= 2;
+        howmany = i_size_x * i_size_y * i_size_z;
 
-    _indexes.append(_indexes.size());
-    _indexes.append(_indexes.size());
-    _indexes.append(_indexes.size());
-}
+     i_data    = new double[ howmany ];
+        i_x_verts = new int  [ howmany ];
+        i_y_verts = new int  [ howmany ];
+        i_z_verts = new int  [ howmany ];
 
-QList<Edge> MarchingCubes::computeIntersections(sMarching_Cube cubo){
-    QList<Edge> aristas;
-    Edge temp;
-    //0-1
-    if(oppositeSign(cubo.vertices[0],cubo.vertices[1])){
-        temp.cut = QVector3D(cubo.center.x()-cubo.half_size,
-                               cubo.center.y()-cubo.half_size,
-                               \
cubo.center.z()-cubo.half_size+2*cubo.half_size*linearInterpolation(cubo.vertices[0],cubo.vertices[1]));
                
-        temp.vertices[0] = 0;
-        temp.vertices[1] = 1;
-        aristas.append(temp);
-    }
-    //0-2
-    if(oppositeSign(cubo.vertices[0],cubo.vertices[2])){
-        temp.cut = QVector3D(cubo.center.x()-cubo.half_size,
-                               \
cubo.center.y()-cubo.half_size+2*cubo.half_size*linearInterpolation(cubo.vertices[0],cubo.vertices[2]),
                
-                               cubo.center.z()-cubo.half_size);
-        temp.vertices[0] = 0;
-        temp.vertices[1] = 2;
-        aristas.append(temp);
-    }
-    //0-4
-    if(oppositeSign(cubo.vertices[0],cubo.vertices[4])){
-        temp.cut = QVector3D(cubo.center.x()-cubo.half_size+2*cubo.half_size*linearInterpolation(cubo.vertices[0],cubo.vertices[4]),
                
-                               cubo.center.y()-cubo.half_size,
-                               cubo.center.z()-cubo.half_size);
-        temp.vertices[0] = 0;
-        temp.vertices[1] = 4;
-        aristas.append(temp);
-    }
-    //1-3
-    if(oppositeSign(cubo.vertices[1],cubo.vertices[3])){
-        temp.cut = QVector3D(cubo.center.x()-cubo.half_size,
-                               \
cubo.center.y()-cubo.half_size+2*cubo.half_size*linearInterpolation(cubo.vertices[1],cubo.vertices[3]),
                
-                               cubo.center.z()+cubo.half_size);
-        temp.vertices[0] = 1;
-        temp.vertices[1] = 3;
-        aristas.append(temp);
     }
-    //1-5
-    if(oppositeSign(cubo.vertices[1],cubo.vertices[5])){
-        temp.cut = QVector3D(cubo.center.x()-cubo.half_size+2*cubo.half_size*linearInterpolation(cubo.vertices[1],cubo.vertices[5]),
                
-                           cubo.center.y()-cubo.half_size,
-                           cubo.center.z()+cubo.half_size);
-        temp.vertices[0] = 1;
-        temp.vertices[1] = 5;
-        aristas.append(temp);
-    }
-    //2-3
-    if(oppositeSign(cubo.vertices[2],cubo.vertices[3])){
-        temp.cut = QVector3D(cubo.center.x()-cubo.half_size,
-                               cubo.center.y()+cubo.half_size,
-                               \
cubo.center.z()-cubo.half_size+2*cubo.half_size*linearInterpolation(cubo.vertices[2],cubo.vertices[3]));
                
-        temp.vertices[0] = 2;
-        temp.vertices[1] = 3;
-        aristas.append(temp);
-    }
-    //2-6
-    if(oppositeSign(cubo.vertices[2],cubo.vertices[6])){
-        temp.cut = QVector3D(cubo.center.x()-cubo.half_size+2*cubo.half_size*linearInterpolation(cubo.vertices[2],cubo.vertices[6]),
                
-                           cubo.center.y()+cubo.half_size,
-                           cubo.center.z()-cubo.half_size);
-        temp.vertices[0] = 2;
-        temp.vertices[1] = 6;
-        aristas.append(temp);
-    }
-    //3-7
-    if(oppositeSign(cubo.vertices[3],cubo.vertices[7])){
-        temp.cut = QVector3D(cubo.center.x()-cubo.half_size+2*cubo.half_size*linearInterpolation(cubo.vertices[3],cubo.vertices[7]),
                
-                           cubo.center.y()+cubo.half_size,
-                           cubo.center.z()+cubo.half_size);
-        temp.vertices[0] = 3;
-        temp.vertices[1] = 7;
-        aristas.append(temp);
-    }
-    //4-5
-    if(oppositeSign(cubo.vertices[4],cubo.vertices[5])){
-        temp.cut = QVector3D(cubo.center.x()+cubo.half_size,
-                               cubo.center.y()-cubo.half_size,
-                               \
cubo.center.z()-cubo.half_size+2*cubo.half_size*linearInterpolation(cubo.vertices[4],cubo.vertices[5]));
                
-        temp.vertices[0] = 4;
-        temp.vertices[1] = 5;
-        aristas.append(temp);
-    }
-    //4-6
-    if(oppositeSign(cubo.vertices[4],cubo.vertices[6])){
-        temp.cut = QVector3D(cubo.center.x()+cubo.half_size,
-                               \
cubo.center.y()-cubo.half_size+2*cubo.half_size*linearInterpolation(cubo.vertices[4],cubo.vertices[6]),
                
-                               cubo.center.z()-cubo.half_size);
-        temp.vertices[0] = 4;
-        temp.vertices[1] = 6;
-        aristas.append(temp);
-    }
-    //5-7
-    if(oppositeSign(cubo.vertices[5],cubo.vertices[7])){
-        temp.cut = QVector3D(cubo.center.x()+cubo.half_size,
-                               \
cubo.center.y()-cubo.half_size+2*cubo.half_size*linearInterpolation(cubo.vertices[5],cubo.vertices[7]),
                
-                               cubo.center.z()+cubo.half_size);
-        temp.vertices[0] = 5;
-        temp.vertices[1] = 7;
-        aristas.append(temp);
-    }
-    //6-7
-    if(oppositeSign(cubo.vertices[6],cubo.vertices[7])){
-        temp.cut = QVector3D(cubo.center.x()+cubo.half_size,
-                               cubo.center.y()+cubo.half_size,
-                               \
cubo.center.z()-cubo.half_size+2*cubo.half_size*linearInterpolation(cubo.vertices[6],cubo.vertices[7]));
                
-        temp.vertices[0] = 6;
-        temp.vertices[1] = 7;
-        aristas.append(temp);
-    }
-    return aristas;
+    memset( i_x_verts, -1, howmany * sizeof( int ) ) ;
+    memset( i_y_verts, -1, howmany * sizeof( int ) ) ;
+    memset( i_z_verts, -1, howmany * sizeof( int ) ) ;
+
+    memset( i_N, 0, 15 * sizeof(int) ) ;
 }
+//_____________________________________________________________________________
+
 
-bool MarchingCubes::oppositeSign(double a, double b){
-    return ((a > 0 && b <= 0) || (a <= 0 && b > 0));
+
+//_____________________________________________________________________________
+// init all structures (must set sizes before call)
+void MarchingCubes::init_all ()
+//-----------------------------------------------------------------------------
+{
+    init_temps() ;
+
+    i_nverts = i_ntrigs = 0 ;
+    i_Nverts = i_Ntrigs = ALLOC_SIZE ;
+    i_vertices  = new Vertex  [i_Nverts] ;
+    i_triangles = new Triangle[i_Ntrigs] ;
 }
+//_____________________________________________________________________________
+
+
 
-double MarchingCubes::linearInterpolation(double vert_1, double vert_2){
-    //Posicion de 0 a 1
-    return qAbs(vert_1/(vert_1 - vert_2));
+//_____________________________________________________________________________
+// clean temporary structures
+void MarchingCubes::clean_temps()
+//-----------------------------------------------------------------------------
+{
+ if (i_data)
+     delete [] i_data;
+    if (i_x_verts)
+        delete [] i_x_verts;
+    if (i_y_verts)
+        delete [] i_y_verts;
+    if (i_z_verts)
+        delete [] i_z_verts;
+
+ i_data     = (double*)NULL ;
+    i_x_verts  = (int*)NULL ;
+    i_y_verts  = (int*)NULL ;
+    i_z_verts  = (int*)NULL ;
 }
+//_____________________________________________________________________________
 
-void MarchingCubes::appendTriangles(QList<QVector3D> &lista_triangulos){
-    
-    for(int i=0; i<lista_triangulos.count();i+=3){
-        
-        if (lista_triangulos.size()-3 < i)
-            continue;
 
-        apendTriangle(lista_triangulos.at(i),lista_triangulos.at(i+1),lista_triangulos.at(i+2));
  
-    }
+//_____________________________________________________________________________
+// clean all structures
+void MarchingCubes::clean_all()
+//-----------------------------------------------------------------------------
+{
+    clean_temps() ;
+    delete [] i_vertices  ;
+    delete [] i_triangles ;
+    i_vertices  = (Vertex   *)NULL ;
+    i_triangles = (Triangle *)NULL ;
+    i_nverts = i_ntrigs = 0 ;
+    i_Nverts = i_Ntrigs = 0 ;
 
+    i_size_x = i_size_y = i_size_z = -1 ;
 }
+//_____________________________________________________________________________
 
-void MarchingCubes::computeTopologyType(const sMarching_Cube& cubo){
-    QList<Edge> aristas;
-    QList<unsigned int> vertices;
-    unsigned int it;
-
-    //Conseguir aristas y vertices
-    aristas = computeIntersections(cubo);
-    it=0;
-    for(unsigned int i=1; i<129; i*=2){
-        if((cubo.type & i) == i){
-            vertices.append(it);
-        }
-        it++;
-    }
-    if(vertices.count() > 4){
-        it=0;
-        vertices.clear();
-        for(unsigned int i=1; i<129; i*=2){
-            if((cubo.type & i) != i){
-                vertices.append(it);
-            }
-            it++;
-        }
-    }
 
-    //get type
-    switch(aristas.count()){
-    case 3:
-        //type 1
-        type01(aristas, vertices);
-        return ;
-    case 4:
-        //types 2, 5
-        if(vertices.count() == 2){
-            //type 2
-            type02(aristas);
-            return ;
-        } else {
-            //type 5
-            type05(aristas, vertices);
-            return ;
-        }
-    case 5:
-    {
-        //type 4
-        type04(aristas, vertices);
-        return ;
-    }
-    case 6:
-        //types 3, 8, 9, 10, 14
-        if(vertices.count() == 2){
-            //types 3 or 10 -> type01 can draw this cases too
-             type01(aristas, vertices); return ;
-        } else {
-            for(int i=0; i<vertices.count(); i++){
-                bool tiene_arista = false;
-                for(int j=0; j<aristas.count(); j++){
-                    if(aristas.at(j).vertices[0] == vertices.at(i) || \
                aristas.at(j).vertices[1] == vertices.at(i)){
-                        tiene_arista = true;
-                        break;
-                    }
+
+//_____________________________________________________________________________
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+// Compute the intersection points
+void MarchingCubes::compute_intersection_points( )
+//-----------------------------------------------------------------------------
+{
+    for( i_k = 0 ; i_k < i_size_z ; i_k++ )
+        for( i_j = 0 ; i_j < i_size_y ; i_j++ )
+            for( i_i = 0 ; i_i < i_size_x ; i_i++ )
+            {
+                i_cube[0] = get_data( i_i, i_j, i_k ) ;
+                if( i_i < i_size_x - 1 )
+                    i_cube[1] = get_data(i_i+1, i_j , i_k ) ;
+                else
+                    i_cube[1] = i_cube[0] ;
+
+                if( i_j < i_size_y - 1 )
+                    i_cube[3] = get_data( i_i ,i_j+1, i_k ) ;
+                else
+                    i_cube[3] = i_cube[0] ;
+
+                if( i_k < i_size_z - 1 )
+                    i_cube[4] = get_data( i_i , i_j ,i_k+1) ;
+                else
+                    i_cube[4] = i_cube[0] ;
+
+                if( fabs( i_cube[0] ) < FLT_EPSILON )
+                    i_cube[0] = FLT_EPSILON ;
+                if( fabs( i_cube[1] ) < FLT_EPSILON )
+                    i_cube[1] = FLT_EPSILON ;
+                if( fabs( i_cube[3] ) < FLT_EPSILON )
+                    i_cube[3] = FLT_EPSILON ;
+                if( fabs( i_cube[4] ) < FLT_EPSILON )
+                    i_cube[4] = FLT_EPSILON ;
+
+                if( i_cube[0] < 0 )
+                {
+                    if( i_cube[1] > 0 )
+                        set_x_vert( add_x_vertex( ), i_i,i_j,i_k ) ;
+                    if( i_cube[3] > 0 )
+                        set_y_vert( add_y_vertex( ), i_i,i_j,i_k ) ;
+                    if( i_cube[4] > 0 )
+                        set_z_vert( add_z_vertex( ), i_i,i_j,i_k ) ;
                 }
-                if(!tiene_arista){
-                    //Tipo 8
-                    type08(aristas, vertices, i);
-                    return ;
+                else
+                {
+                    if( i_cube[1] < 0 )
+                        set_x_vert( add_x_vertex( ), i_i,i_j,i_k ) ;
+                    if( i_cube[3] < 0 )
+                        set_y_vert( add_y_vertex( ), i_i,i_j,i_k ) ;
+                    if( i_cube[4] < 0 )
+                        set_z_vert( add_z_vertex( ), i_i,i_j,i_k ) ;
                 }
             }
-            //types 9 or 14 (are the same)
-            type09(aristas,vertices);
-            return ;
-        }
-    case 7:
-        //type 11
-        {
-            type11(aristas, vertices);
-            return ;
-        }
-    case 8:
+}
+//_____________________________________________________________________________
+
+
+
+
+
+//_____________________________________________________________________________
+// Test a face
+// if face>0 return true if the face contains a part of the surface
+bool MarchingCubes::test_face( char face )
+//-----------------------------------------------------------------------------
+{
+    double A,B,C,D ;
+
+    switch( face )
     {
-        //types 6, 13
-        bool encontrado;
-        for(int i=0; i<vertices.count()-1; i++){
-            encontrado = true;
-            for(int j=i+1;j<vertices.count();j++){
-                if(vertices.at(j) - vertices.at(i) == 1 ||
-                   vertices.at(j) - vertices.at(i) == 2 ||
-                   vertices.at(j) - vertices.at(i) == 4 ){
-                    encontrado = false;
-                    break;
-                    
-                }
+            case -1 :
+            case 1 :
+            A = i_cube[0] ;
+            B = i_cube[4] ;
+            C = i_cube[5] ;
+            D = i_cube[1] ;
+            break ;
+            case -2 :
+            case 2 :
+            A = i_cube[1] ;
+            B = i_cube[5] ;
+            C = i_cube[6] ;
+            D = i_cube[2] ;
+            break ;
+            case -3 :
+            case 3 :
+            A = i_cube[2] ;
+            B = i_cube[6] ;
+            C = i_cube[7] ;
+            D = i_cube[3] ;
+            break ;
+            case -4 :
+            case 4 :
+            A = i_cube[3] ;
+            B = i_cube[7] ;
+            C = i_cube[4] ;
+            D = i_cube[0] ;
+            break ;
+            case -5 :
+            case 5 :
+            A = i_cube[0] ;
+            B = i_cube[3] ;
+            C = i_cube[2] ;
+            D = i_cube[1] ;
+            break ;
+            case -6 :
+            case 6 :
+            A = i_cube[4] ;
+            B = i_cube[7] ;
+            C = i_cube[6] ;
+            D = i_cube[5] ;
+            break ;
+            default :
+//          Aqsis::log() << warning << "Invalid face code " << face << std::endl;
+            print_cube() ;
+            A = B = C = D = 0 ;
+    };
+
+    return face * A * ( A*C - B*D ) >= 0  ;  // face and A invert signs
+}
+//_____________________________________________________________________________
+
+
+
+
+
+//_____________________________________________________________________________
+// Test the interior of a cube
+// if s == 7, return true  if the interior is empty
+// if s ==-7, return false if the interior is empty
+bool MarchingCubes::test_interior( char s )
+//-----------------------------------------------------------------------------
+{
+    double t, At=0, Bt=0, Ct=0, Dt=0, a, b ;
+    char  test =  0 ;
+    char  edge = -1 ; // reference edge of the triangulation
+
+    switch( i_case )
+    {
+            case  4 :
+            case 10 :
+            a = ( i_cube[4] - i_cube[0] ) * ( i_cube[6] - i_cube[2] ) - ( i_cube[7] \
- i_cube[3] ) * ( i_cube[5] - i_cube[1] ) ; +            b =  i_cube[2] * ( i_cube[4] \
- i_cube[0] ) + i_cube[0] * ( i_cube[6] - i_cube[2] ) +                 - i_cube[1] * \
( i_cube[7] - i_cube[3] ) - i_cube[3] * ( i_cube[5] - i_cube[1] ) ; +            t = \
- b / (2*a) ; +            if( t<0 || t>1 )
+                return s>0 ;
+
+            At = i_cube[0] + ( i_cube[4] - i_cube[0] ) * t ;
+            Bt = i_cube[3] + ( i_cube[7] - i_cube[3] ) * t ;
+            Ct = i_cube[2] + ( i_cube[6] - i_cube[2] ) * t ;
+            Dt = i_cube[1] + ( i_cube[5] - i_cube[1] ) * t ;
+            break ;
+
+            case  6 :
+            case  7 :
+            case 12 :
+            case 13 :
+            switch( i_case )
+            {
+                    case  6 :
+                    edge = test6 [i_config][2] ;
+                    break ;
+                    case  7 :
+                    edge = test7 [i_config][4] ;
+                    break ;
+                    case 12 :
+                    edge = test12[i_config][3] ;
+                    break ;
+                    case 13 :
+                    edge = tiling13_5_1[i_config][i_subconfig][0] ;
+                    break ;
             }
-            if(encontrado){
-                //type 6
-                type06(aristas, vertices, i);
-                return ;
+            switch( edge )
+            {
+                    case  0 :
+                    t  = i_cube[0] / ( i_cube[0] - i_cube[1] ) ;
+                    At = 0 ;
+                    Bt = i_cube[3] + ( i_cube[2] - i_cube[3] ) * t ;
+                    Ct = i_cube[7] + ( i_cube[6] - i_cube[7] ) * t ;
+                    Dt = i_cube[4] + ( i_cube[5] - i_cube[4] ) * t ;
+                    break ;
+                    case  1 :
+                    t  = i_cube[1] / ( i_cube[1] - i_cube[2] ) ;
+                    At = 0 ;
+                    Bt = i_cube[0] + ( i_cube[3] - i_cube[0] ) * t ;
+                    Ct = i_cube[4] + ( i_cube[7] - i_cube[4] ) * t ;
+                    Dt = i_cube[5] + ( i_cube[6] - i_cube[5] ) * t ;
+                    break ;
+                    case  2 :
+                    t  = i_cube[2] / ( i_cube[2] - i_cube[3] ) ;
+                    At = 0 ;
+                    Bt = i_cube[1] + ( i_cube[0] - i_cube[1] ) * t ;
+                    Ct = i_cube[5] + ( i_cube[4] - i_cube[5] ) * t ;
+                    Dt = i_cube[6] + ( i_cube[7] - i_cube[6] ) * t ;
+                    break ;
+                    case  3 :
+                    t  = i_cube[3] / ( i_cube[3] - i_cube[0] ) ;
+                    At = 0 ;
+                    Bt = i_cube[2] + ( i_cube[1] - i_cube[2] ) * t ;
+                    Ct = i_cube[6] + ( i_cube[5] - i_cube[6] ) * t ;
+                    Dt = i_cube[7] + ( i_cube[4] - i_cube[7] ) * t ;
+                    break ;
+                    case  4 :
+                    t  = i_cube[4] / ( i_cube[4] - i_cube[5] ) ;
+                    At = 0 ;
+                    Bt = i_cube[7] + ( i_cube[6] - i_cube[7] ) * t ;
+                    Ct = i_cube[3] + ( i_cube[2] - i_cube[3] ) * t ;
+                    Dt = i_cube[0] + ( i_cube[1] - i_cube[0] ) * t ;
+                    break ;
+                    case  5 :
+                    t  = i_cube[5] / ( i_cube[5] - i_cube[6] ) ;
+                    At = 0 ;
+                    Bt = i_cube[4] + ( i_cube[7] - i_cube[4] ) * t ;
+                    Ct = i_cube[0] + ( i_cube[3] - i_cube[0] ) * t ;
+                    Dt = i_cube[1] + ( i_cube[2] - i_cube[1] ) * t ;
+                    break ;
+                    case  6 :
+                    t  = i_cube[6] / ( i_cube[6] - i_cube[7] ) ;
+                    At = 0 ;
+                    Bt = i_cube[5] + ( i_cube[4] - i_cube[5] ) * t ;
+                    Ct = i_cube[1] + ( i_cube[0] - i_cube[1] ) * t ;
+                    Dt = i_cube[2] + ( i_cube[3] - i_cube[2] ) * t ;
+                    break ;
+                    case  7 :
+                    t  = i_cube[7] / ( i_cube[7] - i_cube[4] ) ;
+                    At = 0 ;
+                    Bt = i_cube[6] + ( i_cube[5] - i_cube[6] ) * t ;
+                    Ct = i_cube[2] + ( i_cube[1] - i_cube[2] ) * t ;
+                    Dt = i_cube[3] + ( i_cube[0] - i_cube[3] ) * t ;
+                    break ;
+                    case  8 :
+                    t  = i_cube[0] / ( i_cube[0] - i_cube[4] ) ;
+                    At = 0 ;
+                    Bt = i_cube[3] + ( i_cube[7] - i_cube[3] ) * t ;
+                    Ct = i_cube[2] + ( i_cube[6] - i_cube[2] ) * t ;
+                    Dt = i_cube[1] + ( i_cube[5] - i_cube[1] ) * t ;
+                    break ;
+                    case  9 :
+                    t  = i_cube[1] / ( i_cube[1] - i_cube[5] ) ;
+                    At = 0 ;
+                    Bt = i_cube[0] + ( i_cube[4] - i_cube[0] ) * t ;
+                    Ct = i_cube[3] + ( i_cube[7] - i_cube[3] ) * t ;
+                    Dt = i_cube[2] + ( i_cube[6] - i_cube[2] ) * t ;
+                    break ;
+                    case 10 :
+                    t  = i_cube[2] / ( i_cube[2] - i_cube[6] ) ;
+                    At = 0 ;
+                    Bt = i_cube[1] + ( i_cube[5] - i_cube[1] ) * t ;
+                    Ct = i_cube[0] + ( i_cube[4] - i_cube[0] ) * t ;
+                    Dt = i_cube[3] + ( i_cube[7] - i_cube[3] ) * t ;
+                    break ;
+                    case 11 :
+                    t  = i_cube[3] / ( i_cube[3] - i_cube[7] ) ;
+                    At = 0 ;
+                    Bt = i_cube[2] + ( i_cube[6] - i_cube[2] ) * t ;
+                    Ct = i_cube[1] + ( i_cube[5] - i_cube[1] ) * t ;
+                    Dt = i_cube[0] + ( i_cube[4] - i_cube[0] ) * t ;
+                    break ;
+                    default :
+//                  Aqsis::log() << warning << "Invalid edge " << edge << std::endl;
+                    print_cube() ;
+                    break ;
             }
-        }
-        //type 13
-        type13(aristas, vertices);
-        return ;
+            break ;
+
+            default :
+//          Aqsis::log() << warning << "invalid ambiguous case " << i_case << \
std::endl; +            print_cube() ;
+            break ;
     }
-    case 9:
-        //type 12 -> type01 can draw this case
-        {
-        type01(aristas, vertices);
-        return ;
-        }
-    case 12:
-        //type 7 -> type01 can draw this case
-        {
-                    type01(aristas, vertices);
-            return ;
-            
-        }
-    default: qDebug() << "Can't compute the surface type"; break;
+
+    if( At >= 0 )
+        test ++ ;
+    if( Bt >= 0 )
+        test += 2 ;
+    if( Ct >= 0 )
+        test += 4 ;
+    if( Dt >= 0 )
+        test += 8 ;
+    switch( test )
+    {
+            case  0 :
+            return s>0 ;
+            case  1 :
+            return s>0 ;
+            case  2 :
+            return s>0 ;
+            case  3 :
+            return s>0 ;
+            case  4 :
+            return s>0 ;
+            case  5 :
+            if( At * Ct <  Bt * Dt )
+                return s>0 ;
+            break ;
+            case  6 :
+            return s>0 ;
+            case  7 :
+            return s<0 ;
+            case  8 :
+            return s>0 ;
+            case  9 :
+            return s>0 ;
+            case 10 :
+            if( At * Ct >= Bt * Dt )
+                return s>0 ;
+            break ;
+            case 11 :
+            return s<0 ;
+            case 12 :
+            return s>0 ;
+            case 13 :
+            return s<0 ;
+            case 14 :
+            return s<0 ;
+            case 15 :
+            return s<0 ;
     }
+
+    return s<0 ;
 }
+//_____________________________________________________________________________
 
-void MarchingCubes::type01(QList<Edge> aristas, QList<unsigned int> vertices){
-    QList<QVector3D> triangulos;
 
-    for(int i=0; i<vertices.count(); i++){
-        for(int j=0; j<aristas.count(); j++){
-            if(aristas.at(j).vertices[0]==vertices[i] || \
                aristas.at(j).vertices[1]==vertices[i]){
-                triangulos << aristas.at(j).cut;
-            }
-        }
+
+
+//_____________________________________________________________________________
+// Process a unit cube
+void MarchingCubes::process_cube( )
+//-----------------------------------------------------------------------------
+{
+    if( i_originalMC )
+    {
+        char nt = 0 ;
+        while( casesClassic[i_lut_entry][3*nt] != -1 )
+            nt++ ;
+        add_triangle( casesClassic[i_lut_entry], nt ) ;
+        return ;
     }
-    appendTriangles(triangulos);
-}
-void MarchingCubes::type02(QList<Edge> aristas){
-    QList<QVector3D> triangulos;
-    triangulos << aristas.at(0).cut;
-    triangulos << aristas.at(1).cut;
-    triangulos << aristas.at(2).cut;
-    triangulos << aristas.at(1).cut;
-    triangulos << aristas.at(2).cut;
-    triangulos << aristas.at(3).cut;
-    appendTriangles(triangulos);
-}
 
-void MarchingCubes::type04(QList<Edge> aristas, QList<unsigned int> vertices){
-    QList<QVector3D> triangulos;
-    unsigned int encontrado, sentido, pos_arista;
-    QList< QList<unsigned int> > pos;
-
-    //find the vertex with just one cut
-    for(int i=0;i<vertices.count();i++){
-        encontrado = 0;
-        for(int j=0; j<aristas.count(); j++){
-            if(aristas.at(j).vertices[0]==vertices[i] || \
                aristas.at(j).vertices[1]==vertices[i]){
-                encontrado++;
-                pos_arista = j;
-                if(encontrado == 2){
-                    break;
-                }
+    int   v12 = -1 ;
+    i_case   = cases[i_lut_entry][0] ;
+    i_config = cases[i_lut_entry][1] ;
+    i_subconfig = 0 ;
+
+    i_N[i_case]++ ;
+
+    switch( i_case )
+    {
+            case  0 :
+            break ;
+
+            case  1 :
+            add_triangle( tiling1[i_config], 1 ) ;
+            break ;
+
+            case  2 :
+            add_triangle( tiling2[i_config], 2 ) ;
+            break ;
+
+            case  3 :
+            if( test_face( test3[i_config]) )
+                add_triangle( tiling3_2[i_config], 4 ) ; // 3.2
+            else
+                add_triangle( tiling3_1[i_config], 2 ) ; // 3.1
+            break ;
+
+            case  4 :
+            if( test_interior( test4[i_config]) )
+                add_triangle( tiling4_1[i_config], 2 ) ; // 4.1.1
+            else
+                add_triangle( tiling4_2[i_config], 6 ) ; // 4.1.2
+            break ;
+
+            case  5 :
+            add_triangle( tiling5[i_config], 3 ) ;
+            break ;
+
+            case  6 :
+            if( test_face( test6[i_config][0]) )
+                add_triangle( tiling6_2[i_config], 5 ) ; // 6.2
+            else
+            {
+                if( test_interior( test6[i_config][1]) )
+                    add_triangle( tiling6_1_1[i_config], 3 ) ; // 6.1.1
+                else
+                    add_triangle( tiling6_1_2[i_config], 7 ) ; // 6.1.2
             }
-        }
-        if(encontrado == 1){
-            //we have the singleton vertex in i, so we can get first triangle
-            sentido = \
                aristas.at(pos_arista).vertices[1]-aristas.at(pos_arista).vertices[0];
                
-            for(int j=0; j<aristas.count(); j++){
-                if(aristas.at(j).vertices[1] - aristas.at(j).vertices[0] == \
                sentido){
-                    triangulos << aristas.at(j).cut;
+            break ;
+
+            case  7 :
+            if( test_face( test7[i_config][0] ) )
+                i_subconfig +=  1 ;
+            if( test_face( test7[i_config][1] ) )
+                i_subconfig +=  2 ;
+            if( test_face( test7[i_config][2] ) )
+                i_subconfig +=  4 ;
+            switch( i_subconfig )
+            {
+                    case 0 :
+                    add_triangle( tiling7_1[i_config], 3 ) ;
+                    break ;
+                    case 1 :
+                    add_triangle( tiling7_2[i_config][0], 5 ) ;
+                    break ;
+                    case 2 :
+                    add_triangle( tiling7_2[i_config][1], 5 ) ;
+                    break ;
+                    case 3 :
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling7_3[i_config][0], 9, v12 ) ;
+                    break ;
+                    case 4 :
+                    add_triangle( tiling7_2[i_config][2], 5 ) ;
+                    break ;
+                    case 5 :
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling7_3[i_config][1], 9, v12 ) ;
+                    break ;
+                    case 6 :
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling7_3[i_config][2], 9, v12 ) ;
+                    break ;
+                    case 7 :
+                    if( test_interior( test7[i_config][3]) )
+                        add_triangle( tiling7_4_2[i_config], 9 ) ;
+                    else
+                        add_triangle( tiling7_4_1[i_config], 5 ) ;
+                    break ;
+            };
+            break ;
+
+            case  8 :
+            add_triangle( tiling8[i_config], 2 ) ;
+            break ;
+
+            case  9 :
+            add_triangle( tiling9[i_config], 4 ) ;
+            break ;
+
+            case 10 :
+            if( test_face( test10[i_config][0]) )
+            {
+                if( test_face( test10[i_config][1]) )
+                    add_triangle( tiling10_1_1_[i_config], 4 ) ; // 10.1.1
+                else
+                {
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling10_2[i_config], 8, v12 ) ; // 10.2
                 }
             }
-            aristas.removeAt(pos_arista);
-
-            //group by common vertex
-            for(int k=0;k<vertices.count();k++){
-                if(i==k){
-                    continue;
+            else
+            {
+                if( test_face( test10[i_config][1]) )
+                {
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling10_2_[i_config], 8, v12 ) ; // 10.2
                 }
-                pos.append(QList<unsigned int>());
-                for(int j=0; j<aristas.count(); j++){
-                    if(aristas.at(j).vertices[0] == vertices[k] || \
                aristas.at(j).vertices[1] == vertices[k]){
-                        pos.back().append(j);
-                    }
+                else
+                {
+                    if( test_interior( test10[i_config][2]) )
+                        add_triangle( tiling10_1_1[i_config], 4 ) ; // 10.1.1
+                    else
+                        add_triangle( tiling10_1_2[i_config], 8 ) ; // 10.1.2
                 }
             }
+            break ;
 
-            //first triangle
-            triangulos << aristas.at(pos.at(0).at(0)).cut;
-            triangulos << aristas.at(pos.at(0).at(1)).cut;
-            for(int j=0; j<pos.at(1).count(); j++){
-                if(aristas.at(pos.at(1).at(j)).vertices[1] - \
                aristas.at(pos.at(1).at(j)).vertices[0] == sentido){
-                    triangulos << aristas.at(pos.at(1).at(j)).cut;
+            case 11 :
+            add_triangle( tiling11[i_config], 4 ) ;
+            break ;
+
+            case 12 :
+            if( test_face( test12[i_config][0]) )
+            {
+                if( test_face( test12[i_config][1]) )
+                    add_triangle( tiling12_1_1_[i_config], 4 ) ; // 12.1.1
+                else
+                {
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling12_2[i_config], 8, v12 ) ; // 12.2
                 }
             }
-
-            //second triangle
-            triangulos << aristas.at(pos.at(1).at(0)).cut;
-            triangulos << aristas.at(pos.at(1).at(1)).cut;
-            for(int j=0; j<pos.at(0).count(); j++){
-                if(aristas.at(pos.at(0).at(j)).vertices[1] - \
                aristas.at(pos.at(0).at(j)).vertices[0] != sentido){
-                    triangulos << aristas.at(pos.at(0).at(j)).cut;
+            else
+            {
+                if( test_face( test12[i_config][1]) )
+                {
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling12_2_[i_config], 8, v12 ) ; // 12.2
+                }
+                else
+                {
+                    if( test_interior( test12[i_config][2]) )
+                        add_triangle( tiling12_1_1[i_config], 4 ) ; // 12.1.1
+                    else
+                        add_triangle( tiling12_1_2[i_config], 8 ) ; // 12.1.2
                 }
             }
-            break;
-        }
-    }
-    appendTriangles(triangulos);
+            break ;
+
+            case 13 :
+            if( test_face( test13[i_config][0] ) )
+                i_subconfig +=  1 ;
+            if( test_face( test13[i_config][1] ) )
+                i_subconfig +=  2 ;
+            if( test_face( test13[i_config][2] ) )
+                i_subconfig +=  4 ;
+            if( test_face( test13[i_config][3] ) )
+                i_subconfig +=  8 ;
+            if( test_face( test13[i_config][4] ) )
+                i_subconfig += 16 ;
+            if( test_face( test13[i_config][5] ) )
+                i_subconfig += 32 ;
+            switch( subconfig13[i_subconfig] )
+            {
+                    case 0 :/* 13.1 */
+                    add_triangle( tiling13_1[i_config], 4 ) ;
+                    break ;
+
+                    case 1 :/* 13.2 */
+                    add_triangle( tiling13_2[i_config][0], 6 ) ;
+                    break ;
+                    case 2 :/* 13.2 */
+                    add_triangle( tiling13_2[i_config][1], 6 ) ;
+                    break ;
+                    case 3 :/* 13.2 */
+                    add_triangle( tiling13_2[i_config][2], 6 ) ;
+                    break ;
+                    case 4 :/* 13.2 */
+                    add_triangle( tiling13_2[i_config][3], 6 ) ;
+                    break ;
+                    case 5 :/* 13.2 */
+                    add_triangle( tiling13_2[i_config][4], 6 ) ;
+                    break ;
+                    case 6 :/* 13.2 */
+                    add_triangle( tiling13_2[i_config][5], 6 ) ;
+                    break ;
+
+                    case 7 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3[i_config][0], 10, v12 ) ;
+                    break ;
+                    case 8 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3[i_config][1], 10, v12 ) ;
+                    break ;
+                    case 9 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3[i_config][2], 10, v12 ) ;
+                    break ;
+                    case 10 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3[i_config][3], 10, v12 ) ;
+                    break ;
+                    case 11 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3[i_config][4], 10, v12 ) ;
+                    break ;
+                    case 12 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3[i_config][5], 10, v12 ) ;
+                    break ;
+                    case 13 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3[i_config][6], 10, v12 ) ;
+                    break ;
+                    case 14 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3[i_config][7], 10, v12 ) ;
+                    break ;
+                    case 15 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3[i_config][8], 10, v12 ) ;
+                    break ;
+                    case 16 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3[i_config][9], 10, v12 ) ;
+                    break ;
+                    case 17 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3[i_config][10], 10, v12 ) ;
+                    break ;
+                    case 18 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3[i_config][11], 10, v12 ) ;
+                    break ;
+
+                    case 19 :/* 13.4 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_4[i_config][0], 12, v12 ) ;
+                    break ;
+                    case 20 :/* 13.4 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_4[i_config][1], 12, v12 ) ;
+                    break ;
+                    case 21 :/* 13.4 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_4[i_config][2], 12, v12 ) ;
+                    break ;
+                    case 22 :/* 13.4 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_4[i_config][3], 12, v12 ) ;
+                    break ;
+
+                    case 23 :/* 13.5 */
+                    i_subconfig = 0 ;
+                    if( test_interior( test13[i_config][6] ) )
+                        add_triangle( tiling13_5_1[i_config][0], 6 ) ;
+                    else
+                        add_triangle( tiling13_5_2[i_config][0], 10 ) ;
+                    break ;
+                    case 24 :/* 13.5 */
+                    i_subconfig = 1 ;
+                    if( test_interior( test13[i_config][6] ) )
+                        add_triangle( tiling13_5_1[i_config][1], 6 ) ;
+                    else
+                        add_triangle( tiling13_5_2[i_config][1], 10 ) ;
+                    break ;
+                    case 25 :/* 13.5 */
+                    i_subconfig = 2 ;
+                    if( test_interior( test13[i_config][6] ) )
+                        add_triangle( tiling13_5_1[i_config][2], 6 ) ;
+                    else
+                        add_triangle( tiling13_5_2[i_config][2], 10 ) ;
+                    break ;
+                    case 26 :/* 13.5 */
+                    i_subconfig = 3 ;
+                    if( test_interior( test13[i_config][6] ) )
+                        add_triangle( tiling13_5_1[i_config][3], 6 ) ;
+                    else
+                        add_triangle( tiling13_5_2[i_config][3], 10 ) ;
+                    break ;
+
+                    case 27 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3_[i_config][0], 10, v12 ) ;
+                    break ;
+                    case 28 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3_[i_config][1], 10, v12 ) ;
+                    break ;
+                    case 29 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3_[i_config][2], 10, v12 ) ;
+                    break ;
+                    case 30 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3_[i_config][3], 10, v12 ) ;
+                    break ;
+                    case 31 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3_[i_config][4], 10, v12 ) ;
+                    break ;
+                    case 32 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3_[i_config][5], 10, v12 ) ;
+                    break ;
+                    case 33 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3_[i_config][6], 10, v12 ) ;
+                    break ;
+                    case 34 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3_[i_config][7], 10, v12 ) ;
+                    break ;
+                    case 35 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3_[i_config][8], 10, v12 ) ;
+                    break ;
+                    case 36 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3_[i_config][9], 10, v12 ) ;
+                    break ;
+                    case 37 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3_[i_config][10], 10, v12 ) ;
+                    break ;
+                    case 38 :/* 13.3 */
+                    v12 = add_c_vertex() ;
+                    add_triangle( tiling13_3_[i_config][11], 10, v12 ) ;
+                    break ;
+
+                    case 39 :/* 13.2 */
+                    add_triangle( tiling13_2_[i_config][0], 6 ) ;
+                    break ;
+                    case 40 :/* 13.2 */
+                    add_triangle( tiling13_2_[i_config][1], 6 ) ;
+                    break ;
+                    case 41 :/* 13.2 */
+                    add_triangle( tiling13_2_[i_config][2], 6 ) ;
+                    break ;
+                    case 42 :/* 13.2 */
+                    add_triangle( tiling13_2_[i_config][3], 6 ) ;
+                    break ;
+                    case 43 :/* 13.2 */
+                    add_triangle( tiling13_2_[i_config][4], 6 ) ;
+                    break ;
+                    case 44 :/* 13.2 */
+                    add_triangle( tiling13_2_[i_config][5], 6 ) ;
+                    break ;
+
+                    case 45 :/* 13.1 */
+                    add_triangle( tiling13_1_[i_config], 4 ) ;
+                    break ;
+
+                    default :
+//                  Aqsis::log() << warning << "Impossible case 13 ?" << std::endl;
+                    print_cube() ;
+            }
+            break ;
+
+            case 14 :
+            add_triangle( tiling14[i_config], 4 ) ;
+            break ;
+    };
 }
-void MarchingCubes::type05(QList<Edge> aristas, QList<unsigned int> vertices){
-    QList<QVector3D> triangulos;
-    int vertice_arista[4];
-    //indentify each vertex with its edges (vertices are sort from low to high)
-    for(int i=0; i<vertices.count(); i++){
-        for(int j=0; j<aristas.count(); j++){
-            if(aristas.at(j).vertices[0] == vertices.at(i) || \
                aristas.at(j).vertices[1] == vertices.at(i)){
-                vertice_arista[i] = j;
-                break;
+//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+// Adding triangles
+void MarchingCubes::add_triangle( const int* trig, char n, int v12 )
+//-----------------------------------------------------------------------------
+{
+    int    tv[3] ;
+
+    for( register int t = 0 ; t < 3*n ; t++ )
+    {
+        register int t3 = t % 3;
+        switch( trig[t] )
+        {
+                case  0 :
+                tv[ t3 ] = get_x_vert( i_i , i_j , i_k ) ;
+                break ;
+                case  1 :
+                tv[ t3 ] = get_y_vert(i_i+1, i_j , i_k ) ;
+                break ;
+                case  2 :
+                tv[ t3 ] = get_x_vert( i_i ,i_j+1, i_k ) ;
+                break ;
+                case  3 :
+                tv[ t3 ] = get_y_vert( i_i , i_j , i_k ) ;
+                break ;
+                case  4 :
+                tv[ t3 ] = get_x_vert( i_i , i_j ,i_k+1) ;
+                break ;
+                case  5 :
+                tv[ t3 ] = get_y_vert(i_i+1, i_j ,i_k+1) ;
+                break ;
+                case  6 :
+                tv[ t3 ] = get_x_vert( i_i ,i_j+1,i_k+1) ;
+                break ;
+                case  7 :
+                tv[ t3 ] = get_y_vert( i_i , i_j ,i_k+1) ;
+                break ;
+                case  8 :
+                tv[ t3 ] = get_z_vert( i_i , i_j , i_k ) ;
+                break ;
+                case  9 :
+                tv[ t3 ] = get_z_vert(i_i+1, i_j , i_k ) ;
+                break ;
+                case 10 :
+                tv[ t3 ] = get_z_vert(i_i+1,i_j+1, i_k ) ;
+                break ;
+                case 11 :
+                tv[ t3 ] = get_z_vert( i_i ,i_j+1, i_k ) ;
+                break ;
+                case 12 :
+                tv[ t3 ] = v12 ;
+                break ;
+                default :
+                break ;
+        }
+
+        if( tv[t3] == -1 )
+        {
+//          Aqsis::log() << warning << "Invalid triangle " << i_ntrigs << std::endl;
+            print_cube() ;
+        }
+
+        if( t3 == 2 )
+        {
+            if( i_ntrigs >= i_Ntrigs )
+            {
+                Triangle *temp = i_triangles ;
+                i_triangles = new Triangle[ i_ntrigs + 1024] ;
+                memcpy( i_triangles, temp, i_Ntrigs*sizeof(Triangle) ) ;
+                delete[] temp ;
+/*
+                Aqsis::log() << warning << "allocated triangles " << i_Ntrigs << \
std::endl; +*/
+                i_Ntrigs = i_ntrigs + 1024 ;
             }
+
+            Triangle *T = i_triangles + i_ntrigs++ ;
+            T->v1    = tv[0] ;
+            T->v2    = tv[1] ;
+            T->v3    = tv[2] ;
         }
     }
-    //Pintar triangulos
-    triangulos << aristas.at(vertice_arista[0]).cut;
-    triangulos << aristas.at(vertice_arista[1]).cut;
-    triangulos << aristas.at(vertice_arista[2]).cut;
-    triangulos << triangulos.at(1);
-    triangulos << triangulos.at(2);
-    triangulos << aristas.at(vertice_arista[3]).cut;
-
-    appendTriangles(triangulos);
 }
-void MarchingCubes::type06(QList<Edge> aristas, QList<unsigned int> vertices, int \
                ind_vertice_solitario){
-    //type 1 + 4
-    QList<Edge> aristas2;
-    QList<unsigned int> vertices2;
-    //generate edge2
-    for(int i=0; i<aristas.count();i++){
-        if(aristas.at(i).vertices[0] != vertices.at(ind_vertice_solitario)
-           && aristas.at(i).vertices[1] != vertices.at(ind_vertice_solitario)){
-            aristas2.append(aristas.at(i));
-            aristas.removeAt(i);
-            i--;
-        }
+//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+// Calculating gradient
+
+double MarchingCubes::get_x_grad( const int i, const int j, const int k ) 
+//-----------------------------------------------------------------------------
+{
+    if( i > 0 )
+    {
+        if ( i < i_size_x - 1 )
+            return ( get_data( i+1, j, k ) - get_data( i-1, j, k ) ) / 2 ;
+        else
+            return get_data( i, j, k ) - get_data( i-1, j, k ) ;
     }
-    vertices2.append(vertices.at(ind_vertice_solitario));
-    vertices.removeAt(ind_vertice_solitario);
+    else
+        return get_data( i+1, j, k ) - get_data( i, j, k ) ;
 }
+//-----------------------------------------------------------------------------
 
-void MarchingCubes::type08(QList<Edge> aristas, QList<unsigned int> vertices, \
                unsigned int ind_vertice_solitario){
-    QList<QVector3D> triangulos;
-    unsigned int ind_vert = 0, sentido;
-    QList<int> orden;
-    if(ind_vertice_solitario == 0){
-        ind_vert = 1;
+double MarchingCubes::get_y_grad( const int i, const int j, const int k ) 
+//-----------------------------------------------------------------------------
+{
+    if( j > 0 )
+    {
+        if ( j < i_size_y - 1 )
+            return ( get_data( i, j+1, k ) - get_data( i, j-1, k ) ) / 2 ;
+        else
+            return get_data( i, j, k ) - get_data( i, j-1, k ) ;
     }
+    else
+        return get_data( i, j+1, k ) - get_data( i, j, k ) ;
+}
+//-----------------------------------------------------------------------------
 
-    //join 2 points associated with first vertex
-    for(int j=0; j<aristas.count(); j++){
-        if(aristas.at(j).vertices[0] == vertices.at(ind_vert) || \
                aristas.at(j).vertices[1] == vertices.at(ind_vert)){
-            triangulos << aristas.at(j).cut;
-            orden.append(j);
-        }
-    }
-    //join with points associated with 2nd vertex
-    sentido = aristas.at(orden.at(0)).vertices[1] - \
                aristas.at(orden.at(0)).vertices[0];
-    for(int j=0; j<aristas.count(); j++){
-        if(orden.at(0) == j || orden.at(1) == j){
-            continue;
-        }
-        if(aristas.at(j).vertices[1] - aristas.at(j).vertices[0] == sentido){
-            triangulos << aristas.at(j).cut;
-            orden.append(j);
-            for(int k=0; k<vertices.count(); k++){
-                if(aristas.at(j).vertices[0] == vertices.at(k) || \
                aristas.at(j).vertices[1] == vertices.at(k)){
-                    ind_vert = k;
-                    break;
-                }
-            }
-            break;
-        }
+double MarchingCubes::get_z_grad( const int i, const int j, const int k ) 
+//-----------------------------------------------------------------------------
+{
+    if( k > 0 )
+    {
+        if ( k < i_size_z - 1 )
+            return ( get_data( i, j, k+1 ) - get_data( i, j, k-1 ) ) / 2 ;
+        else
+            return get_data( i, j, k ) - get_data( i, j, k-1 ) ;
     }
-    triangulos << triangulos.at(1);
-    triangulos << triangulos.at(2);
-    for(int j=0; j<aristas.count(); j++){
-        if((aristas.at(j).vertices[0] == vertices.at(ind_vert) || \
                aristas.at(j).vertices[1] == vertices.at(ind_vert))
-            && (aristas.at(j).vertices[1] - aristas.at(j).vertices[0] != sentido)){
-            triangulos << aristas.at(j).cut;
-            orden.append(j);
-            break;
-        }
+    else
+        return get_data( i, j, k+1 ) - get_data( i, j, k ) ;
+}
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+// Adding vertices
+
+void MarchingCubes::test_vertex_addition()
+{
+    if( i_nverts >= i_Nverts )
+    {
+        Vertex *temp = i_vertices ;
+        i_vertices = new Vertex[ i_nverts  + 1024] ;
+        memcpy( i_vertices, temp, i_Nverts*sizeof(Vertex) ) ;
+        delete[] temp ;
+/*
+        Aqsis::log() << warning << "allocated vertices " << i_Nverts << std::endl;
+*/
+        i_Nverts = i_nverts + 1024 ;
     }
-    //2 triangles, we need 2 more ...
-    sentido = aristas.at(orden.at(1)).vertices[1] - \
                aristas.at(orden.at(1)).vertices[0];
-    triangulos << triangulos.at(0);
-    triangulos << triangulos.at(2);
-
-    for(int j=0; j<aristas.count(); j++){
-        if(orden.at(0) == j || orden.at(1) == j || orden.at(2) == j || orden.at(3) \
                == j){
-            continue;
-        }
-        if(aristas.at(j).vertices[1] - aristas.at(j).vertices[0] == sentido){
-            triangulos << aristas.at(j).cut;
-            orden.append(j);
-            for(int k=0; k<vertices.count(); k++){
-                if(aristas.at(j).vertices[0] == vertices.at(k) || \
                aristas.at(j).vertices[1] == vertices.at(k)){
-                    ind_vert = k;
-                    break;
-                }
-            }
-            break;
-        }
+}
+
+
+int MarchingCubes::add_x_vertex( )
+//-----------------------------------------------------------------------------
+{
+    test_vertex_addition() ;
+    Vertex *vert = i_vertices + i_nverts++ ;
+
+    double   u = ( i_cube[0] ) / ( i_cube[0] - i_cube[1] ) ;
+
+    //el mundo de analitza no es discreto, por eso los comentarios al cod original
+    //una cosa mas --- el u es el resultado de la interpolacion lineal sobre el edge
+//     vert->x      = (float)i_i+u;
+//     vert->y      = (float) i_j ;
+//     vert->z      = (float) i_k ;
+
+    vert->x      = xmin+hx*(i_i+u);
+    vert->y      = ymin+hy*i_j;
+    vert->z      = zmin+hz*i_k;
+
+    
+#ifdef COMPUTE_NORMALS
+    vert->nx = (1-u)*get_x_grad(i_i,i_j,i_k) + u*get_x_grad(i_i+1,i_j,i_k) ;
+    vert->ny = (1-u)*get_y_grad(i_i,i_j,i_k) + u*get_y_grad(i_i+1,i_j,i_k) ;
+    vert->nz = (1-u)*get_z_grad(i_i,i_j,i_k) + u*get_z_grad(i_i+1,i_j,i_k) ;
+
+    u = (float) sqrt( vert->nx * vert->nx + vert->ny * vert->ny +vert->nz * vert->nz \
) ; +    if( u > 0 )
+    {
+        vert->nx /= u ;
+        vert->ny /= u ;
+        vert->nz /= u ;
     }
-    triangulos << triangulos.at(0);
-    triangulos << triangulos.at(8);
-    for(int j=0; j<aristas.count(); j++){
-        if((aristas.at(j).vertices[0] == vertices.at(ind_vert) || \
                aristas.at(j).vertices[1] == vertices.at(ind_vert))
-            && (aristas.at(j).vertices[1] - aristas.at(j).vertices[0] != sentido)){
-            triangulos << aristas.at(j).cut;
-            orden.append(j);
-            break;
-        }
+#endif
+
+    return i_nverts-1 ;
+}
+//-----------------------------------------------------------------------------
+
+int MarchingCubes::add_y_vertex( )
+//-----------------------------------------------------------------------------
+{
+    test_vertex_addition() ;
+    Vertex *vert = i_vertices + i_nverts++ ;
+
+    double   u = ( i_cube[0] ) / ( i_cube[0] - i_cube[3] ) ;
+
+//     vert->x      = (float) i_i ;
+//     vert->y      = (float)i_j+u;
+//     vert->z      = (float) i_k ;
+
+    vert->x      = xmin+hx*i_i;
+    vert->y      = ymin+hy*(i_j+u);
+    vert->z      = zmin+hz*i_k;
+
+    
+    
+#ifdef COMPUTE_NORMALS
+    vert->nx = (1-u)*get_x_grad(i_i,i_j,i_k) + u*get_x_grad(i_i,i_j+1,i_k) ;
+    vert->ny = (1-u)*get_y_grad(i_i,i_j,i_k) + u*get_y_grad(i_i,i_j+1,i_k) ;
+    vert->nz = (1-u)*get_z_grad(i_i,i_j,i_k) + u*get_z_grad(i_i,i_j+1,i_k) ;
+
+    u = (float) sqrt( vert->nx * vert->nx + vert->ny * vert->ny +vert->nz * vert->nz \
) ; +    if( u > 0 )
+    {
+        vert->nx /= u ;
+        vert->ny /= u ;
+        vert->nz /= u ;
     }
+#endif
 
-    appendTriangles(triangulos);
+    return i_nverts-1 ;
 }
-void MarchingCubes::type09(QList<Edge> aristas, QList<unsigned int> vertices){
-    QList<QVector3D> triangulos;
-    QList<int> vertices_doble;
-    QList< QList<int> > aristas_doble;
-    bool doble;
-    unsigned int sentido, eje_compartido;
-
-    //find double vertices
-    for(int i=0; i<vertices.count(); i++){
-        doble = false;
-        for(int j=0; j<aristas.count(); j++){
-            if(aristas.at(j).vertices[0] == vertices.at(i) || \
                aristas.at(j).vertices[1] == vertices.at(i)){
-                if(doble){
-                    vertices_doble.append(i);
-                    break;
-                } else {
-                    doble = true;
-                }
-            }
-        }
+//-----------------------------------------------------------------------------
+
+int MarchingCubes::add_z_vertex( )
+//-----------------------------------------------------------------------------
+{
+    test_vertex_addition() ;
+    Vertex *vert = i_vertices + i_nverts++ ;
+
+    double   u = ( i_cube[0] ) / ( i_cube[0] - i_cube[4] ) ;
+
+//     vert->x      = (float) i_i ;
+//     vert->y      = (float) i_j ;
+//     vert->z      = (float)i_k+u;
+
+    vert->x      = xmin+hx*i_i;
+    vert->y      = ymin+hy*i_j;
+    vert->z      = zmin+hz*(i_k+u);
+
+    
+#ifdef COMPUTE_NORMALS
+    vert->nx = (1-u)*get_x_grad(i_i,i_j,i_k) + u*get_x_grad(i_i,i_j,i_k+1) ;
+    vert->ny = (1-u)*get_y_grad(i_i,i_j,i_k) + u*get_y_grad(i_i,i_j,i_k+1) ;
+    vert->nz = (1-u)*get_z_grad(i_i,i_j,i_k) + u*get_z_grad(i_i,i_j,i_k+1) ;
+
+    u = (float) sqrt( vert->nx * vert->nx + vert->ny * vert->ny +vert->nz * vert->nz \
) ; +    if( u > 0 )
+    {
+        vert->nx /= u ;
+        vert->ny /= u ;
+        vert->nz /= u ;
     }
-    //find vertices of double vertices
-    aristas_doble.append(QList<int>());
-    aristas_doble.append(QList<int>());
-    for(int j=0; j<aristas.count(); j++){
-        if(aristas.at(j).vertices[0] == vertices.at(vertices_doble.at(0)) || \
                aristas.at(j).vertices[1] == vertices.at(vertices_doble.at(0))){
-            aristas_doble.front().append(j);
-        } else if(aristas.at(j).vertices[0] == vertices.at(vertices_doble.at(1)) || \
                aristas.at(j).vertices[1] == vertices.at(vertices_doble.at(1))){
-            aristas_doble.back().append(j);
-        }
+#endif
+
+    return i_nverts-1 ;
+}
+
+
+int MarchingCubes::add_c_vertex( )
+//-----------------------------------------------------------------------------
+{
+    test_vertex_addition() ;
+    Vertex *vert = i_vertices + i_nverts++ ;
+
+    double  u = 0 ;
+    int   vid ;
+
+    vert->x = vert->y = vert->z =  0;
+#ifdef COMPUTE_NORMALS
+        vert->nx = vert->ny = vert->nz = 0 ;
+#endif
+
+    // Computes the average of the intersection points of the cube
+    vid = get_x_vert( i_i , i_j , i_k ) ;
+    if( vid != -1 )
+    {
+        ++u ;
+        const Vertex &v = i_vertices[vid] ;
+        vert->x += v.x ;
+        vert->y += v.y ;
+        vert->z += v.z ;
+#ifdef COMPUTE_NORMALS
+        vert->nx += v.nx ;
+        vert->ny += v.ny ;
+        vert->nz += v.nz ;
+#endif
     }
-    //find shared axis
-    for(int i=0; i<2; i++){
-        for(int j=0; j<2; j++){
-            if(aristas.at(aristas_doble.at(0).at(i)).vertices[1] - \
                aristas.at(aristas_doble.at(0).at(i)).vertices[0] ==
-               aristas.at(aristas_doble.at(1).at(j)).vertices[1] - \
                aristas.at(aristas_doble.at(1).at(j)).vertices[0]){
-                eje_compartido = aristas.at(aristas_doble.at(0).at(i)).vertices[1] - \
                aristas.at(aristas_doble.at(0).at(i)).vertices[0];
-                break;
-            }
-        }
+    vid = get_y_vert(i_i+1, i_j , i_k ) ;
+    if( vid != -1 )
+    {
+        ++u ;
+        const Vertex &v = i_vertices[vid] ;
+        vert->x += v.x ;
+        vert->y += v.y ;
+        vert->z += v.z ;
+#ifdef COMPUTE_NORMALS
+        vert->nx += v.nx ;
+        vert->ny += v.ny ;
+        vert->nz += v.nz ;
+#endif
     }
-    //first triangle
-    for(int i=0; i<2; i++){
-        triangulos << aristas.at(aristas_doble.at(0).at(i)).cut;
+    vid = get_x_vert( i_i ,i_j+1, i_k ) ;
+    if( vid != -1 )
+    {
+        ++u ;
+        const Vertex &v = i_vertices[vid] ;
+        vert->x += v.x ;
+        vert->y += v.y ;
+        vert->z += v.z ;
+#ifdef COMPUTE_NORMALS
+        vert->nx += v.nx ;
+        vert->ny += v.ny ;
+        vert->nz += v.nz ;
+#endif
     }
-    for(int i=0; i<2; i++){
-        if(aristas.at(aristas_doble.at(1).at(i)).vertices[1] - \
                aristas.at(aristas_doble.at(1).at(i)).vertices[0] == eje_compartido){
-            triangulos << aristas.at(aristas_doble.at(1).at(i)).cut;
-            break;
-       }
+    vid = get_y_vert( i_i , i_j , i_k ) ;
+    if( vid != -1 )
+    {
+        ++u ;
+        const Vertex &v = i_vertices[vid] ;
+        vert->x += v.x ;
+        vert->y += v.y ;
+        vert->z += v.z ;
+#ifdef COMPUTE_NORMALS
+        vert->nx += v.nx ;
+        vert->ny += v.ny ;
+        vert->nz += v.nz ;
+#endif
     }
-    //second triangle
-    for(int i=0; i<2; i++){
-        triangulos << aristas.at(aristas_doble.at(1).at(i)).cut;
+    vid = get_x_vert( i_i , i_j ,i_k+1) ;
+    if( vid != -1 )
+    {
+        ++u ;
+        const Vertex &v = i_vertices[vid] ;
+        vert->x += v.x ;
+        vert->y += v.y ;
+        vert->z += v.z ;
+#ifdef COMPUTE_NORMALS
+        vert->nx += v.nx ;
+        vert->ny += v.ny ;
+        vert->nz += v.nz ;
+#endif
     }
-    for(int i=0; i<2; i++){
-        if(aristas.at(aristas_doble.at(0).at(i)).vertices[1] - \
                aristas.at(aristas_doble.at(0).at(i)).vertices[0] == eje_compartido){
-            triangulos << aristas.at(aristas_doble.at(0).at(i)).cut;
-            break;
-       }
+    vid = get_y_vert(i_i+1, i_j ,i_k+1) ;
+    if( vid != -1 )
+    {
+        ++u ;
+        const Vertex &v = i_vertices[vid] ;
+        vert->x += v.x ;
+        vert->y += v.y ;
+        vert->z += v.z ;
+#ifdef COMPUTE_NORMALS
+        vert->nx += v.nx ;
+        vert->ny += v.ny ;
+        vert->nz += v.nz ;
+#endif
     }
-    //third triangle
-    for(int i=0; i<2; i++){
-        if(aristas.at(aristas_doble.at(0).at(i)).vertices[1] - \
                aristas.at(aristas_doble.at(0).at(i)).vertices[0] == eje_compartido){
-            triangulos << aristas.at(aristas_doble.at(0).at(i)).cut;
-            break;
-       }
+    vid = get_x_vert( i_i ,i_j+1,i_k+1) ;
+    if( vid != -1 )
+    {
+        ++u ;
+        const Vertex &v = i_vertices[vid] ;
+        vert->x += v.x ;
+        vert->y += v.y ;
+        vert->z += v.z ;
+#ifdef COMPUTE_NORMALS
+        vert->nx += v.nx ;
+        vert->ny += v.ny ;
+        vert->nz += v.nz ;
+#endif
     }
-    for(int i=0; i<2; i++){
-        if(aristas.at(aristas_doble.at(1).at(i)).vertices[1] - \
                aristas.at(aristas_doble.at(1).at(i)).vertices[0] != eje_compartido){
-            triangulos << aristas.at(aristas_doble.at(1).at(i)).cut;
-            sentido = aristas.at(aristas_doble.at(1).at(i)).vertices[1] - \
                aristas.at(aristas_doble.at(1).at(i)).vertices[0];
-            break;
-       }
+    vid = get_y_vert( i_i , i_j ,i_k+1) ;
+    if( vid != -1 )
+    {
+        ++u ;
+        const Vertex &v = i_vertices[vid] ;
+        vert->x += v.x ;
+        vert->y += v.y ;
+        vert->z += v.z ;
+#ifdef COMPUTE_NORMALS
+        vert->nx += v.nx ;
+        vert->ny += v.ny ;
+        vert->nz += v.nz ;
+#endif
     }
-    for(int j=0; j<aristas.count(); j++){
-        if(aristas.at(j).vertices[1] - aristas.at(j).vertices[0] == sentido){
-            triangulos << aristas.at(j).cut;
-        }
+    vid = get_z_vert( i_i , i_j , i_k ) ;
+    if( vid != -1 )
+    {
+        ++u ;
+        const Vertex &v = i_vertices[vid] ;
+        vert->x += v.x ;
+        vert->y += v.y ;
+        vert->z += v.z ;
+#ifdef COMPUTE_NORMALS
+        vert->nx += v.nx ;
+        vert->ny += v.ny ;
+        vert->nz += v.nz ;
+#endif
     }
-    //four triangle
-    for(int i=0; i<2; i++){
-        if(aristas.at(aristas_doble.at(0).at(i)).vertices[1] - \
                aristas.at(aristas_doble.at(0).at(i)).vertices[0] != eje_compartido){
-            triangulos << aristas.at(aristas_doble.at(0).at(i)).cut;
-            sentido = aristas.at(aristas_doble.at(0).at(i)).vertices[1] - \
                aristas.at(aristas_doble.at(0).at(i)).vertices[0];
-            break;
-       }
+    vid = get_z_vert(i_i+1, i_j , i_k ) ;
+    if( vid != -1 )
+    {
+        ++u ;
+        const Vertex &v = i_vertices[vid] ;
+        vert->x += v.x ;
+        vert->y += v.y ;
+        vert->z += v.z ;
+#ifdef COMPUTE_NORMALS
+        vert->nx += v.nx ;
+        vert->ny += v.ny ;
+        vert->nz += v.nz ;
+#endif
     }
-    for(int i=0; i<2; i++){
-        if(aristas.at(aristas_doble.at(1).at(i)).vertices[1] - \
                aristas.at(aristas_doble.at(1).at(i)).vertices[0] == eje_compartido){
-            triangulos << aristas.at(aristas_doble.at(1).at(i)).cut;
-            break;
-       }
+    vid = get_z_vert(i_i+1,i_j+1, i_k ) ;
+    if( vid != -1 )
+    {
+        ++u ;
+        const Vertex &v = i_vertices[vid] ;
+        vert->x += v.x ;
+        vert->y += v.y ;
+        vert->z += v.z ;
+#ifdef COMPUTE_NORMALS
+        vert->nx += v.nx ;
+        vert->ny += v.ny ;
+        vert->nz += v.nz ;
+#endif
     }
-    for(int j=0; j<aristas.count(); j++){
-        if(aristas.at(j).vertices[1] - aristas.at(j).vertices[0] == sentido){
-            triangulos << aristas.at(j).cut;
-        }
+    vid = get_z_vert( i_i ,i_j+1, i_k ) ;
+    if( vid != -1 )
+    {
+        ++u ;
+        const Vertex &v = i_vertices[vid] ;
+        vert->x += v.x ;
+        vert->y += v.y ;
+        vert->z += v.z ;
+#ifdef COMPUTE_NORMALS
+        vert->nx += v.nx ;
+        vert->ny += v.ny ;
+        vert->nz += v.nz ;
+#endif
     }
 
-    appendTriangles(triangulos);
-}
+    vert->x  /= u ;
+    vert->y  /= u ;
+    vert->z  /= u ;
 
-void MarchingCubes::type11(QList<Edge> aristas, QList<unsigned int> vertices){
-    //type 1 + 2
-    unsigned int vert_solitario;
-    bool encontrado;
-    QList<Edge> aristas2;
-
-    //find singleton vertex
-    for(int i=0; i<vertices.count()-1; i++){
-        encontrado = true;
-        for(int j=i+1;j<vertices.count();j++){
-            if(vertices.at(j) - vertices.at(i) == 1 ||
-               vertices.at(j) - vertices.at(i) == 2 ||
-               vertices.at(j) - vertices.at(i) == 4 ){
-                //Son contiguos
-                encontrado = false;
-                break;
-            }
-        }
-        if(encontrado){
-            vert_solitario = vertices.at(i);
-            break;
-        }
-    }
-    //generate edge2
-    for(int i=0; i<aristas.count();i++){
-        if(aristas.at(i).vertices[0] != vert_solitario
-           && aristas.at(i).vertices[1] != vert_solitario){
-            aristas2.append(aristas.at(i));
-            aristas.removeAt(i);
-            i--;
-        }
+#ifdef COMPUTE_NORMALS
+    u = (float) sqrt( vert->nx * vert->nx + vert->ny * vert->ny +vert->nz * vert->nz \
) ; +    if( u > 0 )
+    {
+        vert->nx /= u ;
+        vert->ny /= u ;
+        vert->nz /= u ;
     }
-    vertices.clear();
-    vertices.append(vert_solitario);
-}
+#endif
 
-void MarchingCubes::type13(QList<Edge> aristas, QList<unsigned int> vertices){
-    //type 2 + 2
-    unsigned int verts[2];
-    QList<Edge> aristas2;
-
-    //find couple of vertices
-    verts[0] = vertices.at(0);
-    for(int i=1; i<vertices.count(); i++){
-        if(vertices.at(i) - verts[0] == 1 ||
-               vertices.at(i) - verts[0] == 2 ||
-               vertices.at(i) - verts[0] == 4 ){
-            verts[1] = vertices.at(i);
-            break;
-        }
-    }
-    //generate edge2
-    for(int i=0; i<aristas.count();i++){
-        if(aristas.at(i).vertices[0] != verts[0]
-           && aristas.at(i).vertices[1] != verts[0]
-           && aristas.at(i).vertices[0] != verts[1]
-           && aristas.at(i).vertices[1] != verts[1]){
-            aristas2.append(aristas.at(i));
-            aristas.removeAt(i);
-            i--;
-        }
-    }
+    return i_nverts-1 ;
 }
+//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+//_____________________________________________________________________________
+
+
 
-void MarchingCubes::buildGeometry()
+
+void MarchingCubes::write(const char *fn, bool bin )
+//-----------------------------------------------------------------------------
 {
-    _vertices.clear();
-    _normals.clear();
-    _indexes.clear();
-    
-    QList<sMarching_Cube> cubos = getCubes();
+    FILE       *fp = fopen( fn, "w" );
+    fprintf(fp, "%d %d\n", i_nverts, i_ntrigs);
 
-    sMarching_Cube cubo;
-    foreach(cubo, cubos) {
-        //we can change the type now ... 
-        if(cubo.type > 127){
-            cubo.type = 255 - cubo.type;
-        }
-        computeTopologyType(cubo);
-     }
+    int          i ;
+
+    for ( i = 0; i < i_nverts; i++ )
+        fprintf(fp, "%f %f %f\n", i_vertices[i].x, i_vertices[i].y, \
i_vertices[i].z); +
+    for ( i = 0; i < i_ntrigs; i++ )
+    {
+        fprintf(fp, "%d %d %d \n", i_triangles[i].v1, i_triangles[i].v2, \
i_triangles[i].v3); +    }
+
+    fclose( fp ) ;
 }
+//_____________________________________________________________________________
+
diff --git a/analitzaplot/private/utils/marchingcubes.h \
b/analitzaplot/private/utils/marchingcubes.h index ef0b0c4..78fce61 100644
--- a/analitzaplot/private/utils/marchingcubes.h
+++ b/analitzaplot/private/utils/marchingcubes.h
@@ -1,26 +1,35 @@
-/*************************************************************************************
                
- *  Copyright (C) 2012 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com>      \
                *
- *                                                                                   \
                *
- *  This program is free software; you can redistribute it and/or                    \
                *
- *  modify it under the terms of the GNU General Public License                      \
                *
- *  as published by the Free Software Foundation; either version 2                   \
                *
- *  of the License, or (at your option) any later version.                           \
                *
- *                                                                                   \
                *
- *  This program is distributed in the hope that it will be useful,                  \
                *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   \
                *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    \
                *
- *  GNU General Public License for more details.                                     \
                *
- *                                                                                   \
                *
- *  You should have received a copy of the GNU General Public License                \
                *
- *  along with this program; if not, write to the Free Software                      \
                *
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   \
                *
- *************************************************************************************/
 +// Aqsis
+// Copyright (C) 2006, Paul C. Gregory
+//
+// Contact: pgregory@aqsis.org
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+/** \file
+    \brief MarchingCubes Algorithm
+    \author Thomas Lewiner <thomas.lewiner@polytechnique.org>
+    \author Math Dept, PUC-Rio
+    \version 0.2
+    \date    12/08/2002
+*/
+
+// Minor modifications for KDE-Edu/Analitza Library: Copyright (C) 2014 by Percy \
Camilo T. Aucahuasi <percy.camilo.ta@gmail.com>  
 #ifndef FUNCTIONGRAPH2_H_mcub
 #define FUNCTIONGRAPH2_H_mcub
 
-#include "octree.h"
-
 #include <QVector>
 
 struct SpaceLimits {
@@ -32,66 +41,330 @@ struct SpaceLimits {
     double maxZ;
 };
 
-struct sMarching_Cube{
-    QVector3D center;
-    double half_size;
-    unsigned short int type;
-    double vertices[8];
-};
 
-struct Edge{
-    QVector3D cut;
-    unsigned int vertices[2];
-};
 
-//TODO very bad implementation ... we need to use interval arithmetic plus root \
                finding 
-//to know if a 0 belongs to f(square)
 
+
+
+// Compute normals
+#define COMPUTE_NORMALS 1
+
+#include <QDebug>
+// types
+//-----------------------------------------------------------------------------
+// Vertex structure
+/** \struct Vertex "MarchingCubes.h" MarchingCubes
+ * Position and normal of a vertex
+ * \brief vertex structure
+ * \param x X coordinate
+ * \param y Y coordinate
+ * \param z Z coordinate
+ * \param nx X component of the normal
+ * \param ny Y component of the normal
+ * \param nz Z component of the normal
+ */
+typedef struct
+{
+  double  x,  y,  z ;  /**< Vertex coordinates */
+#ifdef COMPUTE_NORMALS
+  double nx, ny, nz ;  /**< Vertex normal */
+#endif
+} Vertex ;
+
+//-----------------------------------------------------------------------------
+// Triangle structure
+/** \struct Triangle "MarchingCubes.h" MarchingCubes
+ * Indices of the oriented triange vertices
+ * \brief triangle structure
+ * \param v1 First vertex index
+ * \param v2 Second vertex index
+ * \param v3 Third vertex index
+ */
+typedef struct
+{
+  int v1,v2,v3 ;  /**< Triangle vertices */
+} Triangle ;
+//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+/** Marching Cubes algorithm wrapper */
 class MarchingCubes
+//-----------------------------------------------------------------------------
 {
-friend class ImplicitSurf;
-    
-public:
-    virtual double evalScalarField(double x, double y, double z) = 0;
+// Constructors
+public :
+  /**
+   * Main and default constructor
+   * \brief constructor
+   * \param size_x width  of the grid
+   * \param size_y depth  of the grid
+   * \param size_z height of the grid
+   */
+  MarchingCubes () ;
+  /** Destructor */
+  virtual ~MarchingCubes() ;
 
-    MarchingCubes();
-    
-    //here we put the size of intervals for x,z,and z ... call setupSpace before \
buildGeometry +    virtual double evalScalarField(double x, double y, double z) = 0;
     void setupSpace(const SpaceLimits &spaceLimits);
+    void buildGeometry() {run();}
 
-    ~MarchingCubes();
+//-----------------------------------------------------------------------------
+// Accessors
 
-    void buildGeometry();
+  /** accesses the number of vertices of the generated mesh */
+  const int nverts() const { return i_nverts ; }
+  /** accesses the number of triangles of the generated mesh */
+  const int ntrigs() const { return i_ntrigs ; }
+  /** accesses a specific vertex of the generated mesh */
+  Vertex   * vert( const int i ) const { if( i < 0  || i >= i_nverts ) return ( \
Vertex *)NULL ; return i_vertices  + i ; } +  /** accesses a specific triangle of the \
generated mesh */ +  Triangle * trig( const int i ) const { if( i < 0  || i >= \
i_ntrigs ) return (Triangle*)NULL ; return i_triangles + i ; }  
-    QVector<double> _vertices;
-    QVector<double> _normals;
-    QVector<unsigned int> _indexes;
+  /** accesses the vertex buffer of the generated mesh */
+  Vertex   *mc_vertices () { return i_vertices  ; }
+  /** accesses the triangle buffer of the generated mesh */
+  Triangle *triangles() { return i_triangles ; }
+
+  /**  accesses the width  of the grid */
+  const int size_x() const { return i_size_x ; }
+  /**  accesses the depth  of the grid */
+  const int size_y() const { return i_size_y ; }
+  /**  accesses the height of the grid */
+  const int size_z() const { return i_size_z ; }
+
+  /**
+   * changes the size of the grid
+   * \param size_x width  of the grid
+   * \param size_y depth  of the grid
+   * \param size_z height of the grid
+   * se encesita llamar a setup space y buildgeometry para que se tome efecto ... \
esto solo cambia los attr de la clase +   */
+  void set_resolution( const int size_x, const int size_y, const int size_z ) { \
i_size_x = size_x ;  i_size_y = size_y ;  i_size_z = size_z ; } +  
+  
+
+  // Data access
+  /**
+   * accesses a specific cube of the grid
+   * \param i abscisse of the cube
+   * \param j ordinate of the cube
+   * \param k height of the cube
+   */
+  const double get_data  ( const int i, const int j, const int k ) const { return \
i_data[ i + j*i_size_x + k*i_size_x*i_size_y] ; } +
+//eval de analitza es muy costoso, asi que este aproach esta deprecated... es mejor \
el triple bucle para llenar la data +//   const double get_data  ( const int i, const \
int j, const int k )   +//   {
+//       double x = xmin+hx*i;
+//       double y = ymin+hy*j;
+//       double z = zmin+hz*k;
+// 
+// //       qDebug() << x << y << z;
+//       
+//       return evalScalarField(x,y,z);
+//   }
+
+
+  /**
+   * sets a specific cube of the grid
+   * \param val new value for the cube
+   * \param i abscisse of the cube
+   * \param j ordinate of the cube
+   * \param k height of the cube
+   */
+  void  set_data  ( const double val, const int i, const int j, const int k ) { \
i_data[ i + j*i_size_x + k*i_size_x*i_size_y] = val ; }  
 private:
-    QList<sMarching_Cube> getCubes();
-    sMarching_Cube evalCube(Cube cubo);
-    QList<Cube> breadthSearch(int cubos_lado);
-    QList<sMarching_Cube> depthSearch(Octree *arbol, sNode *nodo);
-    QList<Edge> computeIntersections(sMarching_Cube cubo);
-    bool oppositeSign(double a, double b);
-    double linearInterpolation(double vert_1, double vert_2);
-    void apendTriangle(const QVector3D &a, const QVector3D &b, const QVector3D &c);
-    void appendTriangles(QList<QVector3D> &lista_triangulos);
-    void computeTopologyType(const sMarching_Cube& cubo);
-    void type01(QList<Edge> aristas, QList<unsigned int> vertices);
-    void type02(QList<Edge> aristas);
-    void type04(QList<Edge> aristas, QList<unsigned int> vertices);
-    void type05(QList<Edge> aristas, QList<unsigned int> vertices);
-    void type06(QList<Edge> aristas, QList<unsigned int> vertices, int \
                ind_vertice_solitario);
-    void type08(QList<Edge> aristas, QList<unsigned int> vertices, unsigned int \
                ind_vertice_solitario);
-    void type09(QList<Edge> aristas, QList<unsigned int> vertices);
-    void type11(QList<Edge> aristas, QList<unsigned int> vertices);
-    void type13(QList<Edge> aristas, QList<unsigned int> vertices);
-    
-private:
-    double m_worldLength;
-    double m_minCubeSize;
-    SpaceLimits m_worldLimits;
+  /**
+   * selects wether the algorithm will use the enhanced topologically controlled \
lookup table or the original MarchingCubes +   * \param originalMC true for the \
original Marching Cubes +   * DEPRECATED el metodo original no tiene consistencia \
topologica +   */
+  void set_method    ( const bool originalMC = false ) { i_originalMC = originalMC ; \
} +
+  // Data initialization
+  /** inits temporary structures (must set sizes before call) : the grid and the \
vertex index per cube */ +  void init_temps () ;
+  /** inits all structures (must set sizes before call) : the temporary structures \
and the mesh buffers */ +  void init_all   () ;
+  /** clears temporary structures : the grid and the main */
+  void clean_temps() ;
+  /** clears all structures : the temporary structures and the mesh buffers */
+  void clean_all  () ;
+
+
+//-----------------------------------------------------------------------------
+// Exportation
+public :
+  /**
+   * GTS exportation of the generated mesh
+   * \param fn  name of the GTS file to create
+   * \param bin if true, the GTS will be written in binary mode
+   */
+  void write( const char *fn, bool bin = false ) ;
+
+
+//-----------------------------------------------------------------------------
+// Algorithm
+private :
+  /** Main algorithm : must be called after init_all */
+  void run() ;
+
+private :
+  /** tesselates one cube */
+  void process_cube ()             ;
+  /** tests if the components of the tesselation of the cube should be connected by \
the interior of an ambiguous face */ +  bool test_face    ( char face ) ;
+  /** tests if the components of the tesselation of the cube should be connected \
through the interior of the cube */ +  bool test_interior( char s )    ;
+
+
+//-----------------------------------------------------------------------------
+// Operations
+private :
+  /** computes almost all the vertices of the mesh by interpolation along the cubes \
edges */ +  void compute_intersection_points() ;
+
+  /**
+   * routine to add a triangle to the mesh
+   * \param trig the code for the triangle as a sequence of edges index
+   * \param n    the number of triangles to produce
+   * \param v12  the index of the interior vertex to use, if necessary
+   */
+  void add_triangle ( const int* trig, char n, int v12 = -1 ) ;
+
+  /** tests and eventually doubles the vertex buffer capacity for a new vertex \
insertion */ +  void test_vertex_addition() ;
+  /** adds a vertex on the current horizontal edge */
+  int add_x_vertex() ;
+  /** adds a vertex on the current longitudinal edge */
+  int add_y_vertex() ;
+  /** adds a vertex on the current vertical edge */
+  int add_z_vertex() ;
+  /** adds a vertex inside the current cube */
+  int add_c_vertex() ;
+
+  /**
+   * interpolates the horizontal gradient of the implicit function at the lower \
vertex of the specified cube +   * \param i abscisse of the cube
+   * \param j ordinate of the cube
+   * \param k height of the cube
+   */
+  double get_x_grad( const int i, const int j, const int k )  ;
+  /**
+   * interpolates the longitudinal gradient of the implicit function at the lower \
vertex of the specified cube +   * \param i abscisse of the cube
+   * \param j ordinate of the cube
+   * \param k height of the cube
+   */
+  double get_y_grad( const int i, const int j, const int k )  ;
+  /**
+   * interpolates the vertical gradient of the implicit function at the lower vertex \
of the specified cube +   * \param i abscisse of the cube
+   * \param j ordinate of the cube
+   * \param k height of the cube
+   */
+  double get_z_grad( const int i, const int j, const int k )  ;
+
+  /**
+   * accesses the pre-computed vertex index on the lower horizontal edge of a \
specific cube +   * \param i abscisse of the cube
+   * \param j ordinate of the cube
+   * \param k height of the cube
+   */
+  int   get_x_vert( const int i, const int j, const int k ) const { return \
i_x_verts[ i + j*i_size_x + k*i_size_x*i_size_y] ; } +  /**
+   * accesses the pre-computed vertex index on the lower longitudinal edge of a \
specific cube +   * \param i abscisse of the cube
+   * \param j ordinate of the cube
+   * \param k height of the cube
+   */
+  int   get_y_vert( const int i, const int j, const int k ) const { return \
i_y_verts[ i + j*i_size_x + k*i_size_x*i_size_y] ; } +  /**
+   * accesses the pre-computed vertex index on the lower vertical edge of a specific \
cube +   * \param i abscisse of the cube
+   * \param j ordinate of the cube
+   * \param k height of the cube
+   */
+  int   get_z_vert( const int i, const int j, const int k ) const { return \
i_z_verts[ i + j*i_size_x + k*i_size_x*i_size_y] ; } +
+  /**
+   * sets the pre-computed vertex index on the lower horizontal edge of a specific \
cube +   * \param val the index of the new vertex
+   * \param i abscisse of the cube
+   * \param j ordinate of the cube
+   * \param k height of the cube
+   */
+  void  set_x_vert( const int val, const int i, const int j, const int k ) { \
i_x_verts[ i + j*i_size_x + k*i_size_x*i_size_y] = val ; } +  /**
+   * sets the pre-computed vertex index on the lower longitudinal edge of a specific \
cube +   * \param val the index of the new vertex
+   * \param i abscisse of the cube
+   * \param j ordinate of the cube
+   * \param k height of the cube
+   */
+  void  set_y_vert( const int val, const int i, const int j, const int k ) { \
i_y_verts[ i + j*i_size_x + k*i_size_x*i_size_y] = val ; } +  /**
+   * sets the pre-computed vertex index on the lower vertical edge of a specific \
cube +   * \param val the index of the new vertex
+   * \param i abscisse of the cube
+   * \param j ordinate of the cube
+   * \param k height of the cube
+   */
+  void  set_z_vert( const int val, const int i, const int j, const int k ) { \
i_z_verts[ i + j*i_size_x + k*i_size_x*i_size_y] = val ; } +
+  /** prints cube for debug */
+  void print_cube() ;
+
+//-----------------------------------------------------------------------------
+// Elements
+private :
+  int       i_originalMC ;   /**< selects wether the algorithm will use the enhanced \
topologically controlled lookup table or the original MarchingCubes */ +  int       \
i_N[15]      ;   /**< counts the occurence of each case for debug */ +
+  int       i_size_x     ;  /**< width  of the grid */
+  int       i_size_y     ;  /**< depth  of the grid */
+  int       i_size_z     ;  /**< height of the grid */
+  double    *i_data       ;  /**< implicit function values sampled on the grid */
+
+  //BEGIN percy addons
+  double xmin;
+  double xmax;
+  double ymin;
+  double ymax;
+  double zmin;
+  double zmax;
+  double hx;
+  double hy;
+  double hz;
+  //END
+
+  int      *i_x_verts    ;  /**< pre-computed vertex indices on the lower horizontal \
edge of each cube */ +  int      *i_y_verts    ;  /**< pre-computed vertex indices on \
the lower longitudinal edge of each cube */ +  int      *i_z_verts    ;  /**< \
pre-computed vertex indices on the lower vertical     edge of each cube */ +
+  int       i_nverts     ;  /**< number of allocated vertices  in the vertex   \
buffer */ +  int       i_ntrigs     ;  /**< number of allocated triangles in the \
triangle buffer */ +  int       i_Nverts     ;  /**< size of the vertex   buffer */
+  int       i_Ntrigs     ;  /**< size of the triangle buffer */
+  Vertex     *i_vertices   ;  /**< vertex   buffer */
+  Triangle   *i_triangles  ;  /**< triangle buffer */
+
+  int       i_i          ;  /**< abscisse of the active cube */
+  int       i_j          ;  /**< height of the active cube */
+  int       i_k          ;  /**< ordinate of the active cube */
+
+  double     i_cube[8]    ;  /**< values of the implicit function on the active cube \
*/ +  unsigned char     i_lut_entry  ;  /**< cube sign representation in [0..255] */
+  unsigned char     i_case       ;  /**< case of the active cube in [0..15] */
+  unsigned char     i_config     ;  /**< configuration of the active cube */
+  unsigned char     i_subconfig  ;  /**< subconfiguration of the active cube */
 };
+//_____________________________________________________________________________
+
+
+
 
 #endif
diff --git a/analitzaplot/private/utils/octree.cpp \
b/analitzaplot/private/utils/octree.cpp deleted file mode 100644
index 6106120..0000000
--- a/analitzaplot/private/utils/octree.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*************************************************************************************
                
- *  Copyright (C) 2012 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com>      \
                *
- *                                                                                   \
                *
- *  This program is free software; you can redistribute it and/or                    \
                *
- *  modify it under the terms of the GNU General Public License                      \
                *
- *  as published by the Free Software Foundation; either version 2                   \
                *
- *  of the License, or (at your option) any later version.                           \
                *
- *                                                                                   \
                *
- *  This program is distributed in the hope that it will be useful,                  \
                *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   \
                *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    \
                *
- *  GNU General Public License for more details.                                     \
                *
- *                                                                                   \
                *
- *  You should have received a copy of the GNU General Public License                \
                *
- *  along with this program; if not, write to the Free Software                      \
                *
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   \
                *
- *************************************************************************************/
                
-
-#include "octree.h"
-
-
-Octree::Octree(double largo_mundo){
-    m_root = new sNode;
-
-    m_root->cube.setCenter(largo_mundo/2,largo_mundo/2,largo_mundo/2);
-    
-    m_root->cube.setHalfEdge(largo_mundo/2);
-    for(unsigned int i=0;i<8;i++){
-        m_root->nodes[i]=NULL;
-    }
-}
-
-Octree::Octree(Cube cubo){
-    m_root = new sNode;
-    m_root->cube = cubo;
-    for(unsigned int i=0;i<8;i++){
-        m_root->nodes[i]=NULL;
-    }
-}
-Octree::~Octree(){
-    recursiveDelete(m_root);
-}
-
-void Octree::initNodes(sNode* padre){
-    for(unsigned int i=0;i<8;i++){
-        padre->nodes[i] = new sNode;
-        padre->nodes[i]->cube.setHalfEdge(padre->cube.halfEdge()/2);
-        for(unsigned int j=0;j<8;j++){
-            padre->nodes[i]->nodes[j]=NULL;
-        }
-    }
-    
-    double x = padre->cube.center().x();
-    double y = padre->cube.center().y();
-    double z = padre->cube.center().z();
-    double hhedge = padre->cube.halfEdge()/2;
-    
-    
-    padre->nodes[0]->cube.setCenter(x-hhedge, y-hhedge, z-hhedge);
-    padre->nodes[1]->cube.setCenter(x-hhedge, y-hhedge, z+hhedge);
-    padre->nodes[2]->cube.setCenter(x-hhedge, y+hhedge, z-hhedge);
-    padre->nodes[3]->cube.setCenter(x-hhedge, y+hhedge, z+hhedge);
-    padre->nodes[4]->cube.setCenter(x+hhedge, y-hhedge, z-hhedge);
-    padre->nodes[5]->cube.setCenter(x+hhedge, y-hhedge, z+hhedge);
-    padre->nodes[6]->cube.setCenter(x+hhedge, y+hhedge, z-hhedge);
-    padre->nodes[7]->cube.setCenter(x+hhedge, y+hhedge, z+hhedge);
-
-}
-
-void Octree::recursiveDelete(sNode* nodo){
-    if(nodo == NULL){
-        return;
-    }
-    for(unsigned int i=0;i<8;i++){
-        recursiveDelete(nodo->nodes[i]);
-    }
-    delete nodo;
-}
-
-
-void Octree::recursiveCreate(sNode* nodo, unsigned int nivel_actual, unsigned int \
                nivel_max){
-    if(nivel_actual > nivel_max){
-        return;
-    }
-    initNodes(nodo);
-    for(unsigned int i=0;i<8;i++){
-        recursiveCreate(nodo->nodes[i],nivel_actual+1,nivel_max);
-    }
-}
-
-sNode* Octree::getRoot(){
-    return m_root;
-}
-
-void Octree::createLevel(unsigned int nivel){
-    recursiveCreate(m_root,0,nivel);
-}
-
-void Octree::downLevel(sNode* nodo){
-    initNodes(nodo);
-}
-
-void Octree::deleteChildren(sNode* padre){
-    for(unsigned int i=0;i<8;i++){
-        recursiveDelete(padre->nodes[i]);
-        padre->nodes[i] = NULL;
-    }
-}
-
diff --git a/analitzaplot/private/utils/octree.h \
b/analitzaplot/private/utils/octree.h deleted file mode 100644
index 1cf4b24..0000000
--- a/analitzaplot/private/utils/octree.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*************************************************************************************
                
- *  Copyright (C) 2012 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com>      \
                *
- *                                                                                   \
                *
- *  This program is free software; you can redistribute it and/or                    \
                *
- *  modify it under the terms of the GNU General Public License                      \
                *
- *  as published by the Free Software Foundation; either version 2                   \
                *
- *  of the License, or (at your option) any later version.                           \
                *
- *                                                                                   \
                *
- *  This program is distributed in the hope that it will be useful,                  \
                *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   \
                *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    \
                *
- *  GNU General Public License for more details.                                     \
                *
- *                                                                                   \
                *
- *  You should have received a copy of the GNU General Public License                \
                *
- *  along with this program; if not, write to the Free Software                      \
                *
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   \
                *
- *************************************************************************************/
                
-
-#ifndef FUNCTIONGRAPH2_H__Q
-#define FUNCTIONGRAPH2_H__Q
-
-#include <QVector3D>
-
-/*
- Node index
-
- layer z+
-y+
- -----
- |3|7|
- -----
- |1|5|
- ----- x+
-
- layer z-
-y+
- -----
- |2|6|
- -----
- |0|4|
- ----- x+
-*/
-
-
-struct Cube
-{
-    Cube(const QVector3D cent = QVector3D(0,0,0), double halfe = 1) : c(cent), \
                he(halfe) {}
-    Cube(const Cube &other) :c(other.c), he(other.he) {}
-
-    QVector3D c;
-    double he;
-    
-    QVector3D center() const { return c; }
-    double halfEdge() const { return he; }
-    void setCenter(double x, double y, double z) { c = QVector3D(x,y,z); }
-    void setCenter(const QVector3D &cent) { c = cent; }
-    void setHalfEdge(double halfe) { he = halfe; }
-
-};
-
-struct sNode{
-    Cube cube;
-    sNode* nodes[8];
-};
-
-//TODO we can replace this by kdtree (ANN library)
-class Octree
-{
-private:
-    sNode* m_root;
-
-    //create children with correct vertex values
-    void initNodes(sNode* parent);
-
-    void recursiveDelete(sNode* node);
-    void recursiveCreate(sNode* node, unsigned int current_level, unsigned int \
                max_level);
-public:
-    Octree(double world_size);
-    Octree(Cube cubo);
-    ~Octree();
-
-    sNode* getRoot();
-    void createLevel(unsigned int level);
-    void downLevel(sNode* node);
-    void deleteChildren(sNode* parent);
-
-};
-
-#endif
-


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic