svn merge ^/trunk/blender -r43009:43033

This commit is contained in:
Campbell Barton 2011-12-31 12:03:36 +00:00
commit 78a4e24614
52 changed files with 15989 additions and 6384 deletions

@ -169,6 +169,7 @@ option(WITH_MOD_FLUID "Enable Elbeem Modifier (Fluid Simulation)" ON)
option(WITH_MOD_SMOKE "Enable Smoke Modifier (Smoke Simulation)" ON)
option(WITH_MOD_DECIMATE "Enable Decimate Modifier" ON)
option(WITH_MOD_BOOLEAN "Enable Boolean Modifier" ON)
option(WITH_MOD_REMESH "Enable Remesh Modifier" ON)
option(WITH_MOD_CLOTH_ELTOPO "Enable Experemental cloth solver" OFF)
mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
option(WITH_MOD_OCEANSIM "Enable Ocean Modifier" OFF)
@ -765,22 +766,27 @@ elseif(WIN32)
${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader/include
${LIBDIR}/opencollada/include/GeneratedSaxParser/include
)
set_lib_path(OPENCOLLADA_LIBPATH "opencollada/lib")
set(OPENCOLLADA_LIBRARIES
${LIBDIR}/opencollada/lib/OpenCOLLADASaxFrameworkLoader.lib
${LIBDIR}/opencollada/lib/OpenCOLLADAFramework.lib
${LIBDIR}/opencollada/lib/OpenCOLLADABaseUtils.lib
${LIBDIR}/opencollada/lib/OpenCOLLADAStreamWriter.lib
${LIBDIR}/opencollada/lib/MathMLSolver.lib
${LIBDIR}/opencollada/lib/GeneratedSaxParser.lib
${LIBDIR}/opencollada/lib/xml2.lib
${LIBDIR}/opencollada/lib/buffer.lib
${LIBDIR}/opencollada/lib/ftoa.lib
${LIBDIR}/opencollada/lib/UTF.lib
${OPENCOLLADA_LIBPATH}/OpenCOLLADASaxFrameworkLoader.lib
${OPENCOLLADA_LIBPATH}/OpenCOLLADAFramework.lib
${OPENCOLLADA_LIBPATH}/OpenCOLLADABaseUtils.lib
${OPENCOLLADA_LIBPATH}/OpenCOLLADAStreamWriter.lib
${OPENCOLLADA_LIBPATH}/MathMLSolver.lib
${OPENCOLLADA_LIBPATH}/GeneratedSaxParser.lib
${OPENCOLLADA_LIBPATH}/xml2.lib
${OPENCOLLADA_LIBPATH}/buffer.lib
${OPENCOLLADA_LIBPATH}/ftoa.lib
${OPENCOLLADA_LIBPATH}/UTF.lib
)
set(PCRE_LIBRARIES
${LIBDIR}/opencollada/lib/pcre.lib
${OPENCOLLADA_LIBPATH}/pcre.lib
)
unset(OPENCOLLADA_LIBPATH)
endif()
if(WITH_CODEC_FFMPEG)
@ -798,18 +804,8 @@ elseif(WIN32)
endif()
if(WITH_IMAGE_OPENEXR)
if(MSVC90)
set(MSVC_LIB _vs2008)
set(MSVC_INC)
elseif(MSVC10)
set(MSVC_LIB _vs2010)
set(MSVC_INC _vs2010)
else()
set(MSVC_LIB msvc)
set(MSVC_INC)
endif()
set(OPENEXR ${LIBDIR}/openexr)
set(OPENEXR_LIBPATH ${OPENEXR}/lib${MSVC_LIB})
set_lib_path(OPENEXR "openexr")
set_lib_path(OPENEXR_LIBPATH "openexr/lib")
set(OPENEXR_LIBRARIES
${OPENEXR_LIBPATH}/Iex.lib
${OPENEXR_LIBPATH}/Half.lib
@ -817,7 +813,7 @@ elseif(WIN32)
${OPENEXR_LIBPATH}/Imath.lib
${OPENEXR_LIBPATH}/IlmThread.lib
)
set(OPENEXR_INCUDE ${OPENEXR}/include${MSVC_INC})
set_lib_path(OPENEXR_INCUDE "openexr/include")
set(OPENEXR_INCLUDE_DIRS
${OPENEXR_INCUDE}
${OPENEXR_INCUDE}/IlmImf
@ -844,9 +840,9 @@ elseif(WIN32)
if(WITH_PYTHON)
# normally cached but not since we include them with blender
set(PYTHON_VERSION 3.2) # CACHE STRING)
set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}") # CACHE PATH)
set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python32.lib") #CACHE FILEPATH)
set_lib_path(PYTHON_INCLUDE_DIR "python/include/python${PYTHON_VERSION}")
set_lib_path(PYTHON_LIBRARY "python/lib/python32.lib") #CACHE FILEPATH)
# uncached vars
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
@ -879,7 +875,7 @@ elseif(WIN32)
set(OPENIMAGEIO ${LIBDIR}/openimageio)
set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
set(OPENIMAGEIO_LIBRARIES OpenImageIO)
set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
set_lib_path(OPENIMAGEIO_LIBPATH "openimageio/lib")
set(OPENIMAGEIO_DEFINITIONS)
endif()
@ -1431,11 +1427,9 @@ endif()
if(MSVC10)
if(WITH_IMAGE_OPENEXR)
message(WARNING "MSVC 2010 does not support OpenEXR, disabling WITH_IMAGE_OPENEXR. To enable support use Use MSVC 2008")
set(WITH_IMAGE_OPENEXR OFF)
endif()
if(WITH_OPENCOLLADA)
message(WARNING "MSVC 2010 does not support OpenCollada, disabling WITH_OPENCOLLADA. To enable support use Use MSVC 2008")
set(WITH_OPENCOLLADA OFF)
endif()
endif()
@ -1577,6 +1571,7 @@ if(FIRST_RUN)
info_cfg_text("Modifiers:")
info_cfg_option(WITH_MOD_BOOLEAN)
info_cfg_option(WITH_MOD_REMESH)
info_cfg_option(WITH_MOD_DECIMATE)
info_cfg_option(WITH_MOD_FLUID)
info_cfg_option(WITH_MOD_OCEANSIM)

