Commit d2fa9e85 authored by Davis King's avatar Davis King

Cleaned up code and fixed point and dpoint addition actually doing subtraction.

parent bef30d18
...@@ -87,29 +87,6 @@ string print_rect_filter(const rect_filter& r) ...@@ -87,29 +87,6 @@ string print_rect_filter(const rect_filter& r)
} }
rectangle add_point_to_rect(const rectangle& r, const point& p)
{
return r + p;
}
rectangle add_rect_to_rect(const rectangle& r, const rectangle& p)
{
return r + p;
}
rectangle& iadd_point_to_rect(rectangle& r, const point& p)
{
r += p;
return r;
}
rectangle& iadd_rect_to_rect(rectangle& r, const rectangle& p)
{
r += p;
return r;
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -142,10 +119,10 @@ void bind_rectangles(py::module& m) ...@@ -142,10 +119,10 @@ void bind_rectangles(py::module& m)
.def("intersect", &::intersect<type>, py::arg("rectangle")) .def("intersect", &::intersect<type>, py::arg("rectangle"))
.def("__str__", &::print_rectangle_str<type>) .def("__str__", &::print_rectangle_str<type>)
.def("__repr__", &::print_rectangle_repr) .def("__repr__", &::print_rectangle_repr)
.def("__add__", &::add_point_to_rect) .def(py::self += point())
.def("__add__", &::add_rect_to_rect) .def(py::self + point())
.def("__iadd__", &::iadd_point_to_rect) .def(py::self += rectangle())
.def("__iadd__", &::iadd_rect_to_rect) .def(py::self + rectangle())
.def(py::self == py::self) .def(py::self == py::self)
.def(py::self != py::self) .def(py::self != py::self)
.def(py::pickle(&getstate<type>, &setstate<type>)); .def(py::pickle(&getstate<type>, &setstate<type>));
......
...@@ -405,8 +405,8 @@ void bind_vector(py::module& m) ...@@ -405,8 +405,8 @@ void bind_vector(py::module& m)
.def(py::init<>(&numpy_to_dlib_vect<double>), py::arg("v")) .def(py::init<>(&numpy_to_dlib_vect<double>), py::arg("v"))
.def("__repr__", &point__repr__) .def("__repr__", &point__repr__)
.def("__str__", &point__str__) .def("__str__", &point__str__)
.def("__sub__", [](const point& a, const point& b){return a-b;}) .def(py::self + py::self)
.def("__add__", [](const point& a, const point& b){return a-b;}) .def(py::self - py::self)
.def("normalize", &type::normalize, "Returns a unit normalized copy of this vector.") .def("normalize", &type::normalize, "Returns a unit normalized copy of this vector.")
.def_property("x", &point_x, [](point& p, long x){p.x()=x;}, "The x-coordinate of the point.") .def_property("x", &point_x, [](point& p, long x){p.x()=x;}, "The x-coordinate of the point.")
.def_property("y", &point_y, [](point& p, long y){p.x()=y;}, "The y-coordinate of the point.") .def_property("y", &point_y, [](point& p, long y){p.x()=y;}, "The y-coordinate of the point.")
...@@ -434,8 +434,8 @@ void bind_vector(py::module& m) ...@@ -434,8 +434,8 @@ void bind_vector(py::module& m)
.def("normalize", &type::normalize, "Returns a unit normalized copy of this vector.") .def("normalize", &type::normalize, "Returns a unit normalized copy of this vector.")
.def_property("x", &dpoint_x, [](dpoint& p, double x){p.x()=x;}, "The x-coordinate of the dpoint.") .def_property("x", &dpoint_x, [](dpoint& p, double x){p.x()=x;}, "The x-coordinate of the dpoint.")
.def_property("y", &dpoint_y, [](dpoint& p, double y){p.x()=y;}, "The y-coordinate of the dpoint.") .def_property("y", &dpoint_y, [](dpoint& p, double y){p.x()=y;}, "The y-coordinate of the dpoint.")
.def("__sub__", [](const dpoint& a, const dpoint& b){return a-b;}) .def(py::self + py::self)
.def("__add__", [](const dpoint& a, const dpoint& b){return a-b;}) .def(py::self - py::self)
.def(py::pickle(&getstate<type>, &setstate<type>)); .def(py::pickle(&getstate<type>, &setstate<type>));
} }
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment