diff --git a/src/Mod/Points/App/Points.cpp b/src/Mod/Points/App/Points.cpp index bc76f43207c1..0f2462444813 100644 --- a/src/Mod/Points/App/Points.cpp +++ b/src/Mod/Points/App/Points.cpp @@ -27,6 +27,8 @@ # include #endif +#include + #include #include #include @@ -97,6 +99,31 @@ unsigned int PointKernel::getMemSize (void) const return _Points.size() * sizeof(value_type); } +PointKernel::size_type PointKernel::countValid(void) const +{ + size_type num = 0; + for (const_point_iterator it = begin(); it != end(); ++it) { + if (!(boost::math::isnan(it->x) || + boost::math::isnan(it->y) || + boost::math::isnan(it->z))) + num++; + } + return num; +} + +std::vector PointKernel::getValidPoints() const +{ + std::vector valid; + valid.reserve(countValid()); + for (const_point_iterator it = begin(); it != end(); ++it) { + if (!(boost::math::isnan(it->x) || + boost::math::isnan(it->y) || + boost::math::isnan(it->z))) + valid.push_back(value_type(it->x, it->y, it->z)); + } + return valid; +} + void PointKernel::Save (Base::Writer &writer) const { if (!writer.isForceXML()) { diff --git a/src/Mod/Points/App/Points.h b/src/Mod/Points/App/Points.h index cdd62cd97c2b..92e562dc37d4 100644 --- a/src/Mod/Points/App/Points.h +++ b/src/Mod/Points/App/Points.h @@ -47,11 +47,13 @@ class PointsExport PointKernel : public Data::ComplexGeoData public: typedef Base::Vector3f value_type; + typedef std::vector::difference_type difference_type; + typedef std::vector::size_type size_type; PointKernel(void) { } - PointKernel(unsigned long size) + PointKernel(size_type size) { resize(size); } @@ -106,14 +108,13 @@ class PointsExport PointKernel : public Data::ComplexGeoData std::vector _Points; public: - typedef std::vector::difference_type difference_type; - typedef std::vector::size_type size_type; - /// number of points stored size_type size(void) const {return this->_Points.size();} - void resize(unsigned int n){_Points.resize(n);} - void reserve(unsigned int n){_Points.reserve(n);} - inline void erase(unsigned long first, unsigned long last) { + size_type countValid(void) const; + std::vector getValidPoints() const; + void resize(size_type n){_Points.resize(n);} + void reserve(size_type n){_Points.reserve(n);} + inline void erase(size_type first, size_type last) { _Points.erase(_Points.begin()+first,_Points.begin()+last); }