Commit c3dca89c authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[MERGE]

parents e676d1da c2d2c9a9
......@@ -22,6 +22,9 @@
//
//---------------------------------------------------------------------------
#include <string>
#include <vector>
#include "../common/WAssert.h"
#include "../common/WLimits.h"
#include "WDataSetSingle.h"
......@@ -99,3 +102,65 @@ boost::shared_ptr< WPrototyped > WDataSetScalar::getPrototype()
return m_prototype;
}
double WDataSetScalar::interpolate( const wmath::WPosition& pos, bool* success )
{
boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( m_grid );
// TODO(wiebel): change this to eassert.
if( !grid )
{
throw WException( std::string( "This data set has a grid whose type is not yet supported for interpolation." ) );
}
// TODO(wiebel): change this to eassert.
// if( grid->getTransformationMatrix() != wmath::WMatrix<double>( 4, 4 ).makeIdentity() )
// {
// throw WException( std::string( "Only feasible for untranslated grid so far." ) );
// }
// TODO(wiebel): change this to eassert.
if( !( m_valueSet->order() == 0 && m_valueSet->dimension() == 1 ) )
{
throw WException( std::string( "Only implemented for scalar values so far." ) );
}
*success = grid->encloses( pos );
if( !*success )
{
return 0;
}
std::vector< size_t > vertexIds = grid->getCellVertexIds( grid->getCellId( pos ) );
wmath::WPosition localPos = pos - grid->getPosition( vertexIds[0] );
double lambdaX = localPos[0] / grid->getOffsetX();
double lambdaY = localPos[1] / grid->getOffsetY();
double lambdaZ = localPos[2] / grid->getOffsetZ();
std::vector< double > h( 8 );
// lZ lY
// | /
// | 6___/_7
// |/: /|
// 4_:___5 |
// | :...|.|
// |.2 | 3
// |_____|/ ____lX
// 0 1
h[0] = ( 1 - lambdaX ) * ( 1 - lambdaY ) * ( 1 - lambdaZ );
h[1] = ( lambdaX ) * ( 1 - lambdaY ) * ( 1 - lambdaZ );
h[2] = ( 1 - lambdaX ) * ( lambdaY ) * ( 1 - lambdaZ );
h[3] = ( lambdaX ) * ( lambdaY ) * ( 1 - lambdaZ );
h[4] = ( 1 - lambdaX ) * ( 1 - lambdaY ) * ( lambdaZ );
h[5] = ( lambdaX ) * ( 1 - lambdaY ) * ( lambdaZ );
h[6] = ( 1 - lambdaX ) * ( lambdaY ) * ( lambdaZ );
h[7] = ( lambdaX ) * ( lambdaY ) * ( lambdaZ );
double result = 0;
for( size_t i = 0; i < 8; ++i )
{
result += h[i] * getValueAt( vertexIds[i] );
}
*success = true;
return result;
}
......@@ -79,6 +79,18 @@ public:
*/
double getMin() const;
/**
* Interpolate the value fo the valueset at the given position.
* If interpolation fails, the success parameter will be false
* and the value returned zero.
*
* \param pos The position for wich we would like to get a value.
* \param success indicates whether the interpolation was successful
*
* \return Scalar value for that given position
*/
double interpolate( const wmath::WPosition& pos, bool* success );
/**
* Returns a prototype instantiated with the true type of the deriving class.
*
......
......@@ -142,57 +142,3 @@ double WDataSetSingle::getValueAt( int x, int y, int z )
return getValueAt( id );
}
double WDataSetSingle::interpolate( wmath::WPosition pos )
{
boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( m_grid );
// TODO(wiebel): change this to eassert.
if( !grid )
{
throw WException( std::string( "This data set has a grid whose type is not yet supported for interpolation." ) );
}
// TODO(wiebel): change this to eassert.
if( grid->getTransformationMatrix() != wmath::WMatrix<double>( 4, 4 ).makeIdentity() )
{
throw WException( std::string( "Only feasible for untranslated grid so far." ) );
}
// TODO(wiebel): change this to eassert.
if( !( m_valueSet->order() == 0 && m_valueSet->dimension() == 1 ) )
{
throw WException( std::string( "Only implemented for scalar values so far." ) );
}
std::vector< size_t > vertexIds = grid->getCellVertexIds( grid->getCellId( pos ) );
wmath::WPosition localPos = pos - grid->getPosition( vertexIds[0] );
double lambdaX = localPos[0] / grid->getOffsetX();
double lambdaY = localPos[1] / grid->getOffsetY();
double lambdaZ = localPos[2] / grid->getOffsetZ();
std::vector< double > h( 8 );
// lZ lY
// | /
// | 6___/_7
// |/: /|
// 4_:___5 |
// | :...|.|
// |.2 | 3
// |_____|/ ____lX
// 0 1
h[0] = ( 1 - lambdaX ) * ( 1 - lambdaY ) * ( 1 - lambdaZ );
h[1] = ( lambdaX ) * ( 1 - lambdaY ) * ( 1 - lambdaZ );
h[2] = ( 1 - lambdaX ) * ( lambdaY ) * ( 1 - lambdaZ );
h[3] = ( lambdaX ) * ( lambdaY ) * ( 1 - lambdaZ );
h[4] = ( 1 - lambdaX ) * ( 1 - lambdaY ) * ( lambdaZ );
h[5] = ( lambdaX ) * ( 1 - lambdaY ) * ( lambdaZ );
h[6] = ( 1 - lambdaX ) * ( lambdaY ) * ( lambdaZ );
h[7] = ( lambdaX ) * ( lambdaY ) * ( lambdaZ );
double result = 0;
for( size_t i = 0; i < 8; ++i )
{
result += h[i] * getValueAt( vertexIds[i] );
}
return result;
}
......@@ -101,15 +101,6 @@ public:
*/
template< typename T > T getValueAt( size_t id );
/**
* Interpolate the value fo the valueset at the given position
*
* \param pos The position for wich we would like to get a value.
*
* \return Scalar value for that given position
*/
double interpolate( wmath::WPosition pos );
/**
* Get the value stored at a certain grid position of the data set in type double.
*
......@@ -161,17 +152,17 @@ protected:
*/
static boost::shared_ptr< WPrototyped > m_prototype;
private:
/**
* Stores the reference of the WValueSet of this DataSetSingle instance.
* Stores the reference of the WGrid of this DataSetSingle instance.
*/
boost::shared_ptr< WValueSetBase > m_valueSet;
boost::shared_ptr< WGrid > m_grid;
/**
* Stores the reference of the WGrid of this DataSetSingle instance.
* Stores the reference of the WValueSet of this DataSetSingle instance.
*/
boost::shared_ptr< WGrid > m_grid;
boost::shared_ptr< WValueSetBase > m_valueSet;
private:
/**
* The 3D texture representing this dataset.
*/
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WDATASETSCALAR_TEST_H
#define WDATASETSCALAR_TEST_H
#include <vector>
#include <cxxtest/TestSuite.h>
#include "../WDataSetScalar.h"
/**
* TODO(wiebel): Document this!
*/
class WDataSetScalarTest : public CxxTest::TestSuite
{
public:
/**
* Test if the interpolate function works reasonable.
*/
void testInterpolate( void )
{
// create dummies, since they are needed in almost every test
boost::shared_ptr< WGrid > grid = boost::shared_ptr< WGrid >( new WGridRegular3D( 5, 3, 3, 1, 1, 1 ) );
std::vector< double > data( grid->size() );
for( size_t i = 0; i < grid->size(); ++i )
{
data[i] = i;
}
boost::shared_ptr< WValueSet< double > > valueSet( new WValueSet< double >( 0, 1, data, W_DT_DOUBLE ) );
WDataSetScalar ds( valueSet, grid );
bool success = false;
TS_ASSERT_EQUALS( ds.interpolate( wmath::WPosition(), &success ), data[0] );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 1, 0, 0 ), &success ), data[1], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0, 1, 0 ), &success ), data[5], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 1, 1, 0 ), &success ), data[6], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0, 0, 1 ), &success ), data[15], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 1, 0, 1 ), &success ), data[16], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0, 1, 1 ), &success ), data[20], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 1, 1, 1 ), &success ), data[21], 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0.3, 0.4, 0.5 ), &success ), 9.8, 1e-9 );
TS_ASSERT( success );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0.5, 0.5, 0.5 ), &success ), 10.5, 1e-9 );
TS_ASSERT( success );
}
};
#endif // WDATASETSCALAR_TEST_H
......@@ -87,34 +87,5 @@ public:
TS_ASSERT_EQUALS( dataSetSingle.getGrid(), gridDummy );
TS_ASSERT_DIFFERS( dataSetSingle.getGrid(), other );
}
/**
* Test if the interpolate function works reasonable.
*/
void testInterpolate( void )
{
// create dummies, since they are needed in almost every test
boost::shared_ptr< WGrid > grid = boost::shared_ptr< WGrid >( new WGridRegular3D( 5, 3, 3, 1, 1, 1 ) );
std::vector< double > data( grid->size() );
for( size_t i = 0; i < grid->size(); ++i )
{
data[i] = i;
}
boost::shared_ptr< WValueSet< double > > valueSet( new WValueSet< double >( 0, 1, data, W_DT_DOUBLE ) );
WDataSetSingle ds( valueSet, grid );
TS_ASSERT_EQUALS( ds.interpolate( wmath::WPosition() ), data[0] );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 1, 0, 0 ) ), data[1], 1e-9 );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0, 1, 0 ) ), data[5], 1e-9 );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 1, 1, 0 ) ), data[6], 1e-9 );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0, 0, 1 ) ), data[15], 1e-9 );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 1, 0, 1 ) ), data[16], 1e-9 );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0, 1, 1 ) ), data[20], 1e-9 );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 1, 1, 1 ) ), data[21], 1e-9 );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0.3, 0.4, 0.5 ) ), 9.8, 1e-9 );
TS_ASSERT_DELTA( ds.interpolate( wmath::WPosition( 0.5, 0.5, 0.5 ) ), 10.5, 1e-9 );
}
};
#endif // WDATASETSINGLE_TEST_H
......@@ -30,7 +30,6 @@
#include <cmath>
#include "iso_surface.xpm"
#include "marchingCubesCaseTables.h"
#include "../../common/WLimits.h"
#include "../../common/WAssert.h"
......@@ -53,19 +52,13 @@
#include "../../graphicsEngine/WGEUtils.h"
#include "../../kernel/WKernel.h"
#include "WMarchingCubesAlgorithm.h"
#include "WMMarchingCubes.h"
WMMarchingCubes::WMMarchingCubes():
WModule(),
m_recompute( boost::shared_ptr< WCondition >( new WCondition() ) ),
m_nCellsX( 0 ),
m_nCellsY( 0 ),
m_nCellsZ( 0 ),
m_fCellLengthX( 1 ),
m_fCellLengthY( 1 ),
m_fCellLengthZ( 1 ),
m_tIsoLevel( 100 ),
m_dataSet(),
m_shaderUseLighting( false ),
m_shaderUseTransparency( false ),
......@@ -219,6 +212,12 @@ void WMMarchingCubes::generateSurfacePre( double isoValue )
{
debugLog() << "Isovalue: " << isoValue;
WAssert( ( *m_dataSet ).getValueSet()->order() == 0, "This module only works on scalars." );
WMarchingCubesAlgorithm mcAlgo;
boost::shared_ptr< WGridRegular3D > gridRegular3D = boost::shared_dynamic_cast< WGridRegular3D >( ( *m_dataSet ).getGrid() );
WAssert( gridRegular3D, "Grid is not of type WGridRegular3D." );
m_grid = gridRegular3D;
switch( (*m_dataSet).getValueSet()->getDataType() )
{
case W_DT_UNSIGNED_CHAR:
......@@ -226,7 +225,7 @@ void WMMarchingCubes::generateSurfacePre( double isoValue )
boost::shared_ptr< WValueSet< unsigned char > > vals;
vals = boost::shared_dynamic_cast< WValueSet< unsigned char > >( ( *m_dataSet ).getValueSet() );
WAssert( vals, "Data type and data type indicator must fit." );
generateSurface( ( *m_dataSet ).getGrid(), vals, isoValue );
m_triMesh = mcAlgo.generateSurface( m_grid, vals, isoValue, m_progress );
break;
}
case W_DT_INT16:
......@@ -234,7 +233,7 @@ void WMMarchingCubes::generateSurfacePre( double isoValue )
boost::shared_ptr< WValueSet< int16_t > > vals;
vals = boost::shared_dynamic_cast< WValueSet< int16_t > >( ( *m_dataSet ).getValueSet() );
WAssert( vals, "Data type and data type indicator must fit." );
generateSurface( ( *m_dataSet ).getGrid(), vals, isoValue );
m_triMesh = mcAlgo.generateSurface( m_grid, vals, isoValue, m_progress );
break;
}
case W_DT_SIGNED_INT:
......@@ -242,7 +241,7 @@ void WMMarchingCubes::generateSurfacePre( double isoValue )
boost::shared_ptr< WValueSet< int32_t > > vals;
vals = boost::shared_dynamic_cast< WValueSet< int32_t > >( ( *m_dataSet ).getValueSet() );
WAssert( vals, "Data type and data type indicator must fit." );
generateSurface( ( *m_dataSet ).getGrid(), vals, isoValue );
m_triMesh = mcAlgo.generateSurface( m_grid, vals, isoValue, m_progress );
break;
}
case W_DT_FLOAT:
......@@ -250,7 +249,7 @@ void WMMarchingCubes::generateSurfacePre( double isoValue )
boost::shared_ptr< WValueSet< float > > vals;
vals = boost::shared_dynamic_cast< WValueSet< float > >( ( *m_dataSet ).getValueSet() );
WAssert( vals, "Data type and data type indicator must fit." );
generateSurface( ( *m_dataSet ).getGrid(), vals, isoValue );
m_triMesh = mcAlgo.generateSurface( m_grid, vals, isoValue, m_progress );
break;
}
case W_DT_DOUBLE:
......@@ -258,7 +257,7 @@ void WMMarchingCubes::generateSurfacePre( double isoValue )
boost::shared_ptr< WValueSet< double > > vals;
vals = boost::shared_dynamic_cast< WValueSet< double > >( ( *m_dataSet ).getValueSet() );
WAssert( vals, "Data type and data type indicator must fit." );
generateSurface( ( *m_dataSet ).getGrid(), vals, isoValue );
m_triMesh = mcAlgo.generateSurface( m_grid, vals, isoValue, m_progress );
break;
}
default:
......@@ -266,381 +265,9 @@ void WMMarchingCubes::generateSurfacePre( double isoValue )
}
}
void WMMarchingCubes::transformPositions( ID2WPointXYZId* positions )
{
wmath::WMatrix< double > mat = m_grid->getTransformationMatrix();
for( ID2WPointXYZId::iterator it = positions->begin(); it != positions->end(); ++it )
{
wmath::WPosition pos = wmath::WPosition( it->second.x, it->second.y, it->second.z );
std::vector< double > resultPos4D( 4 );
resultPos4D[0] = mat( 0, 0 ) * pos[0] + mat( 0, 1 ) * pos[1] + mat( 0, 2 ) * pos[2] + mat( 0, 3 ) * 1;
resultPos4D[1] = mat( 1, 0 ) * pos[0] + mat( 1, 1 ) * pos[1] + mat( 1, 2 ) * pos[2] + mat( 1, 3 ) * 1;
resultPos4D[2] = mat( 2, 0 ) * pos[0] + mat( 2, 1 ) * pos[1] + mat( 2, 2 ) * pos[2] + mat( 2, 3 ) * 1;
resultPos4D[3] = mat( 3, 0 ) * pos[0] + mat( 3, 1 ) * pos[1] + mat( 3, 2 ) * pos[2] + mat( 3, 3 ) * 1;
it->second.x = resultPos4D[0] / resultPos4D[3];
it->second.y = resultPos4D[1] / resultPos4D[3];
it->second.z = resultPos4D[2] / resultPos4D[3];
}
}
template< typename T > void WMMarchingCubes::generateSurface( boost::shared_ptr< WGrid > inGrid,
boost::shared_ptr< WValueSet< T > > vals,
double isoValue )
{
WAssert( vals, "No value set provided." );
m_idToVertices.clear();
m_trivecTriangles.clear();
boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( inGrid );
m_grid = grid;
WAssert( grid, "Grid is not of type WGridRegular3D." );
// We choose the following to be 1 as we transform the positions later.
m_fCellLengthX = 1;
m_fCellLengthY = 1;
m_fCellLengthZ = 1;
m_nCellsX = grid->getNbCoordsX() - 1;
m_nCellsY = grid->getNbCoordsY() - 1;
m_nCellsZ = grid->getNbCoordsZ() - 1;
m_tIsoLevel = isoValue;
unsigned int nX = m_nCellsX + 1;
unsigned int nY = m_nCellsY + 1;
unsigned int nPointsInSlice = nX * nY;
boost::shared_ptr< WProgress > progress = boost::shared_ptr< WProgress >( new WProgress( "Marching Cubes", m_nCellsZ ) );
m_progress->addSubProgress( progress );
// Generate isosurface.
for( unsigned int z = 0; z < m_nCellsZ; z++ )
{
++*progress;
for( unsigned int y = 0; y < m_nCellsY; y++ )
{
for( unsigned int x = 0; x < m_nCellsX; x++ )
{
// Calculate table lookup index from those
// vertices which are below the isolevel.
unsigned int tableIndex = 0;
if( vals->getScalar( z * nPointsInSlice + y * nX + x ) < m_tIsoLevel )
tableIndex |= 1;
if( vals->getScalar( z * nPointsInSlice + ( y + 1 ) * nX + x ) < m_tIsoLevel )
tableIndex |= 2;
if( vals->getScalar( z * nPointsInSlice + ( y + 1 ) * nX + ( x + 1 ) ) < m_tIsoLevel )
tableIndex |= 4;
if( vals->getScalar( z * nPointsInSlice + y * nX + ( x + 1 ) ) < m_tIsoLevel )
tableIndex |= 8;
if( vals->getScalar( ( z + 1 ) * nPointsInSlice + y * nX + x ) < m_tIsoLevel )
tableIndex |= 16;
if( vals->getScalar( ( z + 1 ) * nPointsInSlice + ( y + 1 ) * nX + x ) < m_tIsoLevel )
tableIndex |= 32;
if( vals->getScalar( ( z + 1 ) * nPointsInSlice + ( y + 1 ) * nX + ( x + 1 ) ) < m_tIsoLevel )
tableIndex |= 64;
if( vals->getScalar( ( z + 1 ) * nPointsInSlice + y * nX + ( x + 1 ) ) < m_tIsoLevel )
tableIndex |= 128;
// Now create a triangulation of the isosurface in this
// cell.
if( wMarchingCubesCaseTables::edgeTable[tableIndex] != 0 )
{
if( wMarchingCubesCaseTables::edgeTable[tableIndex] & 8 )
{
WPointXYZId pt = calculateIntersection( vals, x, y, z, 3 );
unsigned int id = getEdgeID( x, y, z, 3 );
m_idToVertices.insert( ID2WPointXYZId::value_type( id, pt ) );
}
if( wMarchingCubesCaseTables::edgeTable[tableIndex] & 1 )
{
WPointXYZId pt = calculateIntersection( vals, x, y, z, 0 );
unsigned int id = getEdgeID( x, y, z, 0 );
m_idToVertices.insert( ID2WPointXYZId::value_type( id, pt ) );
}
if( wMarchingCubesCaseTables::edgeTable[tableIndex] & 256 )
{
WPointXYZId pt = calculateIntersection( vals, x, y, z, 8 );
unsigned int id = getEdgeID( x, y, z, 8 );
m_idToVertices.insert( ID2WPointXYZId::value_type( id, pt ) );
}
if( x == m_nCellsX - 1 )
{
if( wMarchingCubesCaseTables::edgeTable[tableIndex] & 4 )
{
WPointXYZId pt = calculateIntersection( vals, x, y, z, 2 );
unsigned int id = getEdgeID( x, y, z, 2 );
m_idToVertices.insert( ID2WPointXYZId::value_type( id, pt ) );
}
if( wMarchingCubesCaseTables::edgeTable[tableIndex] & 2048 )
{
WPointXYZId pt = calculateIntersection( vals, x, y, z, 11 );
unsigned int id = getEdgeID( x, y, z, 11 );
m_idToVertices.insert( ID2WPointXYZId::value_type( id, pt ) );
}
}
if( y == m_nCellsY - 1 )
{
if( wMarchingCubesCaseTables::edgeTable[tableIndex] & 2 )
{
WPointXYZId pt = calculateIntersection( vals, x, y, z, 1 );
unsigned int id = getEdgeID( x, y, z, 1 );
m_idToVertices.insert( ID2WPointXYZId::value_type( id, pt ) );
}
if( wMarchingCubesCaseTables::edgeTable[tableIndex] & 512 )
{
WPointXYZId pt = calculateIntersection( vals, x, y, z, 9 );
unsigned int id = getEdgeID( x, y, z, 9 );
m_idToVertices.insert( ID2WPointXYZId::value_type( id, pt ) );
}
}
if( z == m_nCellsZ - 1 )
{
if( wMarchingCubesCaseTables::edgeTable[tableIndex] & 16 )
{
WPointXYZId pt = calculateIntersection( vals, x, y, z, 4 );
unsigned int id = getEdgeID( x, y, z, 4 );
m_idToVertices.insert( ID2WPointXYZId::value_type( id, pt ) );
}
if( wMarchingCubesCaseTables::edgeTable[tableIndex] & 128 )
{
WPointXYZId pt = calculateIntersection( vals, x, y, z, 7 );
unsigned int id = getEdgeID( x, y, z, 7 );
m_idToVertices.insert( ID2WPointXYZId::value_type( id, pt ) );
}
}
if( ( x == m_nCellsX - 1 ) && ( y == m_nCellsY - 1 ) )
if( wMarchingCubesCaseTables::edgeTable[tableIndex] & 1024 )
{
WPointXYZId pt = calculateIntersection( vals, x, y, z, 10 );
unsigned int id = getEdgeID( x, y, z, 10 );
m_idToVertices.insert( ID2WPointXYZId::value_type( id, pt ) );
}
if( ( x == m_nCellsX - 1 ) && ( z == m_nCellsZ - 1 ) )
if( wMarchingCubesCaseTables::edgeTable[tableIndex] & 64 )
{
WPointXYZId pt = calculateIntersection( vals, x, y, z, 6 );
unsigned int id = getEdgeID( x, y, z, 6 );
m_idToVertices.insert( ID2WPointXYZId::value_type( id, pt ) );
}
if( ( y == m_nCellsY - 1 ) && ( z == m_nCellsZ - 1 ) )
if( wMarchingCubesCaseTables::edgeTable[tableIndex] & 32 )
{
WPointXYZId pt = calculateIntersection( vals, x, y, z, 5 );
unsigned int id = getEdgeID( x, y, z, 5 );
m_idToVertices.insert( ID2WPointXYZId::value_type( id, pt ) );
}
for( int i = 0; wMarchingCubesCaseTables::triTable[tableIndex][i] != -1; i += 3 )
{
WMCTriangle triangle;
unsigned int pointID0, pointID1, pointID2;
pointID0 = getEdgeID( x, y, z, wMarchingCubesCaseTables::triTable[tableIndex][i] );
pointID1 = getEdgeID( x, y, z, wMarchingCubesCaseTables::triTable[tableIndex][i + 1] );
pointID2 = getEdgeID( x, y, z, wMarchingCubesCaseTables::triTable[tableIndex][i + 2] );
triangle.pointID[0] = pointID0;