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