OpenWalnut  1.4.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Attributes | Private Member Functions | Private Attributes | Friends
WFiberCluster Class Reference

Represents a cluster of indices of a WDataSetFiberVector. More...

#include <WFiberCluster.h>

+ Inheritance diagram for WFiberCluster:

List of all members.

Public Types

typedef boost::shared_ptr
< WFiberCluster
SPtr
 Shared pointer abbreviation.
typedef boost::shared_ptr
< const WFiberCluster
ConstSPtr
 Const shared pointer abbreviation.
typedef std::list< size_tIndexList
 This is the list of indices of fibers.
typedef IndexList::const_iterator IndexListConstIterator
 Const iterator on the index list.

Public Member Functions

 WFiberCluster (size_t index)
 Constructs an cluster with one fiber and a reference to the fiber dataset to compute the intercluster distance.
 WFiberCluster (const IndexList &indices, const WColor &color=WColor())
 Constructs a cluster with the specified set of indices and the given color.
 WFiberCluster (IndexListConstIterator indicesBegin, IndexListConstIterator indicesEnd, const WColor &color=WColor())
 Constructs a clustering with the given set of indices.
 WFiberCluster (const WFiberCluster &other)
 Copies the specified WFiberCluster Instance.
 WFiberCluster ()
 Constructs an empty cluster.
virtual ~WFiberCluster ()
 Destructs.
bool empty () const
 Returns true if there are no fibers in that cluster, false otherwise.
void merge (WFiberCluster &other)
 Merge the fibers of the other cluster with the fibers of this cluster.
void merge (IndexListConstIterator indicesBegin, IndexListConstIterator indicesEnd)
 Copy the elements denoted by the two iterators to this cluster.
const IndexListgetIndices () const
 Returns a const reference of all indices inside this cluster.
void setIndices (const IndexList &indices)
 Reset the indices belonging to that cluster.
void sort ()
 Sort the indices of fibers associated with this cluster in ascending order.
size_t size () const
void clear ()
 Make this cluster empty.
void setColor (WColor color)
 Sets the color of which all fibers of this clusters should be painted with.
WColor getColor () const
 Gets the color of which all fibers of this clusters should be painted with.
void setMainDirection (osg::Vec3 mainDirection)
 Sets the main direction of the cluster.
osg::Vec3 getMainDirection () const
 Gets the main direction of the cluster ( if set )
virtual const std::string getName () const
 The name of this transferable.
virtual const std::string getDescription () const
 The description of this transferable.
bool operator== (const WFiberCluster &other) const
bool operator!= (const WFiberCluster &other) const
 The opposite of the operator==.
WFiberClusteroperator= (const WFiberCluster &other)
 Copy assignment operator which does NOT copy the mutex's!!!
boost::shared_ptr< WFibergetCenterLine () const
 Returns the center line of this cluster.
boost::shared_ptr< WFibergetLongestLine () const
 Returns the center line of this cluster.
void generateCenterLine () const
 Makes the hard work to compute the center line.
void generateLongestLine () const
 Makes the hard work to find the longest line.
WBoundingBox getBoundingBox () const
 Recomputes on every call the axis aligned bounding box incorporating all tracts in this cluster.

Static Public Member Functions

static boost::shared_ptr
< WPrototyped
getPrototype ()
 Returns a prototype instantiated with the true type of the deriving class.

Protected Member Functions

void unifyDirection (boost::shared_ptr< WDataSetFiberVector > fibs) const
 Alings all fibers within the given dataset to be in one main direction.

Static Protected Attributes

static boost::shared_ptr
< WPrototyped
m_prototype = boost::shared_ptr< WPrototyped >()
 Prototype for this dataset.

Private Member Functions

void elongateCenterLine () const
 The centerline may be shortened due to the averaging of outliers.

Private Attributes

IndexList m_memberIndices
 All indices in this set are members of this cluster.
boost::shared_ptr< const
WDataSetFiberVector
m_fibs
 Reference to the real fibers of the brain this cluster belongs to.
WColor m_color
 Color which is used to paint the members of this cluster.
osg::Vec3 m_mainDirection
 The cluster's main direction.
