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 WJOINCONTOURTREE_H 00026 #define WJOINCONTOURTREE_H 00027 00028 #include <set> 00029 #include <string> 00030 #include <vector> 00031 00032 #include <boost/shared_ptr.hpp> 00033 00034 #include "../../common/WTransferable.h" 00035 #include "../WDataSetSingle.h" 00036 00037 00038 /** 00039 * Processes a dataset for join tree computation. This is a part of those famous contur trees. 00040 * 00041 * Every leaf in that tree represents a local maximum. A branch is a collection of vertices belonging to the 00042 * same component and nodes joining branches represent a data point which melds multiple (at least two) 00043 * branches. 00044 * 00045 * With the Split tree then you may compute the contour tree, but for that you may need to fullfil at least two 00046 * conditions: 00047 * - You operate on a simplicial mesh (WGridRegular3D is not simplicial!!!) 00048 * - All data points are pairwise disjoint 00049 * 00050 * \note You may use this join tree also for finding the vertices belonging to the volume enclosed by the 00051 * biggest isosurface for a given isovalue. Then you don't need "simulation of simplicity" to make the 00052 * data points disjoint also you don't need simplicial meshes. 00053 */ 00054 class WJoinContourTree : public WTransferable // NOLINT 00055 { 00056 friend class WJoinContourTreeTest; 00057 public: 00058 /** 00059 * Initialize this with a data set for which the join tree should be computed. 00060 * 00061 * \throw WNotImplemented If the dataset is not a scalar double field 00062 * 00063 * \param dataset Reference to the dataset. 00064 */ 00065 explicit WJoinContourTree( boost::shared_ptr< WDataSetSingle > dataset ); 00066 00067 WJoinContourTree(); 00068 00069 /** 00070 * Build the join tree. 00071 */ 00072 void buildJoinTree(); 00073 00074 /** 00075 * For a given isovalue all the voxel which are enclosed by the biggest isosurface are computed. 00076 * 00077 * \param isoValue The isovalue 00078 * 00079 * \return Set of voxel indices 00080 */ 00081 boost::shared_ptr< std::set< size_t > > getVolumeVoxelsEnclosedByIsoSurface( const double isoValue ) const; 00082 00083 /** 00084 * Gets the name of this prototype. 00085 * 00086 * \return the name. 00087 */ 00088 virtual const std::string getName() const; 00089 00090 /** 00091 * Gets the description for this prototype. 00092 * 00093 * \return the description 00094 */ 00095 virtual const std::string getDescription() const; 00096 00097 /** 00098 * Returns a prototype instantiated with the true type of the deriving class. 00099 * 00100 * \return the prototype. 00101 */ 00102 static boost::shared_ptr< WPrototyped > getPrototype(); 00103 00104 protected: 00105 /** 00106 * Sort the indices on their element value of the value set in descending order. 00107 */ 00108 void sortIndexArray(); 00109 00110 static boost::shared_ptr< WPrototyped > m_prototype; //!< The prototype as singleton. 00111 00112 private: 00113 boost::shared_ptr< WGridRegular3D > m_grid; //!< Stores the reference to the grid of the given dataset to get the neighbours of a voxel 00114 boost::shared_ptr< WValueSet< double > > m_valueSet; //!< Stores reference to the isovalues, so we may sort them indirect on their value 00115 00116 std::vector< size_t > m_elementIndices; //!< Stores the component number for the i'th vertex in the value set 00117 std::vector< size_t > m_joinTree; //!< For each index stores which node it is connected to 00118 std::vector< size_t > m_lowestVoxel; //!< Stores the index of lowest element for the i'th component 00119 00120 /** 00121 * Comperator for indirect sort so the value set is not modified. 00122 */ 00123 class IndirectCompare 00124 { 00125 public: // NOLINT 00126 /** 00127 * Since we must have access to the value set we need a reference to it. 00128 * 00129 * \param valueSet Value set on which the comparision is done. 00130 */ 00131 explicit IndirectCompare( boost::shared_ptr< WValueSet< double > > valueSet ); 00132 00133 /** 00134 * Compares the isovalue of the elments with index i and j. 00135 * 00136 * \param i The index of the first element 00137 * \param j The index of the other element 00138 * 00139 * \return True if the element in the value set at position i is 00140 * greater than the the element at position j 00141 */ 00142 bool operator()( size_t i, size_t j ); 00143 00144 private: // NOLINT 00145 boost::shared_ptr< WValueSet < double > > m_valueSet; //!< Reference to the isovalues 00146 }; 00147 }; 00148 00149 inline const std::string WJoinContourTree::getName() const 00150 { 00151 return "JoinContourTree"; 00152 } 00153 00154 inline const std::string WJoinContourTree::getDescription() const 00155 { 00156 return "Computes the Join-Tree out of a given dataset."; 00157 } 00158 00159 #endif // WJOINCONTOURTREE_H