@ -264,6 +264,7 @@ if 'blenderlite' in B.targets:
target_env_defs['WITH_BF_OCEANSIM'] = False
target_env_defs['WITH_BF_DECIMATE'] = False
target_env_defs['WITH_BF_BOOLEAN'] = False
target_env_defs['WITH_BF_REMESH'] = False
target_env_defs['WITH_BF_PYTHON'] = False
target_env_defs['WITH_BF_3DMOUSE'] = False

@ -665,3 +665,16 @@ function(delayed_do_install
endif()
endfunction()
macro(set_lib_path
lvar
lproj)
if(MSVC10 AND EXISTS ${LIBDIR}/vc2010/${lproj})
set(${lvar} ${LIBDIR}/vc2010/${lproj})
else()
set(${lvar} ${LIBDIR}/${lproj})
endif()
endmacro()

@ -152,6 +152,7 @@ def validate_arguments(args, bc):
'WITH_BF_FLUID',
'WITH_BF_DECIMATE',
'WITH_BF_BOOLEAN',
'WITH_BF_REMESH',
'WITH_BF_OCEANSIM',
'WITH_BF_CXX_GUARDEDALLOC',
'WITH_BF_JEMALLOC', 'WITH_BF_STATICJEMALLOC', 'BF_JEMALLOC', 'BF_JEMALLOC_INC', 'BF_JEMALLOC_LIBPATH', 'BF_JEMALLOC_LIB', 'BF_JEMALLOC_LIB_STATIC',
@ -261,6 +262,7 @@ def read_opts(env, cfg, args):
(BoolVariable('WITH_BF_FLUID', 'Build with Fluid simulation (Elbeem)', True)),
(BoolVariable('WITH_BF_DECIMATE', 'Build with decimate modifier', True)),
(BoolVariable('WITH_BF_BOOLEAN', 'Build with boolean modifier', True)),
(BoolVariable('WITH_BF_REMESH', 'Build with remesh modifier', True)),
(BoolVariable('WITH_BF_OCEANSIM', 'Build with ocean simulation', False)),
('BF_PROFILE_FLAGS', 'Profiling compiler flags', ''),
(BoolVariable('WITH_BF_OPENAL', 'Use OpenAL if true', False)),

@ -36,6 +36,10 @@ if(WITH_AUDASPACE)
add_subdirectory(audaspace)
endif()
if(WITH_MOD_REMESH)
add_subdirectory(dualcon)
endif()
if(WITH_MOD_FLUID)
add_subdirectory(elbeem)
endif()

@ -22,6 +22,9 @@ SConscript(['audaspace/SConscript',
# perhaps get rid of intern/csg?
NEW_CSG='false'
if env ['WITH_BF_REMESH']:
SConscript(['dualcon/SConscript'])
if env['WITH_BF_FLUID']:
SConscript(['elbeem/SConscript'])

@ -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}" "")

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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}
};

