Commit 5494f314 authored by reichenbach's avatar reichenbach

[CHANGE] path to the stipples file can now be set via property

parent ac69e9a5
......@@ -101,6 +101,9 @@ void WMFiberStipples::connectors()
void WMFiberStipples::properties()
{
m_stipplesFile = m_properties->addProperty( "Stipples file", "File containing the set of stipples to create or use, if existing.",
boost::filesystem::path( "/" ), m_propCondition );
m_color = m_properties->addProperty( "Color", "Color for the fiber stipples", WColor( 1.0, 0.0, 0.0, 1.0 ) );
m_threshold = m_properties->addProperty( "Threshold", "Connectivity scores below this threshold will be discarded.", 0.01 );
m_threshold->setMin( 0.0 );
......@@ -417,13 +420,19 @@ void WMFiberStipples::moduleMain()
// determine which axis to draw stipples
size_t axis = m_sliceSelection->get( true ).at( 0 )->getAs< AxisType >()->getValue();
if( m_sampleRes->changed() )
if( m_sampleRes->changed() || m_stipplesFile->changed() )
{
debugLog() << "New poission sampling resolution";
boost::filesystem::remove( "/tmp/klaus" );
m_stippleFileName = m_stipplesFile->get( true ).string();;
if( m_sampleRes->changed() )
{
debugLog() << "New poission sampling resolution";
if( boost::filesystem::path( "/" ) != boost::filesystem::path( m_stippleFileName ) && boost::filesystem::exists( m_stippleFileName ) && boost::filesystem::is_regular_file( m_stippleFileName ) )
boost::filesystem::remove( m_stippleFileName );
}
boost::shared_ptr< WProgress > splitProgress( new WProgress( "Split Poisson-Disk samplings hierachical", numDensitySlices ) );
m_progress->addSubProgress( splitProgress );
m_samplers = splitSamplingPoisson2( WSampler2DPoisson( m_sampleRes->get( true ) ), numDensitySlices, m_numSamples->get( true ), splitProgress );
m_samplers = splitSamplingPoisson2( WSampler2DPoisson( m_sampleRes->get( true ) ), numDensitySlices, m_numSamples->get( true ), splitProgress, m_stippleFileName );
}
// save data behind connectors since it might change during processing
......
......@@ -122,6 +122,8 @@ private:
*/
boost::shared_ptr< WModuleInputData< WDataSetVector > > m_vectorIC;
WPropFilename m_stipplesFile;
/**
* Color for the fiber stipples.
*/
......@@ -184,6 +186,8 @@ private:
// TODO(math): Remove this ugly hack as soon as possible
std::vector< WSampler2D > m_samplers;
std::string m_stippleFileName;
};
#endif // WMFIBERSTIPPLES_H
......@@ -276,46 +276,11 @@ namespace{
return false;
}
}
std::vector< WSampler2D > splitSamplingPoisson2( const WSampler2D& sampler, const size_t numComponents, const size_t numsamples, boost::shared_ptr< WProgress > progress )
std::vector< WSampler2D > splitSamplingPoisson2( const WSampler2D& sampler, const size_t numComponents, const size_t numsamples, boost::shared_ptr< WProgress > progress, std::string const& cache )
{
// Debug:: BottomUP Variante
// std::vector< WSampler2D > components;
//
// std::vector< Vec2 > pointsSoFar;
//
// for( size_t i = 0; i < numComponents; ++i ) {
// double radius = 1.0 / std::sqrt( static_cast< double >( (i + 1) * sampler.size() / numComponents ) ) / 2.0;
// boost::shared_ptr< PDSampler > s( new BoundarySampler( radius, true ) );
// for( size_t j = 0; j < pointsSoFar.size(); ++j) {
// s->addPoint( pointsSoFar[j] );
// }
// s->complete();
// std::vector< Vec2 > newpoints( s->points );
// // std::sort( newpoints.begin(), newpoints.end(), myless );
// // std::vector< Vec2 > diff( newpoints.size() - pointsSoFar.size(), Vec2( 0.0, 0.0 ) );
// // std::vector< Vec2 >::iterator it = std::set_difference( newpoints.begin(), newpoints.end(), pointsSoFar.begin(), pointsSoFar.end(), diff.begin(), myless );
// // diff.resize( it - diff.begin() );
//
// // double x,y;
// // WSampler2D comp;
// // for( size_t j = 0; j < diff.size(); ++j ) {
// // // rescale to [0,1]^2 domain
// // x = ( diff[j].x + 1.0 ) / 2.0;
// // y = ( diff[j].y + 1.0 ) / 2.0;
// // comp.push_back( WVector2d( x, y ) );
// // }
//
// // components.push_back( comp );
// std::swap( pointsSoFar, newpoints );
// ++*progress;
// }
// progress->finish();
// return components;
std::vector< WSampler2D > components;
std::string cache( "/tmp/klaus" );
if( fileExists( cache ) ) {
if( fileExists( cache ) && boost::filesystem::is_regular_file( cache ) ) {
components = loadHierarchy( cache );
}
else {
......@@ -375,7 +340,10 @@ std::vector< WSampler2D > splitSamplingPoisson2( const WSampler2D& sampler, cons
}
}
saveHierarchy( components, "/tmp/klaus" );
if( boost::filesystem::path( "/" ) != boost::filesystem::path( cache ) && ( !fileExists( cache ) || boost::filesystem::is_regular_file( cache ) ) )
{
saveHierarchy( components, cache );
}
progress->finish();
......
......@@ -221,6 +221,6 @@ public:
std::vector< WSampler2D > splitSampling( const WSampler2D& sampler, size_t numComponents );
std::vector< WSampler2D > splitSamplingPoisson( const WSampler2D& sampler, size_t numComponents, boost::shared_ptr< WProgress > splitProgress );
std::vector< WSampler2D > splitSamplingPoisson2( const WSampler2D& sampler, const size_t numComponents, const size_t numsamples, boost::shared_ptr< WProgress > splitProgress );
std::vector< WSampler2D > splitSamplingPoisson2( const WSampler2D& sampler, const size_t numComponents, const size_t numsamples, boost::shared_ptr< WProgress > splitProgress, std::string const& cache = "/tmp/klaus" );
#endif // WSAMPLER2D_H
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