OpenWalnut
1.4.0
|
Represents a cluster of indices of a WDataSetFiberVector. More...
#include <WFiberCluster.h>
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_t > | IndexList |
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 IndexList & | getIndices () 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==. | |
WFiberCluster & | operator= (const WFiberCluster &other) |
Copy assignment operator which does NOT copy the mutex's!!! | |
boost::shared_ptr< WFiber > | getCenterLine () const |
Returns the center line of this cluster. | |
boost::shared_ptr< WFiber > | getLongestLine () 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< WFiber > | m_centerLine |
Average fiber for this cluster representing the main direction and curvature of this cluster. | |
boost::shared_ptr< WFiber > | m_longestLine |
The longest fiber in the dataset. | |
Friends | |
class | WFiberClusterTest |
Represents a cluster of indices of a WDataSetFiberVector.
Definition at line 43 of file WFiberCluster.h.
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.
WFiberCluster::WFiberCluster | ( | size_t | index | ) | [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 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.
indices | the indices initially used for this clustering |
color | the 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).
indicesBegin | begin iterator in the predefined index set |
indicesEnd | end iterator in the predefined index set |
color | the color of this cluster |
Definition at line 66 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 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().
WFiberCluster::~WFiberCluster | ( | ) | [virtual] |
Destructs.
Frees used locks/mutex.
Definition at line 99 of file WFiberCluster.cpp.
References m_centerLineCreationLock, and m_longestLineCreationLock.
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.
Definition at line 373 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 151 of file WFiberCluster.cpp.
References elongateCenterLine(), m_centerLine, 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 196 of file WFiberCluster.cpp.
References m_fibs, and m_longestLine.
Referenced by getLongestLine().
WBoundingBox WFiberCluster::getBoundingBox | ( | ) | const |
Recomputes on every call the axis aligned bounding box incorporating all tracts in this cluster.
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.
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.
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.
Implements WPrototyped.
Definition at line 418 of file WFiberCluster.h.
const WFiberCluster::IndexList & WFiberCluster::getIndices | ( | ) | const [inline] |
Returns a const reference of all indices inside this cluster.
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.
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 )
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.
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.
Definition at line 142 of file WFiberCluster.cpp.
References m_prototype, and WFiberCluster().
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 105 of file WFiberCluster.cpp.
References clear(), m_centerLine, m_longestLine, and m_memberIndices.
Referenced by WFiberClusterTest::testMerge().
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 118 of file WFiberCluster.cpp.
References m_memberIndices.
bool WFiberCluster::operator!= | ( | const WFiberCluster & | other | ) | const [inline] |
The opposite of the operator==.
other | The other fiber which should be compared |
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!!!
other | The instance to copy. |
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] |
other | The other fiber which should be compared |
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.
color | The 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.
indices | list 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.
mainDirection | the cluster's main direction |
Definition at line 403 of file WFiberCluster.h.
References m_mainDirection.
size_t WFiberCluster::size | ( | ) | const [inline] |
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.
fibs | The 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().
boost::shared_ptr< WFiber > WFiberCluster::m_centerLine [mutable, private] |
Average fiber for this cluster representing the main direction and curvature of this cluster.
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.
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().
IndexList WFiberCluster::m_memberIndices [private] |
All indices in this set are members of this cluster.
Definition at line 327 of file WFiberCluster.h.
Referenced by clear(), elongateCenterLine(), empty(), generateCenterLine(), getBoundingBox(), getIndices(), merge(), operator!=(), operator=(), operator==(), setIndices(), size(), sort(), WFiberClusterTest::testMerge(), and WFiberCluster().
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().