OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
WFiberCluster Class Reference

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

#include <WFiberCluster.h>

+ Inheritance diagram for WFiberCluster:
+ Collaboration diagram for WFiberCluster:

Public Types

typedef std::shared_ptr< WFiberClusterSPtr
 Shared pointer abbreviation. More...
 
typedef std::shared_ptr< const WFiberClusterConstSPtr
 Const shared pointer abbreviation. More...
 
typedef std::list< size_t > IndexList
 This is the list of indices of fibers. More...
 
typedef IndexList::const_iterator IndexListConstIterator
 Const iterator on the index list. More...
 

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. More...
 
 WFiberCluster (const IndexList &indices, const WColor &color=WColor(), std::string const &annotation=std::string())
 Constructs a cluster with the specified set of indices and the given color. More...
 
 WFiberCluster (IndexListConstIterator indicesBegin, IndexListConstIterator indicesEnd, const WColor &color=WColor(), std::string const &annotation=std::string())
 Constructs a clustering with the given set of indices. More...
 
 WFiberCluster (const WFiberCluster &other)
 Copies the specified WFiberCluster Instance. More...
 
 WFiberCluster ()
 Constructs an empty cluster. More...
 
virtual ~WFiberCluster ()
 Destructs. More...
 
bool empty () const
 Returns true if there are no fibers in that cluster, false otherwise. More...
 
void merge (WFiberCluster &other)
 Merge the fibers of the other cluster with the fibers of this cluster. More...
 
void merge (IndexListConstIterator indicesBegin, IndexListConstIterator indicesEnd)
 Copy the elements denoted by the two iterators to this cluster. More...
 
const IndexListgetIndices () const
 Returns a const reference of all indices inside this cluster. More...
 
void setIndices (const IndexList &indices)
 Reset the indices belonging to that cluster. More...
 
void sort ()
 Sort the indices of fibers associated with this cluster in ascending order. More...
 
size_t size () const
 
void clear ()
 Make this cluster empty. More...
 
void setColor (WColor color)
 Sets the color of which all fibers of this clusters should be painted with. More...
 
WColor getColor () const
 Gets the color of which all fibers of this clusters should be painted with. More...
 
void setAnnotation (std::string const &anno)
 Set the annotation for this fiber cluster. More...
 
std::string const & getAnnotation () const
 Get the annotation string. More...
 
void setMainDirection (osg::Vec3 mainDirection)
 Sets the main direction of the cluster. More...
 
osg::Vec3 getMainDirection () const
 Gets the main direction of the cluster ( if set ) More...
 
virtual const std::string getName () const
 The name of this transferable. More...
 
virtual const std::string getDescription () const
 The description of this transferable. More...
 
bool operator== (const WFiberCluster &other) const
 
bool operator!= (const WFiberCluster &other) const
 The opposite of the operator==. More...
 
WFiberClusteroperator= (const WFiberCluster &other)
 Copy assignment operator which does NOT copy the mutex's!!! More...
 
std::shared_ptr< WFibergetCenterLine () const
 Returns the center line of this cluster. More...
 
std::shared_ptr< WFibergetLongestLine () const
 Returns the center line of this cluster. More...
 
void generateCenterLine () const
 Makes the hard work to compute the center line. More...
 
void generateLongestLine () const
 Makes the hard work to find the longest line. More...
 
WBoundingBox getBoundingBox () const
 Recomputes on every call the axis aligned bounding box incorporating all tracts in this cluster. More...
 
- Public Member Functions inherited from WTransferable
 WTransferable ()
 Default constructor. More...
 
virtual ~WTransferable ()
 Destructor. More...
 
- Public Member Functions inherited from WPrototyped
 WPrototyped ()
 Default constructor. More...
 
virtual ~WPrototyped ()
 Destructor. More...
 
template<typename T >
bool isA ()
 Checks whether the actual prototype has the specified runtime type. More...
 

Static Public Member Functions

static std::shared_ptr< WPrototypedgetPrototype ()
 Returns a prototype instantiated with the true type of the deriving class. More...
 

Protected Member Functions

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

Static Protected Attributes

static std::shared_ptr< WPrototypedm_prototype = std::shared_ptr< WPrototyped >()
 Prototype for this dataset. More...
 

Private Member Functions

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

Private Attributes

IndexList m_memberIndices
 All indices in this set are members of this cluster. More...
 
std::shared_ptr< const WDataSetFiberVectorm_fibs
 Reference to the real fibers of the brain this cluster belongs to. More...
 
WColor m_color
 Color which is used to paint the members of this cluster. More...
 
std::string m_annotation
 An annotation for the bundle, usually a name. More...
 
osg::Vec3 m_mainDirection
 The cluster's main direction. More...
 
std::shared_mutex * m_centerLineCreationLock
 Lock the modification in the m_centerLine mutable. More...
 
