30 #include "../../common/WStringUtils.h"
31 #include "../../common/WTransferable.h"
32 #include "../../common/datastructures/WUnionFind.h"
33 #include "../../common/exceptions/WNotImplemented.h"
34 #include "../WValueSet.h"
35 #include "WJoinContourTree.h"
44 m_elementIndices( dataset->getValueSet()->size() ),
45 m_joinTree( dataset->getValueSet()->size() ),
46 m_lowestVoxel( dataset->getValueSet()->size() )
48 if( dataset->getValueSet()->order() != 0 || dataset->getValueSet()->dimension() != 1 )
50 throw WNotImplemented( std::string(
"ATM there is only support for scalar fields" ) );
55 throw WNotImplemented( std::string(
"ATM there is only support for scalar fields with doubles as scalars" ) );
60 throw WNotImplemented( std::string(
"Only WGridRegular3D is supported, despite that its not a simplicial mesh!" ) );
80 for(
size_t i = 0; i <
m_joinTree.size(); ++i )
83 std::vector< size_t > neighbours =
m_grid->getNeighbours( m_elementIndices[i] );
84 std::vector< size_t >::const_iterator n = neighbours.begin();
85 for( ; n != neighbours.end(); ++n )
87 if( uf.find( m_elementIndices[i] ) == uf.find( *n ) ||
m_valueSet->getScalar( *n ) <=
m_valueSet->getScalar( m_elementIndices[i] ) )
93 uf.merge( m_elementIndices[i], *n );
95 m_lowestVoxel[ uf.find( *n ) ] = m_elementIndices[i];
103 boost::shared_ptr< std::vector< size_t > > result(
new std::vector< size_t >(
m_elementIndices ) );
121 if(
m_valueSet->getScalar( target ) >= isoValue )
123 uf.merge( target, m_elementIndices[i] );
127 return uf.getMaxSet();
131 : m_valueSet( valueSet )
Implements a very simple union-find datastructure aka disjoint_sets.
boost::shared_ptr< WValueSet< double > > m_valueSet
Stores reference to the isovalues, so we may sort them indirect on their value.
A grid that has parallelepiped cells which all have the same proportion.
WJoinContourTree(boost::shared_ptr< WDataSetSingle > dataset)
Initialize this with a data set for which the join tree should be computed.
bool operator()(size_t i, size_t j)
Compares the isovalue of the elments with index i and j.
void buildJoinTree()
Build the join tree.
static boost::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
std::vector< size_t > m_lowestVoxel
Stores the index of lowest element for the i'th component.
Indicates invalid element access of a container.
std::vector< size_t > m_joinTree
For each index stores which node it is connected to.
Class building the interface for classes that might be transferred using WModuleConnector.
Comperator for indirect sort so the value set is not modified.
boost::shared_ptr< std::set< size_t > > getVolumeVoxelsEnclosedByIsoSurface(const double isoValue) const
For a given isovalue all the voxel which are enclosed by the biggest isosurface are computed...
boost::shared_ptr< WGridRegular3D > m_grid
Stores the reference to the grid of the given dataset to get the neighbours of a voxel.
void sortIndexArray()
Sort the indices on their element value of the value set in descending order.
Processes a dataset for join tree computation.
Base Class for all value set types.
std::vector< size_t > m_elementIndices
Stores the component number for the i'th vertex in the value set.
IndirectCompare(boost::shared_ptr< WValueSet< double > > valueSet)
Since we must have access to the value set we need a reference to it.
static boost::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.