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