diff --git a/libsrc/occ/python_occ.hpp b/libsrc/occ/python_occ.hpp index 55c6a16c..526b1135 100644 --- a/libsrc/occ/python_occ.hpp +++ b/libsrc/occ/python_occ.hpp @@ -33,6 +33,14 @@ public: return i2; } + + DirectionalInterval Intersect (const DirectionalInterval & i2) + { + DirectionalInterval res = *this; + res.minval = max(res.minval, i2.minval); + res.maxval = min(res.maxval, i2.maxval); + return res; + } bool Contains (gp_Pnt p, double eps = 1e-8) { diff --git a/libsrc/occ/python_occ_basic.cpp b/libsrc/occ/python_occ_basic.cpp index 0d6f31e9..56b897e7 100644 --- a/libsrc/occ/python_occ_basic.cpp +++ b/libsrc/occ/python_occ_basic.cpp @@ -321,6 +321,13 @@ DLL_HEADER void ExportNgOCCBasic(py::module &m) py::class_ (m, "DirectionalInterval") + .def("__str__", [](DirectionalInterval self) + { + stringstream str; + str << "(" << self.minval << ", " << self.maxval << ")"; + return str.str(); + }) + .def("__lt__", [](DirectionalInterval i, double val) { cout << "directionalinterval, lt, imin/max = " << i.minval << " / " << i.maxval << endl; @@ -331,6 +338,10 @@ DLL_HEADER void ExportNgOCCBasic(py::module &m) cout << "directionalinterval, gt, imin/max = " << i.minval << " / " << i.maxval << endl; return i > val; }) + .def("__and__", [](DirectionalInterval self, DirectionalInterval other) { + cout << "and of intervals" << endl; + return self.Intersect(other); + }) ; py::implicitly_convertible();