+ add support to PointKernel to get valid points

This commit is contained in:
wmayer 2015-12-30 15:18:05 +01:00
parent 4e3856acc8
commit 1274967208
2 changed files with 35 additions and 7 deletions

View File

@ -27,6 +27,8 @@
# include <iostream>
#endif
#include <boost/math/special_functions/fpclassify.hpp>
#include <Base/Exception.h>
#include <Base/Matrix.h>
#include <Base/Persistence.h>
@ -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::value_type> PointKernel::getValidPoints() const
{
std::vector<PointKernel::value_type> 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()) {

View File

@ -47,11 +47,13 @@ class PointsExport PointKernel : public Data::ComplexGeoData
public:
typedef Base::Vector3f value_type;
typedef std::vector<value_type>::difference_type difference_type;
typedef std::vector<value_type>::size_type size_type;
PointKernel(void)
{
}
PointKernel(unsigned long size)
PointKernel(size_type size)
{
resize(size);
}
@ -106,14 +108,13 @@ private:
std::vector<value_type> _Points;
public:
typedef std::vector<value_type>::difference_type difference_type;
typedef std::vector<value_type>::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<value_type> 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);
}