std::shared_mutex * m_longestLineCreationLock
 Lock the modification in the m_longestLine mutable. More...
 
std::shared_ptr< WFiberm_centerLine
 Average fiber for this cluster representing the main direction and curvature of this cluster. More...
 
std::shared_ptr< WFiberm_longestLine
 The longest fiber in the dataset. More...
 

Friends

class WFiberClusterTest
 Access for test class. More...
 

Detailed Description

Represents a cluster of indices of a WDataSetFiberVector.

Definition at line 44 of file WFiberCluster.h.

Member Typedef Documentation

◆ ConstSPtr

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

Const shared pointer abbreviation.

Definition at line 56 of file WFiberCluster.h.

◆ IndexList

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

This is the list of indices of fibers.

Definition at line 61 of file WFiberCluster.h.

◆ IndexListConstIterator

typedef IndexList::const_iterator WFiberCluster::IndexListConstIterator

Const iterator on the index list.

Definition at line 66 of file WFiberCluster.h.

◆ SPtr

typedef std::shared_ptr< WFiberCluster > WFiberCluster::SPtr

Shared pointer abbreviation.

Definition at line 51 of file WFiberCluster.h.

Constructor & Destructor Documentation

◆ WFiberCluster() [1/5]

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 49 of file WFiberCluster.cpp.

References m_memberIndices.

◆ WFiberCluster() [2/5]

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

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
annotationan optional annotation string

Definition at line 57 of file WFiberCluster.cpp.

◆ WFiberCluster() [3/5]

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

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
annotationan optional annotation string

Definition at line 68 of file WFiberCluster.cpp.

References m_memberIndices.

◆ WFiberCluster() [4/5]

WFiberCluster::WFiberCluster ( const WFiberCluster other)

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 82 of file WFiberCluster.cpp.

References m_centerLine, and m_longestLine.

◆ WFiberCluster() [5/5]

WFiberCluster::WFiberCluster ( )

Constructs an empty cluster.

Definition at line 42 of file WFiberCluster.cpp.

Referenced by getPrototype().

+ Here is the caller graph for this function:

◆ ~WFiberCluster()

WFiberCluster::~WFiberCluster ( )
virtual

Destructs.

Frees used locks/mutex.

Definition at line 105 of file WFiberCluster.cpp.

References m_centerLineCreationLock, and m_longestLineCreationLock.

Member Function Documentation

◆ clear()

void WFiberCluster::clear ( )
inline

Make this cluster empty.

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

Definition at line 410 of file WFiberCluster.h.

References m_memberIndices.

Referenced by merge().

+ Here is the caller graph for this function:

◆ elongateCenterLine()

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 240 of file WFiberCluster.cpp.

References WMixinVector< ValueT >::back(), WMixinVector< ValueT >::begin(), WPlane::getPosition(), WMixinVector< ValueT >::insert(), m_centerLine, m_fibs, m_memberIndices, WMixinVector< ValueT >::push_back(), WPlane::resetPosition(), and WMixinVector< ValueT >::size().

Referenced by generateCenterLine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ empty()

bool WFiberCluster::empty ( ) const
inline

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

Returns
true if empty

Definition at line 395 of file WFiberCluster.h.

References m_memberIndices.

Referenced by WFiberClusterTest::testMerge().

+ Here is the caller graph for this function:

◆ generateCenterLine()

void WFiberCluster::generateCenterLine ( ) const

Makes the hard work to compute the center line.

Definition at line 157 of file WFiberCluster.cpp.

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

Referenced by getCenterLine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateLongestLine()

void WFiberCluster::generateLongestLine ( ) const

Makes the hard work to find the longest line.

Definition at line 202 of file WFiberCluster.cpp.

References m_fibs, m_longestLine, and m_longestLineCreationLock.

Referenced by getLongestLine().

+ Here is the caller graph for this function:

◆ getAnnotation()

std::string const & WFiberCluster::getAnnotation ( ) const
inline

Get the annotation string.

Returns
The annotation string.

Definition at line 430 of file WFiberCluster.h.

References m_annotation.

◆ getBoundingBox()

WBoundingBox WFiberCluster::getBoundingBox ( ) const

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

Returns
AABB as WBoundingBox.

Definition at line 408 of file WFiberCluster.cpp.

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

+ Here is the call graph for this function:

◆ getCenterLine()

std::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 390 of file WFiberCluster.cpp.

References generateCenterLine(), and m_centerLine.

+ Here is the call graph for this function:

◆ getColor()

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 420 of file WFiberCluster.h.

References m_color.

◆ getDescription()

const std::string WFiberCluster::getDescription ( ) const
inlinevirtual

The description of this transferable.

This is useful information for the users.

Returns
A description

Implements WPrototyped.

Definition at line 450 of file WFiberCluster.h.

◆ getIndices()

