25 #ifndef WTURINGTEXTURECREATOR_H
26 #define WTURINGTEXTURECREATOR_H
31 #include <boost/thread.hpp>
32 #include <core/common/WThreadedRunner.h>
33 #include <core/graphicsEngine/WGETexture.h>
63 osg::ref_ptr< WGETexture3D >
create( std::size_t sizeX, std::size_t sizeY, std::size_t sizeZ );
116 void setTextureSize( std::size_t sizeX, std::size_t sizeY, std::size_t sizeZ );
143 void setBufferPointers( std::vector< float >
const* concentration1, std::vector< float >
const* concentration2,
144 std::vector< float >
const* noise, std::vector< float >* delta1, std::vector< float >* delta2 );
226 std::vector< std::shared_ptr< TextureThread > >
m_threads;
Base class for all classes needing to be executed in a separate thread.
The thread calculating the Turing concentration diffusion in a given range.
float m_diffusionConstant2
The amount of diffusion of fluid 2.
TextureThread(std::size_t id, std::size_t max)
Create a calculation thread.
std::vector< float > const * m_concentration1
the shared memory for concentration values of fluid 1
~TextureThread()
Destructor.
void setDiffusionConstants(float d1, float d2)
Diffusion constants according to Turing Reaction Diffusion algorithm.
float m_diffusionConstant1
The amount of diffusion of fluid 1.
std::size_t m_sizeY
Size of the resulting texture.
std::vector< float > const * m_concentration2
the shared memory for concentration values of fluid 2
std::vector< float > * m_delta2
the shared memory representing the concentration change of fluid 2
std::size_t m_id
ID of the thread.
float m_spotFactor
The factor defining the spot size and shape.
virtual void threadMain()
The actual thread function running the algorithm.
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)
Define the memory to work in.
void setTextureSize(std::size_t sizeX, std::size_t sizeY, std::size_t sizeZ)
Target texture size.
std::size_t m_sizeZ
Size of the resulting texture.
std::vector< float > * m_delta1
the shared memory representing the concentration change of fluid 1
void setSpotFactor(float spotFactor)
The factor influencing size and shape of a spot.
std::size_t m_sizeX
Size of the resulting texture.
std::vector< float > const * m_noise
the input noise.
std::size_t m_maxThreads
Number of all spawned threads.
Class to create a Turing noise texture using multiple threads if needed.
WTuringTextureCreator(std::size_t numThreads=boost::thread::hardware_concurrency())
Constructor.
void setSpotIrregularity(float irr)
The irregularity of the spots.
~WTuringTextureCreator()
Destructor.
void setNumIterations(std::size_t iter)
The number of iterations to use for calculating the texture.
std::vector< std::shared_ptr< TextureThread > > m_threads
The thread pool.
float m_numIterations
Number of iterations.
float m_spotSize
Spot size.
void setSpotSize(float size)
Define the size of the spots inside the texture.
float m_spotIrregularity
Spot irregularity.
osg::ref_ptr< WGETexture3D > create(std::size_t sizeX, std::size_t sizeY, std::size_t sizeZ)
Create the Turing noise texture of arbitrary size.