return info.substr(p1+1,p2-p1-1);
}
+/*!
+ * Returns a new DataArray by concatenating all given arrays, so that (1) the number
+ * of tuples in the result array is a sum of the number of tuples of given arrays and (2)
+ * the number of component in the result array is same as that of each of given arrays.
+ * Info on components is copied from the first of the given arrays. Number of components
+ * in the given arrays must be the same.
+ * \param [in] arrs - a sequence of arrays to include in the result array. All arrays must have the same type.
+ * \return DataArray * - the new instance of DataArray (that can be either DataArrayInt, DataArrayDouble, DataArrayChar).
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If all arrays within \a arrs are NULL.
+ * \throw If all not null arrays in \a arrs have not the same type.
+ * \throw If getNumberOfComponents() of arrays within \a arrs.
+ */
+DataArray *DataArray::Aggregate(const std::vector<const DataArray *>& arrs) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<const DataArray *> arr2;
+ for(std::vector<const DataArray *>::const_iterator it=arrs.begin();it!=arrs.end();it++)
+ if(*it)
+ arr2.push_back(*it);
+ if(arr2.empty())
+ throw INTERP_KERNEL::Exception("DataArray::Aggregate : only null instance in input vector !");
+ std::vector<const DataArrayDouble *> arrd;
+ std::vector<const DataArrayInt *> arri;
+ std::vector<const DataArrayChar *> arrc;
+ for(std::vector<const DataArray *>::const_iterator it=arr2.begin();it!=arr2.end();it++)
+ {
+ const DataArrayDouble *a=dynamic_cast<const DataArrayDouble *>(*it);
+ if(a)
+ { arrd.push_back(a); continue; }
+ const DataArrayInt *b=dynamic_cast<const DataArrayInt *>(*it);
+ if(b)
+ { arri.push_back(b); continue; }
+ const DataArrayChar *c=dynamic_cast<const DataArrayChar *>(*it);
+ if(c)
+ { arrc.push_back(c); continue; }
+ throw INTERP_KERNEL::Exception("DataArray::Aggregate : presence of not null instance in inuput that is not in [DataArrayDouble, DataArrayInt, DataArrayChar] !");
+ }
+ if(arr2.size()==arrd.size())
+ return DataArrayDouble::Aggregate(arrd);
+ if(arr2.size()==arri.size())
+ return DataArrayInt::Aggregate(arri);
+ if(arr2.size()==arrc.size())
+ return DataArrayChar::Aggregate(arrc);
+ throw INTERP_KERNEL::Exception("DataArray::Aggregate : all input arrays must have the same type !");
+}
+
/*!
* Sets information on a component specified by an index.
* To know more on format of this information
MEDCOUPLING_EXPORT virtual DataArray *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const = 0;
MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception) = 0;
MEDCOUPLING_EXPORT virtual DataArray *selectByTupleId2(int bg, int end2, int step) const throw(INTERP_KERNEL::Exception) = 0;
+ MEDCOUPLING_EXPORT virtual void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception) = 0;
MEDCOUPLING_EXPORT void checkNbOfTuples(int nbOfTuples, const char *msg) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void checkNbOfComps(int nbOfCompo, const char *msg) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(const DataArray& other, const char *msg) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static std::string GetVarNameFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static std::string GetUnitFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArray *Aggregate(const std::vector<const DataArray *>& arrs) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT virtual void reprStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception) = 0;
MEDCOUPLING_EXPORT virtual void reprZipStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception) = 0;
MEDCOUPLING_EXPORT virtual void reprWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
%newobject ParaMEDMEM::DataArray::selectByTupleId;
%newobject ParaMEDMEM::DataArray::selectByTupleIdSafe;
%newobject ParaMEDMEM::DataArray::selectByTupleId2;
+%newobject ParaMEDMEM::DataArray::Aggregate;
%newobject ParaMEDMEM::DataArrayInt::New;
%newobject ParaMEDMEM::DataArrayInt::__iter__;
%newobject ParaMEDMEM::DataArrayInt::convertToDblArr;
virtual std::size_t getNbOfElemAllocated() const throw(INTERP_KERNEL::Exception);
virtual DataArray *deepCpy() const throw(INTERP_KERNEL::Exception);
virtual DataArray *selectByTupleId2(int bg, int end2, int step) const throw(INTERP_KERNEL::Exception);
+ virtual void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
void checkNbOfTuples(int nbOfTuples, const char *msg) const throw(INTERP_KERNEL::Exception);
void checkNbOfComps(int nbOfCompo, const char *msg) const throw(INTERP_KERNEL::Exception);
void checkNbOfTuplesAndComp(const DataArray& other, const char *msg) const throw(INTERP_KERNEL::Exception);
throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice contains some unknowns that can't be determined in static method !");
return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
}
+
+ static DataArray *Aggregate(PyObject *arrs) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArray *> tmp;
+ convertFromPyObjVectorOfObj<const ParaMEDMEM::DataArray *>(arrs,SWIGTYPE_p_ParaMEDMEM__DataArray,"DataArray",tmp);
+ return DataArray::Aggregate(tmp);
+ }
int getNumberOfItemGivenBES(PyObject *slic) const throw(INTERP_KERNEL::Exception)
{
DataArrayDouble *fromNoInterlace() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *toNoInterlace() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
- void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
void transpose() throw(INTERP_KERNEL::Exception);
DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception);
void meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
bool isIdentity() const throw(INTERP_KERNEL::Exception);
bool isUniform(int val) const throw(INTERP_KERNEL::Exception);
DataArrayInt *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
- void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
void transpose() throw(INTERP_KERNEL::Exception);
DataArrayInt *changeNbOfComponents(int newNbOfComp, int dftValue) const throw(INTERP_KERNEL::Exception);
void meldWith(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
DataArrayChar *renumberR(const int *new2Old) const throw(INTERP_KERNEL::Exception);
DataArrayChar *renumberAndReduce(const int *old2NewBg, int newNbOfTuple) const throw(INTERP_KERNEL::Exception);
bool isUniform(char val) const throw(INTERP_KERNEL::Exception);
- void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
DataArrayChar *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
DataArrayChar *changeNbOfComponents(int newNbOfComp, char dftValue) const throw(INTERP_KERNEL::Exception);
void meldWith(const DataArrayChar *other) throw(INTERP_KERNEL::Exception);
}
throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 6 !");
}
+ return DataArray::Aggregate(arr);
}
}