From 297c7db3d4899b2f6bd66ac834de34575ff3f717 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 3 Apr 2018 16:46:51 +0200 Subject: [PATCH] Add SetOfPoints in the python API --- src/engine_swig/engtypemaps.i | 38 +++++++++++++++++++++++++++++++++++ src/engine_swig/pilot.i | 17 ++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/src/engine_swig/engtypemaps.i b/src/engine_swig/engtypemaps.i index d31e8870f..9079f89ac 100644 --- a/src/engine_swig/engtypemaps.i +++ b/src/engine_swig/engtypemaps.i @@ -478,6 +478,28 @@ static void convertFromPyObjVectorOfObj(PyObject *pyLi, swig_type_info *ty, cons } } +%typemap(in) const std::list& +{ + if(!PyList_Check($input)) + { + PyErr_SetString(PyExc_TypeError,"not a list"); + return NULL; + } + $1=new std::list; + int size(PyList_Size($input)); + for(int i=0;ipush_back(temp); + } +} + %typemap(out) YACS::ENGINE::Node* { $result=convertNode($1,$owner); @@ -656,6 +678,22 @@ static void convertFromPyObjVectorOfObj(PyObject *pyLi, swig_type_info *ty, cons } } +%typemap(out) std::vector< std::list > +{ + std::vector< std::list >::const_iterator it; + $result = PyList_New($1.size()); + int i(0); + for (it = $1.begin(); it != $1.end(); ++it, ++i) + { + const std::list& elt(*it); + PyObject *tmp(PyList_New(elt.size())); + int j(0); + for (auto it2=elt.begin() ; it2!= elt.end() ; ++it2, ++j) + PyList_SetItem(tmp,j,convertNode(*it2)); + PyList_SetItem($result,i,tmp); + } +} + #endif /* diff --git a/src/engine_swig/pilot.i b/src/engine_swig/pilot.i index f0316e5f4..b89d32ab7 100644 --- a/src/engine_swig/pilot.i +++ b/src/engine_swig/pilot.i @@ -59,6 +59,7 @@ #include "ComponentInstance.hxx" #include "DataNode.hxx" #include "PlayGround.hxx" +#include "SetOfPoints.hxx" using namespace YACS::ENGINE; @@ -447,3 +448,19 @@ EXCEPTION(YACS::ENGINE::ExecutorSwig::waitPause) self->assignPassedResults(passedIds,passedOutputsCpp,nameOfOutputs); } } + +namespace YACS +{ + namespace ENGINE + { + class SetOfPoints + { + public: + SetOfPoints(const std::list& nodes); + ~SetOfPoints(); + void simplify(); + std::string getRepr() const; + }; + } +} + -- 2.39.2