Use std::tuple<double,double> instead of py::tuple with length and type checks

This commit is contained in:
Matthias Hochsteger 2024-11-05 10:46:08 +01:00
parent 45acbbf6ef
commit 629cca9413

View File

@ -167,12 +167,9 @@ DLL_HEADER void ExportNgOCCBasic(py::module &m)
py::class_<gp_Pnt2d>(m, "gp_Pnt2d", "2d OCC point")
.def(py::init([] (py::tuple pnt)
.def(py::init([] (std::tuple<double,double> pnt)
{
if (py::len(pnt) != 2)
throw std::invalid_argument("need 2-tuple to create gp_Pnt2d");
return gp_Pnt2d(py::cast<double>(pnt[0]),
py::cast<double>(pnt[1]));
return gp_Pnt2d(get<0>(pnt), get<1>(pnt));
}))
.def(py::init([] (double x, double y) {
return gp_Pnt2d(x, y);