Add remesh modifier (dual contouring).

This patch adds a new remeshing modifier. The algorithm is based on
the paper "Dual Contouring of Hermite Data", and the implementation
was contributed to Blender by Dr. Tao Ju.

The contributed code is in intern/dualcon, and was modified to compile
under gcc and work on 64-bit systems. Files not needed for Blender
were removed and a small C wrapper was added in order to interface it
with Blender. The rest of the patch is just standard modifier stuff.

Reviewed by Sergey, code review link:
http://codereview.appspot.com/5491053/

The remesh icon was contributed by Zafio:
http://blenderartists.org/forum/showthread.php?240751-Request-for-modifier-icon/page2.
Thanks to everyone in that thread for the icon proposals and
discussion.

Documentation and examples on the Blender wiki:
http://wiki.blender.org/index.php/User:Nicholasbishop/RemeshModifier

In case the history is needed for anything, check the remesh-modifier
branch of this git repository:
https://gitorious.org/~nicholasbishop/blenderprojects/nicholasbishop-blender
This commit is contained in:
2011-12-30 21:11:40 +00:00
parent 792452a7e5
commit 289c8b5758
34 changed files with 15855 additions and 6288 deletions

View File

@@ -31,6 +31,7 @@ add_subdirectory(memutil)
add_subdirectory(iksolver)
add_subdirectory(opennl)
add_subdirectory(mikktspace)
add_subdirectory(dualcon)
if(WITH_AUDASPACE)
add_subdirectory(audaspace)

View File

