27 #include "WMarchingLegoAlgorithm.h"
102 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id2, pt2 ) );
108 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id3, pt3 ) );
114 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id4, pt4 ) );
134 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id1, pt1 ) );
140 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id2, pt2 ) );
146 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id3, pt3 ) );
152 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id4, pt4 ) );
172 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id1, pt1 ) );
178 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id2, pt2 ) );
184 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id3, pt3 ) );
190 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id4, pt4 ) );
210 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id1, pt1 ) );
216 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id2, pt2 ) );
222 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id3, pt3 ) );
228 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id4, pt4 ) );
248 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id1, pt1 ) );
254 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id2, pt2 ) );
260 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id3, pt3 ) );
266 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id4, pt4 ) );
292 const std::vector< size_t >* vals,
294 boost::shared_ptr< WProgressCombiner > mainProgress )
296 WAssert( vals,
"No value set provided." );
307 size_t nX = nbCoordsX;
308 size_t nY = nbCoordsY;
310 size_t nPointsInSlice = nX * nY;
312 boost::shared_ptr< WProgress > progress;
315 progress = boost::shared_ptr< WProgress >(
new WProgress(
"Marching Legos",
m_nCellsZ ) );
316 mainProgress->addSubProgress( progress );
330 if( ( *vals )[ z * nPointsInSlice + y * nX + x ] != isoValue )
335 if( x > 0 && ( ( *vals )[ z * nPointsInSlice + y * nX + x - 1 ] != isoValue ) )
339 if( x < m_nCellsX - 1 && ( ( *vals )[ z * nPointsInSlice + y * nX + x + 1 ] != isoValue ) )
344 if( y > 0 && ( ( *vals )[ z * nPointsInSlice + ( y - 1 ) * nX + x ] != isoValue ) )
349 if( y < m_nCellsY - 1 && ( ( *vals )[ z * nPointsInSlice + ( y + 1 ) * nX + x ] != isoValue ) )
354 if( z > 0 && ( ( *vals )[ ( z - 1 ) * nPointsInSlice + y * nX + x ] != isoValue ) )
359 if( z < m_nCellsZ - 1 && ( ( *vals )[ ( z + 1 ) * nPointsInSlice + y * nX + x ] != isoValue ) )
368 if( x == m_nCellsX - 1 )
378 if( y == m_nCellsY - 1 )
388 if( z == m_nCellsZ - 1 )
395 unsigned int nextID = 0;
403 mapIterator->second.y / nbCoordsY,
404 mapIterator->second.z / nbCoordsZ );
407 WPosition pos =
WPosition( mapIterator->second.x, mapIterator->second.y, mapIterator->second.z );
409 std::vector< double > resultPos4D( 4 );
415 ( *mapIterator ).second.newID = nextID;
416 triMesh->addVertex( resultPos4D[0] / resultPos4D[3],
417 resultPos4D[1] / resultPos4D[3],
418 resultPos4D[2] / resultPos4D[3] );
419 triMesh->addTextureCoordinate( texCoord );
428 for(
unsigned int i = 0; i < 3; i++ )
430 unsigned int newID =
m_idToVertices[( *vecIterator ).pointID[i]].newID;
431 ( *vecIterator ).pointID[i] = newID;
433 triMesh->addTriangle( ( *vecIterator ).pointID[0], ( *vecIterator ).pointID[1], ( *vecIterator ).pointID[2] );
unsigned int newID
ID of the point.
unsigned int pointID[3]
The IDs of the vertices of the triangle.
ID2WMLPointXYZId m_idToVertices
List of WPointXYZIds which form the isosurface.
A point consisting of its coordinates and ID.
Class managing progress inside of modules.
Encapsulated ids representing a triangle.
boost::shared_ptr< WTriangleMesh > genSurfaceOneValue(size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ, const WMatrix< double > &mat, const std::vector< size_t > *vals, size_t isoValue, boost::shared_ptr< WProgressCombiner > progress=boost::shared_ptr< WProgressCombiner >())
Generate the triangles for the surface on the given dataSet (inGrid, vals).
void addSurface(size_t x, size_t y, size_t z, size_t surface)
adds 2 triangles for a given face of the voxel
double y
y coordinates of the point.
unsigned int m_nCellsY
No. of cells in y direction.
This only is a 3d double vector.
unsigned int m_nCellsZ
No. of cells in z direction.
~WMarchingLegoAlgorithm()
destructor
double z
z coordinates of the point.
WMLTriangleVECTOR m_trivecTriangles
List of WMCTriangleS which form the triangulation of the isosurface.
Triangle mesh data structure allowing for convenient access of the elements.
WMarchingLegoAlgorithm()
standard constructor
WMatrix< double > m_matrix
The 4x4 transformation matrix for the triangle vertices.
unsigned int m_nCellsX
No. of cells in x direction.
size_t getVertexID(size_t nX, size_t nY, size_t nZ)
returns a vertex id for a given grid point
double x
x coordinates of the point.