} MEDCouplingAxisType;
// -- WARNING this enum must be synchronized with MEDCouplingCommon.i file ! --
+ class PartDefinition;
+
template<class T>
class MEDCouplingPointer
{
typename Traits<T>::ArrayType *renumberAndReduce(const int *old2New, int newNbOfTuple) const;
typename Traits<T>::ArrayType *changeNbOfComponents(int newNbOfComp, T dftValue) const;
typename Traits<T>::ArrayType *subArray(int tupleIdBg, int tupleIdEnd=-1) const;
+ MCAuto<typename Traits<T>::ArrayTypeCh> selectPartDef(const PartDefinition* pd) const;
void circularPermutation(int nbOfShift=1);
void circularPermutationPerTuple(int nbOfShift=1);
void reversePerTuple();
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<double>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<double>::myKeepSelectedComponents(compoIds); }
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate<double>::mySelectByTupleIdSafeSlice(bg,end2,step); }
- MEDCOUPLING_EXPORT DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<double>::mySelectByTupleRanges(ranges); }
+ MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<double>::mySelectByTupleRanges(ranges); }
MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other);
MEDCOUPLING_EXPORT bool areIncludedInMe(const DataArrayDouble *other, double prec, DataArrayInt *&tupleIds) const;
MEDCOUPLING_EXPORT void findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const;
MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<int>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT DataArrayInt *keepSelectedComponents(const std::vector<int>& compoIds) const { return DataArrayTemplate<int>::myKeepSelectedComponents(compoIds); }
MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafeSlice(int bg, int end, int step) const { return DataArrayTemplate<int>::mySelectByTupleIdSafeSlice(bg,end,step); }
- MEDCOUPLING_EXPORT DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<int>::mySelectByTupleRanges(ranges); }
+ MEDCOUPLING_EXPORT DataArrayInt *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const { return DataArrayTemplate<int>::mySelectByTupleRanges(ranges); }
MEDCOUPLING_EXPORT DataArrayInt *checkAndPreparePermutation() const;
MEDCOUPLING_EXPORT static DataArrayInt *FindPermutationFromFirstToSecond(const DataArrayInt *ids1, const DataArrayInt *ids2);
MEDCOUPLING_EXPORT void changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const;
#include "NormalizedUnstructuredMesh.hxx"
#include "InterpKernelException.hxx"
#include "InterpolationUtils.hxx"
+#include "MEDCouplingPartDefinition.hxx"
#include "InterpKernelAutoPtr.hxx"
#include "MCAuto.hxx"
{
return DataArrayTemplate<T>::mySelectByTupleId(di.begin(),di.end());
}
+
+ template<class T>
+ MCAuto<typename Traits<T>::ArrayTypeCh> DataArrayTemplate<T>::selectPartDef(const PartDefinition *pd) const
+ {
+ if(!pd)
+ throw INTERP_KERNEL::Exception("DataArrayTemplate<T>::selectPartDef : null input pointer !");
+ MCAuto<typename Traits<T>::ArrayTypeCh> ret(Traits<T>::ArrayTypeCh::New());
+ const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
+ if(spd)
+ {
+ int a,b,c;
+ spd->getSlice(a,b,c);
+ if(a==0 && b==getNumberOfTuples() && c==1)
+ {
+ DataArrayTemplate<T> *directRet(const_cast<DataArrayTemplate<T> *>(this));
+ directRet->incrRef();
+ MCAuto<DataArrayTemplate<T> > ret(directRet);
+ return DynamicCastSafe<DataArrayTemplate<T>,typename Traits<T>::ArrayTypeCh>(ret);
+ }
+ else
+ {
+ MCAuto<DataArray> ret(selectByTupleIdSafeSlice(a,b,c));
+ return DynamicCastSafe<DataArray,typename Traits<T>::ArrayTypeCh>(ret);
+ }
+ }
+ const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
+ if(dpd)
+ {
+ MCAuto<DataArrayInt> arr(dpd->toDAI());
+ MCAuto<DataArray> ret(selectByTupleIdSafe(arr->begin(),arr->end()));
+ return DynamicCastSafe<DataArray,typename Traits<T>::ArrayTypeCh>(ret);
+
+ }
+ throw INTERP_KERNEL::Exception("DataArrayTemplate<T>::selectPartDef : unrecognized part def !");
+ }
/*!
* Returns a shorten and permuted copy of \a this array. The new DataArrayDouble is
self.assertEqual( 0, sla0.getLength() )
sla0.set( index, value )
self.assertTrue( index.isEqual( sla0.getIndexArray() ))
- self.assertTrue( value.isEqual( sla0.getValueArray() ))
+ self.assertTrue( value.isEqual( sla0.getValuesArray() ))
self.assertEqual( 4, sla0.getNumberOf() )
self.assertEqual( 6, sla0.getLength() )
sla1 = MEDCouplingSkyLineArray( index, value )
self.assertTrue( index.isEqual( sla1.getIndexArray() ))
- self.assertTrue( value.isEqual( sla1.getValueArray() ))
+ self.assertTrue( value.isEqual( sla1.getValuesArray() ))
self.assertEqual( 4, sla1.getNumberOf() )
self.assertEqual( 6, sla1.getLength() )
sla2 = MEDCouplingSkyLineArray( sla1 )
self.assertTrue( index.isEqual( sla2.getIndexArray() ))
- self.assertTrue( value.isEqual( sla2.getValueArray() ))
+ self.assertTrue( value.isEqual( sla2.getValuesArray() ))
self.assertEqual( 4, sla2.getNumberOf() )
self.assertEqual( 6, sla2.getLength() )
for i in value: valueVec.push_back( i[0] )
sla3 = MEDCouplingSkyLineArray( indexVec, valueVec )
self.assertTrue( index.isEqual( sla3.getIndexArray() ))
- self.assertTrue( value.isEqual( sla3.getValueArray() ))
+ self.assertTrue( value.isEqual( sla3.getValuesArray() ))
self.assertEqual( 4, sla3.getNumberOf() )
self.assertEqual( 6, sla3.getLength() )
%newobject MEDCoupling::DenseMatrix::__add__;
%newobject MEDCoupling::DenseMatrix::__sub__;
%newobject MEDCoupling::DenseMatrix::__mul__;
-%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;
%newobject MEDCoupling::MEDCouplingGaussLocalization::localizePtsInRefCooForEachCell;
%newobject MEDCoupling::MEDCouplingGaussLocalization::buildRefCell;
%feature("unref") MEDCouplingDataForGodFather "$this->decrRef();"
%feature("unref") MEDCouplingAMRAttribute "$this->decrRef();"
%feature("unref") DenseMatrix "$this->decrRef();"
-%feature("unref") PartDefinition "$this->decrRef();"
-%feature("unref") DataArrayPartDefinition "$this->decrRef();"
-%feature("unref") SlicePartDefinition "$this->decrRef();"
%feature("unref") MEDCouplingSkyLineArray "$this->decrRef();"
%rename(assign) *::operator=;
#endif
}
};
-
- 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();
- };
}
%pythoncode %{
%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;
%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;
%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();"
%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
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:
return MEDCoupling_DataArrayDouble_New__SWIG_1(elt0,nbOfTuples,elt2);
}
+ DataArrayDouble *selectPartDef(const PartDefinition* pd) const throw(INTERP_KERNEL::Exception)
+ {
+ MCAuto<DataArrayDouble> ret(self->selectPartDef(pd));
+ return ret.retn();
+ }
+
void pushBackValsSilent(PyObject *li) throw(INTERP_KERNEL::Exception)
{
double val;
{
return self->iterator();
}
+
+ DataArrayInt *selectPartDef(const PartDefinition* pd) const throw(INTERP_KERNEL::Exception)
+ {
+ MCAuto<DataArrayInt> ret(self->selectPartDef(pd));
+ return ret.retn();
+ }
PyObject *accumulate() const throw(INTERP_KERNEL::Exception)
{
#include "MEDFileBlowStrEltUp.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDFileFieldVisitor.hxx"
+#include "MEDCouplingPartDefinition.hxx"
#include "MCAuto.txx"
using namespace MEDCoupling;
bool isClassic() const { return _is_classic; }
bool operator!=(const FieldWalker2& other) const;
bool operator==(const FieldWalker2& other) const;
+ const SlicePartDefinition *getPartDef() const { return _pd; }
private:
std::string _loc;
std::string _pfl;
bool _is_classic;
+ MCAuto<SlicePartDefinition> _pd;
};
class LocInfo
bool operator==(const LocInfo& other) const { return _locs==other._locs && _pfl==other._pfl; }
void push(const std::string& loc, const std::string& pfl) { checkUniqueLoc(loc); _locs.push_back(loc); _pfl.push_back(pfl); }
MCAuto<MEDFileUMesh> generateNonClassicalData(int zePos, const MEDFileUMesh *mesh, const MEDFileFieldGlobsReal *globs) const;
+ const PartDefinition *getPartDef() const { return _pd; }
private:
void checkUniqueLoc(const std::string& loc) const;
static MCAuto<DataArrayDouble> BuildMeshFromAngleVrille(INTERP_KERNEL::NormalizedCellType gt, const DataArrayDouble *angleDeVrille, const std::string& pfl, const MEDFileFieldLoc& loc, const MEDFileEltStruct4Mesh *zeStr, const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileFieldGlobsReal *globs);
private:
std::vector<std::string> _locs;
std::vector<std::string> _pfl;
+ MCAuto<PartDefinition> _pd;
};
const char LocInfo::ANGLE_DE_VRILLE[]="ANGLE DE VRILLE";
{
std::size_t sz(fw.size());
_locs.resize(sz); _pfl.resize(sz);
+ if(sz>0)
+ _pd=fw[0].getPartDef()->deepCopy();
for(std::size_t i=0;i<sz;i++)
{
_locs[i]=fw[i].getLoc();
_pfl[i]=fw[i].getPfl();
+ if(i>0)
+ _pd=(*_pd)+(*(fw[i].getPartDef()));
}
}
_loc=pmptpd->getLocalization();
_pfl=pmptpd->getProfile();
_is_classic=pmptpd->getType()!=ON_GAUSS_PT;
+ _pd=SlicePartDefinition::New(pmptpd->getStart(),pmptpd->getEnd(),1);
}
bool FieldWalker2::operator!=(const FieldWalker2& other) const
{
- bool ret(_loc==other._loc && _pfl==other._pfl && _is_classic==other._is_classic);
- return !ret;
+ return !((*this)==other);
}
bool FieldWalker2::operator==(const FieldWalker2& other) const
{
- bool ret(_loc==other._loc && _pfl==other._pfl && _is_classic==other._is_classic);
+ bool ret2(false);
+ {
+ std::string tmp;
+ ret2=_pd->isEqual(other._pd,tmp);
+ }
+ bool ret(_loc==other._loc && _pfl==other._pfl && _is_classic==other._is_classic && ret2);
return ret;
}
int t2,t3;
double t1(f1ts->getTime(t2,t3));
MCAuto<MEDCouplingFieldDouble> mcf(MEDCouplingFieldDouble::New(ON_NODES));
- mcf->setArray(f1ts->getUndergroundDataArray());
+ MCAuto<DataArrayDouble> arr,arr2;
+ arr.takeRef(f1ts->getUndergroundDataArray());
+ arr2=arr->selectPartDef((*it).getPartDef());
+ mcf->setArray(arr2);
mcf->setTime(t1,t2,t3);
mcf->setName(f1ts->getName());
mcf->setMesh(mcm);