}
}
+void DataArrayDouble::cpyFrom(const DataArrayDouble& other) throw(INTERP_KERNEL::Exception)
+{
+ other.checkAllocated();
+ int nbOfTuples=other.getNumberOfTuples();
+ int nbOfComp=other.getNumberOfComponents();
+ allocIfNecessary(nbOfTuples,nbOfComp);
+ int nbOfElems=nbOfTuples*nbOfComp;
+ double *pt=getPointer();
+ const double *ptI=other.getConstPointer();
+ for(int i=0;i<nbOfElems;i++)
+ pt[i]=ptI[i];
+}
+
+void DataArrayDouble::allocIfNecessary(int nbOfTuple, int nbOfCompo)
+{
+ if(isAllocated())
+ {
+ if(nbOfTuple!=getNumberOfTuples() || nbOfCompo!=getNumberOfComponents())
+ alloc(nbOfTuple,nbOfCompo);
+ }
+ else
+ alloc(nbOfTuple,nbOfCompo);
+}
+
void DataArrayDouble::alloc(int nbOfTuple, int nbOfCompo)
{
_nb_of_tuples=nbOfTuple;
int nbOfTuples=getNumberOfTuples();
for(const int *z=bgComp;z!=endComp;z++)
DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
-// int newNbOfTuples=std::distance(bgTuples,endTuples);
-// int newNbOfComp=std::distance(bgComp,endComp);
double *pt=getPointer();
for(const int *w=bgTuples;w!=endTuples;w++)
for(const int *z=bgComp;z!=endComp;z++)
int nbOfTuples=getNumberOfTuples();
DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value");
DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value");
-// int newNbOfTuples=std::distance(bgTuples,endTuples);
double *pt=getPointer()+bgComp;
for(const int *w=bgTuples;w!=endTuples;w++)
for(int j=0;j<newNbOfComp;j++)
}
}
+void DataArrayInt::cpyFrom(const DataArrayInt& other) throw(INTERP_KERNEL::Exception)
+{
+ other.checkAllocated();
+ int nbOfTuples=other.getNumberOfTuples();
+ int nbOfComp=other.getNumberOfComponents();
+ allocIfNecessary(nbOfTuples,nbOfComp);
+ int nbOfElems=nbOfTuples*nbOfComp;
+ int *pt=getPointer();
+ const int *ptI=other.getConstPointer();
+ for(int i=0;i<nbOfElems;i++)
+ pt[i]=ptI[i];
+}
+
+void DataArrayInt::allocIfNecessary(int nbOfTuple, int nbOfCompo)
+{
+ if(isAllocated())
+ {
+ if(nbOfTuple!=getNumberOfTuples() || nbOfCompo!=getNumberOfComponents())
+ alloc(nbOfTuple,nbOfCompo);
+ }
+ else
+ alloc(nbOfTuple,nbOfCompo);
+}
+
void DataArrayInt::alloc(int nbOfTuple, int nbOfCompo)
{
_nb_of_tuples=nbOfTuple;
_mem.reprZip(getNumberOfComponents(),stream);
}
-void DataArrayInt::transformWithIndArr(const int *indArr)
+void DataArrayInt::transformWithIndArr(const int *indArrBg, const int *indArrEnd) throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("Call transformWithIndArr method on DataArrayInt with only one component, you can call 'rearrange' method before !");
+ int nbElemsIn=std::distance(indArrBg,indArrEnd);
int nbOfTuples=getNumberOfTuples();
int *pt=getPointer();
- for(int i=0;i<nbOfTuples;i++)
- pt[i]=indArr[pt[i]];
+ for(int i=0;i<nbOfTuples;i++,pt++)
+ {
+ if(*pt<nbElemsIn)
+ *pt=indArrBg[*pt];
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::transformWithIndArr : error on tuple #" << i << " value is " << *pt << " and indirectionnal array as a size equal to " << nbElemsIn;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
}
/*!
int nbOfTuples=getNumberOfTuples();
for(const int *z=bgComp;z!=endComp;z++)
DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
-// int newNbOfTuples=std::distance(bgTuples,endTuples);
-// int newNbOfComp=std::distance(bgComp,endComp);
int *pt=getPointer();
for(const int *w=bgTuples;w!=endTuples;w++)
for(const int *z=bgComp;z!=endComp;z++)
int nbOfTuples=getNumberOfTuples();
DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value");
DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value");
-// int newNbOfTuples=std::distance(bgTuples,endTuples);
int *pt=getPointer()+bgComp;
for(const int *w=bgTuples;w!=endTuples;w++)
for(int j=0;j<newNbOfComp;j++)
MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *deepCpy() const;
MEDCOUPLING_EXPORT DataArrayDouble *performCpy(bool deepCpy) const;
+ MEDCOUPLING_EXPORT void cpyFrom(const DataArrayDouble& other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo);
+ MEDCOUPLING_EXPORT void allocIfNecessary(int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT void fillWithZero() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void fillWithValue(double val) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void iota(double init=0.) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *deepCpy() const;
MEDCOUPLING_EXPORT DataArrayInt *performCpy(bool deepCpy) const;
+ MEDCOUPLING_EXPORT void cpyFrom(const DataArrayInt& other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo);
+ MEDCOUPLING_EXPORT void allocIfNecessary(int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT bool isEqual(const DataArrayInt& other) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayInt& other) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArr);
+ MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const;
MEDCOUPLING_EXPORT DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const;
//!alloc or useArray should have been called before.
* an exception is thrown too.
*
* If all geometric types in 'code' are exactly those in 'this' null pointer is returned.
- * If it exists a geometric type in 'this' \b not in 'code' \b no exception is thrown and a DataArrayInt instance is returned that the user as the responsability
+ * If it exists a geometric type in 'this' \b not in 'code' \b no exception is thrown and a DataArrayInt instance is returned that the user has the responsability
* to deallocate.
*/
DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
int sz=code.size();
std::size_t n=sz/3;
if(sz%3!=0)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code size is NOT even !");
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code size is NOT %3 !");
std::vector<INTERP_KERNEL::NormalizedCellType> types;
int nb=0;
for(std::size_t i=0;i<n;i++)
return ret;
}
+/*!
+ * This method is here too emulate the MEDMEM behaviour on BDC (buildDescendingConnectivity). Hoping this method becomes deprecated very soon.
+ * This method make the assumption that 'this' and 'nM1LevMesh' mesh lyies on same coords (same pointer) as MED and MEDMEM does.
+ * The following equality should be verified 'nM1LevMesh->getMeshDimension()==this->getMeshDimension()-1'
+ * This method returns 5+1 elements. 'desc', 'descIndx', 'revDesc', 'revDescIndx' and 'meshnM1' behaves exactly as ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity except the content as described after. The returned array specifies the numbering old2new that is to say the cell #k in 'nM1LevMesh' will have the number ret[k] in returned mesh 'nM1LevMesh'.
+ */
+DataArrayInt *MEDCouplingUMesh::emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh, DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *&revDesc, DataArrayInt *&revDescIndx, MEDCouplingUMesh *& meshnM1) const throw(INTERP_KERNEL::Exception)
+{
+ static const int N=18;
+ static const INTERP_KERNEL::NormalizedCellType MEDMEM_ORDER[N] = { INTERP_KERNEL::NORM_POINT1, INTERP_KERNEL::NORM_SEG2, INTERP_KERNEL::NORM_SEG3, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6, INTERP_KERNEL::NORM_QUAD8, INTERP_KERNEL::NORM_TETRA4, INTERP_KERNEL::NORM_PYRA5, INTERP_KERNEL::NORM_PENTA6, INTERP_KERNEL::NORM_HEXA8, INTERP_KERNEL::NORM_HEXGP12, INTERP_KERNEL::NORM_TETRA10, INTERP_KERNEL::NORM_PYRA13, INTERP_KERNEL::NORM_PENTA15, INTERP_KERNEL::NORM_HEXA20, INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_POLYHED };
+ checkFullyDefined();
+ nM1LevMesh->checkFullyDefined();
+ if(getMeshDimension()-1!=nM1LevMesh->getMeshDimension())
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::emulateMEDMEMBDC : The mesh passed as first argument should have a meshDim equal to this->getMeshDimension()-1 !" );
+ if(_coords!=nM1LevMesh->getCoords())
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::emulateMEDMEMBDC : 'this' and mesh in first argument should share the same coords : Use tryToShareSameCoords method !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp1=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret1=buildDescendingConnectivity(desc,descIndx,tmp0,tmp1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret0=ret1->getRenumArrForConsecutiveCellTypesSpec(MEDMEM_ORDER,MEDMEM_ORDER+N);
+ desc->transformWithIndArr(ret0->getConstPointer(),ret0->getConstPointer()+ret0->getNbOfElems());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp=MEDCouplingUMesh::New();
+ tmp->setConnectivity(tmp0,tmp1);
+ tmp->renumberCells(ret0->getConstPointer(),false);
+ revDesc=tmp->getNodalConnectivity();
+ revDescIndx=tmp->getNodalConnectivityIndex();
+ DataArrayInt *ret=0;
+ if(!ret1->areCellsIncludedIn(nM1LevMesh,2,ret))
+ {
+ int tmp;
+ ret->getMaxValue(tmp);
+ ret->decrRef();
+ std::ostringstream oss; oss << "MEDCouplingUMesh::emulateMEDMEMBDC : input N-1 mesh present a cell not in descending mesh ... Id of cell is " << tmp << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ //
+ revDesc->incrRef();
+ revDescIndx->incrRef();
+ meshnM1=ret1;
+ ret1->incrRef();
+ ret0->incrRef();
+ return ret0;
+}
+
/*!
* This methods checks that cells are sorted by their types.
* This method makes asumption (no check) that connectivity is correctly set before calling.
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception);
//utilities for MED File RW
MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh, DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *&revDesc, DataArrayInt *&revDescIndx, MEDCouplingUMesh *& meshnM1) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool checkConsecutiveCellTypes() const;
MEDCOUPLING_EXPORT bool checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const;
MEDCOUPLING_EXPORT DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const;
d3->incrRef();
return ret;
}
+
+ PyObject *emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+ DataArrayInt *d2;
+ DataArrayInt *d3;
+ MEDCouplingUMesh *mOut;
+ DataArrayInt *d4=self->emulateMEDMEMBDC(nM1LevMesh,d0,d1,d2,d3,mOut);
+ PyObject *ret=PyTuple_New(6);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(mOut),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d4),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(d2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,5,SWIG_NewPointerObj(SWIG_as_voidptr(d3),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ d0->incrRef();
+ d1->incrRef();
+ return ret;
+ }
PyObject *getReverseNodalConnectivity() const throw(INTERP_KERNEL::Exception)
{
return ret;
}
+ void transformWithIndArr(PyObject *li)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->transformWithIndArr(tmp,tmp+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
+ }
+
void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
{
void *da=0;