1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
23
//---------------------------------------------------------------------------
29
#include "../common/WAssert.h"
31
#include "WFiberAccumulator.h"
33
WFiberAccumulator::WFiberAccumulator()
35
m_points( new std::vector< float >() ),
36
m_fiberIndices( new std::vector< size_t >() ),
37
m_fiberLengths( new std::vector< size_t >() ),
38
m_pointToFiber( new std::vector< size_t >() )
42
WFiberAccumulator::~WFiberAccumulator()
46
void WFiberAccumulator::add( std::vector< WVector3d > const& in )
48
boost::unique_lock< boost::mutex > lock( m_fiberMutex );
52
m_fiberIndices->push_back( m_points->size() / 3 );
53
m_fiberLengths->push_back( in.size() );
55
for( size_t k = 0; k < in.size(); ++k )
57
m_points->push_back( in[ k ][ 0 ] );
58
m_points->push_back( in[ k ][ 1 ] );
59
m_points->push_back( in[ k ][ 2 ] );
61
m_pointToFiber->push_back( m_fiberIndices->size() - 1 );
66
boost::shared_ptr< WDataSetFibers > WFiberAccumulator::buildDataSet()
68
boost::unique_lock< boost::mutex > lock( m_fiberMutex );
70
boost::shared_ptr< WDataSetFibers > res = boost::shared_ptr< WDataSetFibers >( new WDataSetFibers( m_points, m_fiberIndices,
71
m_fiberLengths, m_pointToFiber ) );
73
m_points = boost::shared_ptr< std::vector< float > >( new std::vector< float >() );
74
m_fiberIndices = boost::shared_ptr< std::vector< size_t > >( new std::vector< size_t >() );
75
m_fiberLengths = boost::shared_ptr< std::vector< size_t > >( new std::vector< size_t >() );
76
m_pointToFiber = boost::shared_ptr< std::vector< size_t > >( new std::vector< size_t >() );
81
void WFiberAccumulator::clear()
84
m_fiberIndices->clear();
85
m_fiberLengths->clear();
86
m_pointToFiber->clear();