diff --git a/src/Mod/Points/App/PointsPy.xml b/src/Mod/Points/App/PointsPy.xml
index 530bc3856..af555c8b3 100644
--- a/src/Mod/Points/App/PointsPy.xml
+++ b/src/Mod/Points/App/PointsPy.xml
@@ -44,6 +44,16 @@ transforming and much more.
add one or more (list of) points to the object
+
+
+ Get a new point object from a given segment
+
+
+
+
+ Get a new point object from points with valid coordinates (i.e. that are not NaN)
+
+
Return the number of vertices of the points object.
diff --git a/src/Mod/Points/App/PointsPyImp.cpp b/src/Mod/Points/App/PointsPyImp.cpp
index 90e477f20..ca8857177 100644
--- a/src/Mod/Points/App/PointsPyImp.cpp
+++ b/src/Mod/Points/App/PointsPyImp.cpp
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
// inclusion of the generated files (generated out of PointsPy.xml)
#include "PointsPy.h"
@@ -168,6 +169,54 @@ PyObject* PointsPy::addPoints(PyObject * args)
Py_Return;
}
+PyObject* PointsPy::fromSegment(PyObject * args)
+{
+ PyObject *obj;
+ if (!PyArg_ParseTuple(args, "O", &obj))
+ return 0;
+
+ try {
+ const PointKernel* points = getPointKernelPtr();
+ Py::Sequence list(obj);
+ std::auto_ptr pts(new PointKernel());
+ pts->reserve(list.size());
+ int numPoints = static_cast(points->size());
+ for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
+ int index = static_cast(Py::Int(*it));
+ if (index >= 0 && index < numPoints)
+ pts->push_back(points->getPoint(index));
+ }
+
+ return new PointsPy(pts.release());
+ }
+ catch (const Py::Exception&) {
+ PyErr_SetString(Base::BaseExceptionFreeCADError, "expect a list of int");
+ return 0;
+ }
+}
+
+PyObject* PointsPy::fromValid(PyObject * args)
+{
+ if (!PyArg_ParseTuple(args, ""))
+ return 0;
+
+ try {
+ const PointKernel* points = getPointKernelPtr();
+ std::auto_ptr pts(new PointKernel());
+ pts->reserve(points->size());
+ for (PointKernel::const_iterator it = points->begin(); it != points->end(); ++it) {
+ if (!boost::math::isnan(it->x) && !boost::math::isnan(it->y) && !boost::math::isnan(it->z))
+ pts->push_back(*it);
+ }
+
+ return new PointsPy(pts.release());
+ }
+ catch (const Py::Exception&) {
+ PyErr_SetString(Base::BaseExceptionFreeCADError, "expect a list of int");
+ return 0;
+ }
+}
+
Py::Int PointsPy::getCountPoints(void) const
{
return Py::Int((long)getPointKernelPtr()->size());
diff --git a/src/Mod/ReverseEngineering/App/AppReverseEngineering.cpp b/src/Mod/ReverseEngineering/App/AppReverseEngineering.cpp
index dacfd7992..144d14c3b 100644
--- a/src/Mod/ReverseEngineering/App/AppReverseEngineering.cpp
+++ b/src/Mod/ReverseEngineering/App/AppReverseEngineering.cpp
@@ -649,6 +649,7 @@ Mesh.show(m)
for (std::size_t i = 0; i < parameters.size(); i++)
tuple.setItem(i, Py::Float(parameters[i]));
dict.setItem(Py::String("Probability"), Py::Float(probability));
+ dict.setItem(Py::String("Parameters"), tuple);
return dict;
}
diff --git a/src/Mod/ReverseEngineering/App/RegionGrowing.cpp b/src/Mod/ReverseEngineering/App/RegionGrowing.cpp
index a81e5c48d..bb6fd5ef8 100644
--- a/src/Mod/ReverseEngineering/App/RegionGrowing.cpp
+++ b/src/Mod/ReverseEngineering/App/RegionGrowing.cpp
@@ -26,6 +26,7 @@
#include "RegionGrowing.h"
#include
#include
+#include
#if defined(HAVE_PCL_FILTERS)
#include
@@ -55,7 +56,8 @@ void RegionGrowing::perform(int ksearch)
pcl::PointCloud::Ptr cloud (new pcl::PointCloud);
cloud->reserve(myPoints.size());
for (Points::PointKernel::const_iterator it = myPoints.begin(); it != myPoints.end(); ++it) {
- cloud->push_back(pcl::PointXYZ(it->x, it->y, it->z));
+ if (!boost::math::isnan(it->x) && !boost::math::isnan(it->y) && !boost::math::isnan(it->z))
+ cloud->push_back(pcl::PointXYZ(it->x, it->y, it->z));
}
//normal estimation
@@ -102,19 +104,23 @@ void RegionGrowing::perform(const std::vector& myNormals)
pcl::PointCloud::Ptr cloud (new pcl::PointCloud);
cloud->reserve(myPoints.size());
- for (Points::PointKernel::const_iterator it = myPoints.begin(); it != myPoints.end(); ++it) {
- cloud->push_back(pcl::PointXYZ(it->x, it->y, it->z));
+ pcl::PointCloud ::Ptr normals (new pcl::PointCloud );
+ normals->reserve(myNormals.size());
+
+ std::size_t num_points = myPoints.size();
+ const std::vector& points = myPoints.getBasicPoints();
+ for (std::size_t index=0; indexpush_back(pcl::PointXYZ(p.x, p.y, p.z));
+ normals->push_back(pcl::Normal(n.x, n.y, n.z));
+ }
}
pcl::search::Search::Ptr tree = boost::shared_ptr > (new pcl::search::KdTree);
tree->setInputCloud (cloud);
- pcl::PointCloud ::Ptr normals (new pcl::PointCloud );
- normals->reserve(myNormals.size());
- for (std::vector::const_iterator it = myNormals.begin(); it != myNormals.end(); ++it) {
- normals->push_back(pcl::Normal(it->x, it->y, it->z));
- }
-
// pass through
pcl::IndicesPtr indices (new std::vector );
pcl::PassThrough pass;
diff --git a/src/Mod/ReverseEngineering/App/SampleConsensus.cpp b/src/Mod/ReverseEngineering/App/SampleConsensus.cpp
index 2e398bf90..cb0d654a6 100644
--- a/src/Mod/ReverseEngineering/App/SampleConsensus.cpp
+++ b/src/Mod/ReverseEngineering/App/SampleConsensus.cpp
@@ -26,6 +26,7 @@
#include "SampleConsensus.h"
#include
#include
+#include
#if defined(HAVE_PCL_SAMPLE_CONSENSUS)
#include
@@ -48,7 +49,8 @@ double SampleConsensus::perform(std::vector& parameters)
pcl::PointCloud::Ptr cloud (new pcl::PointCloud);
cloud->reserve(myPoints.size());
for (Points::PointKernel::const_iterator it = myPoints.begin(); it != myPoints.end(); ++it) {
- cloud->push_back(pcl::PointXYZ(it->x, it->y, it->z));
+ if (!boost::math::isnan(it->x) && !boost::math::isnan(it->y) && !boost::math::isnan(it->z))
+ cloud->push_back(pcl::PointXYZ(it->x, it->y, it->z));
}
cloud->width = int (cloud->points.size ());