boost::shared_mutex * m_centerLineCreationLock
 Lock the modification in the m_centerLine mutable.
boost::shared_mutex * m_longestLineCreationLock
 Lock the modification in the m_longestLine mutable.
boost::shared_ptr< WFiberm_centerLine
 Average fiber for this cluster representing the main direction and curvature of this cluster.
boost::shared_ptr< WFiberm_longestLine
 The longest fiber in the dataset.

Friends

class WFiberClusterTest

Detailed Description

Represents a cluster of indices of a WDataSetFiberVector.

Definition at line 43 of file WFiberCluster.h.


Member Typedef Documentation

typedef boost::shared_ptr< const WFiberCluster > WFiberCluster::ConstSPtr

Const shared pointer abbreviation.

Definition at line 55 of file WFiberCluster.h.

typedef std::list< size_t > WFiberCluster::IndexList

This is the list of indices of fibers.

Definition at line 60 of file WFiberCluster.h.

typedef IndexList::const_iterator WFiberCluster::IndexListConstIterator

Const iterator on the index list.

Definition at line 65 of file WFiberCluster.h.

typedef boost::shared_ptr< WFiberCluster > WFiberCluster::SPtr

Shared pointer abbreviation.

Definition at line 50 of file WFiberCluster.h.


Constructor & Destructor Documentation

WFiberCluster::WFiberCluster ( size_t  index) [explicit]

Constructs an cluster with one fiber and a reference to the fiber dataset to compute the intercluster distance.

Parameters:
indexThe index of the first fiber belonging to this cluster

Definition at line 48 of file WFiberCluster.cpp.

References m_memberIndices.

WFiberCluster::WFiberCluster ( const IndexList indices,
const WColor &  color = WColor() 
)

Constructs a cluster with the specified set of indices and the given color.

Parameters:
indicesthe indices initially used for this clustering
colorthe color of this cluster

Definition at line 56 of file WFiberCluster.cpp.

WFiberCluster::WFiberCluster ( WFiberCluster::IndexListConstIterator  indicesBegin,
WFiberCluster::IndexListConstIterator  indicesEnd,
const WColor &  color = WColor() 
)

Constructs a clustering with the given set of indices.

The indexlist is generated using the given iterators. It copies the elements in [indicesBegin,indicesEnd).

Parameters:
indicesBeginbegin iterator in the predefined index set
indicesEndend iterator in the predefined index set
colorthe color of this cluster

Definition at line 66 of file WFiberCluster.cpp.

References m_memberIndices.

Copies the specified WFiberCluster Instance.

The copy does not contain a valid centerline or longest line.

Parameters:
otherthe other instance to clone.

Definition at line 77 of file WFiberCluster.cpp.

References m_centerLine, and m_longestLine.

Constructs an empty cluster.

Definition at line 41 of file WFiberCluster.cpp.

Referenced by getPrototype().

Destructs.

Frees used locks/mutex.

Definition at line 99 of file WFiberCluster.cpp.

References m_centerLineCreationLock, and m_longestLineCreationLock.


Member Function Documentation

void WFiberCluster::clear ( ) [inline]

Make this cluster empty.

Note: The real fibers from fiber dataset are not deleted.

Definition at line 388 of file WFiberCluster.h.

References m_memberIndices.

Referenced by merge().

void WFiberCluster::elongateCenterLine ( ) const [private]

The centerline may be shortened due to the averaging of outliers.

To nevertheless color almost the whole bundle surface we need a surface parameterization (given via the centerline) upto the endings of the bundle. Therefore the centerline is stepwise elongated with the last known direction, until no perpendicular plane intersects any of the tracts inside of the bundle.

Definition at line 234 of file WFiberCluster.cpp.

References WPlane::getPosition(), m_centerLine, m_fibs, m_memberIndices, and WPlane::resetPosition().

Referenced by generateCenterLine().

bool WFiberCluster::empty ( ) const [inline]

Returns true if there are no fibers in that cluster, false otherwise.

Returns:
true if empty

Definition at line 373 of file WFiberCluster.h.

References m_memberIndices.

Referenced by WFiberClusterTest::testMerge().

Makes the hard work to compute the center line.

