X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling_Swig%2FMEDCouplingMemArray.i;h=397712f5d8666b668385c02c562585be7fbccc94;hb=b7e277ad50223814bc479c5bd64cf12abe8fc959;hp=dfb31875e981be48fd67413c64f051f01422e6d2;hpb=d4ae1f4845fe7404fb71fba82b2fc9a7f267b215;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index dfb31875e..397712f5d 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -51,6 +51,7 @@ %newobject MEDCoupling::DataArray::Aggregate; %newobject MEDCoupling::DataArrayInt::New; %newobject MEDCoupling::DataArrayInt::__iter__; +%newobject MEDCoupling::DataArrayInt::selectPartDef; %newobject MEDCoupling::DataArrayInt::convertToDblArr; %newobject MEDCoupling::DataArrayInt::performCopyOrIncrRef; %newobject MEDCoupling::DataArrayInt::subArray; @@ -141,6 +142,7 @@ %newobject MEDCoupling::DataArrayAsciiCharTuple::buildDAAsciiChar; %newobject MEDCoupling::DataArrayDouble::New; %newobject MEDCoupling::DataArrayDouble::__iter__; +%newobject MEDCoupling::DataArrayDouble::selectPartDef; %newobject MEDCoupling::DataArrayDouble::convertToIntArr; %newobject MEDCoupling::DataArrayDouble::performCopyOrIncrRef; %newobject MEDCoupling::DataArrayDouble::Aggregate; @@ -202,6 +204,15 @@ %newobject MEDCoupling::DataArrayDouble::__rpow__; %newobject MEDCoupling::DataArrayDoubleTuple::buildDADouble; +%newobject MEDCoupling::PartDefinition::New; +%newobject MEDCoupling::PartDefinition::toDAI; +%newobject MEDCoupling::PartDefinition::__add__; +%newobject MEDCoupling::PartDefinition::composeWith; +%newobject MEDCoupling::PartDefinition::tryToSimplify; +%newobject MEDCoupling::DataArrayPartDefinition::New; +%newobject MEDCoupling::SlicePartDefinition::New; + + %feature("unref") DataArray "$this->decrRef();" %feature("unref") DataArrayDouble "$this->decrRef();" %feature("unref") DataArrayInt "$this->decrRef();" @@ -209,6 +220,10 @@ %feature("unref") DataArrayAsciiChar "$this->decrRef();" %feature("unref") DataArrayByte "$this->decrRef();" +%feature("unref") PartDefinition "$this->decrRef();" +%feature("unref") DataArrayPartDefinition "$this->decrRef();" +%feature("unref") SlicePartDefinition "$this->decrRef();" + namespace MEDCoupling { typedef enum @@ -218,6 +233,109 @@ namespace MEDCoupling AX_SPHER = 5 } MEDCouplingAxisType; + class DataArrayInt; + + class PartDefinition : public RefCountObject, public TimeLabel + { + public: + static PartDefinition *New(int start, int stop, int step) throw(INTERP_KERNEL::Exception); + static PartDefinition *New(DataArrayInt *listOfIds) throw(INTERP_KERNEL::Exception); + virtual DataArrayInt *toDAI() const throw(INTERP_KERNEL::Exception); + virtual int getNumberOfElems() const throw(INTERP_KERNEL::Exception); + virtual std::string getRepr() const throw(INTERP_KERNEL::Exception); + virtual PartDefinition *composeWith(const PartDefinition *other) const throw(INTERP_KERNEL::Exception); + virtual void checkConsistencyLight() const throw(INTERP_KERNEL::Exception); + virtual PartDefinition *tryToSimplify() const throw(INTERP_KERNEL::Exception); + %extend + { + virtual PartDefinition *__add__(const PartDefinition& other) const throw(INTERP_KERNEL::Exception) + { + return (*self)+other; + } + + virtual PyObject *isEqual(const PartDefinition *other) const throw(INTERP_KERNEL::Exception) + { + std::string ret1; + bool ret0(self->isEqual(other,ret1)); + PyObject *ret=PyTuple_New(2); + PyObject *ret0Py=ret0?Py_True:Py_False; + Py_XINCREF(ret0Py); + PyTuple_SetItem(ret,0,ret0Py); + PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str())); + return ret; + } + + virtual PyObject *deepCopy() const throw(INTERP_KERNEL::Exception) + { + return convertPartDefinition(self->deepCopy(),SWIG_POINTER_OWN | 0); + } + } + protected: + virtual ~PartDefinition(); + }; + + class DataArrayPartDefinition : public PartDefinition + { + public: + static DataArrayPartDefinition *New(DataArrayInt *listOfIds) throw(INTERP_KERNEL::Exception); + %extend + { + DataArrayPartDefinition(DataArrayInt *listOfIds) throw(INTERP_KERNEL::Exception) + { + return DataArrayPartDefinition::New(listOfIds); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->getRepr(); + } + + std::string __repr__() const throw(INTERP_KERNEL::Exception) + { + std::ostringstream oss; oss << "DataArrayPartDefinition C++ instance at " << self << "." << std::endl; + oss << self->getRepr(); + return oss.str(); + } + } + protected: + virtual ~DataArrayPartDefinition(); + }; + + class SlicePartDefinition : public PartDefinition + { + public: + static SlicePartDefinition *New(int start, int stop, int step) throw(INTERP_KERNEL::Exception); + int getEffectiveStop() const throw(INTERP_KERNEL::Exception); + %extend + { + SlicePartDefinition(int start, int stop, int step) throw(INTERP_KERNEL::Exception) + { + return SlicePartDefinition::New(start,stop,step); + } + + PyObject *getSlice() const throw(INTERP_KERNEL::Exception) + { + int a,b,c; + self->getSlice(a,b,c); + return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c)); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->getRepr(); + } + + std::string __repr__() const throw(INTERP_KERNEL::Exception) + { + std::ostringstream oss; oss << "SlicePartDefinition C++ instance at " << self << "." << std::endl; + oss << self->getRepr(); + return oss.str(); + } + } + protected: + virtual ~SlicePartDefinition(); + }; + class DataArray : public RefCountObject, public TimeLabel { public: @@ -759,6 +877,12 @@ namespace MEDCoupling return MEDCoupling_DataArrayDouble_New__SWIG_1(elt0,nbOfTuples,elt2); } + DataArrayDouble *selectPartDef(const PartDefinition* pd) const throw(INTERP_KERNEL::Exception) + { + MCAuto ret(self->selectPartDef(pd)); + return ret.retn(); + } + void pushBackValsSilent(PyObject *li) throw(INTERP_KERNEL::Exception) { double val; @@ -1119,6 +1243,16 @@ namespace MEDCoupling convertPyToNewIntArr3(li,tmp); self->setSelectedComponents(a,tmp); } + + PyObject *explodeComponents() const throw(INTERP_KERNEL::Exception) + { + std::vector< MCAuto > retCpp(self->explodeComponents()); + std::size_t sz(retCpp.size()); + PyObject *res(PyList_New(sz)); + for(std::size_t i=0;iiterator(); } + + DataArrayInt *selectPartDef(const PartDefinition* pd) const throw(INTERP_KERNEL::Exception) + { + MCAuto ret(self->selectPartDef(pd)); + return ret.retn(); + } PyObject *accumulate() const throw(INTERP_KERNEL::Exception) { @@ -3244,6 +3384,16 @@ namespace MEDCoupling self->setSelectedComponents(a,tmp); } + PyObject *explodeComponents() const throw(INTERP_KERNEL::Exception) + { + std::vector< MCAuto > retCpp(self->explodeComponents()); + std::size_t sz(retCpp.size()); + PyObject *res(PyList_New(sz)); + for(std::size_t i=0;igetNumberOfComponents();