Ioan Sucan avatar Ioan Sucan committed af4aeb1

minor stylistic fixes

Comments (0)

Files changed (1)

src/ompl/datastructures/NearestNeighborsFLANN.h

     class NearestNeighborsFLANN : public NearestNeighbors<_T>
     {
     public:
+
         NearestNeighborsFLANN(boost::shared_ptr<flann::IndexParams> params)
             : index_(0), params_(params), searchParams_(32, 0., true), dimension_(1)
         {
         }
-        ~NearestNeighborsFLANN()
+
+        virtual ~NearestNeighborsFLANN(void)
         {
-            clear();
+            if (index_)
+                delete index_;
         }
 
         virtual void clear(void)
             }
             data_.clear();
         }
+
         virtual void setDistanceFunction(const typename NearestNeighbors<_T>::DistanceFunction &distFun)
         {
             NearestNeighbors<_T>::setDistanceFunction(distFun);
             rebuildIndex();
         }
+
         virtual void add(const _T &data)
         {
             bool rebuild = index_ && (data_.size() + 1 > data_.capacity());
         }
         virtual void add(const std::vector<_T> &data)
         {
-            unsigned int oldSize = data_.size(), newSize = oldSize + data.size();
+            unsigned int oldSize = data_.size();
+            unsigned int newSize = oldSize + data.size();
             bool rebuild = index_ && (newSize > data_.capacity());
 
             if (rebuild)
             const flann::Matrix<_T> query(&elt, 1, dimension_);
             std::vector<std::vector<size_t> > indices;
             std::vector<std::vector<double> > dists;
-            k = index_? index_->knnSearch(query, indices, dists, k, searchParams_) : 0;
+            k = index_ ? index_->knnSearch(query, indices, dists, k, searchParams_) : 0;
             nbh.resize(k);
-            for (std::size_t i=0; i<k; ++i)
+            for (std::size_t i = 0 ; i < k ; ++i)
                 nbh[i] = *index_->getPoint(indices[0][i]);
         }
 
             std::vector<std::vector<double> > dists;
             int k = index_ ? index_->radiusSearch(query, indices, dists, radius, searchParams_) : 0;
             nbh.resize(k);
-            for (int i=0; i<k; ++i)
+            for (int i = 0 ; i < k ; ++i)
                 nbh[i] = *index_->getPoint(indices[0][i]);
         }
 
         ///
         /// The parameters determine the type of nearest neighbor
         /// data structure to be constructed.
-        virtual void setIndexParams(boost::shared_ptr<flann::IndexParams> params)
+        virtual void setIndexParams(const boost::shared_ptr<flann::IndexParams> &params)
         {
             params_ = params;
             rebuildIndex();
         }
 
         /// \brief Get the FLANN parameters used to build the current index.
-        virtual const boost::shared_ptr<flann::IndexParams>& getIndexParams() const
+        virtual const boost::shared_ptr<flann::IndexParams>& getIndexParams(void) const
         {
             return params_;
         }
 
         /// \brief Get the FLANN parameters used during nearest neighbor
         /// searches
-        flann::SearchParams& getSearchParams()
+        flann::SearchParams& getSearchParams(void)
         {
             return searchParams_;
         }
 
-        unsigned int getContainerSize()
+        /// \brief Get the FLANN parameters used during nearest neighbor
+        /// searches
+        const flann::SearchParams& getSearchParams(void) const
+        {
+            return searchParams_;
+        }
+
+        unsigned int getContainerSize(void) const
         {
             return dimension_;
         }
+
     protected:
+
         /// \brief Internal function to construct nearest neighbor
         /// data structure with initial elements stored in mat.
         void createIndex(const flann::Matrix<_T>& mat)
         {
-            index_ = new flann::Index<_Dist>(mat, *params_,
-                _Dist(NearestNeighbors<_T>::distFun_));
+            index_ = new flann::Index<_Dist>(mat, *params_, _Dist(NearestNeighbors<_T>::distFun_));
             index_->buildIndex();
         }
+
         /// \brief Rebuild the nearest neighbor data structure (necessary when
         /// changing the distance function or index parameters).
         void rebuildIndex(unsigned int capacity = 0)
 
         /// \brief vector of data stored in FLANN's index. FLANN only indexes
         /// references, so we need store the original data.
-        std::vector<_T> data_;
+        std::vector<_T>                       data_;
+
         /// \brief The FLANN index (the actual index type depends on params_).
-        flann::Index<_Dist>* index_;
+        flann::Index<_Dist>*                  index_;
+
         /// \brief The FLANN index parameters. This contains both the type of
         /// index and the parameters for that type.
         boost::shared_ptr<flann::IndexParams> params_;
+
         /// \brief The parameters used to seach for nearest neighbors.
-        mutable flann::SearchParams searchParams_;
+        mutable flann::SearchParams           searchParams_;
+
         /// \brief If each element has an array-like structure that is exposed
         /// to FLANN, then the dimension_ needs to be set to the length of
         /// this array.
-        unsigned int dimension_;
+        unsigned int                          dimension_;
     };
 
     template<>
 
 }
 
-#endif
+#endif
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.