Skip to content

Commit

Permalink
Merge pull request #60 from open-space-collective/users/vishwa/add-in…
Browse files Browse the repository at this point in the history
…terval-union-intersection

feat: add intersection and union methods for Interval class
  • Loading branch information
Derollez authored Oct 17, 2022
2 parents 9836cf1 + ca3ed07 commit 91935bb
Show file tree
Hide file tree
Showing 4 changed files with 531 additions and 335 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ inline void OpenSpaceToolkitMathematicsPy_Objects_Interval (
class_<Interval<Real>> real_interval(aModule, "RealInterval") ;

// Define constructor
real_interval.def(init<const Real&, const Real&, const Interval<Real>::Type&>())
real_interval.def(init<const Real&, const Real&, const Interval<Real>::Type&>(), arg("lower_bound"), arg("upper_bound"), arg("type"))

// Define methods
.def(self == self)
Expand All @@ -36,17 +36,19 @@ inline void OpenSpaceToolkitMathematicsPy_Objects_Interval (

.def("is_defined", &Interval<Real>::isDefined)
.def("is_degenerate", &Interval<Real>::isDegenerate)
.def("intersects", &Interval<Real>::intersects)
.def("contains_real", +[] (const Interval<Real>& anInterval, const Real& aReal) -> bool { return anInterval.contains(aReal) ; })
.def("contains_interval", +[] (const Interval<Real>& anInterval, const Interval<Real>& anOtherInterval) -> bool { return anInterval.contains(anOtherInterval) ; })
.def("intersects", &Interval<Real>::intersects, arg("interval"))
.def("contains_real", +[] (const Interval<Real>& anInterval, const Real& aReal) -> bool { return anInterval.contains(aReal) ; }, arg("real"))
.def("contains_interval", +[] (const Interval<Real>& anInterval, const Interval<Real>& anOtherInterval) -> bool { return anInterval.contains(anOtherInterval) ; }, arg("interval"))
.def("get_intersection_with", &Interval<Real>::getIntersectionWith, arg("interval"))
.def("get_union_with", &Interval<Real>::getUnionWith, arg("interval"))

.def("get_lower_bound", &Interval<Real>::getLowerBound)
.def("get_upper_bound", &Interval<Real>::getUpperBound)
.def("to_string", &Interval<Real>::toString)

// Define static methods
.def_static("undefined", &Interval<Real>::Undefined)
.def_static("closed", &Interval<Real>::Closed)
.def_static("closed", &Interval<Real>::Closed, arg("lower_bound"), arg("upper_bound"))
;

// Add other interval types
Expand Down
Loading

0 comments on commit 91935bb

Please sign in to comment.