@@ -9,6 +9,7 @@ SConscript(['audaspace/SConscript',
'container/SConscript',
'memutil/SConscript/',
'decimation/SConscript',
'dualcon/SConscript',
'iksolver/SConscript',
'itasc/SConscript',
'boolop/SConscript',

View File

@@ -0,0 +1,46 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# 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.
#
# ***** END GPL LICENSE BLOCK *****
set(INC
.
intern
../../extern/Eigen3
)
set(SRC
intern/manifold_table.cpp
intern/marching_cubes_table.cpp
intern/octree.cpp
intern/Projections.cpp
intern/cubes.h
intern/GeoCommon.h
intern/manifold_table.h
intern/marching_cubes_table.h
intern/MemoryAllocator.h
intern/ModelReader.h
intern/octree.h
intern/Projections.h
intern/Queue.h
intern/dualcon_c_api.cpp
dualcon.h
)
blender_add_lib(bf_intern_dualcon "${SRC}" "${INC}" "")

View File

@@ -0,0 +1,9 @@
#!/usr/bin/python
Import ('env')
sources = env.Glob('intern/*.cpp')
incs = '. ../../extern/Eigen3'
defs = ''
env.BlenderLib ('bf_intern_dualcon', sources, Split(incs), Split(defs), libtype=['intern'], priority=[100] )

95
intern/dualcon/dualcon.h Normal file
View File

@@ -0,0 +1,95 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Nicholas Bishop
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef DUALCON_H
#define DUALCON_H
#ifdef __cplusplus
extern "C" {
#endif
typedef float (*DualConCo)[3];
typedef unsigned int (*DualConFaces)[4];
struct DerivedMesh;
typedef struct DualConInput {
DualConCo co;
int co_stride;
int totco;
DualConFaces faces;
int face_stride;
int totface;
float min[3], max[3];
} DualConInput;
/* callback for allocating memory for output */
typedef void *(*DualConAllocOutput)(int totvert, int totquad);
/* callback for adding a new vertex to the output */
typedef void (*DualConAddVert)(void *output, const float co[3]);
/* callback for adding a new quad to the output */
typedef void (*DualConAddQuad)(void *output, const int vert_indices[4]);
typedef enum {
DUALCON_FLOOD_FILL = 1,
} DualConFlags;
typedef enum {
/* blocky */
DUALCON_CENTROID,
/* smooth */
DUALCON_MASS_POINT,
/* keeps sharp edges */
DUALCON_SHARP_FEATURES,
} DualConMode;
/* Usage:
The three callback arguments are used for creating the output
mesh. The alloc_output callback takes the total number of vertices
and faces (quads) that will be in the output. It should allocate
and return a structure to hold the output mesh. The add_vert and
add_quad callbacks will then be called for each new vertex and
quad, and the callback should add the new mesh elements to the
structure.
*/
void *dualcon(const DualConInput *input_mesh,
/* callbacks for output */
DualConAllocOutput alloc_output,
DualConAddVert add_vert,
DualConAddQuad add_quad,
/* flags and settings to control the remeshing
algorithm */
DualConFlags flags,
DualConMode mode,
float threshold,
float hermite_num,
float scale,
int depth);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,69 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Tao Ju
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef GEOCOMMON_H
#define GEOCOMMON_H
#define UCHAR unsigned char
#define USHORT unsigned short
#define USE_MINIMIZER
/**
* Structure definitions for points and triangles.
*
* @author Tao Ju
*/
// 3d point with integer coordinates
typedef struct
{
int x, y, z;
} Point3i;
typedef struct
{
Point3i begin;
Point3i end;
} BoundingBox;
// triangle that points to three vertices
typedef struct
{
float vt[3][3] ;
} Triangle;
// 3d point with float coordinates
typedef struct
{
float x, y, z;
} Point3f;
typedef struct
{
Point3f begin;
Point3f end;
} BoundingBoxf;
#endif

View File

@@ -0,0 +1,219 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Tao Ju
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef MEMORYALLOCATOR_H
#define MEMORYALLOCATOR_H
#include <stdio.h>
#include <stdlib.h>
#define HEAP_BASE 16
#define UCHAR unsigned char
/**
* Customized memory allocators that allocates/deallocates memory in chunks
*
* @author Tao Ju
*/
/**
* Base class of memory allocators
*/
class VirtualMemoryAllocator
{
public:
virtual UCHAR * allocate( ) = 0 ;
virtual void deallocate( UCHAR * obj ) = 0 ;
virtual void destroy( ) = 0 ;
virtual void printInfo( ) = 0 ;
virtual int getAllocated( ) = 0 ;
virtual int getAll( ) = 0 ;
virtual int getBytes( ) = 0 ;
};
/**
* Dynamic memory allocator - allows allocation/deallocation
*
* Note: there are 4 bytes overhead for each allocated yet unused object.
*/
template < int N >
class MemoryAllocator : public VirtualMemoryAllocator
{
private:
/// Constants
int HEAP_UNIT, HEAP_MASK ;
/// Data array
UCHAR ** data ;
/// Allocation stack
UCHAR *** stack ;
/// Number of data blocks
int datablocknum ;
/// Number of stack blocks
int stackblocknum ;
/// Size of stack
int stacksize ;
/// Number of available objects on stack
int available ;
/**
* Allocate a memory block
*/
void allocateDataBlock ( )
{
// Allocate a data block
datablocknum += 1 ;
data = ( UCHAR ** )realloc( data, sizeof ( UCHAR * ) * datablocknum ) ;
data[ datablocknum - 1 ] = ( UCHAR * )malloc( HEAP_UNIT * N ) ;
// Update allocation stack
for ( int i = 0 ; i < HEAP_UNIT ; i ++ )
{
stack[ 0 ][ i ] = ( data[ datablocknum - 1 ] + i * N ) ;
}
available = HEAP_UNIT ;
}
/**
* Allocate a stack block, to store more deallocated objects
*/
void allocateStackBlock( )
{
// Allocate a stack block
stackblocknum += 1 ;
stacksize += HEAP_UNIT ;
stack = ( UCHAR *** )realloc( stack, sizeof ( UCHAR ** ) * stackblocknum ) ;
stack[ stackblocknum - 1 ] = ( UCHAR ** )malloc( HEAP_UNIT * sizeof ( UCHAR * ) ) ;
}
public:
/**
* Constructor
*/
MemoryAllocator( )
{
HEAP_UNIT = 1 << HEAP_BASE ;
HEAP_MASK = ( 1 << HEAP_BASE ) - 1 ;
data = ( UCHAR ** )malloc( sizeof( UCHAR * ) ) ;
data[ 0 ] = ( UCHAR * )malloc( HEAP_UNIT * N ) ;
datablocknum = 1 ;
stack = ( UCHAR *** )malloc( sizeof ( UCHAR ** ) ) ;
stack[ 0 ] = ( UCHAR ** )malloc( HEAP_UNIT * sizeof ( UCHAR * ) ) ;
stackblocknum = 1 ;
stacksize = HEAP_UNIT ;
available = HEAP_UNIT ;
for ( int i = 0 ; i < HEAP_UNIT ; i ++ )
{
stack[ 0 ][ i ] = ( data[ 0 ] + i * N ) ;
}
}
/**
* Destructor
*/
void destroy( )
{
int i ;
for ( i = 0 ; i < datablocknum ; i ++ )
{
free( data[ i ] ) ;
}
for ( i = 0 ; i < stackblocknum ; i ++ )
{
free( stack[ i ] ) ;
}
free( data ) ;
free( stack ) ;
}
/**
* Allocation method
*/
UCHAR * allocate ( )
{
if ( available == 0 )
{
allocateDataBlock ( ) ;
}
// printf("Allocating %d\n", header[ allocated ]) ;
available -- ;
return stack[ available >> HEAP_BASE ][ available & HEAP_MASK ] ;
}
/**
* De-allocation method
*/
void deallocate ( UCHAR * obj )
{
if ( available == stacksize )
{
allocateStackBlock ( ) ;
}
// printf("De-allocating %d\n", ( obj - data ) / N ) ;
stack[ available >> HEAP_BASE ][ available & HEAP_MASK ] = obj ;
available ++ ;
// printf("%d %d\n", allocated, header[ allocated ]) ;
}
/**
* Print information
*/
void printInfo ( )
{
printf("Bytes: %d Used: %d Allocated: %d Maxfree: %d\n", getBytes(), getAllocated(), getAll(), stacksize ) ;
}
/**
* Query methods
*/
int getAllocated( )
{
return HEAP_UNIT * datablocknum - available ;
};
int getAll( )
{
return HEAP_UNIT * datablocknum ;
};
int getBytes( )
{
return N ;
};
};
#endif

View File

@@ -0,0 +1,64 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Tao Ju
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef MODELREADER_H
#define MODELREADER_H
#include "GeoCommon.h"
/*
* Virtual class for input file readers
*
* @author Tao Ju
*/
class ModelReader
{
public:
/// Constructor
ModelReader(){} ;
/// Get next triangle
virtual Triangle* getNextTriangle( ) = 0 ;
virtual int getNextTriangle( int t[3] ) = 0 ;
/// Get bounding box
virtual float getBoundingBox ( float origin[3] ) = 0 ;
/// Get number of triangles
virtual int getNumTriangles ( ) = 0 ;
/// Get storage size
virtual int getMemory ( ) = 0 ;
/// Reset file reading location
virtual void reset( ) = 0 ;
/// For explicit vertex models
virtual int getNumVertices( ) = 0 ;
virtual void getNextVertex( float v[3] ) = 0 ;
virtual void printInfo ( ) = 0 ;
};
#endif

View File

@@ -0,0 +1,76 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Tao Ju
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <math.h>
#include "Projections.h"
const int vertmap[8][3] = {
{0, 0, 0},
{0, 0, 1},
{0, 1, 0},
{0, 1, 1},
{1, 0, 0},
{1, 0, 1},
{1, 1, 0},
{1, 1, 1}
};
const int centmap[3][3][3][2] = {
{{{0, 0}, {0, 1}, {1, 1}},
{{0, 2}, {0, 3}, {1, 3}},
{{2, 2}, {2, 3}, {3, 3}}
},
{{{0, 4}, {0, 5}, {1, 5}},
{{0, 6}, {0, 7}, {1, 7}},
{{2, 6}, {2, 7}, {3, 7}}
},
{{{4, 4}, {4, 5}, {5, 5}},
{{4, 6}, {4, 7}, {5, 7}},
{{6, 6}, {6, 7}, {7, 7}}
}
};
const int edgemap[12][2] = {
{0, 4},
{1, 5},
{2, 6},
{3, 7},
{0, 2},
{1, 3},
{4, 6},
{5, 7},
{0, 1},
{2, 3},
{4, 5},
{6, 7}
};
const int facemap[6][4] = {
{0, 1, 2, 3},
{4, 5, 6, 7},
{0, 1, 4, 5},
{2, 3, 6, 7},
{0, 2, 4, 6},
{1, 3, 5, 7}
};

View File

@@ -0,0 +1,844 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Tao Ju
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef PROJECTIONS_H
#define PROJECTIONS_H
#include <stdio.h>
#include <stdlib.h>
#define CONTAINS_INDEX
#define GRID_DIMENSION 20
#if defined(_WIN32) && !defined(FREE_WINDOWS)
#define LONG __int64
#else
#define LONG int64_t
#endif
#define UCHAR unsigned char
/**
* Structures and classes for computing projections of triangles
* onto separating axes during scan conversion
*
* @author Tao Ju
*/
extern const int vertmap[8][3];
extern const int centmap[3][3][3][2];
extern const int edgemap[12][2];
extern const int facemap[6][4];
/**
* Structure for the projections inheritable from parent
*/
struct InheritableProjections
{
/// Projections of triangle
LONG trigProj[13][2] ;
/// Projections of triangle vertices on primary axes
LONG trigVertProj[13][3] ;
/// Projections of triangle edges
LONG trigEdgeProj[13][3][2] ;
/// Normal of the triangle
double norm[3] ;
double normA, normB ;
/// End points along each axis
//int cubeEnds[13][2] ;
/// Error range on each axis
/// LONG errorProj[13];
#ifdef CONTAINS_INDEX
/// Index of polygon
int index ;
#endif
};
/**
* Class for projections of cube / triangle vertices on the separating axes
*/
class Projections
{
public:
/// Inheritable portion
InheritableProjections* inherit ;
/// Projections of the cube vertices
LONG cubeProj[13][6] ;
public:
Projections( )
{
}
/**
* Construction
* from a cube (axes aligned) and triangle
*/
Projections( LONG cube[2][3], LONG trig[3][3], LONG error, int triind )
{
int i, j ;
inherit = new InheritableProjections ;
#ifdef CONTAINS_INDEX
inherit->index = triind ;
#endif
/// Create axes
LONG axes[13][3] ;
// Cube faces
axes[0][0] = 1 ;
axes[0][1] = 0 ;
axes[0][2] = 0 ;
axes[1][0] = 0 ;
axes[1][1] = 1 ;
axes[1][2] = 0 ;
axes[2][0] = 0 ;
axes[2][1] = 0 ;
axes[2][2] = 1 ;
// Triangle face
LONG trigedge[3][3] ;
for ( i = 0 ; i < 3 ; i ++ )
{
for ( j = 0 ; j < 3 ; j ++ )
{
trigedge[i][j] = trig[(i+1)%3][j] - trig[i][j] ;
}
}
crossProduct( trigedge[0], trigedge[1], axes[3] ) ;
/// Normalize face normal and store
double dedge1[] = { (double) trig[1][0] - (double) trig[0][0],
(double) trig[1][1] - (double) trig[0][1],
(double) trig[1][2] - (double) trig[0][2] } ;
double dedge2[] = { (double) trig[2][0] - (double) trig[1][0],
(double) trig[2][1] - (double) trig[1][1],
(double) trig[2][2] - (double) trig[1][2] } ;
crossProduct( dedge1, dedge2, inherit->norm ) ;
normalize( inherit->norm ) ;
// inherit->normA = norm[ 0 ] ;
// inherit->normB = norm[ 2 ] > 0 ? norm[ 1 ] : 2 + norm[ 1 ] ;
// Face edges and triangle edges
int ct = 4 ;
for ( i = 0 ; i < 3 ; i ++ )
for ( j = 0 ; j < 3 ; j ++ )
{
crossProduct( axes[j], trigedge[i], axes[ct] ) ;
ct ++ ;
}
/// Generate projections
LONG cubeedge[3][3] ;
for ( i = 0 ; i < 3 ; i ++ )
{
for ( j = 0 ; j < 3 ; j ++ )
{
cubeedge[i][j] = 0 ;
}
cubeedge[i][i] = cube[1][i] - cube[0][i] ;
}
for ( j = 0 ; j < 13 ; j ++ )
{
// Origin
cubeProj[j][0] = dotProduct( axes[j], cube[0] ) ;
// 3 direction vectors
for ( i = 1 ; i < 4 ; i ++ )
{
cubeProj[j][i] = dotProduct( axes[j], cubeedge[i-1] ) ;
}
// Offsets of 2 ends of cube projection
LONG max = 0 ;
LONG min = 0 ;
for ( i = 1 ; i < 8 ; i ++ )
{
LONG proj = vertmap[i][0] * cubeProj[j][1] + vertmap[i][1] * cubeProj[j][2] + vertmap[i][2] * cubeProj[j][3] ;
if ( proj > max )
{
max = proj ;
}
if ( proj < min )
{
min = proj ;
}
}
cubeProj[j][4] = min ;
cubeProj[j][5] = max ;
}
for ( j = 0 ; j < 13 ; j ++ )
{
LONG vts[3] = { dotProduct( axes[j], trig[0] ),
dotProduct( axes[j], trig[1] ),
dotProduct( axes[j], trig[2] ) } ;
// Vertex
inherit->trigVertProj[j][0] = vts[0] ;
inherit->trigVertProj[j][1] = vts[1] ;
inherit->trigVertProj[j][2] = vts[2] ;
// Edge
for ( i = 0 ; i < 3 ; i ++ )
{
if ( vts[i] < vts[(i+1) % 3] )
{
inherit->trigEdgeProj[j][i][0] = vts[i] ;
inherit->trigEdgeProj[j][i][1] = vts[(i+1) % 3] ;
}
else
{
inherit->trigEdgeProj[j][i][1] = vts[i] ;
inherit->trigEdgeProj[j][i][0] = vts[(i+1) % 3] ;
}
}
// Triangle
inherit->trigProj[j][0] = vts[0] ;
inherit->trigProj[j][1] = vts[0] ;
for ( i = 1 ; i < 3 ; i ++ )
{
if ( vts[i] < inherit->trigProj[j][0] )
{
inherit->trigProj[j][0] = vts[i] ;
}
if ( vts[i] > inherit->trigProj[j][1] )
{
inherit->trigProj[j][1] = vts[i] ;
}
}
}
}
/**
* Construction
* from a parent Projections object and the index of the children
*/
Projections ( Projections* parent )
{
// Copy inheritable projections
this->inherit = parent->inherit ;
// Shrink cube projections
for ( int i = 0 ; i < 13 ; i ++ )
{
cubeProj[i][0] = parent->cubeProj[i][0] ;
for ( int j = 1 ; j < 6 ; j ++ )
{
cubeProj[i][j] = parent->cubeProj[i][j] >> 1 ;
}
}
};
Projections ( Projections* parent, int box[3], int depth )
{
int mask = ( 1 << depth ) - 1 ;
int nbox[3] = { box[0] & mask, box[1] & mask, box[2] & mask } ;
// Copy inheritable projections
this->inherit = parent->inherit ;
// Shrink cube projections
for ( int i = 0 ; i < 13 ; i ++ )
{
for ( int j = 1 ; j < 6 ; j ++ )
{
cubeProj[i][j] = parent->cubeProj[i][j] >> depth ;
}
cubeProj[i][0] = parent->cubeProj[i][0] + nbox[0] * cubeProj[i][1] + nbox[1] * cubeProj[i][2] + nbox[2] * cubeProj[i][3] ;
}
};
/**
* Testing intersection based on vertex/edge masks
*/
int getIntersectionMasks( UCHAR cedgemask, UCHAR& edgemask )
{
int i, j ;
edgemask = cedgemask ;
// Pre-processing
/*
if ( cvertmask & 1 )
{
edgemask |= 5 ;
}
if ( cvertmask & 2 )
{
edgemask |= 3 ;
}
if ( cvertmask & 4 )
{
edgemask |= 6 ;
}
*/
// Test axes for edge intersection
UCHAR bit = 1 ;
for ( j = 0 ; j < 3 ; j ++ )
{
if ( edgemask & bit )
{
for ( i = 0 ; i < 13 ; i ++ )
{
LONG proj0 = cubeProj[i][0] + cubeProj[i][4] ;
LONG proj1 = cubeProj[i][0] + cubeProj[i][5] ;
if ( proj0 > inherit->trigEdgeProj[i][j][1] ||
proj1 < inherit->trigEdgeProj[i][j][0] )
{
edgemask &= ( ~ bit ) ;
break ;
}
}
}
bit <<= 1 ;
}
/*
if ( edgemask != 0 )
{
printf("%d %d\n", cedgemask, edgemask) ;
}
*/
// Test axes for triangle intersection
if ( edgemask )
{
return 1 ;
}
for ( i = 3 ; i < 13 ; i ++ )
{
LONG proj0 = cubeProj[i][0] + cubeProj[i][4] ;
LONG proj1 = cubeProj[i][0] + cubeProj[i][5] ;
if ( proj0 > inherit->trigProj[i][1] ||
proj1 < inherit->trigProj[i][0] )
{
return 0 ;
}
}
return 1 ;
}
/**
* Retrieving children masks using PRIMARY AXES
*/
UCHAR getChildrenMasks( UCHAR cvertmask, UCHAR vertmask[8] )
{
int i, j, k ;
int bmask[3][2] = {{0,0},{0,0},{0,0}} ;
int vmask[3][3][2] = {{{0,0},{0,0},{0,0}},{{0,0},{0,0},{0,0}},{{0,0},{0,0},{0,0}}} ;
UCHAR boxmask = 0 ;
LONG len = cubeProj[0][1] >> 1 ;
for ( i = 0 ; i < 3 ; i ++ )
{
LONG mid = cubeProj[i][0] + len ;
// Check bounding box
if ( mid >= inherit->trigProj[i][0] )
{
bmask[i][0] = 1 ;
}
if ( mid <= inherit->trigProj[i][1] )
{
bmask[i][1] = 1 ;
}
// Check vertex mask
if ( cvertmask )
{
for ( j = 0 ; j < 3 ; j ++ )
{
if ( cvertmask & ( 1 << j ) )
{
// Only check if it's contained this node
if ( mid >= inherit->trigVertProj[i][j] )
{
vmask[i][j][0] = 1 ;
}
if ( mid <= inherit->trigVertProj[i][j] )
{
vmask[i][j][1] = 1 ;
}
}
}
}
/*
// Check edge mask
if ( cedgemask )
{
for ( j = 0 ; j < 3 ; j ++ )
{
if ( cedgemask & ( 1 << j ) )
{
// Only check if it's contained this node
if ( mid >= inherit->trigEdgeProj[i][j][0] )
{
emask[i][j][0] = 1 ;
}
if ( mid <= inherit->trigEdgeProj[i][j][1] )
{
emask[i][j][1] = 1 ;
}
}
}
}
*/
}
// Fill in masks
int ct = 0 ;
for ( i = 0 ; i < 2 ; i ++ )
for ( j = 0 ; j < 2 ; j ++ )
for ( k = 0 ; k < 2 ; k ++ )
{
boxmask |= ( ( bmask[0][i] & bmask[1][j] & bmask[2][k] ) << ct ) ;
vertmask[ct] = (( vmask[0][0][i] & vmask[1][0][j] & vmask[2][0][k] ) |
(( vmask[0][1][i] & vmask[1][1][j] & vmask[2][1][k] ) << 1 ) |
(( vmask[0][2][i] & vmask[1][2][j] & vmask[2][2][k] ) << 2 ) ) ;
/*
edgemask[ct] = (( emask[0][0][i] & emask[1][0][j] & emask[2][0][k] ) |
(( emask[0][1][i] & emask[1][1][j] & emask[2][1][k] ) << 1 ) |
(( emask[0][2][i] & emask[1][2][j] & emask[2][2][k] ) << 2 ) ) ;
edgemask[ct] = cedgemask ;
*/
ct ++ ;
}
// Return bounding box masks
return boxmask ;
}
UCHAR getBoxMask( )
{
int i, j, k ;
int bmask[3][2] = {{0,0},{0,0},{0,0}} ;
UCHAR boxmask = 0 ;
LONG len = cubeProj[0][1] >> 1 ;
for ( i = 0 ; i < 3 ; i ++ )
{
LONG mid = cubeProj[i][0] + len ;
// Check bounding box
if ( mid >= inherit->trigProj[i][0] )
{
bmask[i][0] = 1 ;
}
if ( mid <= inherit->trigProj[i][1] )
{
bmask[i][1] = 1 ;
}
}
// Fill in masks
int ct = 0 ;
for ( i = 0 ; i < 2 ; i ++ )
for ( j = 0 ; j < 2 ; j ++ )
for ( k = 0 ; k < 2 ; k ++ )
{
boxmask |= ( ( bmask[0][i] & bmask[1][j] & bmask[2][k] ) << ct ) ;
ct ++ ;
}
// Return bounding box masks
return boxmask ;
}
/**
* Get projections for sub-cubes (simple axes)
*/
void getSubProjectionsSimple( Projections* p[8] )
{
// Process the axes cooresponding to the triangle's normal
int ind = 3 ;
LONG len = cubeProj[ 0 ][ 1 ] >> 1 ;
LONG trigproj[3] = { cubeProj[ ind ][ 1 ] >> 1, cubeProj[ ind ][ 2 ] >> 1, cubeProj[ ind ][ 3 ] >> 1 } ;
int ct = 0 ;
for ( int i = 0 ; i < 2 ; i ++ )
for ( int j = 0 ; j < 2 ; j ++ )
for ( int k = 0 ; k < 2 ; k ++ )
{
p[ct] = new Projections( ) ;
p[ct]->inherit = inherit ;
p[ct]->cubeProj[ 0 ][ 0 ] = cubeProj[ 0 ][ 0 ] + i * len ;
p[ct]->cubeProj[ 1 ][ 0 ] = cubeProj[ 1 ][ 0 ] + j * len ;
p[ct]->cubeProj[ 2 ][ 0 ] = cubeProj[ 2 ][ 0 ] + k * len ;
p[ct]->cubeProj[ 0 ][ 1 ] = len ;
for ( int m = 1 ; m < 4 ; m ++ )
{
p[ct]->cubeProj[ ind ][ m ] = trigproj[ m - 1 ] ;
}
p[ct]->cubeProj[ ind ][ 0 ] = cubeProj[ ind ][0] + i * trigproj[0] + j * trigproj[1] + k * trigproj[2] ;
ct ++ ;
}
}
/**
* Shifting a cube to a new origin
*/
void shift ( int off[3] )
{
for ( int i = 0 ; i < 13 ; i ++ )
{
cubeProj[i][0] += off[0] * cubeProj[i][1] + off[1] * cubeProj[i][2] + off[2] * cubeProj[i][3] ;
}
}
void shiftNoPrimary ( int off[3] )
{
for ( int i = 3 ; i < 13 ; i ++ )
{
cubeProj[i][0] += off[0] * cubeProj[i][1] + off[1] * cubeProj[i][2] + off[2] * cubeProj[i][3] ;
}
}
/**
* Method to test intersection of the triangle and the cube
*/
int isIntersecting ( )
{
for ( int i = 0 ; i < 13 ; i ++ )
{
/*
LONG proj0 = cubeProj[i][0] +
vertmap[inherit->cubeEnds[i][0]][0] * cubeProj[i][1] +
vertmap[inherit->cubeEnds[i][0]][1] * cubeProj[i][2] +
vertmap[inherit->cubeEnds[i][0]][2] * cubeProj[i][3] ;
LONG proj1 = cubeProj[i][0] +
vertmap[inherit->cubeEnds[i][1]][0] * cubeProj[i][1] +
vertmap[inherit->cubeEnds[i][1]][1] * cubeProj[i][2] +
vertmap[inherit->cubeEnds[i][1]][2] * cubeProj[i][3] ;
*/
LONG proj0 = cubeProj[i][0] + cubeProj[i][4] ;
LONG proj1 = cubeProj[i][0] + cubeProj[i][5] ;
if ( proj0 > inherit->trigProj[i][1] ||
proj1 < inherit->trigProj[i][0] )
{
return 0 ;
}
}
return 1 ;
};
int isIntersectingNoPrimary ( )
{
for ( int i = 3 ; i < 13 ; i ++ )
{
/*
LONG proj0 = cubeProj[i][0] +
vertmap[inherit->cubeEnds[i][0]][0] * cubeProj[i][1] +
vertmap[inherit->cubeEnds[i][0]][1] * cubeProj[i][2] +
vertmap[inherit->cubeEnds[i][0]][2] * cubeProj[i][3] ;
LONG proj1 = cubeProj[i][0] +
vertmap[inherit->cubeEnds[i][1]][0] * cubeProj[i][1] +
vertmap[inherit->cubeEnds[i][1]][1] * cubeProj[i][2] +
vertmap[inherit->cubeEnds[i][1]][2] * cubeProj[i][3] ;
*/
LONG proj0 = cubeProj[i][0] + cubeProj[i][4] ;
LONG proj1 = cubeProj[i][0] + cubeProj[i][5] ;
if ( proj0 > inherit->trigProj[i][1] ||
proj1 < inherit->trigProj[i][0] )
{
return 0 ;
}
}
return 1 ;
};
/**
* Method to test intersection of the triangle and one edge
*/
int isIntersecting ( int edgeInd )
{
for ( int i = 0 ; i < 13 ; i ++ )
{
LONG proj0 = cubeProj[i][0] +
vertmap[edgemap[edgeInd][0]][0] * cubeProj[i][1] +
vertmap[edgemap[edgeInd][0]][1] * cubeProj[i][2] +
vertmap[edgemap[edgeInd][0]][2] * cubeProj[i][3] ;
LONG proj1 = cubeProj[i][0] +
vertmap[edgemap[edgeInd][1]][0] * cubeProj[i][1] +
vertmap[edgemap[edgeInd][1]][1] * cubeProj[i][2] +
vertmap[edgemap[edgeInd][1]][2] * cubeProj[i][3] ;
if ( proj0 < proj1 )
{
if ( proj0 > inherit->trigProj[i][1] ||
proj1 < inherit->trigProj[i][0] )
{
return 0 ;
}
}
else
{
if ( proj1 > inherit->trigProj[i][1] ||
proj0 < inherit->trigProj[i][0] )
{
return 0 ;
}
}
}
// printf( "Intersecting: %d %d\n", edgemap[edgeInd][0], edgemap[edgeInd][1] ) ;
return 1 ;
};
/**
* Method to test intersection of one triangle edge and one cube face
*/
int isIntersecting ( int edgeInd, int faceInd )
{
for ( int i = 0 ; i < 13 ; i ++ )
{
LONG trigproj0 = inherit->trigVertProj[i][edgeInd] ;
LONG trigproj1 = inherit->trigVertProj[i][(edgeInd+1)%3] ;
if ( trigproj0 < trigproj1 )
{
int t1 = 1 , t2 = 1 ;
for ( int j = 0 ; j < 4 ; j ++ )
{
LONG proj = cubeProj[i][0] +
vertmap[facemap[faceInd][j]][0] * cubeProj[i][1] +
vertmap[facemap[faceInd][j]][1] * cubeProj[i][2] +
vertmap[facemap[faceInd][j]][2] * cubeProj[i][3] ;
if ( proj >= trigproj0 )
{
t1 = 0 ;
}
if ( proj <= trigproj1 )
{
t2 = 0 ;
}
}
if ( t1 || t2 )
{
return 0 ;
}
}
else
{
int t1 = 1 , t2 = 1 ;
for ( int j = 0 ; j < 4 ; j ++ )
{
LONG proj = cubeProj[i][0] +
vertmap[facemap[faceInd][j]][0] * cubeProj[i][1] +
vertmap[facemap[faceInd][j]][1] * cubeProj[i][2] +
vertmap[facemap[faceInd][j]][2] * cubeProj[i][3] ;
if ( proj >= trigproj1 )
{
t1 = 0 ;
}
if ( proj <= trigproj0 )
{
t2 = 0 ;
}
}
if ( t1 || t2 )
{
return 0 ;
}
}
}
return 1 ;
};
int isIntersectingPrimary ( int edgeInd )
{
for ( int i = 0 ; i < 13 ; i ++ )
{
LONG proj0 = cubeProj[i][0] ;
LONG proj1 = cubeProj[i][0] + cubeProj[i][edgeInd + 1] ;
if ( proj0 < proj1 )
{
if ( proj0 > inherit->trigProj[i][1] ||
proj1 < inherit->trigProj[i][0] )
{
return 0 ;
}
}
else
{
if ( proj1 > inherit->trigProj[i][1] ||
proj0 < inherit->trigProj[i][0] )
{
return 0 ;
}
}
}
// printf( "Intersecting: %d %d\n", edgemap[edgeInd][0], edgemap[edgeInd][1] ) ;
return 1 ;
};
double getIntersection ( int edgeInd )
{
int i = 3 ;
LONG proj0 = cubeProj[i][0] +
vertmap[edgemap[edgeInd][0]][0] * cubeProj[i][1] +
vertmap[edgemap[edgeInd][0]][1] * cubeProj[i][2] +
vertmap[edgemap[edgeInd][0]][2] * cubeProj[i][3] ;
LONG proj1 = cubeProj[i][0] +
vertmap[edgemap[edgeInd][1]][0] * cubeProj[i][1] +
vertmap[edgemap[edgeInd][1]][1] * cubeProj[i][2] +
vertmap[edgemap[edgeInd][1]][2] * cubeProj[i][3] ;
LONG proj2 = inherit->trigProj[i][1] ;
/*
if ( proj0 < proj1 )
{
if ( proj2 < proj0 || proj2 > proj1 )
{
return -1 ;
}
}
else
{
if ( proj2 < proj1 || proj2 > proj0 )
{
return -1 ;
}
}
*/
double alpha = (double)( proj2 - proj0 ) / (double)( proj1 - proj0 ) ;
/*
if ( alpha < 0 )
{
alpha = 0.5 ;
}
else if ( alpha > 1 )
{
alpha = 0.5 ;
}
*/
return alpha ;
};
float getIntersectionPrimary ( int edgeInd )
{
int i = 3 ;
LONG proj0 = cubeProj[i][0] ;
LONG proj1 = cubeProj[i][0] + cubeProj[i][edgeInd + 1] ;
LONG proj2 = inherit->trigProj[i][1] ;
// double alpha = (double)( ( proj2 - proj0 ) * cubeProj[edgeInd][edgeInd + 1] ) / (double)( proj1 - proj0 ) ;
double alpha = (double)( ( proj2 - proj0 ) ) / (double)( proj1 - proj0 ) ;
if ( alpha < 0 )
{
alpha = 0.5 ;
}
else if ( alpha > 1 )
{
alpha = 0.5 ;
}
return (float)alpha ;
};
/**
* Method to perform cross-product
*/
void crossProduct ( LONG a[3], LONG b[3], LONG res[3] )
{
res[0] = a[1] * b[2] - a[2] * b[1] ;
res[1] = a[2] * b[0] - a[0] * b[2] ;
res[2] = a[0] * b[1] - a[1] * b[0] ;
}
void crossProduct ( double a[3], double b[3], double res[3] )
{
res[0] = a[1] * b[2] - a[2] * b[1] ;
res[1] = a[2] * b[0] - a[0] * b[2] ;
res[2] = a[0] * b[1] - a[1] * b[0] ;
}
/**
* Method to perform dot product
*/
LONG dotProduct ( LONG a[3], LONG b[3] )
{
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] ;
}
void normalize( double a[3] )
{
double mag = a[0] * a[0] + a[1] * a[1] + a[2] * a[2] ;
if ( mag > 0 )
{
mag = sqrt( mag ) ;
a[0] /= mag ;
a[1] /= mag ;
a[2] /= mag ;
}
}
};
#endif

View File

@@ -0,0 +1,110 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Tao Ju
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef QUEUE_H
#define QUEUE_H
struct gridQueueEle
{
int x, y, z;
UCHAR dir ;
gridQueueEle* next ;
};
class GridQueue
{
gridQueueEle* head ;
gridQueueEle* tail ;
int numEles ;
public:
GridQueue( )
{
head = NULL ;
tail = NULL ;
numEles = 0 ;
}
gridQueueEle* getHead( )
{
return head ;
}
int getNumElements( )
{
return numEles ;
}
void pushQueue( int st[3], int dir )
{
gridQueueEle* ele = new gridQueueEle ;
ele->x = st[0] ;
ele->y = st[1] ;
ele->z = st[2] ;
ele->dir = (UCHAR) dir ;
ele->next = NULL ;
if ( head == NULL )
{
head = ele ;
}
else
{
tail->next = ele ;
}
tail = ele ;
numEles ++ ;
}
int popQueue( int st[3], int& dir )
{
if ( head == NULL )
{
return 0 ;
}
st[0] = head->x ;
st[1] = head->y ;
st[2] = head->z ;
dir = (int) (head->dir) ;
gridQueueEle* temp = head ;
head = head->next ;
delete temp ;
if ( head == NULL )
{
tail = NULL ;
}
numEles -- ;
return 1 ;
}
};
#endif

View File

@@ -0,0 +1,46 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Tao Ju
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef CUBES_H
#define CUBES_H
#include "marching_cubes_table.h"
/* simple wrapper for auto-generated marching cubes data */
class Cubes
{
public:
/// Get number of triangles
int getNumTriangle(int mask)
{
return marching_cubes_numtri[mask];
}
/// Get a triangle
void getTriangle(int mask, int index, int indices[3] )
{
for(int i = 0; i < 3; i++)
indices[i] = marching_cubes_tris[mask][index][i];
}
};
#endif

View File

@@ -0,0 +1,191 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Nicholas Bishop
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <cassert>
#include "dualcon.h"
#include "ModelReader.h"
#include "octree.h"
#include <cstdio>
void veccopy(float dst[3], const float src[3])
{
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
}
#define GET_FACE(_mesh, _n) \
(*(DualConFaces)(((char*)(_mesh)->faces) + ((_n) * (_mesh)->face_stride)))
#define GET_CO(_mesh, _n) \
(*(DualConCo)(((char*)(_mesh)->co) + ((_n) * (_mesh)->co_stride)))
class DualConInputReader : public ModelReader
{
private:
const DualConInput *input_mesh;
int tottri, curface, offset;
float min[3], max[3], maxsize;
float scale;
public:
DualConInputReader(const DualConInput *mesh, float _scale)
: input_mesh(mesh), scale(_scale)
{
reset();
}
void reset()
{
tottri = 0;
curface = 0;
offset = 0;
maxsize = 0;
/* initialize tottri */
for(int i = 0; i < input_mesh->totface; i++)
tottri += GET_FACE(input_mesh, i)[3] ? 2 : 1;
veccopy(min, input_mesh->min);
veccopy(max, input_mesh->max);
/* initialize maxsize */
for(int i = 0; i < 3; i++) {
float d = max[i] - min[i];
if(d > maxsize)
maxsize = d;
}
/* redo the bounds */
for(int i = 0; i < 3; i++)
{
min[i] = (max[i] + min[i]) / 2 - maxsize / 2;
max[i] = (max[i] + min[i]) / 2 + maxsize / 2;
}
for(int i = 0; i < 3; i++)
min[i] -= maxsize * (1 / scale - 1) / 2;
maxsize *= 1 / scale;
}
Triangle* getNextTriangle()
{
if(curface == input_mesh->totface)
return 0;
Triangle* t = new Triangle();
unsigned int *f = GET_FACE(input_mesh, curface);
if(offset == 0) {
veccopy(t->vt[0], GET_CO(input_mesh, f[0]));
veccopy(t->vt[1], GET_CO(input_mesh, f[1]));
veccopy(t->vt[2], GET_CO(input_mesh, f[2]));
}
else {
veccopy(t->vt[0], GET_CO(input_mesh, f[2]));
veccopy(t->vt[1], GET_CO(input_mesh, f[3]));
veccopy(t->vt[2], GET_CO(input_mesh, f[0]));
}
if(offset == 0 && f[3])
offset++;
else {
offset = 0;
curface++;
}
return t;
}
int getNextTriangle(int t[3])
{
if(curface == input_mesh->totface)
return 0;
unsigned int *f = GET_FACE(input_mesh, curface);
if(offset == 0) {
t[0] = f[0];
t[1] = f[1];
t[2] = f[2];
}
else {
t[0] = f[2];
t[1] = f[3];
t[2] = f[0];
}
if(offset == 0 && f[3])
offset++;
else {
offset = 0;
curface++;
}
return 1;
}
int getNumTriangles()
{
return tottri;
}
int getNumVertices()
{
return input_mesh->totco;
}
float getBoundingBox(float origin[3])
{
veccopy(origin, min);
return maxsize ;
}
/* output */
void getNextVertex(float v[3])
{
/* not used */
}
/* stubs */
void printInfo() {}
int getMemory() { return sizeof(DualConInputReader); }
};
void *dualcon(const DualConInput *input_mesh,
/* callbacks for output */
DualConAllocOutput alloc_output,
DualConAddVert add_vert,
DualConAddQuad add_quad,
DualConFlags flags,
DualConMode mode,
float threshold,
float hermite_num,
float scale,
int depth)
{
DualConInputReader r(input_mesh, scale);
Octree o(&r, alloc_output, add_vert, add_quad,
flags, mode, depth, threshold, hermite_num);
o.scanConvert();
return o.getOutputMesh();
}

View File

@@ -0,0 +1,282 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Tao Ju
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "manifold_table.h"
const ManifoldIndices manifold_table[256] = {
{0, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}}},
{2, {{0, 0}, {1, 1}, {2, 2}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}}},
{2, {{1, 1}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {0, 0}, {2, 2}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}}},
{3, {{1, 1}, {2, 2}, {3, 3}, {0, 0}, {3, 3}, {2, 2}, {1, 1}, {0, 0}, {2, 2}, {3, 3}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {0, 0}, {0, 0}, {2, 2}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {0, 0}}},
{2, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {2, 2}, {1, 1}, {2, 2}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {0, 0}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {2, 2}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {0, 0}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {2, 2}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{2, {{0, 0}, {1, 1}, {2, 2}, {0, 0}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {1, 1}, {2, 2}, {0, 0}}},
{2, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {2, 2}, {2, 2}, {1, 1}, {2, 2}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}}},
{2, {{0, 0}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {1, 1}, {0, 0}}},
{3, {{1, 1}, {2, 2}, {0, 0}, {3, 3}, {1, 1}, {3, 3}, {0, 0}, {2, 2}, {1, 1}, {3, 3}, {2, 2}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}}},
{2, {{0, 0}, {1, 1}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {2, 2}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{2, {{1, 1}, {1, 1}, {2, 2}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}}},
{2, {{1, 1}, {0, 0}, {2, 2}, {0, 0}, {2, 2}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {2, 2}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}}},
{2, {{1, 1}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {2, 2}, {1, 1}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {0, 0}}},
{2, {{0, 0}, {1, 1}, {0, 0}, {2, 2}, {1, 1}, {2, 2}, {1, 1}, {1, 1}, {1, 1}, {2, 2}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}}},
{2, {{1, 1}, {1, 1}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{2, {{0, 0}, {2, 2}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {1, 2}, {2, 2}, {2, 1}, {0, 0}, {0, 0}, {0, 0}}},
{2, {{1, 1}, {0, 0}, {2, 2}, {1, 2}, {2, 2}, {0, 0}, {1, 1}, {1, 1}, {2, 1}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}}},
{2, {{1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {2, 2}}},
{2, {{0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {2, 2}}},
{2, {{1, 1}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {2, 2}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}}},
{2, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {2, 2}}},
{1, {{1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}}},
{2, {{0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {0, 0}, {1, 1}}},
{3, {{1, 1}, {0, 0}, {2, 2}, {3, 3}, {1, 1}, {3, 3}, {2, 2}, {0, 0}, {1, 1}, {3, 3}, {0, 0}, {2, 2}}},
{2, {{0, 0}, {1, 1}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {2, 2}}},
{2, {{1, 1}, {1, 1}, {2, 2}, {1, 1}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {2, 2}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}}},
{2, {{1, 1}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {0, 0}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {1, 1}}},
{1, {{0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}},
{2, {{1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {1, 1}, {1, 1}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}}},
{2, {{1, 1}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {1, 1}}},
{2, {{0, 0}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {1, 1}}},
{2, {{1, 1}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {2, 2}, {2, 2}, {1, 1}, {1, 1}}},
{2, {{0, 0}, {1, 2}, {1, 1}, {2, 2}, {2, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {1, 1}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}}},
{2, {{2, 2}, {1, 1}, {0, 0}, {1, 1}, {2, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {1, 2}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}}},
{2, {{0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {2, 2}}},
{3, {{1, 1}, {2, 2}, {3, 3}, {0, 0}, {1, 1}, {0, 0}, {3, 3}, {2, 2}, {1, 1}, {0, 0}, {2, 2}, {3, 3}}},
{2, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, {0, 0}, {2, 2}, {1, 1}}},
{2, {{1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {1, 1}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {2, 2}}},
{2, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {2, 2}, {1, 1}, {2, 2}}},
{2, {{1, 1}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {1, 1}, {2, 2}, {1, 1}}},
{2, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, {1, 1}, {2, 2}, {1, 1}}},
{2, {{2, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {0, 0}, {1, 2}, {1, 1}, {2, 2}}},
{3, {{0, 0}, {1, 1}, {2, 2}, {3, 3}, {0, 0}, {3, 3}, {2, 2}, {1, 1}, {0, 0}, {3, 3}, {1, 1}, {2, 2}}},
{4, {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 1}, {4, 4}, {3, 3}, {2, 2}, {1, 1}, {4, 4}, {2, 2}, {3, 3}}},
{2, {{0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {1, 1}}},
{2, {{1, 1}, {0, 0}, {2, 2}, {1, 1}, {1, 1}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {2, 2}}},
{2, {{0, 0}, {1, 1}, {0, 0}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {2, 2}}},
{2, {{1, 1}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {2, 2}, {1, 1}, {0, 0}, {2, 2}, {1, 1}}},
{2, {{0, 0}, {0, 0}, {0, 0}, {2, 1}, {1, 1}, {0, 0}, {1, 1}, {2, 2}, {1, 2}, {0, 0}, {2, 2}, {1, 1}}},
{2, {{1, 2}, {0, 0}, {0, 0}, {2, 1}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {2, 2}, {1, 1}}},
{1, {{1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {1, 1}}},
{2, {{2, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {1, 2}, {2, 2}, {1, 1}, {0, 0}, {1, 1}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}}},
{2, {{1, 1}, {1, 1}, {1, 1}, {2, 2}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 1}}},
{2, {{0, 0}, {1, 1}, {1, 1}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {1, 1}, {2, 2}, {0, 0}, {1, 1}}},
{2, {{1, 2}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {2, 1}, {1, 1}, {1, 1}, {0, 0}, {2, 2}}},
{2, {{0, 0}, {0, 0}, {2, 2}, {1, 1}, {1, 2}, {0, 0}, {0, 0}, {2, 1}, {0, 0}, {1, 1}, {0, 0}, {2, 2}}},
{2, {{1, 1}, {1, 1}, {0, 0}, {2, 2}, {1, 2}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {2, 1}}},
{2, {{0, 0}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {1, 2}, {0, 0}, {0, 0}, {2, 1}}},
{2, {{1, 1}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {2, 2}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}}},
{2, {{1, 1}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {2, 2}}},
{2, {{0, 0}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {2, 2}}},
{2, {{1, 1}, {1, 1}, {0, 0}, {2, 2}, {1, 1}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {2, 2}}},
{2, {{0, 0}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {2, 2}}},
{2, {{1, 1}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {1, 1}, {0, 0}, {2, 2}}},
{3, {{0, 0}, {1, 1}, {2, 2}, {3, 3}, {2, 2}, {1, 1}, {0, 0}, {3, 3}, {1, 1}, {2, 2}, {0, 0}, {3, 3}}},
{2, {{1, 1}, {1, 1}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {2, 2}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}}},
{2, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {2, 2}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {1, 1}}},
{1, {{1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}}},
{2, {{1, 1}, {0, 0}, {0, 0}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}}},
{2, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {2, 2}, {1, 1}}},
{3, {{1, 1}, {2, 2}, {0, 0}, {3, 3}, {0, 0}, {2, 2}, {1, 1}, {3, 3}, {2, 2}, {0, 0}, {1, 1}, {3, 3}}},
{2, {{0, 0}, {1, 1}, {0, 0}, {2, 2}, {1, 1}, {1, 1}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}}},
{3, {{1, 1}, {0, 0}, {2, 2}, {3, 3}, {2, 2}, {0, 0}, {1, 1}, {3, 3}, {0, 0}, {2, 2}, {1, 1}, {3, 3}}},
{2, {{0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {1, 1}, {1, 1}, {2, 2}}},
{4, {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {3, 3}, {2, 2}, {1, 1}, {4, 4}, {2, 2}, {3, 3}, {1, 1}, {4, 4}}},
{2, {{0, 0}, {1, 1}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {1, 1}, {2, 2}}},
{2, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {2, 2}, {1, 1}, {2, 2}}},
{2, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {2, 2}, {1, 1}, {2, 2}, {1, 1}, {2, 2}}},
{2, {{1, 1}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {2, 2}, {2, 2}, {1, 1}, {2, 2}}},
{2, {{0, 0}, {2, 1}, {0, 0}, {0, 0}, {1, 2}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {1, 1}, {2, 2}, {1, 1}}},
{2, {{1, 1}, {0, 0}, {2, 2}, {0, 0}, {2, 2}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}}},
{2, {{0, 0}, {0, 0}, {2, 1}, {0, 0}, {0, 0}, {1, 2}, {1, 1}, {2, 2}, {1, 1}, {0, 0}, {1, 1}, {2, 2}}},
{2, {{1, 1}, {2, 2}, {2, 2}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {2, 2}, {2, 2}, {0, 0}, {1, 1}, {2, 2}}},
{2, {{0, 0}, {1, 2}, {2, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}}},
{2, {{1, 1}, {2, 2}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {2, 2}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}}},
{2, {{0, 0}, {1, 1}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {1, 1}}},
{2, {{1, 1}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {2, 2}, {2, 2}}},
{2, {{0, 0}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {2, 2}, {2, 2}}},
{2, {{1, 1}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {2, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 2}, {2, 2}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}}},
{2, {{1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {2, 2}, {2, 2}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}}},
{1, {{0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}}},
{2, {{2, 2}, {1, 1}, {1, 2}, {0, 0}, {0, 0}, {2, 1}, {0, 0}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {1, 1}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}}},
{1, {{1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}}},
{1, {{1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}}},
{2, {{1, 1}, {1, 1}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {0, 0}, {1, 1}}},
{2, {{0, 0}, {1, 1}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {2, 1}, {0, 0}, {1, 2}, {2, 2}, {0, 0}, {1, 1}}},
{2, {{1, 1}, {0, 0}, {2, 2}, {1, 1}, {2, 2}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {1, 1}}},
{2, {{0, 0}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {1, 2}, {2, 1}, {0, 0}, {0, 0}, {2, 2}, {0, 0}, {1, 1}}},
{1, {{1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}}},
{2, {{0, 0}, {2, 1}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {1, 2}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}}},
{2, {{2, 2}, {1, 2}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {2, 1}}},
{2, {{0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {2, 2}}},
{2, {{2, 2}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 2}, {0, 0}, {0, 0}, {2, 1}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{2, {{1, 1}, {0, 0}, {2, 2}, {2, 2}, {1, 1}, {0, 0}, {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{2, {{0, 0}, {1, 1}, {2, 2}, {2, 2}, {0, 0}, {1, 1}, {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{2, {{1, 1}, {1, 1}, {2, 2}, {2, 2}, {1, 1}, {1, 1}, {2, 2}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}}},
{2, {{0, 0}, {1, 1}, {0, 0}, {2, 2}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {0, 0}}},
{2, {{1, 2}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {1, 1}, {1, 1}, {0, 0}, {2, 1}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}}},
{2, {{1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {2, 2}, {2, 2}, {2, 2}, {1, 1}, {2, 2}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}}},
{2, {{1, 1}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {1, 2}, {0, 0}, {2, 1}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {1, 1}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {0, 0}}},
{2, {{0, 0}, {1, 1}, {1, 2}, {2, 2}, {1, 1}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {0, 0}, {2, 1}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {0, 0}, {1, 1}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {1, 1}, {0, 0}}},
{2, {{0, 0}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 2}, {2, 1}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}}},
{2, {{0, 0}, {0, 0}, {2, 1}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {1, 2}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {2, 1}, {2, 2}, {1, 2}, {1, 1}, {0, 0}}},
{2, {{0, 0}, {1, 1}, {2, 2}, {0, 0}, {2, 2}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {1, 1}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {0, 0}, {0, 0}, {1, 2}, {0, 0}, {0, 0}, {2, 1}, {2, 2}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {2, 2}, {2, 2}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}}},
{2, {{2, 2}, {0, 0}, {1, 1}, {1, 1}, {2, 2}, {1, 2}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {2, 1}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {0, 0}, {1, 2}, {0, 0}, {0, 0}, {2, 1}, {0, 0}, {1, 1}, {1, 1}, {2, 2}, {0, 0}}},
{2, {{0, 0}, {0, 0}, {0, 0}, {2, 1}, {2, 2}, {1, 1}, {1, 2}, {0, 0}, {1, 1}, {2, 2}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {0, 0}, {0, 0}, {2, 2}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {2, 2}, {0, 0}, {1, 1}, {2, 2}, {2, 2}, {0, 0}, {1, 1}, {2, 2}, {2, 2}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {0, 0}, {2, 2}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {0, 0}, {0, 0}, {2, 1}, {1, 2}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{2, {{1, 1}, {2, 2}, {0, 0}, {0, 0}, {0, 0}, {1, 2}, {2, 1}, {0, 0}, {1, 1}, {0, 0}, {2, 2}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}}},
{1, {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {1, 1}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}}},
{2, {{1, 2}, {0, 0}, {0, 0}, {2, 1}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}}},
{2, {{0, 0}, {1, 2}, {2, 1}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, {2, 2}, {1, 1}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {0, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{1, {{1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}}},
{0, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}}
};

View File

@@ -0,0 +1,33 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Tao Ju
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef MANIFOLD_TABLE_H
#define MANIFOLD_TABLE_H
typedef struct {
int comps;
int pairs[12][2];
} ManifoldIndices;
extern const ManifoldIndices manifold_table[256];
#endif

View File

@@ -0,0 +1,554 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Tao Ju
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "marching_cubes_table.h"
/* number of triangles in each configuration */
const int marching_cubes_numtri[TOTCONF] = {
0, 1, 1, 2, 1, 2, 4, 3, 1, 4, 2, 3, 2, 3, 3, 2, 1, 2, 4, 3, 4, 3, 5, 4,
6, 5, 5, 4, 5, 4, 4, 3, 1, 4, 2, 3, 6, 5, 5, 4, 4, 5, 3, 4, 5, 4, 4, 3,
2, 3, 3, 2, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2, 1, 4, 6, 5, 2, 3, 5, 4,
4, 5, 5, 4, 3, 4, 4, 3, 2, 3, 5, 4, 3, 2, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2,
4, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2, 3, 4, 4, 3, 4, 3, 3, 2,
4, 3, 3, 2, 3, 2, 2, 1, 1, 6, 4, 5, 4, 5, 5, 4, 2, 5, 3, 4, 3, 4, 4, 3,
4, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2, 2, 5, 3, 4, 5, 4, 4, 3,
3, 4, 2, 3, 4, 3, 3, 2, 3, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1,
2, 5, 5, 4, 3, 4, 4, 3, 3, 4, 4, 3, 2, 3, 3, 2, 3, 4, 4, 3, 4, 3, 3, 2,
4, 3, 3, 2, 3, 2, 2, 1, 3, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1,
2, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0
};
/* table of triangles in each configuration */
const int marching_cubes_tris[TOTCONF][MAX_TRIS][3] = {
{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,0,8}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,1,5}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,0,1}, {4,1,5}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,9,2}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,8,9}, {0,9,2}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,5,9}, {1,9,2}, {1,2,4}, {1,4,8}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,1,5}, {0,5,9}, {0,9,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,3,9}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,8,5}, {0,5,3}, {0,3,9}, {0,9,4}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,1,3}, {8,3,9}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,0,1}, {4,1,3}, {4,3,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,5,3}, {4,3,2}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,8,5}, {0,5,3}, {0,3,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,1}, {4,1,3}, {4,3,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,1,3}, {0,3,2}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,6,10}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,4,6}, {8,6,10}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,10,1}, {6,1,5}, {6,5,8}, {6,8,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,6,10}, {4,10,1}, {4,1,5}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,0,4}, {10,4,9}, {10,9,2}, {10,2,6}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,10,8}, {6,8,9}, {6,9,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {6,10,1}, {6,1,5}, {6,5,9}, {6,9,2},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,10,1}, {6,1,5}, {6,5,9}, {6,9,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,0,5}, {0,6,9}, {9,5,0}, {6,10,3}, {5,3,10},
{3,9,6}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,8,5}, {10,5,3}, {9,4,6}, {6,10,3}, {6,3,9},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,3}, {9,8,0}, {9,0,6}, {6,10,3}, {6,3,9},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,6,10}, {4,10,1}, {4,1,3}, {4,3,9}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,4,5}, {3,2,6}, {3,6,10}, {10,0,5}, {10,5,3},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,10,8}, {6,8,5}, {6,5,3}, {6,3,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {6,10,1}, {6,1,3}, {6,3,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,10,1}, {6,1,3}, {6,3,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,7,1}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,0,10}, {4,10,7}, {4,7,1}, {4,1,8}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,10,7}, {8,7,5}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,0,10}, {4,10,7}, {4,7,5}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,2,4}, {10,4,1}, {7,2,10}, {1,9,7}, {1,4,9},
{9,2,7}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,8,9}, {2,0,10}, {2,10,7}, {7,1,9}, {7,9,2},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,10}, {7,5,9}, {7,9,2}, {2,4,10}, {2,10,7},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,7}, {0,7,5}, {0,5,9}, {0,9,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,7,3}, {10,3,9}, {10,9,5}, {10,5,1}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,5,1}, {4,0,10}, {4,10,7}, {4,7,3}, {4,3,9},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,10,7}, {8,7,3}, {8,3,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,0,10}, {4,10,7}, {4,7,3}, {4,3,9}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,5,1}, {4,1,10}, {7,3,2}, {2,4,10}, {2,10,7},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,5,1}, {0,10,7}, {0,7,3}, {0,3,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,10}, {4,10,7}, {4,7,3}, {4,3,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,7}, {0,7,3}, {0,3,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,6,7}, {0,7,1}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,4,6}, {8,6,7}, {8,7,1}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,0,6}, {8,6,7}, {8,7,5}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,6,7}, {4,7,5}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,0,4}, {1,4,9}, {2,6,7}, {7,1,9}, {7,9,2},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,7,1}, {6,1,8}, {6,8,9}, {6,9,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {6,7,5}, {6,5,9}, {6,9,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,7,5}, {6,5,9}, {6,9,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,1,0}, {6,7,3}, {6,3,9}, {9,5,0}, {9,0,6},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,5,1}, {4,6,7}, {4,7,3}, {4,3,9}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,0,6}, {8,6,7}, {8,7,3}, {8,3,9}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,6,7}, {4,7,3}, {4,3,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,4,5}, {0,5,1}, {6,7,3}, {6,3,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,5,1}, {6,7,3}, {6,3,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {6,7,3}, {6,3,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,7,3}, {6,3,2}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,2,11}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,4,2}, {8,2,11}, {8,11,6}, {8,6,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,1,6}, {6,1,11}, {11,1,5}, {2,11,5}, {2,5,8},
{6,2,8}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,0,1}, {5,4,2}, {5,2,11}, {11,6,1}, {11,1,5},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,4,9}, {6,9,11}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,0,8}, {6,8,9}, {6,9,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,4,8}, {6,8,1}, {5,9,11}, {11,6,1}, {11,1,5},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,0,1}, {6,1,5}, {6,5,9}, {6,9,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,2,9}, {6,9,5}, {6,5,3}, {6,3,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,2,9}, {6,0,8}, {6,8,5}, {6,5,3}, {6,3,11},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{2,9,8}, {1,3,11}, {1,11,6}, {6,2,8}, {6,8,1},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,2,9}, {6,0,1}, {6,1,3}, {6,3,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,4,5}, {6,5,3}, {6,3,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,0,8}, {6,8,5}, {6,5,3}, {6,3,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,4,8}, {6,8,1}, {6,1,3}, {6,3,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,0,1}, {6,1,3}, {6,3,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,0,2}, {10,2,11}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,8,4}, {10,4,2}, {10,2,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,0,2}, {11,10,1}, {11,1,5}, {5,8,2}, {5,2,11},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,5}, {10,5,4}, {10,4,2}, {10,2,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,0,4}, {10,4,9}, {10,9,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,8,9}, {10,9,11}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {10,1,5}, {10,5,9}, {10,9,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,5}, {10,5,9}, {10,9,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,2,9}, {0,9,5}, {3,11,10}, {10,0,5}, {10,5,3},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,2,9}, {10,8,5}, {10,5,3}, {10,3,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,0,2}, {8,2,9}, {10,1,3}, {10,3,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,2,9}, {10,1,3}, {10,3,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,0,4}, {10,4,5}, {10,5,3}, {10,3,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,8,5}, {10,5,3}, {10,3,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {10,1,3}, {10,3,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,3}, {10,3,11}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,10,6}, {1,6,2}, {1,2,11}, {1,11,7}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {7,1,8}, {7,8,4}, {7,4,2}, {7,2,11},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,10,6}, {8,6,2}, {11,7,5}, {5,8,2}, {5,2,11},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {7,5,4}, {7,4,2}, {7,2,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,6,4}, {9,11,7}, {9,7,1}, {1,10,4}, {1,4,9},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {7,1,8}, {7,8,9}, {7,9,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,10}, {4,10,6}, {7,5,9}, {7,9,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {7,5,9}, {7,9,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,1,10}, {5,10,6}, {5,6,2}, {5,2,9}, {7,3,11},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {8,5,1}, {4,2,9}, {7,3,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,10,6}, {8,6,2}, {8,2,9}, {7,3,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {4,2,9}, {7,3,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,6,4}, {10,4,5}, {10,5,1}, {7,3,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {8,5,1}, {7,3,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,10}, {4,10,6}, {7,3,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {7,3,11}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,1,0}, {7,0,2}, {7,2,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,1,8}, {7,8,4}, {7,4,2}, {7,2,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,5,8}, {7,8,0}, {7,0,2}, {7,2,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,5,4}, {7,4,2}, {7,2,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,1,0}, {7,0,4}, {7,4,9}, {7,9,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,1,8}, {7,8,9}, {7,9,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {7,5,9}, {7,9,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,5,9}, {7,9,11}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,1,0}, {5,0,2}, {5,2,9}, {7,3,11}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,5,1}, {4,2,9}, {7,3,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,0,2}, {8,2,9}, {7,3,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,2,9}, {7,3,11}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,4,5}, {0,5,1}, {7,3,11}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,5,1}, {7,3,11}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {7,3,11}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,3,11}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,11,3}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,11,0}, {7,0,8}, {0,11,4}, {8,3,7}, {11,3,4},
{3,8,4}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,1,7}, {8,7,11}, {8,11,3}, {8,3,5}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,1,7}, {0,7,11}, {3,5,4}, {4,0,11}, {4,11,3},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,9,3}, {4,3,7}, {4,7,11}, {4,11,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,9,3}, {8,3,7}, {11,2,0}, {0,8,7}, {0,7,11},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,9,3}, {4,8,1}, {4,1,7}, {4,7,11}, {4,11,2},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,9,3}, {0,1,7}, {0,7,11}, {0,11,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,7,11}, {5,11,9}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,5,7}, {11,9,4}, {11,4,0}, {0,8,7}, {0,7,11},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,1,7}, {8,7,11}, {8,11,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,0,1}, {4,1,7}, {4,7,11}, {4,11,9}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,5,7}, {4,7,11}, {4,11,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,8,5}, {0,5,7}, {0,7,11}, {0,11,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,1}, {4,1,7}, {4,7,11}, {4,11,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,1,7}, {0,7,11}, {0,11,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,6,11}, {0,11,3}, {0,3,7}, {0,7,10}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,10,8}, {4,6,11}, {4,11,3}, {3,7,8}, {3,8,4},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,7}, {5,8,0}, {5,0,6}, {5,6,11}, {5,11,3},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,7}, {5,4,6}, {5,6,11}, {5,11,3}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,10,0}, {7,0,4}, {7,4,9}, {7,9,3}, {6,11,2},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,10,8}, {7,8,9}, {7,9,3}, {6,11,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {10,1,7}, {5,9,3}, {6,11,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,7}, {5,9,3}, {6,11,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,7,10}, {5,10,0}, {6,11,9}, {9,5,0}, {9,0,6},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,8,5}, {10,5,7}, {4,6,11}, {4,11,9}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,7}, {8,0,6}, {8,6,11}, {8,11,9}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,7}, {4,6,11}, {4,11,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,0,4}, {10,4,5}, {10,5,7}, {6,11,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,8,5}, {10,5,7}, {6,11,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {10,1,7}, {6,11,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,7}, {6,11,2}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,10,11}, {1,11,3}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,11}, {3,1,8}, {3,8,4}, {4,0,11}, {4,11,3},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,8,10}, {5,10,11}, {5,11,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,4,0}, {5,0,10}, {5,10,11}, {5,11,3}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{9,3,1}, {10,11,2}, {10,2,4}, {4,9,1}, {4,1,10},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,8,9}, {1,9,3}, {0,10,11}, {0,11,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,9,3}, {4,8,10}, {4,10,11}, {4,11,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,9,3}, {0,10,11}, {0,11,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,1,10}, {5,10,11}, {5,11,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,5,1}, {4,0,10}, {4,10,11}, {4,11,9}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,10,11}, {8,11,9}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,0,10}, {4,10,11}, {4,11,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,5,1}, {4,1,10}, {4,10,11}, {4,11,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,5,1}, {0,10,11}, {0,11,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,10}, {4,10,11}, {4,11,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,11}, {0,11,2}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,0,6}, {1,6,11}, {1,11,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,8,4}, {1,4,6}, {1,6,11}, {1,11,3}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,8,0}, {5,0,6}, {5,6,11}, {5,11,3}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,4,6}, {5,6,11}, {5,11,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,0,4}, {1,4,9}, {1,9,3}, {6,11,2}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,8,9}, {1,9,3}, {6,11,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {5,9,3}, {6,11,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,9,3}, {6,11,2}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,1,0}, {5,0,6}, {5,6,11}, {5,11,9}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,5,1}, {4,6,11}, {4,11,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,0,6}, {8,6,11}, {8,11,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,6,11}, {4,11,9}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,4,5}, {0,5,1}, {6,11,2}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,5,1}, {6,11,2}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {6,11,2}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,11,2}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,6,2}, {7,2,3}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,6,0}, {7,0,8}, {4,2,3}, {3,7,8}, {3,8,4},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,7,6}, {2,3,5}, {2,5,8}, {8,1,6}, {8,6,2},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,0,1}, {6,1,7}, {5,4,2}, {5,2,3}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,6,4}, {7,4,9}, {7,9,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,6,0}, {7,0,8}, {7,8,9}, {7,9,3}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,4,8}, {6,8,1}, {6,1,7}, {5,9,3}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,0,1}, {6,1,7}, {5,9,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,7,6}, {5,6,2}, {5,2,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,0,8}, {6,8,5}, {6,5,7}, {4,2,9}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,1,7}, {8,7,6}, {8,6,2}, {8,2,9}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,0,1}, {6,1,7}, {4,2,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,4,5}, {6,5,7}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,0,8}, {6,8,5}, {6,5,7}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,4,8}, {6,8,1}, {6,1,7}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{6,0,1}, {6,1,7}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,10,0}, {7,0,2}, {7,2,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,10,8}, {7,8,4}, {7,4,2}, {7,2,3}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,7}, {5,8,0}, {5,0,2}, {5,2,3}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,7}, {5,4,2}, {5,2,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,10,0}, {7,0,4}, {7,4,9}, {7,9,3}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{7,10,8}, {7,8,9}, {7,9,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {10,1,7}, {5,9,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,7}, {5,9,3}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,7,10}, {5,10,0}, {5,0,2}, {5,2,9}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,8,5}, {10,5,7}, {4,2,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,7}, {8,0,2}, {8,2,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,7}, {4,2,9}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,0,4}, {10,4,5}, {10,5,7}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,8,5}, {10,5,7}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {10,1,7}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,1,7}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,10,6}, {1,6,2}, {1,2,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {1,8,4}, {1,4,2}, {1,2,3}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,8,10}, {5,10,6}, {5,6,2}, {5,2,3}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {5,4,2}, {5,2,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,10,6}, {1,6,4}, {1,4,9}, {1,9,3}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {1,8,9}, {1,9,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,10}, {4,10,6}, {5,9,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {5,9,3}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,1,10}, {5,10,6}, {5,6,2}, {5,2,9}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {8,5,1}, {4,2,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,10,6}, {8,6,2}, {8,2,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {4,2,9}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{10,6,4}, {10,4,5}, {10,5,1}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {8,5,1}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,10}, {4,10,6}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,10,6}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,0,2}, {1,2,3}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,8,4}, {1,4,2}, {1,2,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,8,0}, {5,0,2}, {5,2,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,4,2}, {5,2,3}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,0,4}, {1,4,9}, {1,9,3}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{1,8,9}, {1,9,3}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {5,9,3}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,9,3}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{5,1,0}, {5,0,2}, {5,2,9}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,5,1}, {4,2,9}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,0,2}, {8,2,9}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,2,9}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,4,5}, {0,5,1}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{8,5,1}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{4,8,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}
};

