OpenWalnut
1.5.0dev
|
Represents a cluster of indices of a WDataSetFiberVector. More...
#include <WFiberCluster.h>
Public Types | |
typedef std::shared_ptr< WFiberCluster > | SPtr |
Shared pointer abbreviation. More... | |
typedef std::shared_ptr< const WFiberCluster > | ConstSPtr |
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 IndexList & | getIndices () 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... | |
WFiberCluster & | operator= (const WFiberCluster &other) |
Copy assignment operator which does NOT copy the mutex's!!! More... | |
std::shared_ptr< WFiber > | getCenterLine () const |
Returns the center line of this cluster. More... | |
std::shared_ptr< WFiber > | getLongestLine () 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< WPrototyped > | getPrototype () |
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< WPrototyped > | m_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 WDataSetFiberVector > | m_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< WFiber > | m_centerLine |
Average fiber for this cluster representing the main direction and curvature of this cluster. More... | |
std::shared_ptr< WFiber > | m_longestLine |
The longest fiber in the dataset. More... | |
Friends | |
class | WFiberClusterTest |
Access for test class. More... | |
Represents a cluster of indices of a WDataSetFiberVector.
Definition at line 44 of file WFiberCluster.h.
typedef std::shared_ptr< const WFiberCluster > WFiberCluster::ConstSPtr |
Const shared pointer abbreviation.
Definition at line 56 of file WFiberCluster.h.
typedef std::list< size_t > WFiberCluster::IndexList |
This is the list of indices of fibers.
Definition at line 61 of file WFiberCluster.h.
typedef IndexList::const_iterator WFiberCluster::IndexListConstIterator |
Const iterator on the index list.
Definition at line 66 of file WFiberCluster.h.
typedef std::shared_ptr< WFiberCluster > WFiberCluster::SPtr |
Shared pointer abbreviation.
Definition at line 51 of file WFiberCluster.h.
|
explicit |
Constructs an cluster with one fiber and a reference to the fiber dataset to compute the intercluster distance.
index | The index of the first fiber belonging to this cluster |
Definition at line 49 of file WFiberCluster.cpp.
References m_memberIndices.
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.
indices | the indices initially used for this clustering |
color | the color of this cluster |
annotation | an optional annotation string |
Definition at line 57 of file WFiberCluster.cpp.
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).
indicesBegin | begin iterator in the predefined index set |
indicesEnd | end iterator in the predefined index set |
color | the color of this cluster |
annotation | an optional annotation string |
Definition at line 68 of file WFiberCluster.cpp.
References m_memberIndices.
WFiberCluster::WFiberCluster | ( | const WFiberCluster & | other | ) |
Copies the specified WFiberCluster Instance.
The copy does not contain a valid centerline or longest line.
other | the other instance to clone. |
Definition at line 82 of file WFiberCluster.cpp.
References m_centerLine, and m_longestLine.
WFiberCluster::WFiberCluster | ( | ) |
Constructs an empty cluster.
Definition at line 42 of file WFiberCluster.cpp.
Referenced by getPrototype().
|
virtual |
Destructs.
Frees used locks/mutex.
Definition at line 105 of file WFiberCluster.cpp.
References m_centerLineCreationLock, and m_longestLineCreationLock.
|
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().
|
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().
|
inline |
Returns true if there are no fibers in that cluster, false otherwise.
Definition at line 395 of file WFiberCluster.h.
References m_memberIndices.
Referenced by WFiberClusterTest::testMerge().
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().
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().
|
inline |
Get the annotation string.
Definition at line 430 of file WFiberCluster.h.
References m_annotation.
WBoundingBox WFiberCluster::getBoundingBox | ( | ) | const |
Recomputes on every call the axis aligned bounding box incorporating all tracts in this cluster.
Definition at line 408 of file WFiberCluster.cpp.
References WBoundingBoxImpl< VT >::expandBy(), m_fibs, and m_memberIndices.
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.
Definition at line 390 of file WFiberCluster.cpp.
References generateCenterLine(), and m_centerLine.
|
inline |
Gets the color of which all fibers of this clusters should be painted with.
Definition at line 420 of file WFiberCluster.h.
References m_color.
|
inlinevirtual |
The description of this transferable.
This is useful information for the users.
Implements WPrototyped.
Definition at line 450 of file WFiberCluster.h.
|
inline |
Returns a const reference of all indices inside this cluster.
Definition at line 465 of file WFiberCluster.h.
References m_memberIndices.
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.
Definition at line 399 of file WFiberCluster.cpp.
References generateLongestLine(), and m_longestLine.
|
inline |
Gets the main direction of the cluster ( if set )
Definition at line 440 of file WFiberCluster.h.
References m_mainDirection.
|
inlinevirtual |
The name of this transferable.
This is useful information for the users.
Implements WPrototyped.
Definition at line 445 of file WFiberCluster.h.
|
static |
Returns a prototype instantiated with the true type of the deriving class.
Definition at line 148 of file WFiberCluster.cpp.
References m_prototype, and WFiberCluster().
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.
indicesBegin | begin iterator in the predefined index set |
indicesEnd | end iterator in the predefined index set |
Definition at line 124 of file WFiberCluster.cpp.
References m_memberIndices.
void WFiberCluster::merge | ( | WFiberCluster & | other | ) |
Merge the fibers of the other cluster with the fibers of this cluster.
Afterwards the other cluster is empty.
other | The 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().
|
inline |
The opposite of the operator==.
other | The other fiber which should be compared |
Definition at line 460 of file WFiberCluster.h.
References m_memberIndices.
|
inline |
Copy assignment operator which does NOT copy the mutex's!!!
other | The instance to copy. |
Definition at line 249 of file WFiberCluster.h.
References m_centerLine, m_centerLineCreationLock, m_color, m_fibs, m_longestLine, m_longestLineCreationLock, and m_memberIndices.
|
inline |
other | The other fiber which should be compared |
Definition at line 455 of file WFiberCluster.h.
References m_memberIndices.
|
inline |
Set the annotation for this fiber cluster.
anno | The new annotation. |
Definition at line 425 of file WFiberCluster.h.
References m_annotation.
|
inline |
Sets the color of which all fibers of this clusters should be painted with.
color | The color for all fibers of this cluster. |
Definition at line 415 of file WFiberCluster.h.
References m_color.
|
inline |
Reset the indices belonging to that cluster.
indices | list of indices |
Definition at line 470 of file WFiberCluster.h.
References m_memberIndices.
|
inline |
Sets the main direction of the cluster.
mainDirection | the cluster's main direction |
Definition at line 435 of file WFiberCluster.h.
References m_mainDirection.
|
inline |
Definition at line 405 of file WFiberCluster.h.
References m_memberIndices.
|
inline |
Sort the indices of fibers associated with this cluster in ascending order.
Definition at line 400 of file WFiberCluster.h.
References m_memberIndices.
|
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.
fibs | The 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().
|
friend |
Access for test class.
Definition at line 46 of file WFiberCluster.h.
|
private |
An annotation for the bundle, usually a name.
Definition at line 363 of file WFiberCluster.h.
Referenced by getAnnotation(), and setAnnotation().
|
mutableprivate |
Average fiber for this cluster representing the main direction and curvature of this cluster.
Definition at line 385 of file WFiberCluster.h.
Referenced by elongateCenterLine(), generateCenterLine(), getCenterLine(), merge(), operator=(), and WFiberCluster().
|
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().
|
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().
|
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=().
|
mutableprivate |
The longest fiber in the dataset.
Definition at line 392 of file WFiberCluster.h.
Referenced by generateLongestLine(), getLongestLine(), merge(), operator=(), and WFiberCluster().
|
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().
|
private |
The cluster's main direction.
Definition at line 368 of file WFiberCluster.h.
Referenced by getMainDirection(), and setMainDirection().
|
private |
All indices in this set are members of this cluster.
Definition at line 344 of file WFiberCluster.h.
Referenced by clear(), elongateCenterLine(), empty(), generateCenterLine(), getBoundingBox(), getIndices(), merge(), operator!=(), operator=(), operator==(), setIndices(), size(), sort(), WFiberClusterTest::testMerge(), and WFiberCluster().
|
staticprotected |
Prototype for this dataset.
Definition at line 320 of file WFiberCluster.h.
Referenced by getPrototype().