28 #include "WMarchingLegoAlgorithm.h"
103 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id2, pt2 ) );
109 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id3, pt3 ) );
115 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id4, pt4 ) );
135 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id1, pt1 ) );
141 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id2, pt2 ) );
147 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id3, pt3 ) );
153 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id4, pt4 ) );
173 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id1, pt1 ) );
179 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id2, pt2 ) );
185 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id3, pt3 ) );
191 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id4, pt4 ) );
211 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id1, pt1 ) );
217 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id2, pt2 ) );
223 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id3, pt3 ) );
229 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id4, pt4 ) );
249 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id1, pt1 ) );
255 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id2, pt2 ) );
261 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id3, pt3 ) );
267 m_idToVertices.insert( ID2WMLPointXYZId::value_type( id4, pt4 ) );
293 const std::vector< size_t >* vals,
295 std::shared_ptr< WProgressCombiner > mainProgress )
297 WAssert( vals,
"No value set provided." );
308 size_t nX = nbCoordsX;
309 size_t nY = nbCoordsY;
311 size_t nPointsInSlice = nX * nY;
313 std::shared_ptr< WProgress > progress;
316 progress = std::shared_ptr< WProgress >(
new WProgress(
"Marching Legos",
m_nCellsZ ) );
317 mainProgress->addSubProgress( progress );
331 if( ( *vals )[ z * nPointsInSlice + y * nX + x ] != isoValue )
336 if( x > 0 && ( ( *vals )[ z * nPointsInSlice + y * nX + x - 1 ] != isoValue ) )
340 if( x <
m_nCellsX - 1 && ( ( *vals )[ z * nPointsInSlice + y * nX + x + 1 ] != isoValue ) )
345 if( y > 0 && ( ( *vals )[ z * nPointsInSlice + ( y - 1 ) * nX + x ] != isoValue ) )
350 if( y <
m_nCellsY - 1 && ( ( *vals )[ z * nPointsInSlice + ( y + 1 ) * nX + x ] != isoValue ) )
355 if( z > 0 && ( ( *vals )[ ( z - 1 ) * nPointsInSlice + y * nX + x ] != isoValue ) )
360 if( z <
m_nCellsZ - 1 && ( ( *vals )[ ( z + 1 ) * nPointsInSlice + y * nX + x ] != isoValue ) )
396 unsigned int nextID = 0;
404 mapIterator->second.y / nbCoordsY,
405 mapIterator->second.z / nbCoordsZ );
408 WPosition pos =
WPosition( mapIterator->second.x, mapIterator->second.y, mapIterator->second.z );
410 std::vector< double > resultPos4D( 4 );
416 ( *mapIterator ).second.newID = nextID;
417 triMesh->addVertex( resultPos4D[0] / resultPos4D[3],
418 resultPos4D[1] / resultPos4D[3],
419 resultPos4D[2] / resultPos4D[3] );
420 triMesh->addTextureCoordinate( texCoord );
429 for(
unsigned int i = 0; i < 3; i++ )
431 unsigned int newID =
m_idToVertices[( *vecIterator ).pointID[i]].newID;
432 ( *vecIterator ).pointID[i] = newID;
434 triMesh->addTriangle( ( *vecIterator ).pointID[0], ( *vecIterator ).pointID[1], ( *vecIterator ).pointID[2] );
ID2WMLPointXYZId m_idToVertices
List of WPointXYZIds which form the isosurface.
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.
std::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, std::shared_ptr< WProgressCombiner > progress=std::shared_ptr< WProgressCombiner >())
Generate the triangles for the surface on the given dataSet (inGrid, vals).
size_t getVertexID(size_t nX, size_t nY, size_t nZ)
returns a vertex id for a given grid point
unsigned int m_nCellsZ
No. of cells in z direction.
WMLTriangleVECTOR m_trivecTriangles
List of WMCTriangleS which form the triangulation of the isosurface.
void addSurface(size_t x, size_t y, size_t z, size_t surface)
adds 2 triangles for a given face of the voxel
~WMarchingLegoAlgorithm()
destructor
unsigned int m_nCellsY
No. of cells in y direction.
This only is a 3d double vector.
Class managing progress inside of modules.
Triangle mesh data structure allowing for convenient access of the elements.
A point consisting of its coordinates and ID.
double x
x coordinates of the point.
double y
y coordinates of the point.
double z
z coordinates of the point.
unsigned int newID
ID of the point.
Encapsulated ids representing a triangle.
unsigned int pointID[3]
The IDs of the vertices of the triangle.