diff --git a/modules/geom/pymod/export_vec3.cc b/modules/geom/pymod/export_vec3.cc index e0c4ac6c8e4b7bf4184bf79ddfa445188a643f59..1f1e20662496fa0b9772fe0c67c039abb4f0e816 100644 --- a/modules/geom/pymod/export_vec3.cc +++ b/modules/geom/pymod/export_vec3.cc @@ -95,6 +95,19 @@ void export_Vec3() class_<Vec3List>("Vec3List", init<>()) .def(vector_indexing_suite<Vec3List>()) .def(geom::VectorAdditions<Vec3List>()) + .def(self *= Real()) + .def(self /= Real()) + .def(self += Real()) + .def(self += self) + .def(self -= self) + //.def(-self) + .def(self * Real()) + .def(Real() * self) + .def(self / Real()) + .def(self + self) + .def(self + Real()) + .def(Real() + 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 b585d4a76e5e8ba29e618794338e888deca3584f..647b4bdd11f9d10b7b3c5c4d8e7f23c8e6d5438e 100644 --- a/modules/geom/src/vec3.hh +++ b/modules/geom/src/vec3.hh @@ -207,7 +207,13 @@ namespace geom { // TODO: move to separate file class Mat3; -class DLLEXPORT_OST_GEOM Vec3List : public std::vector<Vec3> { +class DLLEXPORT_OST_GEOM Vec3List : + public std::vector<Vec3>, + private boost::equality_comparable<Vec3List>, + private boost::additive<Vec3List>, + private boost::additive<Vec3List, Real>, + private boost::multiplicative<Vec3List, Real> + { public: typedef std::vector<Vec3> base_type; Vec3List() : base_type() {} @@ -222,7 +228,67 @@ public: base_type::operator=(rhs); return *this; } - + //! addable op + Vec3List& operator+=(const Vec3List& rhs) + { + for (unsigned int i=0;i!=this->size();++i) { + (*this)[i]+=(rhs)[i]; + } + return *this; + } + Vec3List& operator+=(Real d) + { + for (unsigned int i=0;i!=this->size();++i) { + (*this)[i]+=d; + } + return *this; + } + + //! subtractable op + Vec3List& operator-=(const Vec3List& rhs) + { + for (unsigned int i=0;i!=this->size();++i) { + (*this)[i]-=(rhs)[i]; + } + return *this; + } + + Vec3List& operator-=(Real d) + { + for (unsigned int i=0;i!=this->size();++i) { + (*this)[i]-=d; + } + return *this; + } + //! negateable + //Vec3List3 operator-() const + //{ + // geom::Vec3List vl; + // for (unsigned int i=0;i!=this->size();++i) { + // geom::Vec3 v=(*this)[i]; + // vl.push_back(-v); + // } + // return vl; + //} + + //! multipliable + Vec3List& operator*=(Real d) + { + for (unsigned int i=0;i!=this->size();++i) { + (*this)[i]*=d; + } + return *this; + } + + //! dividable + Vec3List& operator/=(Real d) + { + for (unsigned int i=0;i!=this->size();++i) { + (*this)[i]/=d; + } + return *this; + } + // TODO: move some or all of these to stand-alone functions Mat3 GetInertia() const; Vec3 GetCenter() const;