more features of DirectionalInterval

This commit is contained in:
Joachim Schoeberl 2021-08-24 10:40:30 +02:00
parent 2dc506fcfd
commit bd5699d5f1
2 changed files with 19 additions and 0 deletions

View File

@ -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)
{

View File

@ -321,6 +321,13 @@ DLL_HEADER void ExportNgOCCBasic(py::module &m)
py::class_<DirectionalInterval> (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<py::tuple, gp_Pnt>();