From 2d4d60d2ab6cff50885dd58d1bd30bf11c0353ec Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 2 Nov 2015 17:36:45 +0100 Subject: [PATCH] + allow in approxSurface() to also pass points object --- .../App/AppReverseEngineering.cpp | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Mod/ReverseEngineering/App/AppReverseEngineering.cpp b/src/Mod/ReverseEngineering/App/AppReverseEngineering.cpp index e20d21478..a12a6da7f 100644 --- a/src/Mod/ReverseEngineering/App/AppReverseEngineering.cpp +++ b/src/Mod/ReverseEngineering/App/AppReverseEngineering.cpp @@ -120,19 +120,33 @@ private: } try { - Py::Sequence l(o); - TColgp_Array1OfPnt clPoints(0, l.size()-1); + std::vector pts; + if (PyObject_TypeCheck(o, &(Points::PointsPy::Type))) { + Points::PointsPy* pPoints = static_cast(o); + Points::PointKernel* points = pPoints->getPointKernelPtr(); + pts = points->getBasicPoints(); + } + else { + Py::Sequence l(o); + pts.reserve(l.size()); + for (Py::Sequence::iterator it = l.begin(); it != l.end(); ++it) { + Py::Tuple t(*it); + pts.push_back(Base::Vector3f( + (float)Py::Float(t.getItem(0)), + (float)Py::Float(t.getItem(1)), + (float)Py::Float(t.getItem(2))) + ); + } + } + + TColgp_Array1OfPnt clPoints(0, pts.size()-1); if (clPoints.Length() < uPoles * vPoles) { throw Py::ValueError("Too less data points for the specified number of poles"); } int index=0; - for (Py::Sequence::iterator it = l.begin(); it != l.end(); ++it) { - Py::Tuple t(*it); - clPoints(index++) = gp_Pnt( - (double)Py::Float(t.getItem(0)), - (double)Py::Float(t.getItem(1)), - (double)Py::Float(t.getItem(2))); + for (std::vector::iterator it = pts.begin(); it != pts.end(); ++it) { + clPoints(index++) = gp_Pnt(it->x, it->y, it->z); } Reen::BSplineParameterCorrection pc(uOrder,vOrder,uPoles,vPoles);