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 WDATASETFIBERVECTOR_H 00026 #define WDATASETFIBERVECTOR_H 00027 00028 #include <string> 00029 #include <vector> 00030 00031 #include <boost/shared_ptr.hpp> 00032 00033 #include "../common/datastructures/WFiber.h" 00034 #include "WDataSet.h" 00035 #include "WDataSetFibers.h" 00036 #include "WExportDataHandler.h" 00037 00038 /** 00039 * Represents a simple set of WFibers. 00040 */ 00041 class OWDATAHANDLER_EXPORT WDataSetFiberVector : public WMixinVector< WFiber >, public WDataSet // NOLINT 00042 { 00043 public: 00044 /** 00045 * Default constructor for creating an empty fiber vector. 00046 */ 00047 WDataSetFiberVector(); 00048 00049 /** 00050 * Constructs a new set of WFibers 00051 * 00052 * \param fibs Fiber vector to store in this data set 00053 */ 00054 explicit WDataSetFiberVector( boost::shared_ptr< std::vector< WFiber > > fibs ); 00055 00056 /** 00057 * Convert a WDataSetFibers into a fiber vector dataset. 00058 * 00059 * \param fiberDS Dataset which has to be converted 00060 */ 00061 explicit WDataSetFiberVector( boost::shared_ptr< const WDataSetFibers > fiberDS ); 00062 00063 /** 00064 * Copy constructor for fibers 00065 * 00066 * \param other Instance to copy from 00067 */ 00068 // defined since rule of three 00069 WDataSetFiberVector( const WDataSetFiberVector& other ); // NOLINT since cxxtest need it as unexcplicit! 00070 00071 /** 00072 * Destructs WDataSetFiberVector instances 00073 */ 00074 virtual ~WDataSetFiberVector(); // defined since rule of three 00075 00076 /** 00077 * Operator for assigning instances of WDataSetFiberVector 00078 * 00079 * \param other Instance which should replace this 00080 * 00081 * \return Reference for further usage of the outcome of the assigment 00082 */ 00083 WDataSetFiberVector& operator=( const WDataSetFiberVector& other ); // defined since rule of three 00084 00085 /** 00086 * Sort fibers descending on their length and update 00087 */ 00088 void sortDescLength(); 00089 00090 /** 00091 * Generates new WDataSetFiberVector out of the used fibers from this dataset. 00092 * 00093 * \param unused If the i'th postion of this vector is true, then this fiber is considered as used. 00094 * 00095 * \return A reference to the new generate WDataSetFiberVector 00096 */ 00097 boost::shared_ptr< WDataSetFiberVector > generateDataSetOutOfUsedFibers( const std::vector< bool > &unused ) const; 00098 00099 /** 00100 * Determines whether this dataset can be used as a texture. 00101 * 00102 * \return true if usable as texture. 00103 */ 00104 virtual bool isTexture() const; 00105 00106 /** 00107 * Gets the name of this prototype. 00108 * 00109 * \return the name. 00110 */ 00111 virtual const std::string getName() const; 00112 00113 /** 00114 * Gets the description for this prototype. 00115 * 00116 * \return the description 00117 */ 00118 virtual const std::string getDescription() const; 00119 00120 /** 00121 * Returns a prototype instantiated with the true type of the deriving class. 00122 * 00123 * \return the prototype. 00124 */ 00125 static boost::shared_ptr< WPrototyped > getPrototype(); 00126 00127 /** 00128 * Convert this dataset into WDataSetFibers format for other purposes if needed. (e.g. display) 00129 * 00130 * \return Reference to the dataset in WDataSetFibers format 00131 */ 00132 boost::shared_ptr< WDataSetFibers > toWDataSetFibers() const; 00133 00134 protected: 00135 /** 00136 * The prototype as singleton. 00137 */ 00138 static boost::shared_ptr< WPrototyped > m_prototype; 00139 }; 00140 00141 boost::shared_ptr< WFiber > centerLine( boost::shared_ptr< const WDataSetFibers > tracts ); 00142 00143 boost::shared_ptr< WFiber > longestLine( boost::shared_ptr< const WDataSetFibers > tracts ); 00144 00145 boost::shared_ptr< WFiber > centerLine( boost::shared_ptr< const WDataSetFiberVector > tracts ); 00146 00147 boost::shared_ptr< WFiber > longestLine( boost::shared_ptr< const WDataSetFiberVector > tracts ); 00148 00149 #endif // WDATASETFIBERVECTOR_H