OpenWalnut  1.4.0
WDataSetFibers.h
00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WDATASETFIBERS_H
00026 #define WDATASETFIBERS_H
00027 
00028 #include <string>
00029 #include <utility>
00030 #include <vector>
00031 
00032 #include <boost/shared_ptr.hpp>
00033 #include <boost/tuple/tuple.hpp>
00034 
00035 #include "../common/math/linearAlgebra/WPosition.h"
00036 #include "../common/WBoundingBox.h"
00037 #include "../common/WProperties.h"
00038 #include "WDataSet.h"
00039 
00040 
00041 // forward declarations
00042 class WFiber;
00043 
00044 class WFiberIterator;
00045 
00046 class WFiberPointsIterator;
00047 
00048 /**
00049  * Represents a simple set of WFibers.
00050  */
00051 class WDataSetFibers : public WDataSet // NOLINT
00052 {
00053 public:
00054     // some type alias for the used arrays.
00055     /**
00056      * Pointer to dataset.
00057      */
00058     typedef boost::shared_ptr< WDataSetFibers > SPtr;
00059 
00060     /**
00061      * Pointer to const dataset.
00062      */
00063     typedef boost::shared_ptr< const WDataSetFibers > ConstSPtr;
00064 
00065     /**
00066      * List of vertex coordinates in term of components of vertices.
00067      */
00068     typedef boost::shared_ptr< std::vector< float > > VertexArray;
00069 
00070     /**
00071      * Index list indexing fibers in VertexArray in terms of vertex numbers.
00072      */
00073     typedef boost::shared_ptr< std::vector< size_t > > IndexArray;
00074 
00075     /**
00076      * Lengths of fibers in terms of vertices.
00077      */
00078     typedef boost::shared_ptr< std::vector< size_t > > LengthArray;
00079 
00080     /**
00081      * Tangents at each vertex in VertexArray.
00082      */
00083     typedef boost::shared_ptr< std::vector< float > > TangentArray;
00084 
00085     /**
00086      * Colors for each vertex in VertexArray.
00087      */
00088     typedef boost::shared_ptr< std::vector< float > > ColorArray;
00089 
00090     /**
00091      * Parameter storage for each vertex.
00092      */
00093     typedef boost::shared_ptr< std::vector< double > > VertexParemeterArray;
00094 
00095     /**
00096      * Iterator to go through the fibers.
00097      */
00098     typedef WFiberIterator iterator;
00099 
00100     /**
00101      * Const iterator to go through fibers. As the WFiberIterators does not allow any modifications per-se, the const iterator and the standard
00102      * iterator are the same.
00103      */
00104     typedef WFiberIterator const_iterator;
00105 
00106     /**
00107      * Item used in the selection below also containing color info.
00108      */
00109     class ColorScheme: public WItemSelectionItem
00110     {
00111     friend class WDataSetFibers;
00112     public:
00113         /**
00114          * different kinds of color arrays can be used in this class. This enum defines their possible types.
00115          */
00116         typedef enum
00117         {
00118             GRAY = 1,   //!< gray value per vertex
00119             RGB  = 3,   //!< rgb per vertex
00120             RGBA = 4    //!< rgba per vertex
00121         }
00122         ColorMode;
00123 
00124         /**
00125          * Constructor. Creates new item.
00126          *
00127          * \param name name, name of item.
00128          * \param description description of item. Can be empty.
00129          * \param icon icon, can be NULL
00130          * \param color the color array of this item.
00131          * \param mode the mode of the color array. This defines whether the colors are luminance, RGB or RGBA
00132          */
00133         ColorScheme( std::string name, std::string description, const char** icon, ColorArray color, ColorMode mode = RGB ):
00134             WItemSelectionItem( name, description, icon ),
00135             m_color( color ),
00136             m_mode( mode )
00137         {
00138         };
00139 
00140         /**
00141          * Get the color.
00142          *
00143          * \return the color array.
00144          */
00145         ColorArray getColor() const
00146         {
00147             return m_color;
00148         };
00149 
00150         /**
00151          * Returns the mode of the color scheme.
00152          *
00153          * \return the mode.
00154          */
00155         ColorMode getMode() const
00156         {
00157             return m_mode;
00158         };
00159 
00160     protected:
00161         /**
00162          * Sets the color array for this item.
00163          *
00164          * \param color the color to set.
00165          * \param mode the mode of the color array. This defines whether the colors are luminance, RGB or RGBA
00166          */
00167         void setColor( ColorArray color, ColorMode mode = RGB )
00168         {
00169             m_color = color;
00170             m_mode = mode;
00171         };
00172 
00173     private:
00174         /**
00175          * The color array associated with the item.
00176          */
00177         ColorArray m_color;
00178 
00179         /**
00180          * Coloring mode.
00181          */
00182         ColorMode m_mode;
00183     };
00184 
00185     /**
00186      * Constructs a new set of fibers.
00187      *
00188      * \param vertices the vertices of the fibers, stored in x1,y1,z1,x2,y2,z2, ..., xn,yn,zn scheme
00189      * \param lineStartIndexes the index in which the fiber start (index of the 3D-vertex, not the index of the float in the vertices vector)
00190      * \param lineLengths how many vertices belong to a fiber
00191      * \param verticesReverse stores for each vertex the index of the corresponding fiber
00192      * \param boundingBox The bounding box of the fibers (first minimum, second maximum).
00193      */
00194     WDataSetFibers( boost::shared_ptr< std::vector< float > >vertices,
00195                     boost::shared_ptr< std::vector< size_t > > lineStartIndexes,
00196                     boost::shared_ptr< std::vector< size_t > > lineLengths,
00197                     boost::shared_ptr< std::vector< size_t > > verticesReverse,
00198                     WBoundingBox boundingBox );
00199 
00200     /**
00201      * Constructs a new set of fibers. This constructor determines the bounding box by using the coordinates of the vertices.
00202      *
00203      * \param vertices the vertices of the fibers, stored in x1,y1,z1,x2,y2,z2, ..., xn,yn,zn scheme
00204      * \param lineStartIndexes the index in which the fiber start (index of the 3D-vertex, not the index of the float in the vertices vector)
00205      * \param lineLengths how many vertices belong to a fiber
00206      * \param verticesReverse stores for each vertex the index of the corresponding fiber
00207      */
00208     WDataSetFibers( boost::shared_ptr< std::vector< float > >vertices,
00209                     boost::shared_ptr< std::vector< size_t > > lineStartIndexes,
00210                     boost::shared_ptr< std::vector< size_t > > lineLengths,
00211                     boost::shared_ptr< std::vector< size_t > > verticesReverse );
00212 
00213     /**
00214      * Constructs a new set of fibers.
00215      *
00216      * \param vertices the vertices of the fibers, stored in x1,y1,z1,x2,y2,z2, ..., xn,yn,zn scheme
00217      * \param lineStartIndexes the index in which the fiber start (index of the 3D-vertex, not the index of the float in the vertices vector)
00218      * \param lineLengths how many vertices belong to a fiber
00219      * \param verticesReverse stores for each vertex the index of the corresponding fiber
00220      * \param boundingBox The bounding box of the fibers (first minimum, second maximum).
00221      * \param vertexParameters optional per-vertex scalar.
00222      */
00223     WDataSetFibers( boost::shared_ptr< std::vector< float > >vertices,
00224                     boost::shared_ptr< std::vector< size_t > > lineStartIndexes,
00225                     boost::shared_ptr< std::vector< size_t > > lineLengths,
00226                     boost::shared_ptr< std::vector< size_t > > verticesReverse,
00227                     WBoundingBox boundingBox,
00228                     VertexParemeterArray vertexParameters );
00229 
00230     /**
00231      * Constructs a new set of fibers. This constructor determines the bounding box by using the coordinates of the vertices.
00232      *
00233      * \param vertices the vertices of the fibers, stored in x1,y1,z1,x2,y2,z2, ..., xn,yn,zn scheme
00234      * \param lineStartIndexes the index in which the fiber start (index of the 3D-vertex, not the index of the float in the vertices vector)
00235      * \param lineLengths how many vertices belong to a fiber
00236      * \param verticesReverse stores for each vertex the index of the corresponding fiber
00237      * \param vertexParameters optional per-vertex scalar.
00238      */
00239     WDataSetFibers( boost::shared_ptr< std::vector< float > >vertices,
00240                     boost::shared_ptr< std::vector< size_t > > lineStartIndexes,
00241                     boost::shared_ptr< std::vector< size_t > > lineLengths,
00242                     boost::shared_ptr< std::vector< size_t > > verticesReverse,
00243                     VertexParemeterArray vertexParameters );
00244 
00245     /**
00246      * Constructs a new set of tracts. The constructed instance is not usable but needed for prototype mechanism.
00247      */
00248     WDataSetFibers();
00249 
00250     /**
00251      * Get number of tracts in this data set.
00252      * \return number of fibers
00253      */
00254     size_t size() const;
00255 
00256     /**
00257      * Determines whether this dataset can be used as a texture.
00258      *
00259      * \return true if usable as texture.
00260      */
00261     virtual bool isTexture() const;
00262 
00263     /**
00264      * Gets the name of this prototype.
00265      *
00266      * \return the name.
00267      */
00268     virtual const std::string getName() const;
00269 
00270     /**
00271      * Gets the description for this prototype.
00272      *
00273      * \return the description
00274      */
00275     virtual const std::string getDescription() const;
00276 
00277     /**
00278      * Returns a prototype instantiated with the true type of the deriving class.
00279      *
00280      * \return the prototype.
00281      */
00282     static boost::shared_ptr< WPrototyped > getPrototype();
00283 
00284     /**
00285      * Getter for the lines' vertices
00286      * \return The vertices of the lines
00287      */
00288     VertexArray getVertices() const;
00289 
00290     /**
00291      * Return the indices that indicate at which vertex ID each line begins in the vertex array.
00292      * \return The start indices of the lines
00293      */
00294     IndexArray getLineStartIndexes() const;
00295 
00296     /**
00297      * Return the number of vertices for all lines.
00298      * \return The numbers of all lines' vertices
00299      */
00300     LengthArray getLineLengths() const;
00301 
00302     /**
00303      * Returns a reverse lookup table that allow do find out which vertex belongs to which line.
00304      * \return Lookup table from vertices to lines.
00305      */
00306     IndexArray getVerticesReverse() const;
00307 
00308     /**
00309      * Returns an array containing the tangents of the fibers at the vertices.
00310      * \return The tangents of the fibers.
00311      */
00312     TangentArray getTangents() const;
00313 
00314     /**
00315      * Get the parameter values for each vertex. Same indexing as vertices. Used to store additional scalar values for each vertex.
00316      *
00317      * \return the array. Can be NULL.
00318      */
00319     VertexParemeterArray getVertexParameters() const;
00320 
00321     /**
00322      * This method adds a new color scheme to the list of available colors. The color scheme needs to have a name and description to allow the
00323      * user to identify which color has which meaning. If the specified color array already exists, only an update is triggered and the name and
00324      * description is ignored. It detects the type of colors by its size.
00325      *
00326      * \param colors the color array. Needs to have exactly getVertices()->size() items.
00327      * \param name name of the color scheme. Should be a telling name.
00328      * \param description description. How calculated and so on.
00329      */
00330     void addColorScheme( WDataSetFibers::ColorArray colors, std::string name, std::string description );
00331 
00332     /**
00333      * This method removes the specified color scheme from the list and triggers an update.
00334      *
00335      * \param colors the color array.
00336      */
00337     void removeColorScheme( WDataSetFibers::ColorArray colors );
00338 
00339     /**
00340      * Replaces the specified old color scheme by the new color scheme. If the old color scheme did not exist, nothing happens.
00341      *
00342      * \param oldColors old colors to remove
00343      * \param newColors new colors to set
00344      */
00345     void replaceColorScheme( WDataSetFibers::ColorArray oldColors, WDataSetFibers::ColorArray newColors );
00346 
00347     /**
00348      * Get the color scheme with the specified name. If it is not found, an exception gets thrown.
00349      *
00350      * \param name the name of the color scheme
00351      *
00352      * \return the color scheme
00353      * \throw WDHNoSuchDataSet if the name could not be found.
00354      */
00355     const boost::shared_ptr< ColorScheme > getColorScheme( std::string name ) const;
00356 
00357     /**
00358      * Get the color scheme with the specified ID. If the index is invalid, an exception gets thrown.
00359      *
00360      * \param idx the index
00361      *
00362      * \return the color scheme
00363      */
00364     const boost::shared_ptr< ColorScheme > getColorScheme( size_t idx ) const;
00365 
00366     /**
00367      * Convenience method returning the currently selected scheme. This is a comfortable alternative to using the color scheme selection
00368      * property.
00369      *
00370      * \return the current active color scheme
00371      */
00372     const boost::shared_ptr< ColorScheme > getColorScheme() const;
00373 
00374     /**
00375      * Returns the property controlling the color scheme selection.
00376      *
00377      * \return the property.
00378      */
00379     const WPropSelection getColorSchemeProperty() const;
00380 
00381     /**
00382      * returns the position in space for a vertex of a given fiber
00383      *
00384      * \param fiber Index of fiber
00385      * \param vertex Index of vertex in fiber.
00386      *
00387      * \return Position of the given vertex of the also given fiber
00388      */
00389     WPosition getPosition( size_t fiber, size_t vertex ) const;
00390 
00391     /**
00392      * calculates the tangent for a point on the fiber
00393      *
00394      * \param fiber Index of fiber
00395      * \param vertex Index of vertex in fiber
00396      *
00397      * \return Tangent of the given vertex of the also given fiber
00398      */
00399     WPosition getTangent( size_t fiber, size_t vertex ) const;
00400 
00401     /**
00402      * Get the bounding box.
00403      * \return The bounding box of all lines.
00404      */
00405     WBoundingBox getBoundingBox() const;
00406 
00407     /**
00408      * Constructs a WFiber out of the given tract number.
00409      *
00410      * \param numTract Number of the tract to generate a WFiber object for
00411      *
00412      * \return The WFiber object. Attention: copy by value!
00413      */
00414     WFiber operator[]( size_t numTract ) const;
00415 
00416     /**
00417      * Returns an iterator to the first fiber of the dataset. The iterator does not allow any modification of the data.
00418      *
00419      * \return An iterator to the first fiber.
00420      */
00421     const_iterator begin() const;
00422 
00423     /**
00424      * Returns an iterator pointing beyond the last fiber. The iterator does not allow any modification of the data.
00425      *
00426      * \return An iterator pointing beyond the last fiber.
00427      */
00428     const_iterator end() const;
00429 
00430 protected:
00431     /**
00432      * The prototype as singleton.
00433      */
00434     static boost::shared_ptr< WPrototyped > m_prototype;
00435 
00436 private:
00437     /**
00438      * This does the common initialisation of the constructors.
00439      */
00440     void init();
00441 
00442     /**
00443      * Point vector for all fibers
00444      */
00445     VertexArray m_vertices;
00446 
00447     /**
00448      * Point vector for tangents at each vertex, used for fake tubes
00449      */
00450     TangentArray m_tangents;
00451 
00452     /**
00453      * An array of color arrays. The first two elements are: 0: global color, 1: local color
00454      */
00455     boost::shared_ptr< WItemSelection > m_colors;
00456 
00457     /**
00458      * Property keeping track of the active color in m_colors.
00459      */
00460     WPropSelection m_colorProp;
00461 
00462     /**
00463      * Line vector that contains the start index of its first point for each line.
00464      * \warning The index returned cannot be used in the vertices array until
00465      * the number of components for each point is multiplied.
00466      */
00467     IndexArray m_lineStartIndexes;
00468 
00469     /**
00470      * Line vector that contains the number of vertices for each line
00471      */
00472     LengthArray m_lineLengths;
00473 
00474     /**
00475      * Reverse lookup table for which point belongs to which fiber
00476      */
00477     IndexArray m_verticesReverse;
00478 
00479     /**
00480      * Axis aligned bounding box for all tract-vertices of this dataset.
00481      */
00482     WBoundingBox m_bb;
00483 
00484     /**
00485      * Parameter array. Used to store additional scalar values for each vertex.
00486      */
00487     VertexParemeterArray m_vertexParameters;
00488 };
00489 
00490 /**
00491  * \class WFiberIterator
00492  *
00493  * \brief An iterator for fibers of a fiber dataset.
00494  *
00495  * This class iterates fibers of a fiber dataset.
00496  */
00497 class WFiberIterator
00498 {
00499 public:
00500     /**
00501      * Constructor. Creates an invalid iterator pointing nowhere.
00502      */
00503     WFiberIterator();
00504 
00505     /**
00506      * Constructor. Creates an iterator for a specific fiber dataset.
00507      *
00508      * \param fibers A pointer to the fiber data.
00509      * \param idx The index of the fiber to point to.
00510      */
00511     WFiberIterator( WDataSetFibers const* fibers, std::size_t idx );
00512 
00513     /**
00514      * Copy constructor.
00515      *
00516      * \param iter The iterator to copy from.
00517      */
00518     WFiberIterator( WFiberIterator const& iter ); // NOLINT explicit
00519 
00520     /**
00521      * Destructor.
00522      */
00523     ~WFiberIterator();
00524 
00525     /**
00526      * Copy operator.
00527      *
00528      * \param iter The iterator to copy from.
00529      *
00530      * \return *this
00531      */
00532     WFiberIterator& operator= ( WFiberIterator const& iter );
00533 
00534     /**
00535      * Increment operator. Makes the iterator point to the next fiber.
00536      *
00537      * \return The incremented iterator.
00538      */
00539     WFiberIterator& operator++ ();
00540 
00541     /**
00542      * Decrement operator. Makes the iterator point to the previous fiber.
00543      *
00544      * \return The decremented iterator.
00545      */
00546     WFiberIterator& operator-- ();
00547 
00548     /**
00549      * Increment operator. Makes the iterator point to the next fiber.
00550      *
00551      * \return The iterator before incrementing.
00552      */
00553     WFiberIterator operator++ ( int );
00554 
00555     /**
00556      * Decrement operator. Makes the iterator point to the previous fiber.
00557      *
00558      * \return The iterator before decrementing.
00559      */
00560     WFiberIterator operator-- ( int );
00561 
00562     /**
00563      * Compare to another fiber iterator.
00564      *
00565      * \param rhs The second fiber iterator.
00566      *
00567      * \return true, iff the two iterators point to the same fiber of the same fiber dataset.
00568      */
00569     bool operator == ( WFiberIterator const& rhs ) const;
00570 
00571     /**
00572      * Compare to another fiber iterator.
00573      *
00574      * \param rhs The second fiber iterator.
00575      *
00576      * \return false, iff the two iterators point to the same fiber of the same fiber dataset.
00577      */
00578     bool operator != ( WFiberIterator const& rhs ) const;
00579 
00580     /**
00581      * Creates a point iterator for forward iteration, pointing to the first point of the fiber.
00582      *
00583      * \return A point iterator pointing to the first point.
00584      */
00585     WFiberPointsIterator begin();
00586 
00587     /**
00588      * Creates a point iterator for forward iteration, pointing beyond the last point of the fiber.
00589      *
00590      * \return A point iterator pointing beyond the last point.
00591      */
00592     WFiberPointsIterator end();
00593 
00594     /**
00595      * Creates a point iterator for backward iteration, pointing to the last point of the fiber.
00596      *
00597      * \return A point iterator pointing to the last point.
00598      */
00599     WFiberPointsIterator rbegin();
00600 
00601     /**
00602      * Creates a point iterator for backward iteration, pointing beyond the first point of the fiber.
00603      *
00604      * \return A point iterator pointing beyond the first point.
00605      */
00606     WFiberPointsIterator rend();
00607 
00608     /**
00609      * Returns the number of points of the current fiber.
00610      *
00611      * \return The number of points.
00612      */
00613     std::size_t numPoints() const;
00614 
00615     /**
00616      * Get the index in the point array where the points data starts for this line. You can use \ref numPoints to know how much data to read
00617      * from the vertex array.
00618      *
00619      * \note You should avoid using these indices as can use the iterators to query the data. But it might get handy in some situations,
00620      * where raw data processing is needed.
00621      *
00622      * \return the start index.
00623      */
00624     std::size_t getLineStartIndex() const;
00625 
00626     /**
00627      * Get the index of the line.
00628      *
00629      * \note You should avoid using these indices as can use the iterators to query the data. But it might get handy in some situations,
00630      * where raw data processing is needed.
00631      *
00632      * \return the index.
00633      */
00634     std::size_t getIndex() const;
00635 
00636 private:
00637     //! The pointer to the fibers.
00638     WDataSetFibers const* m_fibers;
00639 
00640     //! The current index in the fiber data.
00641     std::size_t m_index;
00642 };
00643 
00644 /**
00645  * \class WFiberPointsIterator
00646  *
00647  * \brief An iterator for iterating the points of a fiber.
00648  *
00649  * Allows for both forward and backward iteration of points.
00650  */
00651 class WFiberPointsIterator
00652 {
00653 public:
00654     /**
00655      * Default contructor. Creates an invalid iterator.
00656      */
00657     WFiberPointsIterator();
00658 
00659     /**
00660      * Constructor. Creates an iterator pointing to a certain point of a fiber.
00661      *
00662      * \param fibers The pointer to the fiber data.
00663      * \param fbIdx The index of the fiber in the fiber dataset.
00664      * \param idx The index of the point of the curent fiber.
00665      * \param reverse Whether to iterate backwards.
00666      */
00667     WFiberPointsIterator( WDataSetFibers const* fibers, std::size_t fbIdx, std::size_t idx, bool reverse = false );
00668 
00669     /**
00670      * Copy constructor.
00671      *
00672      * \param iter The iterator to copy from.
00673      */
00674     WFiberPointsIterator( WFiberPointsIterator const& iter ); //NOLINT explicit
00675 
00676     /**
00677      * Destructor.
00678      */
00679     ~WFiberPointsIterator();
00680 
00681     /**
00682      * Copy operator.
00683      *
00684      * \param iter The iterator to copy from.
00685      *
00686      * \return *this
00687      */
00688     WFiberPointsIterator& operator= ( WFiberPointsIterator const& iter );
00689 
00690     /**
00691      * Increment operator. Makes the iterator point to the next point.
00692      *
00693      * \return The incremented iterator.
00694      */
00695     WFiberPointsIterator& operator++ ();
00696 
00697     /**
00698      * Decrement operator. Makes the iterator point to the previous point.
00699      *3
00700      * \return The incremented iterator.
00701      */
00702     WFiberPointsIterator& operator-- ();
00703 
00704     /**
00705      * Increment operator. Makes the iterator point to the next point.
00706      *
00707      * \return The iterator before incrementing.
00708      */
00709     WFiberPointsIterator operator++ ( int );
00710 
00711     /**
00712      * Decrement operator. Makes the iterator point to the previous point.
00713      *
00714      * \return The iterator before decrementing.
00715      */
00716     WFiberPointsIterator operator-- ( int );
00717 
00718     /**
00719      * Compare to another point iterator.
00720      *
00721      * \param rhs The second point iterator.
00722      *
00723      * \return true, iff the two iterators point to the same point of the same fiber.
00724      */
00725     bool operator== ( WFiberPointsIterator const& rhs ) const;
00726 
00727     /**
00728      * Compare to another point iterator.
00729      *
00730      * \param rhs The second point iterator.
00731      *
00732      * \return false, iff the two iterators point to the same point of the same fiber.
00733      */
00734     bool operator!= ( WFiberPointsIterator const& rhs ) const;
00735 
00736     /**
00737      * Returns the coordinates of the point currently pointed to.
00738      *
00739      * \return The current coordinates.
00740      */
00741     WPosition operator* ();
00742 
00743     /**
00744      * Returns the parameter specified in the vertex parameter array of the dataset. If no such array was set, the specified default will be
00745      * returned.
00746      *
00747      * \param def the default value which will be returned if no vertex parameter array was defined.
00748      *
00749      * \return the value or the specified default
00750      */
00751     double getParameter( double def = 0.0 ) const;
00752 
00753     /**
00754      * The tangent of the point.
00755      *
00756      * \return the tangent
00757      */
00758     WPosition getTangent() const;
00759 
00760     /**
00761      * Return the color of the point.
00762      *
00763      * \return the color.
00764      */
00765     WColor getColor() const;
00766 
00767     /**
00768      * Return the color of the point.
00769      *
00770      * \param idx the index of the colorscheme to use.
00771      *
00772      * \throw WDHNoSuchDataSet if the colorscheme does not exist.
00773      *
00774      * \return the color.
00775      */
00776     WColor getColor( std::size_t idx ) const;
00777 
00778     /**
00779      * Return the color of the point.
00780      *
00781      * \param name the name of the colorscheme to use.
00782      *
00783      * \throw WDHNoSuchDataSet if the colorscheme does not exist.
00784      *
00785      * \return the color.
00786      */
00787     WColor getColor( std::string name ) const;
00788 
00789     /**
00790      * Return the color of the point.
00791      *
00792      * \param scheme the colorscheme to use.
00793      *
00794      * \throw WDHNoSuchDataSet if the colorscheme does not exist.
00795      *
00796      * \return the color.
00797      */
00798     WColor getColor( const boost::shared_ptr< WDataSetFibers::ColorScheme > scheme ) const;
00799 
00800 protected:
00801     /**
00802      * Calculates the index of this point in the dataset arrays. But be aware that this index works vertex-wise. This mens, getting the y
00803      * coordinate of the vertex in the dataset vertex array, use  3 * getBaseIndex() + 1. This depends on the type of array you like to query.
00804      *
00805      * \note this function properly handles the case when walking in reverse direction.
00806      *
00807      * \return the base index, vertex-wise.
00808      */
00809     std::size_t getBaseIndex() const;
00810 
00811 private:
00812     //! The pointer to the fibers.
00813     WDataSetFibers const* m_fibers;
00814 
00815     //! The index of the fiber.
00816     std::size_t m_fiberIndex;
00817 
00818     //! The index of the current point.
00819     std::size_t m_index;
00820 
00821     //! Whether to iterate backwards.
00822     bool m_reverse;
00823 };
00824 
00825 #endif  // WDATASETFIBERS_H