From: Anthony Geay Date: Tue, 5 Jan 2016 08:07:44 +0000 (+0100) Subject: Encourage users at most to use cartesian. X-Git-Tag: V7_8_0a1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7b6eff8e6bab094a69379d7b70b5d1ef1b3fd36a;p=tools%2Fmedcoupling.git Encourage users at most to use cartesian. --- diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 692da3e72..0e1b5a321 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -3207,6 +3207,7 @@ const DataArrayInt *MEDFileUMesh::getRevNumberFieldAtLevel(int meshDimRelToMaxEx */ DataArrayDouble *MEDFileUMesh::getCoords() const { + checkCartesian(); MEDCouplingAutoRefCountObjectPtr tmp(_coords); if((DataArrayDouble *)tmp) { @@ -3231,6 +3232,7 @@ DataArrayDouble *MEDFileUMesh::getCoords() const */ MEDCouplingUMesh *MEDFileUMesh::getGroup(int meshDimRelToMaxExt, const std::string& grp, bool renum) const { + checkCartesian(); synchronizeTinyInfoOnLeaves(); std::vector tmp(1); tmp[0]=grp; @@ -3253,6 +3255,7 @@ MEDCouplingUMesh *MEDFileUMesh::getGroup(int meshDimRelToMaxExt, const std::stri */ MEDCouplingUMesh *MEDFileUMesh::getGroups(int meshDimRelToMaxExt, const std::vector& grps, bool renum) const { + checkCartesian(); synchronizeTinyInfoOnLeaves(); std::vector fams2=getFamiliesOnGroups(grps); MEDCouplingAutoRefCountObjectPtr zeRet=getFamilies(meshDimRelToMaxExt,fams2,renum); @@ -3277,6 +3280,7 @@ MEDCouplingUMesh *MEDFileUMesh::getGroups(int meshDimRelToMaxExt, const std::vec */ MEDCouplingUMesh *MEDFileUMesh::getFamily(int meshDimRelToMaxExt, const std::string& fam, bool renum) const { + checkCartesian(); synchronizeTinyInfoOnLeaves(); std::vector tmp(1); tmp[0]=fam; @@ -3299,6 +3303,7 @@ MEDCouplingUMesh *MEDFileUMesh::getFamily(int meshDimRelToMaxExt, const std::str */ MEDCouplingUMesh *MEDFileUMesh::getFamilies(int meshDimRelToMaxExt, const std::vector& fams, bool renum) const { + checkCartesian(); synchronizeTinyInfoOnLeaves(); if(meshDimRelToMaxExt==1) { @@ -3374,6 +3379,7 @@ DataArrayInt *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::ve */ MEDCouplingUMesh *MEDFileUMesh::getMeshAtLevel(int meshDimRelToMaxExt, bool renum) const { + checkCartesian(); synchronizeTinyInfoOnLeaves(); if(meshDimRelToMaxExt==1) { @@ -3473,6 +3479,7 @@ void MEDFileUMesh::forceComputationOfParts() const */ std::vector MEDFileUMesh::getDirectUndergroundSingleGeoTypeMeshes(int meshDimRelToMax) const { + checkCartesian(); const MEDFileUMeshSplitL1 *sp(getMeshAtLevSafe(meshDimRelToMax)); return sp->getDirectUndergroundSingleGeoTypeMeshes(); } @@ -3484,7 +3491,8 @@ std::vector MEDFileUMesh::getDirectUndergroundSingleGeoTy */ MEDCoupling1GTUMesh *MEDFileUMesh::getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const { - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(gt); + checkCartesian(); + const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(gt)); int lev=(int)cm.getDimension()-getMeshDimension(); const MEDFileUMeshSplitL1 *sp(getMeshAtLevSafe(lev)); return sp->getDirectUndergroundSingleGeoTypeMesh(gt); @@ -3955,6 +3963,7 @@ DataArrayInt *MEDFileUMesh::zipCoords() */ MEDFileUMesh *MEDFileUMesh::buildExtrudedMesh(const MEDCouplingUMesh *m1D, int policy) const { + checkCartesian(); if(getMeshDimension()!=2) throw INTERP_KERNEL::Exception("MEDFileUMesh::buildExtrudedMesh : this is expected to be with mesh dimension equal to 2 !"); MEDCouplingAutoRefCountObjectPtr ret(MEDFileUMesh::New()); @@ -4099,6 +4108,7 @@ MEDFileUMesh *MEDFileUMesh::buildExtrudedMesh(const MEDCouplingUMesh *m1D, int p */ MEDFileUMesh *MEDFileUMesh::linearToQuadratic(int conversionType, double eps) const { + checkCartesian(); MEDCouplingAutoRefCountObjectPtr ret(MEDFileUMesh::New()); int initialNbNodes(getNumberOfNodes()); MEDCouplingAutoRefCountObjectPtr m0Tmp(getMeshAtLevel(0)); @@ -4175,6 +4185,7 @@ MEDFileUMesh *MEDFileUMesh::linearToQuadratic(int conversionType, double eps) co */ MEDFileUMesh *MEDFileUMesh::quadraticToLinear(double eps) const { + checkCartesian(); MEDCouplingAutoRefCountObjectPtr ret(MEDFileUMesh::New()); MEDCouplingAutoRefCountObjectPtr m0Tmp(getMeshAtLevel(0)); MEDCouplingAutoRefCountObjectPtr m0(dynamic_cast(m0Tmp->deepCpy())); @@ -5596,6 +5607,7 @@ void MEDFileStructuredMesh::deepCpyAttributes() */ MEDCouplingMesh *MEDFileStructuredMesh::getMeshAtLevel(int meshDimRelToMax, bool renum) const { + checkCartesian(); if(renum) throw INTERP_KERNEL::Exception("MEDFileCurveLinearMesh does not support renumbering ! To do it perform request of renum array directly !"); const MEDCouplingStructuredMesh *m(getStructuredMesh()); @@ -5726,6 +5738,7 @@ void MEDFileStructuredMesh::releaseImplicitPartIfAny() const */ MEDCoupling1SGTUMesh *MEDFileStructuredMesh::getImplicitFaceMesh() const { + checkCartesian(); return _faces_if_necessary; } diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index f717cbda1..13b3e4318 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -4751,7 +4751,7 @@ class MEDLoaderTest(unittest.TestCase): """ This test is advanced to be sure that no unnecessary copies had been made during cartesianization process. """ # UMesh non cart arr=DataArrayDouble(4) ; arr.iota() ; m=MEDCouplingCMesh() ; m.setCoords(arr,arr) ; m=m.buildUnstructured() - mm=MEDFileUMesh() ; mm[0]=m ; mm.forceComputationOfParts() ; mm.setAxType(AX_CYL) #<- important + mm=MEDFileUMesh() ; mm[0]=m ; mm.forceComputationOfParts() d0=DataArrayInt(16) ; d0[:]=0 d1=DataArrayInt(9) ; d1[:]=0 mm.setFamilyFieldArr(0,d1) ; mm.setFamilyFieldArr(1,d0) @@ -4762,8 +4762,10 @@ class MEDLoaderTest(unittest.TestCase): ref2=mm[0].getNodalConnectivityIndex().getHiddenCppPointer() ref3=mm.getDirectUndergroundSingleGeoTypeMesh(NORM_QUAD4).getNodalConnectivity().getHiddenCppPointer() self.assertEqual(ref0,mm.getDirectUndergroundSingleGeoTypeMesh(NORM_QUAD4).getCoords().getHiddenCppPointer()) + mm.setAxType(AX_CYL) #<- important mm2=mm.cartesianize() # the trigger self.assertEqual(mm2.getAxType(),AX_CART) + mm.setAxType(AX_CART) # this is here only to avoid complaints self.assertTrue(isinstance(mm2,MEDFileUMesh)) self.assertTrue(mm.getHiddenCppPointer()!=mm2.getHiddenCppPointer()) self.assertTrue(ref0==mm.getCoords().getHiddenCppPointer()) # <- here important