~ubuntu-branches/ubuntu/raring/openwalnut/raring

« back to all changes in this revision

Viewing changes to src/core/dataHandler/datastructures/WFiberCluster.cpp

  • Committer: Package Import Robot
  • Author(s): Sebastian Eichelbaum
  • Date: 2012-12-12 11:26:32 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20121212112632-xhiuwkxuz5h0idkh
Tags: 1.3.1+hg5849-1
* Minor changes compared to 1.3.0 but included several bug fixes.
* See http://www.openwalnut.org/versions/4

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
#include <list>
26
26
#include <vector>
 
27
#include <algorithm>
27
28
 
28
29
#include <boost/shared_ptr.hpp>
29
30
 
34
35
#include "../WDataSetFiberVector.h"
35
36
#include "WFiberCluster.h"
36
37
 
37
 
// TODO(math): The only reason why we store here a Reference to the fiber
38
 
// dataset is, we need it in the WMVoxelizer module as well as the clustering
39
 
// information. Since we don't have the possibility of multiple
40
 
// InputConnectors we must agglomerate those into one object. Please remove this.
41
 
// initializes the variable and provides a linker reference
42
 
// \cond Suppress_Doxygen
 
38
// The prototype as singleton. Created during first getPrototype() call
43
39
boost::shared_ptr< WPrototyped > WFiberCluster::m_prototype = boost::shared_ptr< WPrototyped >();
44
 
// \endcond
45
40
 
46
41
WFiberCluster::WFiberCluster()
47
42
    : WTransferable(),
58
53
    m_memberIndices.push_back( index );
59
54
}
60
55
 
 
56
WFiberCluster::WFiberCluster( const WFiberCluster::IndexList& indices, const WColor& color )
 
57
    : WTransferable(),
 
58
    m_memberIndices( indices ),
 
59
    m_color( color ),
 
60
    m_centerLineCreationLock( new boost::shared_mutex() ),
 
61
    m_longestLineCreationLock( new boost::shared_mutex() )
 
62
{
 
63
    // init
 
64
}
 
65
 
 
66
WFiberCluster::WFiberCluster( WFiberCluster::IndexListConstIterator indicesBegin,
 
67
                              WFiberCluster::IndexListConstIterator indicesEnd, const WColor& color )
 
68
    : WTransferable(),
 
69
    m_color( color ),
 
70
    m_centerLineCreationLock( new boost::shared_mutex() ),
 
71
    m_longestLineCreationLock( new boost::shared_mutex() )
 
72
{
 
73
    // now copy the index list
 
74
    std::copy( indicesBegin, indicesEnd, m_memberIndices.begin() );
 
75
}
 
76
 
61
77
WFiberCluster::WFiberCluster( const WFiberCluster& other )
62
78
    : WTransferable( other ),
63
79
    m_memberIndices( other.m_memberIndices ),
88
104
 
89
105
void WFiberCluster::merge( WFiberCluster& other ) // NOLINT
90
106
{
91
 
    std::list< size_t >::const_iterator cit = other.m_memberIndices.begin();
 
107
    WFiberCluster::IndexList::const_iterator cit = other.m_memberIndices.begin();
92
108
    for( ; cit != other.m_memberIndices.end(); ++cit)
93
109
    {
94
110
        m_memberIndices.push_back( *cit );
99
115
    other.clear();
100
116
}
101
117
 
 
118
void WFiberCluster::merge( WFiberCluster::IndexListConstIterator indicesBegin,
 
119
                           WFiberCluster::IndexListConstIterator indicesEnd )
 
120
{
 
121
    // now copy the index list
 
122
    m_memberIndices.insert( m_memberIndices.end(), indicesBegin, indicesEnd );
 
123
}
 
124
 
102
125
// NODOXYGEN
103
126
// \cond Suppress_Doxygen
104
127
void WFiberCluster::setDataSetReference( boost::shared_ptr< const WDataSetFiberVector > fibs )
110
133
{
111
134
    return m_fibs;
112
135
}
113
 
 
114
136
// TODO(math): The only reason why we store here a Reference to the fiber
115
137
// dataset is, we need it in the WMVoxelizer module as well as the clustering
116
138
// information. Since we don't have the possibility of multiple
117
139
// InputConnectors we must agglomerate those into one object. Please remove this.
 
140
// \endcond
 
141
 
118
142
boost::shared_ptr< WPrototyped > WFiberCluster::getPrototype()
119
143
{
120
144
    if( !m_prototype )
123
147
    }
124
148
    return m_prototype;
125
149
}
126
 
// \endcond
127
150
 
128
151
void WFiberCluster::generateCenterLine() const
129
152
{
139
162
    // make copies of the fibers
140
163
    boost::shared_ptr< WDataSetFiberVector > fibs( new WDataSetFiberVector() );
141
164
    size_t avgFiberSize = 0;
142
 
    for( std::list< size_t >::const_iterator cit = m_memberIndices.begin(); cit != m_memberIndices.end(); ++cit )
 
165
    for( WFiberCluster::IndexList::const_iterator cit = m_memberIndices.begin(); cit != m_memberIndices.end(); ++cit )
143
166
    {
144
167
        fibs->push_back( m_fibs->at( *cit ) );
145
168
        avgFiberSize += fibs->back().size();
219
242
 
220
243
    // in the beginning all fibers participate
221
244
    boost::shared_ptr< WDataSetFiberVector > fibs( new WDataSetFiberVector() );
222
 
    for( std::list< size_t >::const_iterator cit = m_memberIndices.begin(); cit != m_memberIndices.end(); ++cit )
 
245
    for( WFiberCluster::IndexList::const_iterator cit = m_memberIndices.begin(); cit != m_memberIndices.end(); ++cit )
223
246
    {
224
247
        fibs->push_back( m_fibs->at( *cit ) );
225
248
    }
268
291
    }
269
292
    // second ending of the centerline
270
293
    boost::shared_ptr< WDataSetFiberVector > fobs( new WDataSetFiberVector() );
271
 
    for( std::list< size_t >::const_iterator cit = m_memberIndices.begin(); cit != m_memberIndices.end(); ++cit )
 
294
    for( WFiberCluster::IndexList::const_iterator cit = m_memberIndices.begin(); cit != m_memberIndices.end(); ++cit )
272
295
    {
273
296
        fobs->push_back( m_fibs->at( *cit ) );
274
297
    }
379
402
WBoundingBox WFiberCluster::getBoundingBox() const
380
403
{
381
404
    WBoundingBox result;
382
 
    for( std::list< size_t >::const_iterator cit = m_memberIndices.begin(); cit != m_memberIndices.end(); ++cit )
 
405
    for( WFiberCluster::IndexList::const_iterator cit = m_memberIndices.begin(); cit != m_memberIndices.end(); ++cit )
383
406
    {
384
407
        result.expandBy( computeBoundingBox( m_fibs->at( *cit ) ) );
385
408
    }