Merge branch 'ge_directionalintervall' into 'master'

__ge__ and __le__ operator for DirectionalInterval

See merge request ngsolve/netgen!502
This commit is contained in:
Schöberl, Joachim 2022-05-05 18:09:09 +02:00
commit 81b22633cd
3 changed files with 27 additions and 3 deletions

View File

@ -230,13 +230,13 @@ namespace netgen
bool openmin = false, openmax = false;
DirectionalInterval (gp_Vec adir) : dir(adir) { ; }
DirectionalInterval (const DirectionalInterval & i2)
: dir(i2.dir), minval(i2.minval), maxval(i2.maxval) { ; }
DirectionalInterval (const DirectionalInterval & i2) = default;
DirectionalInterval operator< (double val) const
{
DirectionalInterval i2 = *this;
i2.maxval = val;
i2.openmax = true;
return i2;
}
@ -244,9 +244,25 @@ namespace netgen
{
DirectionalInterval i2 = *this;
i2.minval = val;
i2.openmin = true;
return i2;
}
DirectionalInterval operator<= (double val) const
{
DirectionalInterval i2 = *this;
i2.maxval = val;
i2.openmax = false;
return i2;
}
DirectionalInterval operator>= (double val) const
{
DirectionalInterval i2 = *this;
i2.minval = val;
i2.openmin = false;
return i2;
}
DirectionalInterval Intersect (const DirectionalInterval & i2)
{

View File

@ -103,6 +103,14 @@ DLL_HEADER void ExportNgOCCBasic(py::module &m)
cout << IM(6) << "vec, gt v - " << netgen::occ2ng(v) << ", val = " << val << endl;
return DirectionalInterval(v) > val;
})
.def("__le__", [](gp_Vec v, double val)
{
return DirectionalInterval(v) <= val;
})
.def("__ge__", [](gp_Vec v, double val)
{
return DirectionalInterval(v) >= val;
})
;
py::class_<gp_Dir>(m, "gp_Dir", "3d OCC direction")

View File

@ -1589,7 +1589,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
{
ListOfShapes selected;
for (auto s : self)
if (interval.Contains(Center(s)))
if (interval.Contains(Center(s), GetBoundingBox(s).Diam() * 1e-7))
selected.push_back(s);
return selected;
})