diff --git a/modules/geom/pymod/export_vec3.cc b/modules/geom/pymod/export_vec3.cc index 1f1e20662496fa0b9772fe0c67c039abb4f0e816..0df8101549767a5c3a7af43bdde4bd33da3b9dd2 100644 --- a/modules/geom/pymod/export_vec3.cc +++ b/modules/geom/pymod/export_vec3.cc @@ -108,6 +108,8 @@ void export_Vec3() .def(self + Real()) .def(Real() + self) .def(self - self) + .def(self == self) + .def(self != self) .add_property("center", &Vec3List::GetCenter) .add_property("inertia", &Vec3List::GetInertia) .add_property("principal_axes", &Vec3List::GetPrincipalAxes) diff --git a/modules/geom/src/vec3.hh b/modules/geom/src/vec3.hh index 647b4bdd11f9d10b7b3c5c4d8e7f23c8e6d5438e..58e63b89258294462a34e9ab28311ddde59a9670 100644 --- a/modules/geom/src/vec3.hh +++ b/modules/geom/src/vec3.hh @@ -228,9 +228,25 @@ public: base_type::operator=(rhs); return *this; } + //! comparable + bool operator==(const Vec3List& rhs) const + { + if (this->size()!=rhs.size()){ + throw std::length_error("Vec3List must have the same size"); + } + for (unsigned int i=0;i!=this->size();++i) { + if (((*this)[i])!=((rhs)[i])){ + return false; + } + } + return true; + } //! addable op Vec3List& operator+=(const Vec3List& rhs) { + if (this->size()!=rhs.size()){ + throw std::length_error("Vec3List must have the same size"); + } for (unsigned int i=0;i!=this->size();++i) { (*this)[i]+=(rhs)[i]; } @@ -246,7 +262,10 @@ public: //! subtractable op Vec3List& operator-=(const Vec3List& rhs) - { + { + if (this->size()!=rhs.size()){ + throw std::length_error("Vec3List must have the same size"); + } for (unsigned int i=0;i!=this->size();++i) { (*this)[i]-=(rhs)[i]; }