29 #include "../common/WAssert.h"
30 #include "../common/WLimits.h"
31 #include "WDataSetScalar.h"
32 #include "WDataSetSingle.h"
33 #include "datastructures/WValueSetHistogram.h"
39 std::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." );
80 return "WDataSetScalar";
85 return "A scalar dataset, i.e. one scalar value per voxel.";
110 std::shared_ptr< WGridRegular3D > grid = std::dynamic_pointer_cast< WGridRegular3D >(
m_grid );
112 WAssert( grid,
"This data set has a grid whose type is not yet supported for interpolation." );
114 "Only implemented for scalar values so far." );
116 bool isInside =
true;
117 size_t cellId = grid->getCellId( pos, &isInside );
127 WPosition localPos = grid->getTransform().directionToGridSpace( pos - grid->getPosition( vertexIds[0] ) );
129 double lambdaX = localPos[0];
130 double lambdaY = localPos[1];
131 double lambdaZ = localPos[2];
132 std::vector< double > h( 8 );
142 h[0] = ( 1 - lambdaX ) * ( 1 - lambdaY ) * ( 1 - lambdaZ );
143 h[1] = ( lambdaX ) * ( 1 - lambdaY ) * ( 1 - lambdaZ );
144 h[2] = ( 1 - lambdaX ) * ( lambdaY ) * ( 1 - lambdaZ );
145 h[3] = ( lambdaX ) * ( lambdaY ) * ( 1 - lambdaZ );
146 h[4] = ( 1 - lambdaX ) * ( 1 - lambdaY ) * ( lambdaZ );
147 h[5] = ( lambdaX ) * ( 1 - lambdaY ) * ( lambdaZ );
148 h[6] = ( 1 - lambdaX ) * ( lambdaY ) * ( lambdaZ );
149 h[7] = ( lambdaX ) * ( lambdaY ) * ( lambdaZ );
152 for(
size_t i = 0; i < 8; ++i )
163 std::shared_ptr< WGridRegular3D > grid = std::dynamic_pointer_cast< WGridRegular3D >(
m_grid );
164 size_t id = x + y * grid->getNbCoordsX() + z * grid->getNbCoordsX() * grid->getNbCoordsY();
virtual ~WDataSetScalar()
Destroys this DataSet instance.
static std::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
double getMin() const
Returns the smallest of the scalars stored in the data set.
double interpolate(const WPosition &pos, bool *success) const
Interpolate the value for the valueset at the given position.
static std::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
T getValueAt(int x, int y, int z) const
Get the value stored at a certain grid position of the data set.
std::map< size_t, std::shared_ptr< WValueSetHistogram > > m_histograms
The histograms for later use.
virtual const std::string getName() const
Gets the name of this prototype.
std::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.
boost::mutex m_histogramLock
The lock used for securely creating m_histogram on demand.
virtual const std::string getDescription() const
Gets the description for this prototype.
WDataSetScalar()
Construct an empty and unusable instance.
A data set consisting of a set of values based on a grid.
std::shared_ptr< WValueSetBase > getValueSet() const
std::shared_ptr< WGrid > m_grid
Stores the reference of the WGrid of this DataSetSingle instance.
std::shared_ptr< WGrid > getGrid() const
double getSingleRawValue(size_t id) const
Get the raw scalar value stored at id-th position of the raw array of the value set.
std::shared_ptr< WValueSetBase > m_valueSet
Stores the reference of the WValueSet of this DataSetSingle instance.
std::shared_ptr< WDataSetSingle > SPtr
Convenience typedef for a std::shared_ptr.
boost::array< size_t, 8 > CellVertexArray
Convenience typedef for a boost::array< size_t, 8 >.
This only is a 3d double vector.
Used to find the occurrence frequencies of values in a value set.