View File

@@ -0,0 +1,38 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Tao Ju
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef MARCHING_CUBES_TABLE_H
#define MARCHING_CUBES_TABLE_H
/* number of configurations */
#define TOTCONF 256
/* maximum number of triangles per configuration */
#define MAX_TRIS 10
/* number of triangles in each configuration */
extern const int marching_cubes_numtri[TOTCONF];
/* table of triangles in each configuration */
extern const int marching_cubes_tris[TOTCONF][MAX_TRIS][3];
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,112 @@
PolyMender program for robustly repairing a polygonal model.
Author: Tao Ju (jutao@cs.wustl.edu)
Version: 1.6 (Updated: Oct. 12, 2006)
Platform: Windows
I. What's new in v1.6:
> Removal of disconnected components
> Topologically manifold dual contouring
> Output signed octree with geometry
II. Introduction
PolyMender is based on the algorithm presented in the paper "Robust Repair of Polygonal Models" (SIGGRAPH 2004). The program reads in a polygonal model (i.e., a bag of polygons) and produces a closed surface that approximates the original model. PolyMender consumes a small amount of time and memory space, and can accurately reproduce the original geometry. PolyMender is suitable for repairing CAD models and gigantic polygonal models. Alternatively, PolyMender can also be used to generate a signed volume from any polygonal models.
III. How to run
The executable package contains three programs:
1. PolyMender, PolyMender-clean
Purpose: repairs general purpose models, such as those created from range scanners. The repaired surface is constructed using Marching Cubes. Consumes minimal memory and time and generates closed, manifold triangular surfaces. The -clean option removes isolated pieces.
2. PolyMender-qd, PolyMender-qd-clean
Purpose: same as PolyMender and PolyMender-clean, but outputs a quad-mesh.
3. PolyMender-dc, PolyMender-dc-clean
Purpose: repairs models containing sharp features, such as CAD models. The repaired surface is constructed using Dual Contouring with a manifold topology, which is capable of reproducing sharp edges and corners. However, more memory is required. Generates closed triangular and quadrilateral surfaces. The -clean option removes isolated pieces.
Type the program names (e.g., PolyMender) on the DOS prompt and you will see their usages:
Usage: PolyMender <input_file> <octree_depth> <scale> <output_file>
Example: PolyMender bunny.ply 6 0.9 closedbunny.ply
Description:
<input_file> Polygonal file of format STL (binary only), ASC, or PLY.
<octree_depth> Integer depth of octree. The dimension of the volumetric
grid is 2^<octree_depth> on each side.
<scale> Floating point number between 0 and 1 denoting the ratio of
the largest dimension of the model over the size of the grid.
<output_file> Output in polygonal format PLY or signed-octree format SOF (or SOG).
Additional notes:
1. STL(binary) is preferred input format, since the program does not need to store the model in memory at all. ASC or PLY formats require additional storage of vertices, due to their topology-geometry file structure.
2. The running time and memory consumption of the program depends on several factors: the number of input polygons, the depth of the octree, and the surface area of the model (hence the number of leaf nodes on the octree). To give an idea, processing the David model with 56 million triangles at depth 13 takes 45 minutes using 500 MB RAM (excluding the mem allocated for storing vertices when reading PLY format) on a PC with AMD 1.5Hz CPU.
3. The number of output polygons can be finely controlled using the scale argument. The large the scale, the more polygons are generated, since the model occupies a larger portion of the volume grid.
4. As an alternative of output repaired models, the intermediate signed octree can be generated as a SOF or SOG file. The signed octree can be used for generating signed distance field, extracting isosurfaces, or multiresolution spatial representation of the polygonal model.
IV SOF format
SOF (Signed Octree Format) records an octree grid with signes attached to the 8 corners of each leaf node. All leaf nodes appear at the same depth that is specified by the <octree_depth> argument to the program. The tree is recorded in SOF file using pre-order traversal. Here is the structure of a SOF file (binary):
<header>
<node>
<header> is a 4-bytes integer that equals 2 ^ octree_depth. The first byte of a <node> is either 0 (denoting an intermediate node) or 1 (denoting an empty node) or 2 (denoting a leaf node). After the first byte, an intermediate node <node> contains (after the first byte) eight <node> structures for its eight children; an empty node <node> contains one byte of value 0 or 1 denoting if it is inside or outside; and a leaf node contains one byte whose eight bits correspond to the signs at its eight corners (0 for inside and 1 for outside). The order of enumeration of the eight children nodes in an intermediate nodeis the following (expressed in coordinates <x,y,z> ): <0,0,0>,<0,0,1>,<0,1,0>,<0,1,1>,<1,0,0>,<1,0,1>,<1,1,0>,<1,1,1>. The enumeration of the eight corners in a leaf node follows the same order (e.g., the lowest bit records the sign at <0,0,0>).
V SOG format
SOF (Signed Octree with Geometry) has the same data structure with SOG, with the addition of following features:
1. The file starts with a 128-byte long header. Currently, the header begins with the string "SOG.Format 1.0" followed by 3 floats representing the lower-left-near corner of the octree follwed by 1 float denoting the length of the octree (in one direction). The locations and lengths are in the input model's coordinate space. The rest of the header is left empty.
2. Each leaf node has additioanl three floats {x,y,z} (following the signs) denoting the geometric location of a feature vertex within the cell.
VI Test data
Three models are included in the testmodels package. (Suggested arguments are provided in the parathesis).
bunny.ply (octree depth: 7, scale: 0.9)
- The Stanford Bunny (containing big holes at the bottom)
horse.stl (octree depth: 8, scale: 0.9)
- The horse model with 1/3 of all polygons removed and vertices randomly perturbed.
mechanic.asc (octree depth: 6, scale: 0.9)
- A mechanic part with hanging triangles

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 213 KiB

View File

@@ -813,6 +813,20 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col.prop(md, "width", slider=True)
col.prop(md, "narrowness", slider=True)
def REMESH(self, layout, ob, md):
layout.prop(md, "mode")
layout.prop(md, "octree_depth")
layout.prop(md, "scale")
row = layout.row()
row.active = md.mode == "SHARP"
row.prop(md, "sharpness")
layout.prop(md, "remove_disconnected_pieces")
row = layout.row()
row.active = md.remove_disconnected_pieces
row.prop(md, "threshold")
@staticmethod
def vertex_weight_mask(layout, ob, md):
layout.label(text="Influence/Mask Options:")

View File

@@ -135,9 +135,9 @@ typedef struct IndexNode {
struct IndexNode *next, *prev;
int index;
} IndexNode;
void create_vert_face_map(ListBase **map, IndexNode **mem, const struct MFace *mface,
void create_vert_face_map(struct ListBase **map, IndexNode **mem, const struct MFace *mface,
const int totvert, const int totface);
void create_vert_edge_map(ListBase **map, IndexNode **mem, const struct MEdge *medge,
void create_vert_edge_map(struct ListBase **map, IndexNode **mem, const struct MEdge *medge,
const int totvert, const int totedge);
/* functions for making menu's from customdata layers */

File diff suppressed because it is too large Load Diff

View File

@@ -589,8 +589,8 @@ DEF_ICON(MOD_SOLIDIFY)
DEF_ICON(MOD_SCREW)
DEF_ICON(MOD_VERTEX_WEIGHT)
DEF_ICON(MOD_DYNAMICPAINT)
DEF_ICON(MOD_REMESH)
#ifndef DEF_ICON_BLANK_SKIP
DEF_ICON(BLANK162)
DEF_ICON(BLANK163)
DEF_ICON(BLANK164)
DEF_ICON(BLANK165)

View File

@@ -76,6 +76,7 @@ typedef enum ModifierType {
eModifierType_WeightVGProximity,
eModifierType_Ocean,
eModifierType_DynamicPaint,
eModifierType_Remesh,
NUM_MODIFIER_TYPES
} ModifierType;
@@ -1032,4 +1033,39 @@ typedef struct DynamicPaintModifierData {
int pad;
} DynamicPaintModifierData;
/* Remesh modifier */
typedef enum RemeshModifierFlags {
MOD_REMESH_FLOOD_FILL = 1,
} RemeshModifierFlags;
typedef enum RemeshModifierMode {
/* blocky */
MOD_REMESH_CENTROID = 0,
/* smooth */
MOD_REMESH_MASS_POINT = 1,
/* keeps sharp edges */
MOD_REMESH_SHARP_FEATURES = 2,
} RemeshModifierMode;
typedef struct RemeshModifierData {
ModifierData modifier;
/* floodfill option, controls how small components can be
before they are removed */
float threshold;
/* ratio between size of model and grid */
float scale;
float hermite_num;
/* octree depth */
char depth;
char flag;
char mode;
char pad;
} RemeshModifierData;
#endif

View File

@@ -69,6 +69,7 @@ EnumPropertyItem modifier_type_items[] ={
{eModifierType_Mask, "MASK", ICON_MOD_MASK, "Mask", ""},
{eModifierType_Mirror, "MIRROR", ICON_MOD_MIRROR, "Mirror", ""},
{eModifierType_Multires, "MULTIRES", ICON_MOD_MULTIRES, "Multiresolution", ""},
{eModifierType_Remesh, "REMESH", ICON_MOD_REMESH, "Remesh", ""},
{eModifierType_Screw, "SCREW", ICON_MOD_SCREW, "Screw", ""},
{eModifierType_Solidify, "SOLIDIFY", ICON_MOD_SOLIDIFY, "Solidify", ""},
{eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""},
@@ -199,6 +200,8 @@ static StructRNA* rna_Modifier_refine(struct PointerRNA *ptr)
return &RNA_VertexWeightProximityModifier;
case eModifierType_DynamicPaint:
return &RNA_DynamicPaintModifier;
case eModifierType_Remesh:
return &RNA_RemeshModifier;
default:
return &RNA_Modifier;
}
@@ -2867,6 +2870,57 @@ static void rna_def_modifier_weightvgproximity(BlenderRNA *brna)
rna_def_modifier_weightvg_mask(brna, srna);
}
static void rna_def_modifier_remesh(BlenderRNA *brna)
{
static EnumPropertyItem mode_items[]= {
{MOD_REMESH_CENTROID, "BLOCKS", 0, "Blocks", "Output a blocky surface with no smoothing"},
{MOD_REMESH_MASS_POINT, "SMOOTH", 0, "Smooth", "Output a smooth surface with no sharp-features detection"},
{MOD_REMESH_SHARP_FEATURES, "SHARP", 0, "Sharp", "Output a surface that reproduces sharp edges and corners from the input mesh"},
{0, NULL, 0, NULL, NULL}};
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "RemeshModifier", "Modifier");
RNA_def_struct_ui_text(srna, "Remesh Modifier", "Generate a new surface with regular topology that follows the shape of the input mesh");
RNA_def_struct_sdna(srna, "RemeshModifierData");
RNA_def_struct_ui_icon(srna, ICON_MOD_REMESH);
prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, mode_items);
RNA_def_property_ui_text(prop, "Mode", "");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_range(prop, 0, 0.99, 0.01, 3);
RNA_def_property_range(prop, 0, 0.99);
RNA_def_property_ui_text(prop, "Scale", "The ratio of the largest dimension of the model over the size of the grid");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop= RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
RNA_def_property_range(prop, 0, 1);
RNA_def_property_ui_text(prop, "Threshold", "If removing disconnected pieces, minimum size of components to preserve as a ratio of the number of polygons in the largest component");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop= RNA_def_property(srna, "octree_depth", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "depth");
RNA_def_property_range(prop, 1, 10);
RNA_def_property_ui_text(prop, "Octree Depth", "Resolution of the octree; higher values give finer details");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop= RNA_def_property(srna, "sharpness", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "hermite_num");
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Sharpness", "Tolerance for outliers; lower values filter noise while higher values will reproduce edges closer to the input");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop= RNA_def_property(srna, "remove_disconnected_pieces", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_REMESH_FLOOD_FILL);
RNA_def_property_ui_text(prop, "Remove Disconnected Pieces", "");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
static void rna_def_modifier_ocean(BlenderRNA *brna)
{
StructRNA *srna;
@@ -3148,6 +3202,7 @@ void RNA_def_modifier(BlenderRNA *brna)
rna_def_modifier_weightvgproximity(brna);
rna_def_modifier_dynamic_paint(brna);
rna_def_modifier_ocean(brna);
rna_def_modifier_remesh(brna);
}
#endif

View File

@@ -36,6 +36,7 @@ set(INC
../render/extern/include
../../../intern/elbeem/extern
../../../intern/guardedalloc
../../../intern/dualcon
)
set(INC_SYS
@@ -70,6 +71,7 @@ set(SRC
intern/MOD_ocean.c
intern/MOD_particleinstance.c
intern/MOD_particlesystem.c
intern/MOD_remesh.c
intern/MOD_screw.c
intern/MOD_shapekey.c
intern/MOD_shrinkwrap.c

View File

@@ -73,6 +73,7 @@ extern ModifierTypeInfo modifierType_WeightVGEdit;
extern ModifierTypeInfo modifierType_WeightVGMix;
extern ModifierTypeInfo modifierType_WeightVGProximity;
extern ModifierTypeInfo modifierType_DynamicPaint;
extern ModifierTypeInfo modifierType_Remesh;
/* MOD_util.c */
void modifier_type_init(ModifierTypeInfo *types[]);

View File

@@ -4,7 +4,7 @@ Import ('env')
sources = env.Glob('intern/*.c')
incs = '. ./intern'
incs += ' #/intern/guardedalloc #/intern/decimation/extern #/intern/bsp/extern #/intern/elbeem/extern #/extern/glew/include'
incs += ' #/intern/guardedalloc #/intern/decimation/extern #/intern/bsp/extern #/intern/elbeem/extern #/extern/glew/include #/intern/dualcon'
incs += ' ../render/extern/include ../blenloader'
incs += ' ../include ../blenlib ../makesdna ../makesrna ../blenkernel ../blenkernel/intern'
incs += ' ../gpu'

View File

@@ -0,0 +1,214 @@
/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* The Original Code is Copyright (C) 2011 by Nicholas Bishop.
*
* ***** END GPL LICENSE BLOCK *****
*
*/
/** \file blender/modifiers/intern/MOD_remesh.c
* \ingroup modifiers
*/
#include "MEM_guardedalloc.h"
#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_DerivedMesh.h"
#include "BKE_mesh.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "MOD_modifiertypes.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "dualcon.h"
static void initData(ModifierData *md)
{
RemeshModifierData *rmd = (RemeshModifierData*) md;
rmd->scale = 0.9;
rmd->depth = 4;
rmd->hermite_num = 1;
rmd->flag = MOD_REMESH_FLOOD_FILL;
rmd->mode = MOD_REMESH_SHARP_FEATURES;
rmd->threshold = 1;
}
static void copyData(ModifierData *md, ModifierData *target)
{
RemeshModifierData *rmd = (RemeshModifierData*) md;
RemeshModifierData *trmd = (RemeshModifierData*) target;
trmd->threshold = rmd->threshold;
trmd->scale = rmd->scale;
trmd->hermite_num = rmd->hermite_num;
trmd->depth = rmd->depth;
trmd->flag = rmd->flag;
trmd->mode = rmd->mode;
}
void init_dualcon_mesh(DualConInput *mesh, DerivedMesh *dm)
{
memset(mesh, 0, sizeof(DualConInput));
mesh->co = (void*)dm->getVertArray(dm);
mesh->co_stride = sizeof(MVert);
mesh->totco = dm->getNumVerts(dm);
mesh->faces = (void*)dm->getFaceArray(dm);
mesh->face_stride = sizeof(MFace);
mesh->totface = dm->getNumFaces(dm);
dm->getMinMax(dm, mesh->min, mesh->max);
}
/* simple structure to hold the output: a CDDM and two counters to
keep track of the current elements */
typedef struct {
DerivedMesh *dm;
int curvert, curface;
} DualConOutput;
/* allocate and initialize a DualConOutput */
void *dualcon_alloc_output(int totvert, int totquad)
{
DualConOutput *output;
if(!(output = MEM_callocN(sizeof(DualConOutput),
"DualConOutput")))
return NULL;
output->dm = CDDM_new(totvert, 0, totquad);
return output;
}
void dualcon_add_vert(void *output_v, const float co[3])
{
DualConOutput *output = output_v;
DerivedMesh *dm = output->dm;
assert(output->curvert < dm->getNumVerts(dm));
copy_v3_v3(CDDM_get_verts(dm)[output->curvert].co, co);
output->curvert++;
}
void dualcon_add_quad(void *output_v, const int vert_indices[4])
{
DualConOutput *output = output_v;
DerivedMesh *dm = output->dm;
MFace *mface;
assert(output->curface < dm->getNumFaces(dm));
mface = &CDDM_get_faces(dm)[output->curface];
mface->v1 = vert_indices[0];
mface->v2 = vert_indices[1];
mface->v3 = vert_indices[2];
mface->v4 = vert_indices[3];
if(test_index_face(mface, NULL, 0, 4))
output->curface++;
}
static DerivedMesh *applyModifier(ModifierData *md,
Object *UNUSED(ob),
DerivedMesh *dm,
int UNUSED(useRenderParams),
int UNUSED(isFinalCalc))
{
RemeshModifierData *rmd;
DualConOutput *output;
DualConInput input;
DerivedMesh *result;
DualConFlags flags = 0;
DualConMode mode;
rmd = (RemeshModifierData*)md;
init_dualcon_mesh(&input, dm);
if(rmd->flag & MOD_REMESH_FLOOD_FILL)
flags |= DUALCON_FLOOD_FILL;
switch(rmd->mode) {
case MOD_REMESH_CENTROID:
mode = DUALCON_CENTROID;
break;
case MOD_REMESH_MASS_POINT:
mode = DUALCON_MASS_POINT;
break;
case MOD_REMESH_SHARP_FEATURES:
mode = DUALCON_SHARP_FEATURES;
break;
}
output = dualcon(&input,
dualcon_alloc_output,
dualcon_add_vert,
dualcon_add_quad,
flags,
mode,
rmd->threshold,
rmd->hermite_num,
rmd->scale,
rmd->depth);
result = output->dm;
CDDM_lower_num_faces(result, output->curface);
MEM_freeN(output);
CDDM_calc_edges(result);
CDDM_calc_normals(result);
return result;
}
ModifierTypeInfo modifierType_Remesh = {
/* name */ "Remesh",
/* structName */ "RemeshModifierData",
/* structSize */ sizeof(RemeshModifierData),
/* type */ eModifierTypeType_Nonconstructive,
/* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode,
/* copyData */ copyData,
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
/* applyModifier */ applyModifier,
/* applyModifierEM */ NULL,
/* initData */ initData,
/* requiredDataMask */ NULL,
/* freeData */ NULL,
/* isDisabled */ NULL,
/* updateDepgraph */ NULL,
/* dependsOnTime */ NULL,
/* dependsOnNormals */ NULL,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
};

View File

@@ -276,5 +276,6 @@ void modifier_type_init(ModifierTypeInfo *types[])
INIT_TYPE(WeightVGMix);
INIT_TYPE(WeightVGProximity);
INIT_TYPE(DynamicPaint);
INIT_TYPE(Remesh);
#undef INIT_TYPE
}

View File

@@ -464,6 +464,17 @@ void BPY_DECREF(void *pyob_ptr) {}
void BPY_pyconstraint_exec(struct bPythonConstraint *con, struct bConstraintOb *cob, struct ListBase *targets) {}
void macro_wrapper(struct wmOperatorType *ot, void *userdata) {} ;
/* intern/dualcon */
struct DualConMesh;
struct DualConMesh *dualcon(const struct DualConMesh *input_mesh,
void *create_mesh,
int flags,
int mode,
float threshold,
float hermite_num,
float scale,
int depth) {return 0;}
char blender_path[] = "";

View File

@@ -821,6 +821,7 @@ endif()
bf_blenfont
bf_intern_audaspace
bf_intern_mikktspace
bf_intern_dualcon
bf_intern_cycles
cycles_render
cycles_bvh