Skip to content

Commit 846ae44

Browse files
committed
fix: ramer_douglas_peucker Q output is MatrixXd not VectorXi
1 parent f50a6c7 commit 846ae44

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/compas_libigl/simplify.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ def ramer_douglas_peucker(points, threshold):
1818
1919
Returns
2020
-------
21-
tuple[list[list[float]], list[int], list[int]]
21+
tuple[list[list[float]], list[int], list[list[float]]]
2222
A tuple containing
23-
* the simplified polyline points,
24-
* indices in original polyline that were kept,
25-
* for each simplified point, its index in the original polyline.
23+
* the simplified polyline points (S),
24+
* indices in original polyline that were kept (J),
25+
* for each original point, the corresponding point on the simplified curve (Q).
2626
"""
2727
P = np.asarray(points, dtype=np.float64)
2828
S, J, Q = _simplify.ramer_douglas_peucker(P, float(threshold))

src/simplify.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
#include "simplify.hpp"
22

3-
std::tuple<compas::RowMatrixXd, Eigen::VectorXi, Eigen::VectorXi>
3+
std::tuple<compas::RowMatrixXd, Eigen::VectorXi, compas::RowMatrixXd>
44
ramer_douglas_peucker(
55
Eigen::Ref<const compas::RowMatrixXd> P,
66
double threshold
77
) {
88
Eigen::MatrixXd S; // Simplified polyline
99
Eigen::VectorXi J; // Indices of kept points in original polyline
10-
Eigen::VectorXi Q; // For each point in S, index in original P
10+
Eigen::MatrixXd Q; // For each point in original P, the corresponding point on simplified curve
1111

1212
igl::ramer_douglas_peucker(P, threshold, S, J, Q);
1313

1414
compas::RowMatrixXd S_row = S;
15-
return std::make_tuple(S_row, J, Q);
15+
compas::RowMatrixXd Q_row = Q;
16+
return std::make_tuple(S_row, J, Q_row);
1617
}
1718

1819
NB_MODULE(_simplify, m) {

src/simplify.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
*
1010
* @param P #P x 3 matrix of polyline points
1111
* @param threshold Maximum distance threshold for simplification
12-
* @return Tuple of (simplified points, indices of kept points, mapping from simplified to original)
12+
* @return Tuple of (simplified points, indices of kept points, mapping from original to simplified)
1313
*/
14-
std::tuple<compas::RowMatrixXd, Eigen::VectorXi, Eigen::VectorXi>
14+
std::tuple<compas::RowMatrixXd, Eigen::VectorXi, compas::RowMatrixXd>
1515
ramer_douglas_peucker(
1616
Eigen::Ref<const compas::RowMatrixXd> P,
1717
double threshold);

0 commit comments

Comments
 (0)