Changeset 20:8f9a14fd63eb in rrlib_geometry for space_partitioning/tKDTree.h


Ignore:
Timestamp:
09.01.2012 02:03:03 (8 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Message:

Readded support for different metrics using C++11 constucts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • space_partitioning/tKDTree.h

    r19 r20  
    147147  typedef geometry::tPoint<Tdimension, TElement> tPoint; 
    148148  typedef geometry::tBoundingBox<Tdimension, TElement> tBoundingBox; 
    149  
    150 //  /*! 
    151 //   * \brief An instantiation of std::binary_function for easier implementation of an own appropriate metric 
    152 //   */ 
    153 //  typedef std::binary_function<tCoordinates, tCoordinates, typename tCoordinates::tElement> tMetric; 
     149  typedef std::function < TElement(const tPoint &, const tPoint &) > tMetric; 
    154150 
    155151  /*! 
     
    185181     */ 
    186182    template <typename TIterator> 
    187     tNode(TIterator begin, TIterator end); 
     183    tNode(TIterator begin, TIterator end, tMetric metric); 
    188184 
    189185    /*! 
     
    263259    tPoint center_of_mass; 
    264260 
    265     size_t SelectSplitAxis() const; 
     261    size_t SelectSplitAxis(tMetric metric) const; 
    266262  }; 
    267263 
     
    288284  tKDTree(TIterator begin, TIterator end); 
    289285 
     286  template <typename TIterator> 
     287  tKDTree(TIterator begin, TIterator end, tMetric metric); 
     288 
    290289  /*! 
    291290   * \brief The dtor of tKDTree 
     
    300299  inline const tNode &Root() const; 
    301300 
    302 //  /*! 
    303 //   * \brief The default metric (Euklidian norm) used in this algorithm 
    304 //   */ 
    305 //  struct tDefaultMetric : public tMetric 
    306 //  { 
    307 //    inline const typename tMetric::result_type operator()(const typename tMetric::first_argument_type &x, const typename tMetric::second_argument_type &y) const 
    308 //    { 
    309 //      return (x - y).Length(); 
    310 //    } 
    311 //  }; 
    312  
    313301//---------------------------------------------------------------------- 
    314302// Private fields and methods 
Note: See TracChangeset for help on using the changeset viewer.