25 #ifndef WTURINGPATTERNCREATOR_H
26 #define WTURINGPATTERNCREATOR_H
31 #include <boost/thread.hpp>
32 #include <core/common/WConditionSet.h>
33 #include <core/common/WCounter.h>
34 #include <core/common/WProgress.h>
35 #include <core/common/WThreadedRunner.h>
36 #include <core/graphicsEngine/WGETexture.h>
52 WTuringPatternCreator( std::shared_ptr< WProgress >
const progress, std::size_t numThreads = boost::thread::hardware_concurrency() );
68 std::shared_ptr< std::vector< float > >
create( std::size_t sizeX, std::size_t sizeY, std::size_t sizeZ );
110 PatternThread( std::size_t
id, std::size_t max, std::shared_ptr< WCondition >
const mainThreadContinueCondition,
111 std::shared_ptr< WCondition >
const waitForMainThreadCondition,
WCounter*
const counter );
125 void setDomainSize( std::size_t sizeX, std::size_t sizeY, std::size_t sizeZ );
151 void setBufferPointers( std::vector< float >
const* concentration1, std::vector< float >
const* concentration2,
152 std::vector< float >
const* noise, std::vector< float >* delta1, std::vector< float >* delta2 );
This is a simple but thread-safe counter.
Base class for all classes needing to be executed in a separate thread.
A thread calculating the reaction for a certain part of the domain.
std::vector< float > * m_delta1
A buffer that will store the change in concentration for the first substance.
void setDomainSize(std::size_t sizeX, std::size_t sizeY, std::size_t sizeZ)
Set the domain size.
std::size_t m_id
The number of this thread.
std::vector< float > * m_delta2
A buffer that will store the change in concentration for the second substance.
std::vector< float > const * m_concentration1
The buffer for the concentration of the first substance.
std::shared_ptr< WCondition > m_waitForMainThreadCondition
The condition used by the main thread to notify we are ready to start the next iteration.
void setDiffusionConstants(float d1, float d2)
Set the diffusion constants.
std::size_t m_sizeY
The size of the domain in y-direction.
PatternThread(std::size_t id, std::size_t max, std::shared_ptr< WCondition > const mainThreadContinueCondition, std::shared_ptr< WCondition > const waitForMainThreadCondition, WCounter *const counter)
Constructor.
void setBufferPointers(std::vector< float > const *concentration1, std::vector< float > const *concentration2, std::vector< float > const *noise, std::vector< float > *delta1, std::vector< float > *delta2)
Set the pointers to the buffer all threads share.
void setSpotFactor(float spotFactor)
Set the spot factor.
void finish()
Tells the thread to finish.
WCounter *const m_counter
Counts the number of threads done with the current iteration.
std::size_t m_sizeZ
The size of the domain in z-direction.
std::size_t m_maxThreads
The maximum number of threads.
virtual void threadMain()
The entry point for the thread.
std::vector< float > const * m_noise
A constant buffer containing a random value per voxel.
std::shared_ptr< WCondition > m_mainThreadContinueCondition
The condition used to tell the main thread we are done for this iteration.
~PatternThread()
Destructor.
float m_diffusionConstant1
The first diffusion constant.
bool m_stop
Whether we are to stop the thread.
float m_diffusionConstant2
The second diffusion constant.
std::vector< float > const * m_concentration2
The buffer for the concentration of the second substance.
float m_spotFactor
The spot factor.
std::size_t m_sizeX
The size of the domain in x-direction.
Creates a pattern of evenly spaced dots via simulating a chemical reaction.
std::shared_ptr< std::vector< float > > create(std::size_t sizeX, std::size_t sizeY, std::size_t sizeZ)
Creates the 3D pattern and writes it into a vector of floats.
void setSpotIrregularity(float irr)
Sets the spot irregularity parameter.
float m_spotSize
The spot size parameter.
void setSpotSize(float size)
Sets the spotsize parameter.
float m_spotIrregularity
The spot irregularity parameter.
~WTuringPatternCreator()
Destructor.
void setNumIterations(std::size_t iter)
Sets the number of iterations for the chemical simulation that creates the pattern.
WTuringPatternCreator(std::shared_ptr< WProgress > const progress, std::size_t numThreads=boost::thread::hardware_concurrency())
Constructor.
float m_numIterations
The number of iterations for the simulation.
std::size_t m_numThreads
The number of threads to use.
std::shared_ptr< WProgress > m_progress
The progress to increment.