Skip to content

Commit

Permalink
+ add support to PointKernel to get valid points
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Dec 30, 2015
1 parent 4e3856a commit 1274967
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
27 changes: 27 additions & 0 deletions src/Mod/Points/App/Points.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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()) {
Expand Down
15 changes: 8 additions & 7 deletions src/Mod/Points/App/Points.h
Expand Up @@ -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);
}
Expand Down Expand Up @@ -106,14 +108,13 @@ class PointsExport PointKernel : public Data::ComplexGeoData
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);
}

Expand Down

0 comments on commit 1274967

Please sign in to comment.