From: ageay Date: Mon, 23 Sep 2013 14:02:25 +0000 (+0000) Subject: Management of QPOLYGON in MEDCouplingUMesh::orientCorrectly2DCells method. X-Git-Tag: V7_3_1b1~134 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=693d8fb6ff12c9bef7e505b7d8791c93acbc96dc;p=tools%2Fmedcoupling.git Management of QPOLYGON in MEDCouplingUMesh::orientCorrectly2DCells method. --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index c04843cf7..c246f9814 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -5692,13 +5692,25 @@ void MEDCouplingUMesh::orientCorrectly2DCells(const double *vec, bool polyOnly) INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]]; if(!polyOnly || (type==INTERP_KERNEL::NORM_POLYGON || type==INTERP_KERNEL::NORM_QPOLYG)) { - bool isQuadratic=INTERP_KERNEL::CellModel::GetCellModel(type).isQuadratic(); + bool isQuadratic(INTERP_KERNEL::CellModel::GetCellModel(type).isQuadratic()); if(!IsPolygonWellOriented(isQuadratic,vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr)) { isModified=true; - std::vector tmp(connI[i+1]-connI[i]-2); - std::copy(conn+connI[i]+2,conn+connI[i+1],tmp.rbegin()); - std::copy(tmp.begin(),tmp.end(),conn+connI[i]+2); + if(!isQuadratic) + { + std::vector tmp(connI[i+1]-connI[i]-2); + std::copy(conn+connI[i]+2,conn+connI[i+1],tmp.rbegin()); + std::copy(tmp.begin(),tmp.end(),conn+connI[i]+2); + } + else + { + int sz(((int)(connI[i+1]-connI[i]-1))/2); + std::vector tmp0(sz-1),tmp1(sz); + std::copy(conn+connI[i]+2,conn+connI[i]+1+sz,tmp0.rbegin()); + std::copy(conn+connI[i]+1+sz,conn+connI[i+1],tmp1.rbegin()); + std::copy(tmp0.begin(),tmp0.end(),conn+connI[i]+2); + std::copy(tmp1.begin(),tmp1.end(),conn+connI[i]+1+sz); + } } } } diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 9d61dd3af..ee96fd4f6 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -13889,6 +13889,24 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(c.isEqual(DataArrayInt([0,-1]))) pass + def testSwig2MeshOrientCorrectly2DCells1(self): + m=MEDCouplingUMesh("mesh",2) + coo=DataArrayDouble([1.,0.,0.5,-0.1,0.,1.,0.,0.,0.07,0.5,0.59,0.5],6,2) + m.setCoords(coo) + m.allocateCells() + m.insertNextCell(NORM_TRI6,[3,0,2,1,5,4]) + m.insertNextCell(NORM_QPOLYG,[3,0,2,1,5,4]) + self.assertTrue(DataArrayDouble([-0.58093333350930543,-0.58093333350930543]).isEqual(m.getMeasureField(False).getArray(),1e-12)) + m.changeSpaceDimension(3) + m.orientCorrectly2DCells([0.,0.,-1.],False) + # + m.checkCoherency() + self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([6,3,2,0,4,5,1, 32,3,2,0,4,5,1]))) + self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,7,14]))) + m.changeSpaceDimension(2) + self.assertTrue(DataArrayDouble([0.58093333350930543,0.58093333350930543]).isEqual(m.getMeasureField(False).getArray(),1e-12)) + pass + def setUp(self): pass pass