28 #include "../common/WAssert.h"
29 #include "../common/WLimits.h"
30 #include "datastructures/WValueSetHistogram.h"
31 #include "WDataSetSingle.h"
33 #include "WDataSetScalar.h"
39 boost::shared_ptr< WGrid > newGrid )
42 WAssert( newValueSet,
"No value set given." );
43 WAssert( newGrid,
"No grid given." );
44 WAssert( newValueSet->size() == newGrid->size(),
"Number of values unequal number of positions in grid." );
45 WAssert( newValueSet->order() == 0,
"The value set does not contain scalars." );
75 return "WDataSetScalar";
80 return "A scalar dataset, i.e. one scalar value per voxel.";
105 boost::shared_ptr< WGridRegular3D > grid = boost::dynamic_pointer_cast<
WGridRegular3D >(
m_grid );
107 WAssert( grid,
"This data set has a grid whose type is not yet supported for interpolation." );
109 "Only implemented for scalar values so far." );
111 bool isInside =
true;
112 size_t cellId = grid->getCellId( pos, &isInside );
122 WPosition localPos = grid->getTransform().positionToGridSpace( pos - grid->getPosition( vertexIds[0] ) );
124 double lambdaX = localPos[0];
125 double lambdaY = localPos[1];
126 double lambdaZ = localPos[2];
127 std::vector< double > h( 8 );
137 h[0] = ( 1 - lambdaX ) * ( 1 - lambdaY ) * ( 1 - lambdaZ );
138 h[1] = ( lambdaX ) * ( 1 - lambdaY ) * ( 1 - lambdaZ );
139 h[2] = ( 1 - lambdaX ) * ( lambdaY ) * ( 1 - lambdaZ );
140 h[3] = ( lambdaX ) * ( lambdaY ) * ( 1 - lambdaZ );
141 h[4] = ( 1 - lambdaX ) * ( 1 - lambdaY ) * ( lambdaZ );
142 h[5] = ( lambdaX ) * ( 1 - lambdaY ) * ( lambdaZ );
143 h[6] = ( 1 - lambdaX ) * ( lambdaY ) * ( lambdaZ );
144 h[7] = ( lambdaX ) * ( lambdaY ) * ( lambdaZ );
147 for(
size_t i = 0; i < 8; ++i )
158 boost::shared_ptr< WGridRegular3D > grid = boost::dynamic_pointer_cast<
WGridRegular3D >(
m_grid );
159 size_t id = x + y * grid->
getNbCoordsX() + z * grid->getNbCoordsX() * grid->getNbCoordsY();
Used to find the occurrence frequencies of values in a value set.
boost::shared_ptr< WGrid > m_grid
Stores the reference of the WGrid of this DataSetSingle instance.
A grid that has parallelepiped cells which all have the same proportion.
static boost::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
virtual ~WDataSetScalar()
Destroys this DataSet instance.
boost::array< size_t, 8 > CellVertexArray
Convenience typedef for a boost::array< size_t, 8 >.
virtual const std::string getName() const
Gets the name of this prototype.
boost::shared_ptr< WValueSetBase > getValueSet() const
double interpolate(const WPosition &pos, bool *success) const
Interpolate the value fo the valueset at the given position.
boost::mutex m_histogramLock
The lock used for securely creating m_histogram on demand.
std::map< size_t, boost::shared_ptr< WValueSetHistogram > > m_histograms
The histograms for later use.
This only is a 3d double vector.
boost::shared_ptr< WGrid > getGrid() const
WDataSetScalar()
Construct an empty and unusable instance.
boost::shared_ptr< WValueSetBase > m_valueSet
Stores the reference of the WValueSet of this DataSetSingle instance.
A data set consisting of a set of values based on a grid.
static boost::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
virtual const std::string getDescription() const
Gets the description for this prototype.
double getMin() const
Returns the smallest of the scalars stored in the data set.
boost::shared_ptr< WDataSetSingle > SPtr
Convenience typedef for a boost::shared_ptr.
T getValueAt(int x, int y, int z) const
Get the value stored at a certain grid position of the data set.
boost::shared_ptr< const WValueSetHistogram > getHistogram(size_t buckets=1000)
Returns the histogram of this dataset's valueset.
virtual WDataSetSingle::SPtr clone() const
Creates a copy (clone) of this instance.
double getMax() const
Returns the largest of the scalars stored in the data set.
unsigned int getNbCoordsX() const
Returns the number of samples in x direction.
T getValueAt(size_t id)
Get the value stored at position of the value set.