Definition at line 151 of file WFiberCluster.cpp.

References elongateCenterLine(), m_centerLine, m_fibs, m_memberIndices, and unifyDirection().

Referenced by getCenterLine().

Makes the hard work to find the longest line.

Definition at line 196 of file WFiberCluster.cpp.

References m_fibs, and m_longestLine.

Referenced by getLongestLine().

Recomputes on every call the axis aligned bounding box incorporating all tracts in this cluster.

Returns:
AABB as WBoundingBox.

Definition at line 402 of file WFiberCluster.cpp.

References WBoundingBoxImpl< VT >::expandBy(), m_fibs, and m_memberIndices.

boost::shared_ptr< WFiber > WFiberCluster::getCenterLine ( ) const

Returns the center line of this cluster.

The centerline gets calculated during the first call of this method.

Returns:
Reference to the center line

Definition at line 384 of file WFiberCluster.cpp.

References generateCenterLine(), and m_centerLine.

WColor WFiberCluster::getColor ( ) const [inline]

Gets the color of which all fibers of this clusters should be painted with.

Returns:
cluster color.

Definition at line 398 of file WFiberCluster.h.

References m_color.

const std::string WFiberCluster::getDescription ( ) const [inline, virtual]

The description of this transferable.

This is useful information for the users.

Returns:
A description

Implements WPrototyped.

Definition at line 418 of file WFiberCluster.h.

Returns a const reference of all indices inside this cluster.

Returns:
the index list

Definition at line 433 of file WFiberCluster.h.

References m_memberIndices.

boost::shared_ptr< WFiber > WFiberCluster::getLongestLine ( ) const

Returns the center line of this cluster.

The longest line gets calculated during the first call if this method.

Returns:
Reference to the longest line

Definition at line 393 of file WFiberCluster.cpp.

References generateLongestLine(), and m_longestLine.

osg::Vec3 WFiberCluster::getMainDirection ( ) const [inline]

Gets the main direction of the cluster ( if set )

Returns:
the cluster's main direction

Definition at line 408 of file WFiberCluster.h.

References m_mainDirection.

const std::string WFiberCluster::getName ( ) const [inline, virtual]

The name of this transferable.

This is useful information for the users.

Returns:
the name.

Implements WPrototyped.

Definition at line 413 of file WFiberCluster.h.

boost::shared_ptr< WPrototyped > WFiberCluster::getPrototype ( ) [static]

Returns a prototype instantiated with the true type of the deriving class.

Returns:
the prototype.

Definition at line 142 of file WFiberCluster.cpp.

References m_prototype, and WFiberCluster().

Merge the fibers of the other cluster with the fibers of this cluster.

Afterwards the other cluster is empty.

Parameters:
otherThe other WFiberCluster which should merged into this one

Definition at line 105 of file WFiberCluster.cpp.

References clear(), m_centerLine, m_longestLine, and m_memberIndices.

Referenced by WFiberClusterTest::testMerge().

Copy the elements denoted by the two iterators to this cluster.

In contrast to the other merge() methods, this will not clean the source list.

Parameters:
indicesBeginbegin iterator in the predefined index set
indicesEndend iterator in the predefined index set

Definition at line 118 of file WFiberCluster.cpp.

References m_memberIndices.

bool WFiberCluster::operator!= ( const WFiberCluster other) const [inline]

The opposite of the operator==.

Parameters:
otherThe other fiber which should be compared
Returns:
false If both clusters having same fibers IN SAME ORDER!

Definition at line 428 of file WFiberCluster.h.

References m_memberIndices.

WFiberCluster& WFiberCluster::operator= ( const WFiberCluster other) [inline]

Copy assignment operator which does NOT copy the mutex's!!!

Parameters:
otherThe instance to copy.
Returns:
itself

Definition at line 232 of file WFiberCluster.h.

References m_centerLine, m_centerLineCreationLock, m_color, m_fibs, m_longestLine, m_longestLineCreationLock, and m_memberIndices.

bool WFiberCluster::operator== ( const WFiberCluster other) const [inline]
Parameters:
otherThe other fiber which should be compared
Returns:
true If both clusters having same fibers IN SAME ORDER!