@ -0,0 +1,845 @@
/*
* ***** 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(__MINGW32__)
#define LONG __int64
#else
#include <stdint.h>
#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

@ -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

@ -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

@ -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();
}

@ -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}}}
};

@ -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

@ -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}}
};

@ -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

@ -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

@ -94,7 +94,9 @@ typedef unsigned long uintptr_t;
#include <stdint.h>
/* XXX */
#ifndef uint64_t
#ifndef UINT64_MAX
# define UINT64_MAX 18446744073709551615
typedef uint8_t u_int8_t;
typedef uint16_t u_int16_t;
typedef uint32_t u_int32_t;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 213 KiB

@ -823,6 +823,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:")

@ -16,7 +16,8 @@
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
# <pep8-80 compliant>
import bpy
from bpy.types import Panel, Header, Menu
@ -209,12 +210,9 @@ class CLIP_PT_tools_solve(Panel):
col = layout.column(align=True)
if tracking_object.is_camera:
solve_text = "Camera Motion"
else:
solve_text = "Object Motion"
col.operator("clip.solve_camera", text=solve_text)
col.operator("clip.solve_camera",
text="Camera Motion" if tracking_object.is_camera
else "Object Motion")
col.operator("clip.clear_solution")
col = layout.column(align=True)
@ -379,11 +377,12 @@ class CLIP_PT_objects(Panel):
def draw(self, context):
layout = self.layout
sc = context.space_data
clip = context.space_data.clip
clip = sc.clip
tracking = clip.tracking
row = layout.row()
row.template_list(tracking, "objects", tracking, "active_object_index", rows=3)
row.template_list(tracking, "objects",
tracking, "active_object_index", rows=3)
sub = row.column(align=True)
@ -472,7 +471,7 @@ class CLIP_PT_tracking_camera(Panel):
def poll(cls, context):
sc = context.space_data
return sc.mode in ['TRACKING', 'DISTORTION'] and sc.clip
return sc.mode in {'TRACKING', 'DISTORTION'} and sc.clip
def draw(self, context):
layout = self.layout

@ -179,9 +179,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 */

