瀏覽代碼

rename

Former-commit-id: 23e9373fdfcd310e9e22360a9b59fedfe7e49cf9
Alec Jacobson 6 年之前
父節點
當前提交
93cba2e044
共有 2 個文件被更改,包括 38 次插入32 次删除
  1. 21 18
      include/igl/dijkstra.cpp
  2. 17 14
      include/igl/dijkstra.h

+ 21 - 18
include/igl/dijkstra.cpp

@@ -5,15 +5,16 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#include <igl/dijkstra.h>
+#include "dijkstra.h"
 
 template <typename IndexType, typename DerivedD, typename DerivedP>
-IGL_INLINE int igl::dijkstra_compute_paths(const IndexType &source,
-                                           const std::set<IndexType> &targets,
-                                           const std::vector<std::vector<IndexType> >& VV,
-                                           const std::vector<double>& weights,
-                                           Eigen::PlainObjectBase<DerivedD> &min_distance,
-                                           Eigen::PlainObjectBase<DerivedP> &previous)
+IGL_INLINE int igl::dijkstra(
+  const IndexType &source,
+  const std::set<IndexType> &targets,
+  const std::vector<std::vector<IndexType> >& VV,
+  const std::vector<double>& weights,
+  Eigen::PlainObjectBase<DerivedD> &min_distance,
+  Eigen::PlainObjectBase<DerivedP> &previous)
 {
   int numV = VV.size();
   min_distance.setConstant(numV, 1, std::numeric_limits<typename DerivedD::Scalar>::infinity());
@@ -55,20 +56,22 @@ IGL_INLINE int igl::dijkstra_compute_paths(const IndexType &source,
 }
 
 template <typename IndexType, typename DerivedD, typename DerivedP>
-IGL_INLINE int igl::dijkstra_compute_paths(const IndexType &source,
-                                           const std::set<IndexType> &targets,
-                                           const std::vector<std::vector<IndexType> >& VV,
-                                           Eigen::PlainObjectBase<DerivedD> &min_distance,
-                                           Eigen::PlainObjectBase<DerivedP> &previous)
+IGL_INLINE int igl::dijkstra(
+  const IndexType &source,
+  const std::set<IndexType> &targets,
+  const std::vector<std::vector<IndexType> >& VV,
+  Eigen::PlainObjectBase<DerivedD> &min_distance,
+  Eigen::PlainObjectBase<DerivedP> &previous)
 {
   std::vector<double> weights(VV.size(), 1.0);
-  return dijkstra_compute_paths(source, targets, VV, weights, min_distance, previous);
+  return dijkstra(source, targets, VV, weights, min_distance, previous);
 }
 
 template <typename IndexType, typename DerivedP>
-IGL_INLINE void igl::dijkstra_get_shortest_path_to(const IndexType &vertex,
-                                                   const Eigen::PlainObjectBase<DerivedP> &previous,
-                                                   std::vector<IndexType> &path)
+IGL_INLINE void igl::dijkstra(
+  const IndexType &vertex,
+  const Eigen::MatrixBase<DerivedP> &previous,
+  std::vector<IndexType> &path)
 {
   IndexType source = vertex;
   path.clear();
@@ -78,6 +81,6 @@ IGL_INLINE void igl::dijkstra_get_shortest_path_to(const IndexType &vertex,
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instantiation
-template int igl::dijkstra_compute_paths<int, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(int const&, std::set<int, std::less<int>, std::allocator<int> > const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::dijkstra_get_shortest_path_to<int, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(int const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, std::vector<int, std::allocator<int> >&);
+template int igl::dijkstra<int, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(int const&, std::set<int, std::less<int>, std::allocator<int> > const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::dijkstra<int, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(int const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, std::vector<int, std::allocator<int> >&);
 #endif

+ 17 - 14
include/igl/dijkstra.h

@@ -31,12 +31,13 @@ namespace igl {
   //   previous         #V by 1 list of the previous visited vertices (for each vertex) - used for backtracking
   //
   template <typename IndexType, typename DerivedD, typename DerivedP>
-  IGL_INLINE int dijkstra_compute_paths(const IndexType &source,
-                                        const std::set<IndexType> &targets,
-                                        const std::vector<std::vector<IndexType> >& VV,
-                                        const std::vector<double>& weights,
-                                        Eigen::PlainObjectBase<DerivedD> &min_distance,
-                                        Eigen::PlainObjectBase<DerivedP> &previous);
+  IGL_INLINE int dijkstra(
+    const IndexType &source,
+    const std::set<IndexType> &targets,
+    const std::vector<std::vector<IndexType> >& VV,
+    const std::vector<double>& weights,
+    Eigen::PlainObjectBase<DerivedD> &min_distance,
+    Eigen::PlainObjectBase<DerivedP> &previous);
 
   // Dijkstra's algorithm for shortest paths, with multiple targets.
   // Adapted from http://rosettacode.org/wiki/Dijkstra%27s_algorithm .
@@ -52,11 +53,12 @@ namespace igl {
   //   previous         #V by 1 list of the previous visited vertices (for each vertex) - used for backtracking
   //
   template <typename IndexType, typename DerivedD, typename DerivedP>
-  IGL_INLINE int dijkstra_compute_paths(const IndexType &source,
-                                        const std::set<IndexType> &targets,
-                                        const std::vector<std::vector<IndexType> >& VV,
-                                        Eigen::PlainObjectBase<DerivedD> &min_distance,
-                                        Eigen::PlainObjectBase<DerivedP> &previous);
+  IGL_INLINE int dijkstra(
+    const IndexType &source,
+    const std::set<IndexType> &targets,
+    const std::vector<std::vector<IndexType> >& VV,
+    Eigen::PlainObjectBase<DerivedD> &min_distance,
+    Eigen::PlainObjectBase<DerivedP> &previous);
 
   // Backtracking after Dijkstra's algorithm, to find shortest path.
   //
@@ -68,9 +70,10 @@ namespace igl {
   //   path             #P by 1 list of vertex indices in the shortest path from source to vertex
   //
   template <typename IndexType, typename DerivedP>
-  IGL_INLINE void dijkstra_get_shortest_path_to(const IndexType &vertex,
-                                                const Eigen::PlainObjectBase<DerivedP> &previous,
-                                                std::vector<IndexType> &path);
+  IGL_INLINE void dijkstra(
+    const IndexType &vertex,
+    const Eigen::MatrixBase<DerivedP> &previous,
+    std::vector<IndexType> &path);
 };