OpenWalnut  1.4.0
WDataSetFibers.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 WDATASETFIBERS_H
26 #define WDATASETFIBERS_H
27 
28 #include <string>
29 #include <utility>
30 #include <vector>
31 
32 #include <boost/shared_ptr.hpp>
33 #include <boost/tuple/tuple.hpp>
34 
35 #include "../common/math/linearAlgebra/WPosition.h"
36 #include "../common/WBoundingBox.h"
37 #include "../common/WProperties.h"
38 #include "WDataSet.h"
39 
40 
41 // forward declarations
42 class WFiber;
43 
44 class WFiberIterator;
45 
47 
48 /**
49  * Represents a simple set of WFibers.
50  */
51 class WDataSetFibers : public WDataSet // NOLINT
52 {
53 public:
54  // some type alias for the used arrays.
55  /**
56  * Pointer to dataset.
57  */
58  typedef boost::shared_ptr< WDataSetFibers > SPtr;
59 
60  /**
61  * Pointer to const dataset.
62  */
63  typedef boost::shared_ptr< const WDataSetFibers > ConstSPtr;
64 
65  /**
66  * List of vertex coordinates in term of components of vertices.
67  */
68  typedef boost::shared_ptr< std::vector< float > > VertexArray;
69 
70  /**
71  * Index list indexing fibers in VertexArray in terms of vertex numbers.
72  */
73  typedef boost::shared_ptr< std::vector< size_t > > IndexArray;
74 
75  /**
76  * Lengths of fibers in terms of vertices.
77  */
78  typedef boost::shared_ptr< std::vector< size_t > > LengthArray;
79 
80  /**
81  * Tangents at each vertex in VertexArray.
82  */
83  typedef boost::shared_ptr< std::vector< float > > TangentArray;
84 
85  /**
86  * Colors for each vertex in VertexArray.
87  */
88  typedef boost::shared_ptr< std::vector< float > > ColorArray;
89 
90  /**
91  * Parameter storage for each vertex.
92  */
93  typedef boost::shared_ptr< std::vector< double > > VertexParemeterArray;
94 
95  /**
96  * Iterator to go through the fibers.
97  */
99 
100  /**
101  * Const iterator to go through fibers. As the WFiberIterators does not allow any modifications per-se, the const iterator and the standard
102  * iterator are the same.
103  */
105 
106  /**
107  * Item used in the selection below also containing color info.
108  */
110  {
111  friend class WDataSetFibers;
112  public:
113  /**
114  * different kinds of color arrays can be used in this class. This enum defines their possible types.
115  */
116  typedef enum
117  {
118  GRAY = 1, //!< gray value per vertex
119  RGB = 3, //!< rgb per vertex
120  RGBA = 4 //!< rgba per vertex
121  }
122  ColorMode;
123 
124  /**
125  * Constructor. Creates new item.
126  *
127  * \param name name, name of item.
128  * \param description description of item. Can be empty.
129  * \param icon icon, can be NULL
130  * \param color the color array of this item.
131  * \param mode the mode of the color array. This defines whether the colors are luminance, RGB or RGBA
132  */
133  ColorScheme( std::string name, std::string description, const char** icon, ColorArray color, ColorMode mode = RGB ):
134  WItemSelectionItem( name, description, icon ),
135  m_color( color ),
136  m_mode( mode )
137  {
138  };
139 
140  /**
141  * Get the color.
142  *
143  * \return the color array.
144  */
146  {
147  return m_color;
148  };
149 
150  /**
151  * Returns the mode of the color scheme.
152  *
153  * \return the mode.
154  */
156  {
157  return m_mode;
158  };
159 
160  protected:
161  /**
162  * Sets the color array for this item.
163  *
164  * \param color the color to set.
165  * \param mode the mode of the color array. This defines whether the colors are luminance, RGB or RGBA
166  */
167  void setColor( ColorArray color, ColorMode mode = RGB )
168  {
169  m_color = color;
170  m_mode = mode;
171  };
172 
173  private:
174  /**
175  * The color array associated with the item.
176  */
178 
179  /**
180  * Coloring mode.
181  */
183  };
184 
185  /**
186  * Constructs a new set of fibers.
187  *
188  * \param vertices the vertices of the fibers, stored in x1,y1,z1,x2,y2,z2, ..., xn,yn,zn scheme
189  * \param lineStartIndexes the index in which the fiber start (index of the 3D-vertex, not the index of the float in the vertices vector)
190  * \param lineLengths how many vertices belong to a fiber
191  * \param verticesReverse stores for each vertex the index of the corresponding fiber
192  * \param boundingBox The bounding box of the fibers (first minimum, second maximum).
193  */
194  WDataSetFibers( boost::shared_ptr< std::vector< float > >vertices,
195  boost::shared_ptr< std::vector< size_t > > lineStartIndexes,
196  boost::shared_ptr< std::vector< size_t > > lineLengths,
197  boost::shared_ptr< std::vector< size_t > > verticesReverse,
198  WBoundingBox boundingBox );
199 
200  /**
201  * Constructs a new set of fibers. This constructor determines the bounding box by using the coordinates of the vertices.
202  *
203  * \param vertices the vertices of the fibers, stored in x1,y1,z1,x2,y2,z2, ..., xn,yn,zn scheme
204  * \param lineStartIndexes the index in which the fiber start (index of the 3D-vertex, not the index of the float in the vertices vector)
205  * \param lineLengths how many vertices belong to a fiber
206  * \param verticesReverse stores for each vertex the index of the corresponding fiber
207  */
208  WDataSetFibers( boost::shared_ptr< std::vector< float > >vertices,
209  boost::shared_ptr< std::vector< size_t > > lineStartIndexes,
210  boost::shared_ptr< std::vector< size_t > > lineLengths,
211  boost::shared_ptr< std::vector< size_t > > verticesReverse );
212 
213  /**
214  * Constructs a new set of fibers.
215  *
216  * \param vertices the vertices of the fibers, stored in x1,y1,z1,x2,y2,z2, ..., xn,yn,zn scheme
217  * \param lineStartIndexes the index in which the fiber start (index of the 3D-vertex, not the index of the float in the vertices vector)
218  * \param lineLengths how many vertices belong to a fiber
219  * \param verticesReverse stores for each vertex the index of the corresponding fiber
220  * \param boundingBox The bounding box of the fibers (first minimum, second maximum).
221  * \param vertexParameters optional per-vertex scalar.
222  */
223  WDataSetFibers( boost::shared_ptr< std::vector< float > >vertices,
224  boost::shared_ptr< std::vector< size_t > > lineStartIndexes,
225  boost::shared_ptr< std::vector< size_t > > lineLengths,
226  boost::shared_ptr< std::vector< size_t > > verticesReverse,
227  WBoundingBox boundingBox,
228  VertexParemeterArray vertexParameters );
229 
230  /**
231  * Constructs a new set of fibers. This constructor determines the bounding box by using the coordinates of the vertices.
232  *
233  * \param vertices the vertices of the fibers, stored in x1,y1,z1,x2,y2,z2, ..., xn,yn,zn scheme
234  * \param lineStartIndexes the index in which the fiber start (index of the 3D-vertex, not the index of the float in the vertices vector)
235  * \param lineLengths how many vertices belong to a fiber
236  * \param verticesReverse stores for each vertex the index of the corresponding fiber
237  * \param vertexParameters optional per-vertex scalar.
238  */
239  WDataSetFibers( boost::shared_ptr< std::vector< float > >vertices,
240  boost::shared_ptr< std::vector< size_t > > lineStartIndexes,
241  boost::shared_ptr< std::vector< size_t > > lineLengths,
242  boost::shared_ptr< std::vector< size_t > > verticesReverse,
243  VertexParemeterArray vertexParameters );
244 
245  /**
246  * Constructs a new set of tracts. The constructed instance is not usable but needed for prototype mechanism.
247  */
248  WDataSetFibers();
249 
250  /**
251  * Get number of tracts in this data set.
252  * \return number of fibers
253  */
254  size_t size() const;
255 
256  /**
257  * Determines whether this dataset can be used as a texture.
258  *
259  * \return true if usable as texture.
260  */
261  virtual bool isTexture() const;
262 
263  /**
264  * Gets the name of this prototype.
265  *
266  * \return the name.
267  */
268  virtual const std::string getName() const;
269 
270  /**
271  * Gets the description for this prototype.
272  *
273  * \return the description
274  */
275  virtual const std::string getDescription() const;
276 
277  /**
278  * Returns a prototype instantiated with the true type of the deriving class.
279  *
280  * \return the prototype.
281  */
282  static boost::shared_ptr< WPrototyped > getPrototype();
283 
284  /**
285  * Getter for the lines' vertices
286  * \return The vertices of the lines
287  */
288  VertexArray getVertices() const;
289 
290  /**
291  * Return the indices that indicate at which vertex ID each line begins in the vertex array.
292  * \return The start indices of the lines
293  */
295 
296  /**
297  * Return the number of vertices for all lines.
298  * \return The numbers of all lines' vertices
299  */
300  LengthArray getLineLengths() const;
301 
302  /**
303  * Returns a reverse lookup table that allow do find out which vertex belongs to which line.
304  * \return Lookup table from vertices to lines.
305  */
307 
308  /**
309  * Returns an array containing the tangents of the fibers at the vertices.
310  * \return The tangents of the fibers.
311  */
312  TangentArray getTangents() const;
313 
314  /**
315  * Get the parameter values for each vertex. Same indexing as vertices. Used to store additional scalar values for each vertex.
316  *
317  * \return the array. Can be NULL.
318  */
320 
321  /**
322  * 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
323  * user to identify which color has which meaning. If the specified color array already exists, only an update is triggered and the name and
324  * description is ignored. It detects the type of colors by its size.
325  *
326  * \param colors the color array. Needs to have exactly getVertices()->size() items.
327  * \param name name of the color scheme. Should be a telling name.
328  * \param description description. How calculated and so on.
329  */
330  void addColorScheme( WDataSetFibers::ColorArray colors, std::string name, std::string description );
331 
332  /**
333  * This method removes the specified color scheme from the list and triggers an update.
334  *
335  * \param colors the color array.
336  */
338 
339  /**
340  * Replaces the specified old color scheme by the new color scheme. If the old color scheme did not exist, nothing happens.
341  *
342  * \param oldColors old colors to remove
343  * \param newColors new colors to set
344  */
346 
347  /**
348  * Get the color scheme with the specified name. If it is not found, an exception gets thrown.
349  *
350  * \param name the name of the color scheme
351  *
352  * \return the color scheme
353  * \throw WDHNoSuchDataSet if the name could not be found.
354  */
355  const boost::shared_ptr< ColorScheme > getColorScheme( std::string name ) const;
356 
357  /**
358  * Get the color scheme with the specified ID. If the index is invalid, an exception gets thrown.
359  *
360  * \param idx the index
361  *
362  * \return the color scheme
363  */
364  const boost::shared_ptr< ColorScheme > getColorScheme( size_t idx ) const;
365 
366  /**
367  * Convenience method returning the currently selected scheme. This is a comfortable alternative to using the color scheme selection
368  * property.
369  *
370  * \return the current active color scheme
371  */
372  const boost::shared_ptr< ColorScheme > getColorScheme() const;
373 
374  /**
375  * Returns the property controlling the color scheme selection.
376  *
377  * \return the property.
378  */
379  const WPropSelection getColorSchemeProperty() const;
380 
381  /**
382  * returns the position in space for a vertex of a given fiber
383  *
384  * \param fiber Index of fiber
385  * \param vertex Index of vertex in fiber.
386  *
387  * \return Position of the given vertex of the also given fiber
388  */
389  WPosition getPosition( size_t fiber, size_t vertex ) const;
390 
391  /**
392  * calculates the tangent for a point on the fiber
393  *
394  * \param fiber Index of fiber
395  * \param vertex Index of vertex in fiber
396  *
397  * \return Tangent of the given vertex of the also given fiber
398  */
399  WPosition getTangent( size_t fiber, size_t vertex ) const;
400 
401  /**
402  * Get the bounding box.
403  * \return The bounding box of all lines.
404  */
406 
407  /**
408  * Constructs a WFiber out of the given tract number.
409  *
410  * \param numTract Number of the tract to generate a WFiber object for
411  *
412  * \return The WFiber object. Attention: copy by value!
413  */
414  WFiber operator[]( size_t numTract ) const;
415 
416  /**
417  * Returns an iterator to the first fiber of the dataset. The iterator does not allow any modification of the data.
418  *
419  * \return An iterator to the first fiber.
420  */
421  const_iterator begin() const;
422 
423  /**
424  * Returns an iterator pointing beyond the last fiber. The iterator does not allow any modification of the data.
425  *
426  * \return An iterator pointing beyond the last fiber.
427  */
428  const_iterator end() const;
429 
430 protected:
431  /**
432  * The prototype as singleton.
433  */
434  static boost::shared_ptr< WPrototyped > m_prototype;
435 
436 private:
437  /**
438  * This does the common initialisation of the constructors.
439  */
440  void init();
441 
442  /**
443  * Point vector for all fibers
444  */
446 
447  /**
448  * Point vector for tangents at each vertex, used for fake tubes
449  */
451 
452  /**
453  * An array of color arrays. The first two elements are: 0: global color, 1: local color
454  */
455  boost::shared_ptr< WItemSelection > m_colors;
456 
457  /**
458  * Property keeping track of the active color in m_colors.
459  */
460  WPropSelection m_colorProp;
461 
462  /**
463  * Line vector that contains the start index of its first point for each line.
464  * \warning The index returned cannot be used in the vertices array until
465  * the number of components for each point is multiplied.
466  */
468 
469  /**
470  * Line vector that contains the number of vertices for each line
471  */
473 
474  /**
475  * Reverse lookup table for which point belongs to which fiber
476  */
478 
479  /**
480  * Axis aligned bounding box for all tract-vertices of this dataset.
481  */
483 
484  /**
485  * Parameter array. Used to store additional scalar values for each vertex.
486  */
488 };
489 
490 /**
491  * \class WFiberIterator
492  *
493  * \brief An iterator for fibers of a fiber dataset.
494  *
495  * This class iterates fibers of a fiber dataset.
496  */
498 {
499 public:
500  /**
501  * Constructor. Creates an invalid iterator pointing nowhere.
502  */
503  WFiberIterator();
504 
505  /**
506  * Constructor. Creates an iterator for a specific fiber dataset.
507  *
508  * \param fibers A pointer to the fiber data.
509  * \param idx The index of the fiber to point to.
510  */
511  WFiberIterator( WDataSetFibers const* fibers, std::size_t idx );
512 
513  /**
514  * Copy constructor.
515  *
516  * \param iter The iterator to copy from.
517  */
518  WFiberIterator( WFiberIterator const& iter ); // NOLINT explicit
519 
520  /**
521  * Destructor.
522  */
523  ~WFiberIterator();
524 
525  /**
526  * Copy operator.
527  *
528  * \param iter The iterator to copy from.
529  *
530  * \return *this
531  */
532  WFiberIterator& operator= ( WFiberIterator const& iter );
533 
534  /**
535  * Increment operator. Makes the iterator point to the next fiber.
536  *
537  * \return The incremented iterator.
538  */
540 
541  /**
542  * Decrement operator. Makes the iterator point to the previous fiber.
543  *
544  * \return The decremented iterator.
545  */
547 
548  /**
549  * Increment operator. Makes the iterator point to the next fiber.
550  *
551  * \return The iterator before incrementing.
552  */
554 
555  /**
556  * Decrement operator. Makes the iterator point to the previous fiber.
557  *
558  * \return The iterator before decrementing.
559  */
561 
562  /**
563  * Compare to another fiber iterator.
564  *
565  * \param rhs The second fiber iterator.
566  *
567  * \return true, iff the two iterators point to the same fiber of the same fiber dataset.
568  */
569  bool operator == ( WFiberIterator const& rhs ) const;
570 
571  /**
572  * Compare to another fiber iterator.
573  *
574  * \param rhs The second fiber iterator.
575  *
576  * \return false, iff the two iterators point to the same fiber of the same fiber dataset.
577  */
578  bool operator != ( WFiberIterator const& rhs ) const;
579 
580  /**
581  * Creates a point iterator for forward iteration, pointing to the first point of the fiber.
582  *
583  * \return A point iterator pointing to the first point.
584  */
586 
587  /**
588  * Creates a point iterator for forward iteration, pointing beyond the last point of the fiber.
589  *
590  * \return A point iterator pointing beyond the last point.
591  */
593 
594  /**
595  * Creates a point iterator for backward iteration, pointing to the last point of the fiber.
596  *
597  * \return A point iterator pointing to the last point.
598  */
600 
601  /**
602  * Creates a point iterator for backward iteration, pointing beyond the first point of the fiber.
603  *
604  * \return A point iterator pointing beyond the first point.
605  */
607 
608  /**
609  * Returns the number of points of the current fiber.
610  *
611  * \return The number of points.
612  */
613  std::size_t numPoints() const;
614 
615  /**
616  * 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
617  * from the vertex array.
618  *
619  * \note You should avoid using these indices as can use the iterators to query the data. But it might get handy in some situations,
620  * where raw data processing is needed.
621  *
622  * \return the start index.
623  */
624  std::size_t getLineStartIndex() const;
625 
626  /**
627  * Get the index of the line.
628  *
629  * \note You should avoid using these indices as can use the iterators to query the data. But it might get handy in some situations,
630  * where raw data processing is needed.
631  *
632  * \return the index.
633  */
634  std::size_t getIndex() const;
635 
636 private:
637  //! The pointer to the fibers.
639 
640  //! The current index in the fiber data.
641  std::size_t m_index;
642 };
643 
644 /**
645  * \class WFiberPointsIterator
646  *
647  * \brief An iterator for iterating the points of a fiber.
648  *
649  * Allows for both forward and backward iteration of points.
650  */
652 {
653 public:
654  /**
655  * Default contructor. Creates an invalid iterator.
656  */
658 
659  /**
660  * Constructor. Creates an iterator pointing to a certain point of a fiber.
661  *
662  * \param fibers The pointer to the fiber data.
663  * \param fbIdx The index of the fiber in the fiber dataset.
664  * \param idx The index of the point of the curent fiber.
665  * \param reverse Whether to iterate backwards.
666  */
667  WFiberPointsIterator( WDataSetFibers const* fibers, std::size_t fbIdx, std::size_t idx, bool reverse = false );
668 
669  /**
670  * Copy constructor.
671  *
672  * \param iter The iterator to copy from.
673  */
674  WFiberPointsIterator( WFiberPointsIterator const& iter ); //NOLINT explicit
675 
676  /**
677  * Destructor.
678  */
680 
681  /**
682  * Copy operator.
683  *
684  * \param iter The iterator to copy from.
685  *
686  * \return *this
687  */
689 
690  /**
691  * Increment operator. Makes the iterator point to the next point.
692  *
693  * \return The incremented iterator.
694  */
696 
697  /**
698  * Decrement operator. Makes the iterator point to the previous point.
699  *3
700  * \return The incremented iterator.
701  */
703 
704  /**
705  * Increment operator. Makes the iterator point to the next point.
706  *
707  * \return The iterator before incrementing.
708  */
710 
711  /**
712  * Decrement operator. Makes the iterator point to the previous point.
713  *
714  * \return The iterator before decrementing.
715  */
717 
718  /**
719  * Compare to another point iterator.
720  *
721  * \param rhs The second point iterator.
722  *
723  * \return true, iff the two iterators point to the same point of the same fiber.
724  */
725  bool operator== ( WFiberPointsIterator const& rhs ) const;
726 
727  /**
728  * Compare to another point iterator.
729  *
730  * \param rhs The second point iterator.
731  *
732  * \return false, iff the two iterators point to the same point of the same fiber.
733  */
734  bool operator!= ( WFiberPointsIterator const& rhs ) const;
735 
736  /**
737  * Returns the coordinates of the point currently pointed to.
738  *
739  * \return The current coordinates.
740  */
742 
743  /**
744  * Returns the parameter specified in the vertex parameter array of the dataset. If no such array was set, the specified default will be
745  * returned.
746  *
747  * \param def the default value which will be returned if no vertex parameter array was defined.
748  *
749  * \return the value or the specified default
750  */
751  double getParameter( double def = 0.0 ) const;
752 
753  /**
754  * The tangent of the point.
755  *
756  * \return the tangent
757  */
758  WPosition getTangent() const;
759 
760  /**
761  * Return the color of the point.
762  *
763  * \return the color.
764  */
765  WColor getColor() const;
766 
767  /**
768  * Return the color of the point.
769  *
770  * \param idx the index of the colorscheme to use.
771  *
772  * \throw WDHNoSuchDataSet if the colorscheme does not exist.
773  *
774  * \return the color.
775  */
776  WColor getColor( std::size_t idx ) const;
777 
778  /**
779  * Return the color of the point.
780  *
781  * \param name the name of the colorscheme to use.
782  *
783  * \throw WDHNoSuchDataSet if the colorscheme does not exist.
784  *
785  * \return the color.
786  */
787  WColor getColor( std::string name ) const;
788 
789  /**
790  * Return the color of the point.
791  *
792  * \param scheme the colorscheme to use.
793  *
794  * \throw WDHNoSuchDataSet if the colorscheme does not exist.
795  *
796  * \return the color.
797  */
798  WColor getColor( const boost::shared_ptr< WDataSetFibers::ColorScheme > scheme ) const;
799 
800 protected:
801  /**
802  * Calculates the index of this point in the dataset arrays. But be aware that this index works vertex-wise. This mens, getting the y
803  * coordinate of the vertex in the dataset vertex array, use 3 * getBaseIndex() + 1. This depends on the type of array you like to query.
804  *
805  * \note this function properly handles the case when walking in reverse direction.
806  *
807  * \return the base index, vertex-wise.
808  */
809  std::size_t getBaseIndex() const;
810 
811 private:
812  //! The pointer to the fibers.
814 
815  //! The index of the fiber.
816  std::size_t m_fiberIndex;
817 
818  //! The index of the current point.
819  std::size_t m_index;
820 
821  //! Whether to iterate backwards.
822  bool m_reverse;
823 };
824 
825 #endif // WDATASETFIBERS_H
WFiberPointsIterator & operator--()
Decrement operator.
double getParameter(double def=0.0) const
Returns the parameter specified in the vertex parameter array of the dataset.
VertexArray m_vertices
Point vector for all fibers.
Represents a simple set of WFibers.
bool m_reverse
Whether to iterate backwards.
ColorScheme(std::string name, std::string description, const char **icon, ColorArray color, ColorMode mode=RGB)
Constructor.
virtual bool isTexture() const
Determines whether this dataset can be used as a texture.
ColorMode getMode() const
Returns the mode of the color scheme.
Represents a neural pathway.
Definition: WFiber.h:39
Base class for all data set types.
Definition: WDataSet.h:51
WFiberPointsIterator & operator=(WFiberPointsIterator const &iter)
Copy operator.
const_iterator end() const
Returns an iterator pointing beyond the last fiber.
static boost::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
WFiberIterator & operator++()
Increment operator.
boost::shared_ptr< const WDataSetFibers > ConstSPtr
Pointer to const dataset.
virtual const std::string getName() const
Gets the name of this prototype.
ColorMode m_mode
Coloring mode.
Item used in the selection below also containing color info.
bool operator!=(WFiberIterator const &rhs) const
Compare to another fiber iterator.
std::size_t m_index
The index of the current point.
WPosition getPosition(size_t fiber, size_t vertex) const
returns the position in space for a vertex of a given fiber
WDataSetFibers const * m_fibers
The pointer to the fibers.
WFiberPointsIterator rbegin()
Creates a point iterator for backward iteration, pointing to the last point of the fiber...
~WFiberIterator()
Destructor.
std::size_t getBaseIndex() const
Calculates the index of this point in the dataset arrays.
WFiberIterator const_iterator
Const iterator to go through fibers.
This only is a 3d double vector.
VertexParemeterArray m_vertexParameters
Parameter array.
ColorArray getColor() const
Get the color.
WPropSelection m_colorProp
Property keeping track of the active color in m_colors.
WDataSetFibers const * m_fibers
The pointer to the fibers.
virtual const std::string getDescription() const
Gets the description for this prototype.
WBoundingBox getBoundingBox() const
Get the bounding box.
void replaceColorScheme(WDataSetFibers::ColorArray oldColors, WDataSetFibers::ColorArray newColors)
Replaces the specified old color scheme by the new color scheme.
void removeColorScheme(WDataSetFibers::ColorArray colors)
This method removes the specified color scheme from the list and triggers an update.
void setColor(ColorArray color, ColorMode mode=RGB)
Sets the color array for this item.
boost::shared_ptr< WDataSetFibers > SPtr
Pointer to dataset.
const boost::shared_ptr< ColorScheme > getColorScheme() const
Convenience method returning the currently selected scheme.
std::size_t m_index
The current index in the fiber data.
WPosition getTangent(size_t fiber, size_t vertex) const
calculates the tangent for a point on the fiber
LengthArray m_lineLengths
Line vector that contains the number of vertices for each line.
~WFiberPointsIterator()
Destructor.
const WPropSelection getColorSchemeProperty() const
Returns the property controlling the color scheme selection.
WFiberIterator & operator=(WFiberIterator const &iter)
Copy operator.
std::size_t numPoints() const
Returns the number of points of the current fiber.
TangentArray getTangents() const
Returns an array containing the tangents of the fibers at the vertices.
WFiberPointsIterator begin()
Creates a point iterator for forward iteration, pointing to the first point of the fiber...
WPosition getTangent() const
The tangent of the point.
const_iterator begin() const
Returns an iterator to the first fiber of the dataset.
bool operator==(WFiberIterator const &rhs) const
Compare to another fiber iterator.
WFiberIterator iterator
Iterator to go through the fibers.
std::size_t m_fiberIndex
The index of the fiber.
bool operator==(WFiberPointsIterator const &rhs) const
Compare to another point iterator.
An iterator for fibers of a fiber dataset.
WPosition operator*()
Returns the coordinates of the point currently pointed to.
bool operator!=(WFiberPointsIterator const &rhs) const
Compare to another point iterator.
boost::shared_ptr< std::vector< float > > VertexArray
List of vertex coordinates in term of components of vertices.
std::size_t getIndex() const
Get the index of the line.
IndexArray getVerticesReverse() const
Returns a reverse lookup table that allow do find out which vertex belongs to which line...
WDataSetFibers()
Constructs a new set of tracts.
WFiberPointsIterator rend()
Creates a point iterator for backward iteration, pointing beyond the first point of the fiber...
IndexArray getLineStartIndexes() const
Return the indices that indicate at which vertex ID each line begins in the vertex array...
boost::shared_ptr< std::vector< float > > ColorArray
Colors for each vertex in VertexArray.
std::size_t getLineStartIndex() const
Get the index in the point array where the points data starts for this line.
boost::shared_ptr< WItemSelection > m_colors
An array of color arrays.
boost::shared_ptr< std::vector< size_t > > LengthArray
Lengths of fibers in terms of vertices.
boost::shared_ptr< std::vector< float > > TangentArray
Tangents at each vertex in VertexArray.
ColorMode
different kinds of color arrays can be used in this class.
void init()
This does the common initialisation of the constructors.
WFiberPointsIterator()
Default contructor.
static boost::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
ColorArray m_color
The color array associated with the item.
LengthArray getLineLengths() const
Return the number of vertices for all lines.
boost::shared_ptr< std::vector< double > > VertexParemeterArray
Parameter storage for each vertex.
WFiberPointsIterator end()
Creates a point iterator for forward iteration, pointing beyond the last point of the fiber...
boost::shared_ptr< std::vector< size_t > > IndexArray
Index list indexing fibers in VertexArray in terms of vertex numbers.
void addColorScheme(WDataSetFibers::ColorArray colors, std::string name, std::string description)
This method adds a new color scheme to the list of available colors.
WColor getColor() const
Return the color of the point.
WFiberIterator & operator--()
Decrement operator.
VertexParemeterArray getVertexParameters() const
Get the parameter values for each vertex.
WFiberPointsIterator & operator++()
Increment operator.
WBoundingBox m_bb
Axis aligned bounding box for all tract-vertices of this dataset.
IndexArray m_lineStartIndexes
Line vector that contains the start index of its first point for each line.
Class for keeping a single named item in a WItemSelection.
size_t size() const
Get number of tracts in this data set.
IndexArray m_verticesReverse
Reverse lookup table for which point belongs to which fiber.
WFiberIterator()
Constructor.
VertexArray getVertices() const
Getter for the lines' vertices.
WFiber operator[](size_t numTract) const
Constructs a WFiber out of the given tract number.
TangentArray m_tangents
Point vector for tangents at each vertex, used for fake tubes.
An iterator for iterating the points of a fiber.