OpenWalnut
1.4.0
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WTRACTADAPTER_H 00026 #define WTRACTADAPTER_H 00027 00028 #include <vector> 00029 00030 #include <boost/shared_ptr.hpp> 00031 00032 #include "../common/math/linearAlgebra/WPosition.h" 00033 00034 /** 00035 * Adapter 00036 */ 00037 class WTractAdapter 00038 { 00039 public: 00040 /** 00041 * Constructs a new WTract which has \ref numPoints points and a startIndex inside of the 00042 * given components array. 00043 * 00044 * \param pointComponents Array where the components of the tract points are inside of 00045 * \param startIndex The position inside of the components array of the first x coordinate. 00046 * \param numPoints How many points this tract has 00047 */ 00048 WTractAdapter( boost::shared_ptr< const std::vector< float > > pointComponents, size_t startIndex, size_t numPoints ); 00049 00050 /** 00051 * How many positions this tract incorporates. 00052 * 00053 * \return number of points 00054 */ 00055 size_t numPoints() const; 00056 00057 /** 00058 * Constructs and returns a \ref WPosition out of the i'th position of this tract. 00059 * 00060 * \param index The index of the position of this tract. It may start at \c 0 and is always 00061 * smaller than \ref numPoints(). 00062 * 00063 * \return The i'th position of this tract as \ref WPosition. 00064 */ 00065 WPosition operator[]( size_t index ) const; 00066 00067 // void reset( boost::shared_ptr< const WTractData > tracts, size_t startIndex, size_t numPoints ) 00068 00069 protected: 00070 private: 00071 /** 00072 * The array where the components of this tracts live. But you will need the starting position 00073 * and the length of the tract to access them. 00074 */ 00075 boost::shared_ptr< const std::vector< float > > m_pointComponents; 00076 00077 /** 00078 * How many \e points aka WPositions this tract consists of. 00079 */ 00080 size_t m_numPoints; 00081 00082 /** 00083 * The index of the x-component of the first point of this tract inside the \ref m_pointComponents array. 00084 */ 00085 size_t m_startIndex; 00086 }; 00087 00088 inline size_t WTractAdapter::numPoints() const 00089 { 00090 return m_numPoints; 00091 } 00092 00093 #endif // WTRACTADAPTER_H