From: ageay Date: Fri, 19 Feb 2010 11:35:46 +0000 (+0000) Subject: Correction of bug concerning -1D mesh. X-Git-Tag: V5_1_main_FINAL~202 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=38a0c708336c4c30c12eba0ee95da189e1e82dc6;p=tools%2Fmedcoupling.git Correction of bug concerning -1D mesh. --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index ab3ca95c1..984704e1a 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -433,10 +433,22 @@ DataArrayInt *MEDCouplingUMesh::mergeNodes(double precision, bool& areNodesMerge MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const { - MEDCouplingUMesh *ret=buildPartOfMySelfKeepCoords(start,end); - if(!keepCoords) - ret->zipCoords(); - return ret; + if(getMeshDimension()!=-1) + { + MEDCouplingUMesh *ret=buildPartOfMySelfKeepCoords(start,end); + if(!keepCoords) + ret->zipCoords(); + return ret; + } + else + { + if(end-start!=1) + throw INTERP_KERNEL::Exception("-1D mesh has only one cell !"); + if(start[0]!=0) + throw INTERP_KERNEL::Exception("-1D mesh has only one cell : 0 !"); + incrRef(); + return (MEDCouplingUMesh *)this; + } } /*! @@ -543,6 +555,11 @@ void MEDCouplingUMesh::renumberNodes(const int *newNodeNumbers, int newNbOfNodes */ void MEDCouplingUMesh::giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems) { + if(getMeshDimension()==-1) + { + elems.push_back(0); + return; + } int dim=getSpaceDimension(); double* elem_bb=new double[2*dim]; const int* conn = getNodalConnectivity()->getConstPointer(); @@ -686,6 +703,11 @@ void MEDCouplingUMesh::getTinySerializationInformation(std::vector& tinyInf tinyInfo.push_back(-1); } +bool MEDCouplingUMesh::isEmptyMesh(const std::vector& tinyInfo) const +{ + return tinyInfo[4]<=0; +} + /*! * @param tinyInfo must be equal to the result given by getTinySerializationInformation method. */ diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 7743d2e99..e793c931c 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -52,6 +52,7 @@ namespace ParaMEDMEM int getMeshLength() const; //! size of returned tinyInfo must be always the same. void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; + bool isEmptyMesh(const std::vector& tinyInfo) const; void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings); void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; void unserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx index 35e6ad11c..1dba15e9a 100644 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx +++ b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx @@ -119,6 +119,11 @@ void MEDCouplingUMeshDesc::getTinySerializationInformation(std::vector& tin tinyInfo.push_back(getFaceMeshLength()); } +bool MEDCouplingUMeshDesc::isEmptyMesh(const std::vector& tinyInfo) const +{ + return tinyInfo[5]<=0; +} + void MEDCouplingUMeshDesc::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) { std::vector tinyInfoTmp(tinyInfo.begin()+1,tinyInfo.end()); diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx b/src/MEDCoupling/MEDCouplingUMeshDesc.hxx index 14589cdef..b6ef8aa0c 100644 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx +++ b/src/MEDCoupling/MEDCouplingUMeshDesc.hxx @@ -43,6 +43,7 @@ namespace ParaMEDMEM void setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx); //tools to overload void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; + bool isEmptyMesh(const std::vector& tinyInfo) const; void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings); void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; void unserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2,