const WFiberCluster::IndexList & WFiberCluster::getIndices ( ) const
inline

Returns a const reference of all indices inside this cluster.

Returns
the index list

Definition at line 465 of file WFiberCluster.h.

References m_memberIndices.

◆ getLongestLine()

std::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 399 of file WFiberCluster.cpp.

References generateLongestLine(), and m_longestLine.

+ Here is the call graph for this function:

◆ getMainDirection()

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

Gets the main direction of the cluster ( if set )

Returns
the cluster's main direction

Definition at line 440 of file WFiberCluster.h.

References m_mainDirection.

◆ getName()

const std::string WFiberCluster::getName ( ) const
inlinevirtual

The name of this transferable.

This is useful information for the users.

Returns
the name.

Implements WPrototyped.

Definition at line 445 of file WFiberCluster.h.

◆ getPrototype()

std::shared_ptr< WPrototyped > WFiberCluster::getPrototype ( )
static

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

Returns
the prototype.

Definition at line 148 of file WFiberCluster.cpp.

References m_prototype, and WFiberCluster().

+ Here is the call graph for this function:

◆ merge() [1/2]

void WFiberCluster::merge ( WFiberCluster::IndexListConstIterator  indicesBegin,
WFiberCluster::IndexListConstIterator  indicesEnd 
)

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 124 of file WFiberCluster.cpp.

References m_memberIndices.

◆ merge() [2/2]

void WFiberCluster::merge ( WFiberCluster other)

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 111 of file WFiberCluster.cpp.

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

Referenced by WFiberClusterTest::testMerge().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator!=()

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 460 of file WFiberCluster.h.

References m_memberIndices.

◆ operator=()

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 249 of file WFiberCluster.h.

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

◆ operator==()

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 455 of file WFiberCluster.h.

References m_memberIndices.

◆ setAnnotation()

void WFiberCluster::setAnnotation ( std::string const &  anno)
inline

Set the annotation for this fiber cluster.

Parameters
annoThe new annotation.

Definition at line 425 of file WFiberCluster.h.

References m_annotation.

◆ setColor()

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 415 of file WFiberCluster.h.

References m_color.

◆ setIndices()

void WFiberCluster::setIndices ( const IndexList indices)
inline

Reset the indices belonging to that cluster.

Parameters
indiceslist of indices

Definition at line 470 of file WFiberCluster.h.

References m_memberIndices.

◆ setMainDirection()

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

Sets the main direction of the cluster.

Parameters
mainDirectionthe cluster's main direction

Definition at line 435 of file WFiberCluster.h.

References m_mainDirection.

◆ size()

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

Definition at line 405 of file WFiberCluster.h.

References m_memberIndices.

◆ sort()

void WFiberCluster::sort ( )
inline

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

Definition at line 400 of file WFiberCluster.h.

References m_memberIndices.

◆ unifyDirection()

void WFiberCluster::unifyDirection ( std::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 354 of file WFiberCluster.cpp.

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

Referenced by generateCenterLine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ WFiberClusterTest

friend class WFiberClusterTest
friend

Access for test class.

Definition at line 46 of file WFiberCluster.h.

Member Data Documentation

◆ m_annotation

std::string WFiberCluster::m_annotation
private

An annotation for the bundle, usually a name.

Definition at line 363 of file WFiberCluster.h.

Referenced by getAnnotation(), and setAnnotation().

◆ m_centerLine

std::shared_ptr< WFiber > WFiberCluster::m_centerLine
mutableprivate

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

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

Definition at line 385 of file WFiberCluster.h.

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

◆ m_centerLineCreationLock

std::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 373 of file WFiberCluster.h.

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

◆ m_color

WColor WFiberCluster::m_color
private

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

Definition at line 358 of file WFiberCluster.h.

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

◆ m_fibs

std::shared_ptr< const WDataSetFiberVector > WFiberCluster::m_fibs
private

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

Definition at line 353 of file WFiberCluster.h.

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

◆ m_longestLine

std::shared_ptr< WFiber > WFiberCluster::m_longestLine
mutableprivate

The longest fiber in the dataset.

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

Definition at line 392 of file WFiberCluster.h.

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

◆ m_longestLineCreationLock

std::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 378 of file WFiberCluster.h.

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

◆ m_mainDirection

osg::Vec3 WFiberCluster::m_mainDirection
private

The cluster's main direction.

Definition at line 368 of file WFiberCluster.h.

Referenced by getMainDirection(), and setMainDirection().

◆ m_memberIndices

IndexList WFiberCluster::m_memberIndices
private

◆ m_prototype

std::shared_ptr< WPrototyped > WFiberCluster::m_prototype = std::shared_ptr< WPrototyped >()
staticprotected

Prototype for this dataset.

Definition at line 320 of file WFiberCluster.h.

Referenced by getPrototype().


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