@ -2564,7 +2564,9 @@ static void dag_id_flush_update(Scene *sce, ID *id)
bConstraint *con;
for (con = obt->constraints.first; con; con=con->next) {
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
if(ELEM(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER)) {
if(ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER,
CONSTRAINT_TYPE_OBJECTSOLVER))
{
obt->recalc |= OB_RECALC_OB;
break;
}

@ -510,8 +510,6 @@ static void scene_setSubframe(Scene *scene, float subframe)
scene->r.subframe = subframe;
}
#define BRUSH_USES_VELOCITY (1<<0)
static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
{
Base *base = NULL;
@ -2285,7 +2283,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
tPoint->quad = (isInside == 2) ? 1 : 0; /* quad or tri part*/
/* save vertex indexes */
tPoint->v1 = mface[i].v1; /* (isInside == 2) ? mface[i].v1 : mface[i].v1; */ /* same! */
tPoint->v1 = mface[i].v1;
tPoint->v2 = (isInside == 2) ? mface[i].v3 : mface[i].v2;
tPoint->v3 = (isInside == 2) ? mface[i].v4 : mface[i].v3;
@ -2365,7 +2363,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
tPoint->quad = tempPoints[ind].quad; // quad or tri
/* save vertex indexes */
tPoint->v1 = (tPoint->quad) ? mface[i].v1 : mface[i].v1;
tPoint->v1 = mface[i].v1;
tPoint->v2 = (tPoint->quad) ? mface[i].v3 : mface[i].v2;
tPoint->v3 = (tPoint->quad) ? mface[i].v4 : mface[i].v3;
@ -2395,10 +2393,8 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
}
}
/* If any effect enabled, create surface effect / wet layer
* neighbour lists. Processes possibly moving data. */
if (surface_usesAdjData(surface)) {
/* Generate surface adjacency data. */
{
int i, cursor=0;
/* Create a temporary array of final indexes (before unassigned
@ -2411,12 +2407,11 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
}
/* allocate memory */
sData->total_points = w*h;
dynamicPaint_initAdjacencyData(surface, 0);
dynamicPaint_initAdjacencyData(surface, 1);
if (sData->adj_data) {
PaintAdjData *ed = sData->adj_data;
unsigned int n_pos = 0;
//#pragma omp parallel for schedule(static)
for (ty = 0; ty < h; ty++)
{
int tx;

@ -1258,8 +1258,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
double x1, y1, x2, y2;
ImBuf *ibuf= NULL;
MovieTrackingMarker marker_new, *marker_keyed;
int onbound= 0, coords_correct= 0;
int nextfra;
int onbound= 0, nextfra;
if(track->pattern_match==TRACK_MATCH_KEYFRAME)
need_readjust= context->first_time;
@ -1377,8 +1376,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
MEM_freeN(image_new);
}
coords_correct= !onbound && !isnan(x2) && !isnan(y2) && finite(x2) && finite(y2);
if(coords_correct && !onbound && tracked) {
if(tracked && !onbound && finite(x2) && finite(y2)) {
if(context->first_time) {
#pragma omp critical
{
@ -1682,7 +1680,8 @@ int BKE_tracking_can_reconstruct(MovieTracking *tracking, MovieTrackingObject *o
return 1;
#else
BLI_strncpy(error_msg, "Blender is compiled without motion tracking library", error_size);
(void) tracking;
(void)tracking;
(void)object;
return 0;
#endif
@ -2274,6 +2273,7 @@ void BKE_tracking_detect_fast(MovieTracking *tracking, ListBase *tracksbase, ImB
libmv_destroyFeatures(features);
#else
(void)tracking;
(void)tracksbase;
(void)ibuf;
(void)framenr;
(void)margin;

@ -87,7 +87,8 @@ typedef unsigned long uintptr_t;
#include <stdint.h>
/* XXX */
#ifndef uint64_t
#ifndef UINT64_MAX
# define UINT64_MAX 18446744073709551615
typedef uint8_t u_int8_t;
typedef uint16_t u_int16_t;
typedef uint32_t u_int32_t;

File diff suppressed because it is too large Load Diff

@ -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)

@ -1613,9 +1613,6 @@ static void solve_camera_freejob(void *scv)
id_us_plus(&clip->id);
/* set blender camera focal length so result would look fine there */
if(!scene->camera)
scene->camera= scene_find_camera(scene);
if(scene->camera) {
Camera *camera= (Camera*)scene->camera->data;
int width, height;
@ -2468,16 +2465,16 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution)
if(tracking_object->flag&TRACKING_OBJECT_CAMERA) {
mul_v3_fl(object->size, scale);
mul_v3_fl(object->loc, scale);
} else
if(!scale_solution){
Object *camera= object_solver_camera(scene, object);
}
else if(!scale_solution){
Object *solver_camera= object_solver_camera(scene, object);
object->size[0]= object->size[1]= object->size[2]= 1.0f/scale;
if(camera) {
object->size[0]/= camera->size[0];
object->size[1]/= camera->size[1];
object->size[2]/= camera->size[2];
if(solver_camera) {
object->size[0]/= solver_camera->size[0];
object->size[1]/= solver_camera->size[1];
object->size[2]/= solver_camera->size[2];
}
}
else {

@ -667,9 +667,13 @@ void autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v))
void ED_fileselect_clear(struct bContext *C, struct SpaceFile *sfile)
{
thumbnails_stop(sfile->files, C);
filelist_freelib(sfile->files);
filelist_free(sfile->files);
/* only NULL in rare cases - [#29734] */
if (sfile->files) {
thumbnails_stop(sfile->files, C);
filelist_freelib(sfile->files);
filelist_free(sfile->files);
}
sfile->params->active_file = -1;
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL);
}

@ -1014,6 +1014,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
UI_icon_draw(x, y, ICON_MOD_SOLIDIFY); break;
case eModifierType_Screw:
UI_icon_draw(x, y, ICON_MOD_SCREW); break;
case eModifierType_Remesh:
UI_icon_draw(x, y, ICON_MOD_REMESH); break;
case eModifierType_WeightVGEdit:
case eModifierType_WeightVGMix:
case eModifierType_WeightVGProximity:

@ -1521,9 +1521,6 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d)
clip= NULL;
if(bgpic->flag&V3D_BGPIC_CAMERACLIP) {
if(!scene->camera)
scene->camera= scene_find_camera(scene);
if(scene->camera)
clip= object_get_movieclip(scene, scene->camera, 1);
} else clip= bgpic->clip;

@ -817,18 +817,15 @@ void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot)
static void bundle_midpoint(Scene *scene, Object *ob, float vec[3])
{
MovieClip *clip= object_get_movieclip(scene, ob, 0);
MovieTracking *tracking= &clip->tracking;
MovieTrackingObject *object= tracking->objects.first;
MovieTracking *tracking;
MovieTrackingObject *object;
int ok= 0;
float min[3], max[3], mat[4][4], pos[3], cammat[4][4];
float min[3], max[3], mat[4][4], pos[3], cammat[4][4] = MAT4_UNITY;
if(!clip)
return;
unit_m4(cammat);
if(!scene->camera)
scene->camera= scene_find_camera(scene);
tracking= &clip->tracking;
if(scene->camera)
copy_m4_m4(cammat, scene->camera->obmat);
@ -837,7 +834,7 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3])
INIT_MINMAX(min, max);
while(object) {
for (object= tracking->objects.first; object; object= object->next) {
ListBase *tracksbase= BKE_tracking_object_tracks(tracking, object);
MovieTrackingTrack *track= tracksbase->first;
float obmat[4][4];
@ -863,8 +860,6 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3])
track= track->next;
}
object= object->next;
}
if(ok) {

@ -76,6 +76,7 @@ typedef enum ModifierType {
eModifierType_WeightVGProximity,
eModifierType_Ocean,
eModifierType_DynamicPaint,
eModifierType_Remesh,
/* BMESH ONLY - keeps getting bumped by new modifiers in trunk */
eModifierType_NgonInterp,
@ -1041,4 +1042,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

@ -433,7 +433,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
prop= RNA_def_property(srna, "frame_substeps", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "substeps");
RNA_def_property_range(prop, 0.0, 10.0);
RNA_def_property_range(prop, 0.0, 20.0);
RNA_def_property_ui_range(prop, 0.0, 10, 1, 0);
RNA_def_property_ui_text(prop, "Sub-Steps", "Do extra frames between scene frames to ensure smooth motion");
@ -618,7 +618,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
/* wave simulator settings */
prop= RNA_def_property(srna, "wave_damping", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.001, 1.0);
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_range(prop, 0.01, 1.0, 1, 2);
RNA_def_property_ui_text(prop, "Damping", "Wave damping factor");
@ -633,7 +633,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Timescale", "Wave time scaling factor");
prop= RNA_def_property(srna, "wave_spring", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.001, 1.0);
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_range(prop, 0.01, 1.0, 1, 2);
RNA_def_property_ui_text(prop, "Spring", "Spring force that pulls water level back to zero");

@ -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", ""},
@ -202,6 +203,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;
}
@ -2883,6 +2886,56 @@ 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)
{
@ -3186,7 +3239,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);
/* BMESH_ONLY */
rna_def_modifier_ngoninterp(brna);

@ -72,6 +72,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
@ -108,6 +109,13 @@ if(WITH_MOD_BOOLEAN)
)
endif()
if(WITH_MOD_REMESH)
add_definitions(-DWITH_MOD_REMESH)
list(APPEND INC
../../../intern/dualcon
)
endif()
if(WITH_MOD_DECIMATE)
add_definitions(-DWITH_MOD_DECIMATE)
list(APPEND INC

@ -73,6 +73,7 @@ extern ModifierTypeInfo modifierType_WeightVGEdit;
extern ModifierTypeInfo modifierType_WeightVGMix;
extern ModifierTypeInfo modifierType_WeightVGProximity;
extern ModifierTypeInfo modifierType_DynamicPaint;
extern ModifierTypeInfo modifierType_Remesh;
extern ModifierTypeInfo modifierType_NgonInterp;
/* MOD_util.c */

@ -14,8 +14,12 @@ incs += ' ' + env['BF_ZLIB_INC']
defs = []
if env ['WITH_BF_BOOLEAN']:
incs += ' #/intern/dualcon'
defs.append('WITH_MOD_BOOLEAN')
if env['WITH_BF_REMESH']:
defs.append('WITH_MOD_REMESH')
if env ['WITH_BF_DECIMATE']:
defs.append('WITH_MOD_DECIMATE')

@ -0,0 +1,230 @@
/*
* $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>
#ifdef WITH_MOD_REMESH
# include "dualcon.h"
#endif
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;
}
#ifdef WITH_MOD_REMESH
static 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 */
static 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;
}
static 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++;
}
static 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;
}
#else /* !WITH_MOD_REMESH */
static DerivedMesh *applyModifier(ModifierData *UNUSED(md), Object *UNUSED(ob),
DerivedMesh *derivedData,
int UNUSED(useRenderParams),
int UNUSED(isFinalCalc))
{
return derivedData;
}
#endif /* !WITH_MOD_REMESH */
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,
};

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

@ -1712,9 +1712,9 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
}
if( (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL ) { // vertexcolor light
shr->emit[0]= shi->r*(shi->emit+shi->vcol[0]);
shr->emit[1]= shi->g*(shi->emit+shi->vcol[1]);
shr->emit[2]= shi->b*(shi->emit+shi->vcol[2]);
shr->emit[0]= shi->r*(shi->emit+shi->vcol[0]*shi->vcol[3]);
shr->emit[1]= shi->g*(shi->emit+shi->vcol[1]*shi->vcol[3]);
shr->emit[2]= shi->b*(shi->emit+shi->vcol[2]*shi->vcol[3]);
}
else {
shr->emit[0]= shi->r*shi->emit;

@ -487,6 +487,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[] = "";

@ -437,15 +437,15 @@ elseif(WIN32)
# )
if(WITH_PYTHON)
set_lib_path(PYLIB "python/lib")
install(
FILES ${LIBDIR}/python/lib/python32.dll
FILES ${PYLIB}/python32.dll
DESTINATION ${TARGETDIR}
CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
)
install(
FILES ${LIBDIR}/python/lib/python32_d.dll
FILES ${PYLIB}/python32_d.dll
DESTINATION ${TARGETDIR}
CONFIGURATIONS Debug
)
@ -558,9 +558,10 @@ elseif(WIN32)
)
if(WITH_OPENIMAGEIO)
set_lib_path(OIIOBIN "openimageio/bin")
install(
FILES
${LIBDIR}/openimageio/bin/OpenImageIO.dll
${OIIOBIN}/OpenImageIO.dll
DESTINATION ${TARGETDIR}
)
endif()
@ -822,6 +823,7 @@ endif()
bf_blenfont
bf_intern_audaspace
bf_intern_mikktspace
bf_intern_dualcon
bf_intern_cycles
cycles_render
cycles_bvh

@ -118,8 +118,8 @@ void KX_FontObject::ProcessReplica()
void KX_FontObject::DrawText()
{
/* Allow for some logic brick control */
if(this->GetProperty("text"))
m_text = split_string(this->GetProperty("text")->GetText());
if(this->GetProperty("Text"))
m_text = split_string(this->GetProperty("Text")->GetText());
/* only draws the text if visible */
if(this->GetVisible() == 0) return;