Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions python/src/ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ void define_ipc(py::module_& m)
},
R"ipc_Qu8mg5v7(
Constructs a list of unique edges represented in a given mesh F

Parameters:
F: #F by 3 list of mesh faces (must be triangles)

Returns:
#E by 2 list of edges in no particular order
)ipc_Qu8mg5v7",
Expand Down
23 changes: 23 additions & 0 deletions python/src/utils/intersection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <ipc/utils/intersection.hpp>

#include <igl/predicates/segment_segment_intersect.h>

namespace py = pybind11;
using namespace ipc;

Expand All @@ -11,4 +13,25 @@ void define_intersection(py::module_& m)
"is_edge_intersecting_triangle", &is_edge_intersecting_triangle, "",
py::arg("e0"), py::arg("e1"), py::arg("t0"), py::arg("t1"),
py::arg("t2"));

m.def(
"segment_segment_intersect",
[](const Eigen::Vector2d& A, const Eigen::Vector2d& B,
const Eigen::Vector2d& C, const Eigen::Vector2d& D) -> bool {
igl::predicates::exactinit();
return igl::predicates::segment_segment_intersect(A, B, C, D);
},
R"ipc_Qu8mg5v7(
Given two segments in 2d test whether they intersect each other using predicates orient2d

Parameters:
A: 1st endpoint of segment 1
B: 2st endpoint of segment 1
C: 1st endpoint of segment 2
D: 2st endpoint of segment 2

Returns:
true if they intersect
)ipc_Qu8mg5v7",
py::arg("A"), py::arg("B"), py::arg("C"), py::arg("D"));
}
7 changes: 7 additions & 0 deletions python/tests/test_intersections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import numpy as np
import ipctk


def test_segment_segment_intersect():
assert ipctk.segment_segment_intersect(
np.array([-1, 0]), np.array([1, 0]), np.array([0, -1]), np.array([0, 1]))