OpenWalnut  1.5.0dev
WDataSetVector.h
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 #ifndef WDATASETVECTOR_H
26 #define WDATASETVECTOR_H
27 
28 #include <memory>
29 
30 #include "WDataSetSingle.h"
31 
32 
33 /**
34  * This data set type contains vectors as values.
35  * \ingroup dataHandler
36  */
37 class WDataSetVector : public WDataSetSingle // NOLINT
38 {
39 public:
40  /**
41  * shared_ptr abbreviation
42  */
43  typedef std::shared_ptr< WDataSetVector > SPtr;
44 
45  /**
46  * const shared_ptr abbreviation
47  */
48  typedef std::shared_ptr< const WDataSetVector > ConstSPtr;
49 
50  /**
51  * Constructs an instance out of an appropriate value set and a grid.
52  *
53  * \param newValueSet the vector value set to use
54  * \param newGrid the grid which maps world space to the value set
55  */
56  WDataSetVector( std::shared_ptr< WValueSetBase > newValueSet,
57  std::shared_ptr< WGrid > newGrid );
58 
59  /**
60  * Construct an empty and unusable instance. This is needed for the prototype mechanism.
61  */
63 
64  /**
65  * Destroys this DataSet instance
66  */
67  virtual ~WDataSetVector();
68 
69  /**
70  * Creates a copy (clone) of this instance but allows one to change the valueset. Unlike copy construction, this is a very useful function if you
71  * want to keep the dynamic type of your dataset.
72  *
73  * \param newValueSet the new valueset.
74  * \param newGrid the new grid.
75  *
76  * \return the clone
77  */
78  virtual WDataSetSingle::SPtr clone( std::shared_ptr< WValueSetBase > newValueSet, std::shared_ptr< WGrid > newGrid ) const;
79 
80  /**
81  * Creates a copy (clone) of this instance but allows one to change the valueset. Unlike copy construction, this is a very useful function if you
82  * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
83  *
84  * \param newValueSet the new valueset.
85  *
86  * \return the clone
87  */
88  virtual WDataSetSingle::SPtr clone( std::shared_ptr< WValueSetBase > newValueSet ) const;
89 
90  /**
91  * Creates a copy (clone) of this instance but allows one to change the grid. Unlike copy construction, this is a very useful function if you
92  * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
93  *
94  * \param newGrid the new grid.
95  *
96  * \return the clone
97  */
98  virtual WDataSetSingle::SPtr clone( std::shared_ptr< WGrid > newGrid ) const;
99 
100  /**
101  * Creates a copy (clone) of this instance. Unlike copy construction, this is a very useful function if you
102  * want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
103  *
104  * \return the clone
105  */
106  virtual WDataSetSingle::SPtr clone() const;
107 
108  /**
109  * Returns a prototype instantiated with the true type of the deriving class.
110  *
111  * \return the prototype.
112  */
113  static std::shared_ptr< WPrototyped > getPrototype();
114 
115  /**
116  * Interpolates the vector field at the given position
117  *
118  * \param pos position to interpolate
119  * \param success if the position was inside the grid
120  *
121  * \return Vector beeing the interpolate.
122  */
123  WVector3d interpolate( const WPosition &pos, bool *success ) const;
124 
125  /**
126  * Interpolates the very same way as \ref interpolate but it assures that all vecs are aligned to point into the same
127  * half-space. This is useful for eigenvector fields, where -v, and v both are eigenvectors.
128  *
129  * \param pos Position to interpolate a vector for
130  * \param success return parameter which is true if pos was inside of the grid, false otherwise.
131  *
132  * \return The resulting interpolated vector.
133  */
134  WVector3d eigenVectorInterpolate( const WPosition &pos, bool *success ) const;
135 
136  /**
137  * Get the vector on the given position in value set.
138  * \note currently only implmented for WVector3d
139  *
140  * \param index the position where to get the vector from
141  *
142  * \return the vector
143  */
144  WVector3d getVectorAt( size_t index ) const;
145 
146  /**
147  * Determines whether this dataset can be used as a texture.
148  *
149  * \return true if usable as texture.
150  */
151  virtual bool isTexture() const;
152 
153  /**
154  * Overwrites the isVectorDataSet check.
155  *
156  * \return Non empty reference to the dataset if it is a vector dataset, empty if not.
157  */
158  std::shared_ptr< WDataSetVector > isVectorDataSet();
159 
160 protected:
161  /**
162  * The prototype as singleton.
163  */
164  static std::shared_ptr< WPrototyped > m_prototype;
165 
166 private:
167 };
168 
169 inline std::shared_ptr< WDataSetVector > WDataSetVector::isVectorDataSet()
170 {
171  return std::static_pointer_cast< WDataSetVector >( shared_from_this() );
172 }
173 
174 #endif // WDATASETVECTOR_H
A data set consisting of a set of values based on a grid.
std::shared_ptr< WDataSetSingle > SPtr
Convenience typedef for a std::shared_ptr.
This data set type contains vectors as values.
std::shared_ptr< const WDataSetVector > ConstSPtr
const shared_ptr abbreviation
static std::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
virtual bool isTexture() const
Determines whether this dataset can be used as a texture.
virtual WDataSetSingle::SPtr clone() const
Creates a copy (clone) of this instance.
WVector3d eigenVectorInterpolate(const WPosition &pos, bool *success) const
Interpolates the very same way as interpolate but it assures that all vecs are aligned to point into ...
static std::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
virtual ~WDataSetVector()
Destroys this DataSet instance.
WDataSetVector()
Construct an empty and unusable instance.
WVector3d getVectorAt(size_t index) const
Get the vector on the given position in value set.
std::shared_ptr< WDataSetVector > isVectorDataSet()
Overwrites the isVectorDataSet check.
WVector3d interpolate(const WPosition &pos, bool *success) const
Interpolates the vector field at the given position.
std::shared_ptr< WDataSetVector > SPtr
shared_ptr abbreviation
This only is a 3d double vector.