OpenWalnut  1.5.0dev
WDataCreatorTuring.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <memory>
26 #include <vector>
27 
28 #include <core/common/WAssert.h>
29 
30 #include "WDataCreatorTuring.h"
31 #include "WTuringPatternCreator.h"
32 
34  : WObjectNDIP< WDataSetSingleCreatorInterface >( "Turing", "Creates a volume with evenly distributed dots." )
35 {
36  m_spotSize = m_properties->addProperty( "Spot size", "", 0.65 );
37  m_spotSize->setMax( 1.0 );
38  m_spotSize->setMin( 0.0 );
39 
40  m_spotIrregularity = m_properties->addProperty( "Spot irregularity", "", 0.0 );
41  m_spotIrregularity->setMax( 1.0 );
42  m_spotIrregularity->setMin( 0.0 );
43 
44  m_iterations = m_properties->addProperty( "Turing integration steps", "", 100 );
45  m_iterations->setMin( 0 );
46  m_iterations->setMax( 1000000000 );
47 }
48 
50 {
51 }
52 
54  unsigned char dimension, dataType type )
55 {
56  WAssert( order == 0 && dimension == 1 && type == W_DT_FLOAT, "The data creator only supports floating point scalar data." );
57 
58  WTuringPatternCreator creator( progress );
59  creator.setSpotSize( m_spotSize->get() );
60  creator.setSpotIrregularity( m_spotIrregularity->get() );
61  creator.setNumIterations( m_iterations->get() );
62 
63  std::shared_ptr< std::vector< float > > data = creator.create( grid->getNbCoordsX(), grid->getNbCoordsY(), grid->getNbCoordsZ() );
64 
65  return WValueSet< float >::SPtr( new WValueSet< float >( 0, 1, data ) );
66 }
67 
virtual WValueSetBase::SPtr operator()(WProgress::SPtr progress, WGridRegular3D::ConstSPtr grid, unsigned char order=0, unsigned char dimension=1, dataType type=W_DT_FLOAT)
Create the dataset.
WDataCreatorTuring()
Default constructor.
virtual ~WDataCreatorTuring()
Destructor.
WPropDouble m_spotSize
Property for the size of the spots.
WPropInt m_iterations
Property for the number of iterations during simulation.
WPropDouble m_spotIrregularity
Property for the irregularity of the spots.
Define the interface which is injected into an WObjectNDIP.
std::shared_ptr< const WGridRegular3DTemplate > ConstSPtr
Convenience typedef for a std::shared_ptr< const WGridRegular3DTemplate >.
This is a base class for everything which has a Name,Description,Icon and Properties (=NDIP).
Definition: WObjectNDIP.h:42
WProperties::SPtr m_properties
the properties of the object.
Definition: WObjectNDIP.h:99
std::shared_ptr< WProgress > SPtr
Shared pointer on a WProgress.
Definition: WProgress.h:48
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.
void setSpotSize(float size)
Sets the spotsize parameter.
void setNumIterations(std::size_t iter)
Sets the number of iterations for the chemical simulation that creates the pattern.
std::shared_ptr< WValueSetBase > SPtr
Shared pointer to an instance of this class.
Definition: WValueSetBase.h:65
Base Class for all value set types.
Definition: WValueSet.h:47
dataType
Data types and number values taken from the nifti1.h, at this point it's unknown if it makes sense to...