From 4c31ad9d2f02011d17b055f24b8bfc65dde4c2df Mon Sep 17 00:00:00 2001 From: ageay Date: Tue, 24 Apr 2012 14:04:40 +0000 Subject: [PATCH] MEDCouplingUMesh::shiftNodeNumbersInConn --- src/MEDCoupling/MEDCouplingUMesh.cxx | 34 +++++++++++++++++-- src/MEDCoupling/MEDCouplingUMesh.hxx | 1 + src/MEDCoupling_Swig/MEDCoupling.i | 1 + src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 6 +++- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index b87040333..a0fb11f79 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -1538,12 +1538,14 @@ void MEDCouplingUMesh::renumberNodes2(const int *newNodeNumbers, int newNbOfNode } /*! - * This method renumbers nodes in connectivity only without any reference with coords. - * Use it with care ! - * @param 'newNodeNumbers' in old2New convention + * This method renumbers nodes \b in \b connectivity \b only \b without \b any \b reference \b to \b coords. + * This method performs no check on the fact that new coordinate ids are valid. \b Use \b it \b with \b care ! + * This method is an generalization of \ref ParaMEDMEM::MEDCouplingUMesh::shiftNodeNumbersInConn "shiftNodeNumbersInConn method". + * @param [in] newNodeNumbers in old2New convention */ void MEDCouplingUMesh::renumberNodesInConn(const int *newNodeNumbersO2N) { + checkConnectivityFullyDefined(); int *conn=getNodalConnectivity()->getPointer(); const int *connIndex=getNodalConnectivityIndex()->getConstPointer(); int nbOfCells=getNumberOfCells(); @@ -1560,6 +1562,32 @@ void MEDCouplingUMesh::renumberNodesInConn(const int *newNodeNumbersO2N) updateTime(); } +/*! + * This method renumbers nodes \b in \b connectivity \b only \b without \b any \b reference \b to \b coords. + * This method performs no check on the fact that new coordinate ids are valid. \b Use \b it \b with \b care ! + * This method is an specialization of \ref ParaMEDMEM::MEDCouplingUMesh::renumberNodesInConn "renumberNodesInConn method". + * + * @param [in] delta specifies the shift size applied to nodeId in nodal connectivity in \b this. + */ +void MEDCouplingUMesh::shiftNodeNumbersInConn(int delta) throw(INTERP_KERNEL::Exception) +{ + checkConnectivityFullyDefined(); + int *conn=getNodalConnectivity()->getPointer(); + const int *connIndex=getNodalConnectivityIndex()->getConstPointer(); + int nbOfCells=getNumberOfCells(); + for(int i=0;i=0)//avoid polyhedron separator + { + node+=delta; + } + } + _nodal_connec->declareAsNew(); + updateTime(); +} + /*! * This method renumbers cells of 'this' using the array specified by [old2NewBg;old2NewBg+getNumberOfCells()) * diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 97988cb7f..1fe716996 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -118,6 +118,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes); MEDCOUPLING_EXPORT void renumberNodes2(const int *newNodeNumbers, int newNbOfNodes); MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N); + MEDCOUPLING_EXPORT void shiftNodeNumbersInConn(int delta) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void getCellsInBoundingBox(const double *bbox, double eps, std::vector& elems) const; MEDCOUPLING_EXPORT void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems); diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 1437a0e34..f4d20e66d 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -1071,6 +1071,7 @@ namespace ParaMEDMEM std::string reprConnectivityOfThis() const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *buildSetInstanceFromThis(int spaceDim) const throw(INTERP_KERNEL::Exception); //tools + void shiftNodeNumbersInConn(int delta) throw(INTERP_KERNEL::Exception); std::vector getQuadraticStatus() const throw(INTERP_KERNEL::Exception); DataArrayInt *findCellsIdsOnBoundary() const throw(INTERP_KERNEL::Exception); bool checkConsecutiveCellTypes() const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 523dfa791..22e91b1c4 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -9662,16 +9662,20 @@ class MEDCouplingBasicsTest(unittest.TestCase): # mesh3D_2=mesh3D.deepCpy(); mesh2D_2=mesh2D.deepCpy(); + oldNbOf3DNodes=mesh3D.getNumberOfNodes(); renumNodes=DataArrayInt.New(); renumNodes.alloc(mesh2D.getNumberOfNodes(),1); - renumNodes.iota(mesh3D.getNumberOfNodes()); + renumNodes.iota(oldNbOf3DNodes); coo=DataArrayDouble.Aggregate(mesh3D.getCoords(),mesh2D.getCoords()); mesh3D.setCoords(coo); mesh2D.setCoords(coo); mesh2DCpy=mesh2D.deepCpy() + mesh2D_3=mesh2D.deepCpy(); + mesh2D_3.shiftNodeNumbersInConn(oldNbOf3DNodes); mesh2D.renumberNodesInConn(renumNodes); mesh2DCpy.renumberNodesInConn(renumNodes.getValues()); self.assertTrue(mesh2D.isEqual(mesh2DCpy,1e-12)) + self.assertTrue(mesh2D.isEqual(mesh2D_3,1e-12)) # da1,da2=mesh3D.checkGeoEquivalWith(mesh3D_2,10,1e-12); self.assertTrue(da1==None); -- 2.39.2