Definition at line 423 of file WFiberCluster.h.

References m_memberIndices.

void WFiberCluster::setColor ( WColor  color) [inline]

Sets the color of which all fibers of this clusters should be painted with.

Parameters:
colorThe color for all fibers of this cluster.

Definition at line 393 of file WFiberCluster.h.

References m_color.

void WFiberCluster::setIndices ( const IndexList indices) [inline]

Reset the indices belonging to that cluster.

Parameters:
indiceslist of indices

Definition at line 438 of file WFiberCluster.h.

References m_memberIndices.

void WFiberCluster::setMainDirection ( osg::Vec3  mainDirection) [inline]

Sets the main direction of the cluster.

Parameters:
mainDirectionthe cluster's main direction

Definition at line 403 of file WFiberCluster.h.

References m_mainDirection.

size_t WFiberCluster::size ( ) const [inline]
Returns:
Number of fibers associated with this cluster.

Definition at line 383 of file WFiberCluster.h.

References m_memberIndices.

void WFiberCluster::sort ( ) [inline]

Sort the indices of fibers associated with this cluster in ascending order.

Definition at line 378 of file WFiberCluster.h.

References m_memberIndices.

void WFiberCluster::unifyDirection ( boost::shared_ptr< WDataSetFiberVector fibs) const [protected]

Alings all fibers within the given dataset to be in one main direction.

But Alignment only may swap the ordering of the fibers but not the positions or something similar. We need this only for the centerline generation.

Parameters:
fibsThe dataset

Definition at line 348 of file WFiberCluster.cpp.

References WMixinVector< ValueT >::at(), WMixinVector< ValueT >::back(), WMixinVector< ValueT >::front(), and WMixinVector< ValueT >::size().

Referenced by generateCenterLine().


Member Data Documentation

boost::shared_ptr< WFiber > WFiberCluster::m_centerLine [mutable, private]

Average fiber for this cluster representing the main direction and curvature of this cluster.

Notes:
This member is mutable as it needs to be modified during a const getter.

Definition at line 363 of file WFiberCluster.h.

Referenced by elongateCenterLine(), generateCenterLine(), getCenterLine(), merge(), operator=(), and WFiberCluster().

boost::shared_mutex* WFiberCluster::m_centerLineCreationLock [private]

Lock the modification in the m_centerLine mutable.

The lock is stored as pointer to avoid copy construction problems.

Definition at line 351 of file WFiberCluster.h.

Referenced by operator=(), and ~WFiberCluster().

WColor WFiberCluster::m_color [private]

Color which is used to paint the members of this cluster.

Definition at line 341 of file WFiberCluster.h.

Referenced by getColor(), operator=(), and setColor().

boost::shared_ptr< const WDataSetFiberVector > WFiberCluster::m_fibs [private]

Reference to the real fibers of the brain this cluster belongs to.

Definition at line 336 of file WFiberCluster.h.

Referenced by elongateCenterLine(), generateCenterLine(), generateLongestLine(), getBoundingBox(), and operator=().

boost::shared_ptr< WFiber > WFiberCluster::m_longestLine [mutable, private]

The longest fiber in the dataset.

Notes:
This member is mutable as it needs to be modified during a const getter.

Definition at line 370 of file WFiberCluster.h.

Referenced by generateLongestLine(), getLongestLine(), merge(), operator=(), and WFiberCluster().

boost::shared_mutex* WFiberCluster::m_longestLineCreationLock [private]

Lock the modification in the m_longestLine mutable.

The lock is stored as pointer to avoid copy construction problems.

Definition at line 356 of file WFiberCluster.h.

Referenced by operator=(), and ~WFiberCluster().

osg::Vec3 WFiberCluster::m_mainDirection [private]

The cluster's main direction.

Definition at line 346 of file WFiberCluster.h.

Referenced by getMainDirection(), and setMainDirection().

boost::shared_ptr< WPrototyped > WFiberCluster::m_prototype = boost::shared_ptr< WPrototyped >() [static, protected]

Prototype for this dataset.

Definition at line 303 of file WFiberCluster.h.

Referenced by getPrototype().


The documentation for this class was generated from the following files: