From: ageay Date: Fri, 8 Apr 2011 14:29:43 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: V6_main_FINAL~1031 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b73da6a8fea40b221677c85fd6b6f08638fc508f;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 1c5f05bb9..855dc3843 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -273,6 +273,30 @@ DataArrayDouble *DataArrayDouble::performCpy(bool dCpy) const } } +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& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) @@ -3350,7 +3350,7 @@ DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector< 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 types; int nb=0; for(std::size_t i=0;igetMeshDimension()==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 tmp0=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr tmp1=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr ret1=buildDescendingConnectivity(desc,descIndx,tmp0,tmp1); + MEDCouplingAutoRefCountObjectPtr ret0=ret1->getRenumArrForConsecutiveCellTypesSpec(MEDMEM_ORDER,MEDMEM_ORDER+N); + desc->transformWithIndArr(ret0->getConstPointer(),ret0->getConstPointer()+ret0->getNbOfElems()); + MEDCouplingAutoRefCountObjectPtr 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. diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index cb4c35d45..7a159d4fc 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -139,6 +139,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception); //utilities for MED File RW MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& 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; diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index de622e96f..bfdbadbd5 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -1055,6 +1055,26 @@ namespace ParaMEDMEM d3->incrRef(); return ret; } + + PyObject *emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh) + { + MEDCouplingAutoRefCountObjectPtr d0=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr 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) { @@ -2333,6 +2353,23 @@ namespace ParaMEDMEM 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 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;