Skip to content

Commit 707f488

Browse files
authored
Refactor edges_to_path for int type compatibility
Updated edges_to_path function to ensure input is 32-bit int for compatibility with libigl's implementation.
1 parent 81f9aa4 commit 707f488

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/edges_to_path.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,18 @@ namespace pyigl
1212
// Wrapper for igl::edges_to_path
1313
auto edges_to_path(const nb::DRef<const Eigen::MatrixXI> &E)
1414
{
15-
Eigen::VectorXI I, J, K;
16-
igl::edges_to_path(E, I, J, K);
15+
// libigl's implementation internally maps to an int-backed buffer,
16+
// so ensure the input scalar type is 32-bit int to avoid Map pointer mismatches.
17+
using MatXI32 = Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Options>;
18+
using VecXI32 = Eigen::Matrix<int, Eigen::Dynamic, 1>;
19+
20+
MatXI32 Ei = E.template cast<int>();
21+
VecXI32 Ii, Ji, Ki;
22+
igl::edges_to_path(Ei, Ii, Ji, Ki);
23+
24+
Eigen::VectorXI I = Ii.template cast<Integer>();
25+
Eigen::VectorXI J = Ji.template cast<Integer>();
26+
Eigen::VectorXI K = Ki.template cast<Integer>();
1727
return std::make_tuple(I, J, K);
1828
}
1929
}

0 commit comments

Comments
 (0)