Commit d05fd742 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[MERGE]

parents 1492bfc4 d356fd65
......@@ -119,96 +119,6 @@ std::vector< size_t > WHierarchicalTree::findXBiggestClusters( size_t cluster, s
return returnVector;
}
std::vector< size_t > WHierarchicalTree::findXBiggestClusters2( size_t cluster, size_t number )
{
//std::cout << number << " largest clusters for cluster: " << cluster << std::endl;
if ( number > m_containsLeafes[cluster].size() )
{
number = m_containsLeafes[cluster].size();
}
// init
std::list<size_t>worklist;
worklist.push_back( cluster );
while ( worklist.size() < number )
{
size_t current = worklist.front();
worklist.pop_front();
if ( m_containsLeafes[current].size() > 1 )
{
size_t left = m_children[current].first;
size_t right = m_children[current].second;
worklist.push_back( left );
worklist.push_back( right );
}
else
{
worklist.push_back( current );
}
}
worklist.sort( compSize( this ) );
bool newSplit = true;
while ( newSplit )
{
newSplit = false;
size_t current = worklist.front();
if ( m_containsLeafes[current].size() > 1 )
{
size_t left = m_children[current].first;
size_t right = m_children[current].second;
size_t last = worklist.back();
if ( ( m_containsLeafes[left].size() > m_containsLeafes[last].size() ) &&
( m_containsLeafes[right].size() > m_containsLeafes[last].size() ) )
{
if ( m_containsLeafes[left].size() > m_containsLeafes[last].size() )
{
worklist.pop_front();
worklist.push_back( left );
worklist.sort( compSize( this ) );
newSplit = true;
}
last = worklist.back();
if ( m_containsLeafes[right].size() > m_containsLeafes[last].size() )
{
if ( !newSplit )
{
worklist.pop_front();
}
if ( worklist.size() == number )
{
worklist.pop_back();
}
worklist.push_back( right );
worklist.sort( compSize( this ) );
newSplit = true;
}
}
}
}
std::vector<size_t>returnVector;
std::list<size_t>::iterator it;
for ( it = worklist.begin(); it != worklist.end(); ++it )
{
size_t current = *it;
//std::cout << "cluster:" << current << " size:" << m_containsLeafes[current].size() << std::endl;
returnVector.push_back( current );
}
return returnVector;
}
std::vector< size_t > WHierarchicalTree::downXLevelsFromTop( size_t level, bool hideOutliers )
{
if ( level > m_maxLevel )
......
......@@ -153,14 +153,6 @@ public:
*/
std::vector< size_t >findXBiggestClusters( size_t cluster, size_t number = 10 );
// TODO(schurade): merge these two function
/**
* finds the X biggest clusters for a given cluster
* \param cluster
* \param number of sub clusters
*/
std::vector< size_t >findXBiggestClusters2( size_t cluster, size_t number = 10 );
/**
* sets the color for a selected cluster and all sub clusters
* \param cluster
......
......@@ -399,9 +399,9 @@ boost::shared_ptr<WTriangleMesh> WMarchingLegoAlgorithm::genSurfaceOneValue( siz
resultPos4D[3] = m_matrix( 3, 0 ) * pos[0] + m_matrix( 3, 1 ) * pos[1] + m_matrix( 3, 2 ) * pos[2] + m_matrix( 3, 3 ) * 1;
( *mapIterator ).second.newID = nextID;
triMesh->addVertex( resultPos4D[0] / resultPos4D[3] - 0.5,
resultPos4D[1] / resultPos4D[3] - 0.5,
resultPos4D[2] / resultPos4D[3] - 0.5 );
triMesh->addVertex( resultPos4D[0] / resultPos4D[3],
resultPos4D[1] / resultPos4D[3],
resultPos4D[2] / resultPos4D[3] );
triMesh->addTextureCoordinate( texCoord );
nextID++;
mapIterator++;
......
......@@ -253,9 +253,9 @@ template<typename T> boost::shared_ptr<WTriangleMesh> WMarchingLegoAlgorithm::ge
resultPos4D[3] = m_matrix( 3, 0 ) * pos[0] + m_matrix( 3, 1 ) * pos[1] + m_matrix( 3, 2 ) * pos[2] + m_matrix( 3, 3 ) * 1;
( *mapIterator ).second.newID = nextID;
triMesh->addVertex( resultPos4D[0] / resultPos4D[3] - 0.5,
resultPos4D[1] / resultPos4D[3] - 0.5,
resultPos4D[2] / resultPos4D[3] - 0.5 );
triMesh->addVertex( resultPos4D[0] / resultPos4D[3],
resultPos4D[1] / resultPos4D[3],
resultPos4D[2] / resultPos4D[3] );
triMesh->addTextureCoordinate( texCoord );
nextID++;
mapIterator++;
......
......@@ -37,6 +37,7 @@
#include "../../common/WPathHelper.h"
#include "../../common/WPropertyHelper.h"
#include "../../graphicsEngine/algorithms/WMarchingLegoAlgorithm.h"
#include "../../graphicsEngine/WGEColormapping.h"
#include "../../graphicsEngine/WGEUtils.h"
#include "../../kernel/WKernel.h"
#include "../../kernel/WSelectionManager.h"
......@@ -127,19 +128,19 @@ void WMClusterDisplayVoxels::properties()
m_propSelectedCluster = m_groupSelection->addProperty( "Selected Cluster", "", 0, m_propCondition );
m_propSelectedCluster = m_groupSelection->addProperty( "Selected Cluster", "Selects a single cluster by number.", 0, m_propCondition );
m_propSelectedCluster->setMin( 0 );
m_propSelectedCluster->setMax( 0 );
m_propXBiggestClusters = m_groupSelection->addProperty( "Biggest Clusters", "", 5, m_propCondition );
m_propXBiggestClusters = m_groupSelection->addProperty( "Biggest Clusters", "Selects a number of biggest clusters.", 5, m_propCondition );
m_propXBiggestClusters->setMin( 1 );
m_propXBiggestClusters->setMax( 1000 );
m_propXClusters = m_groupSelection->addProperty( "X Clusters", "", 5, m_propCondition );
m_propXClusters = m_groupSelection->addProperty( "X Clusters", "Selects a number of clusters by dividing clusters.", 5, m_propCondition );
m_propXClusters->setMin( 1 );
m_propXClusters->setMax( 1000 );
m_propValue = m_groupSelection->addProperty( "Similarity Value", "", 1.0, m_propCondition );
m_propValue = m_groupSelection->addProperty( "Similarity Value", "Selects clusters below a given similarity value", 1.0, m_propCondition );
m_propValue->setMin( 0.0 );
m_propValue->setMax( 1.0 );
......@@ -365,9 +366,11 @@ void WMClusterDisplayVoxels::moduleMain()
m_propSelectedCluster->setHidden( false );
break;
case 1:
m_propSelectedCluster->setHidden( false );
m_propXBiggestClusters->setHidden( false );
break;
case 2:
m_propSelectedCluster->setHidden( false );
m_propXClusters->setHidden( false );
break;
case 3:
......@@ -473,7 +476,7 @@ void WMClusterDisplayVoxels::updateAll()
m_currentDisplayModeString = std::string( "Single selection" );
break;
case CDV_BIGGEST:
m_activatedClusters = m_tree.findXBiggestClusters2( m_propSelectedCluster->get(), m_propXBiggestClusters->get( true ) );
m_activatedClusters = m_tree.findXBiggestClusters( m_propSelectedCluster->get(), m_propXBiggestClusters->get( true ) );
m_currentDisplayModeString = std::string( "Biggest clusters" );
break;
case CDV_X:
......@@ -650,6 +653,26 @@ void WMClusterDisplayVoxels::createTexture()
WKernel::getRunningKernel()->getSelectionManager()->setUseTexture( true );
WDataHandler::getDefaultSubject()->getChangeCondition()->notify();
// osg::ref_ptr< osg::Image > ima = new osg::Image;
// ima->allocateImage( m_grid->getNbCoordsX(), m_grid->getNbCoordsY(), m_grid->getNbCoordsZ(), GL_RGB, GL_UNSIGNED_BYTE );
//
// unsigned char* data = ima->data();
// m_data.resize( m_grid->getNbCoordsX() * m_grid->getNbCoordsY() * m_grid->getNbCoordsZ(), 0 );
//
// for ( unsigned int i = 0; i < m_grid->size() * 3; ++i )
// {
// data[i] = 0.0;
// }
//
// m_texture = osg::ref_ptr< WGETexture3D >( new WGETexture3D( ima ) );
// m_texture->setFilterMinMag( osg::Texture3D::LINEAR );
// m_texture->setWrapSTR( osg::Texture::CLAMP_TO_BORDER );
// m_texture->colormap()->set( m_texture->colormap()->get().newSelector( WItemSelector::IndexList( 1, 4 ) ) );
// m_properties->addProperty( m_texture->alpha() );
//
// WGEColormapping::registerTexture( m_texture, "Cluster Texture" );
}
void WMClusterDisplayVoxels::createMesh()
......
......@@ -35,6 +35,7 @@
#include "../../dataHandler/WDataHandler.h"
#include "../../dataHandler/WDataSetScalar.h"
#include "../../dataHandler/WDataTexture3D.h"
#include "../../graphicsEngine/WGETexture.h"
#include "../../dataHandler/WSubject.h"
#include "../../dataHandler/WValueSet.h"
#include "../../graphicsEngine/geodes/WDendrogramGeode.h"
......@@ -228,6 +229,12 @@ private:
*/
osg::ref_ptr<osg::Texture3D>m_texture;
/**
* stores a pointer to the texture we paint in
*/
// osg::ref_ptr< WGETexture3D > m_texture;
/**
* label vector for texture creation
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment