]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Management of QPOLYGON in MEDCouplingUMesh::orientCorrectly2DCells method.
authorageay <ageay>
Mon, 23 Sep 2013 14:02:25 +0000 (14:02 +0000)
committerageay <ageay>
Mon, 23 Sep 2013 14:02:25 +0000 (14:02 +0000)
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index c04843cf7ec1b11e21997818d4425c4ed080cc2a..c246f98141475fa25771fe5cb77cdc3341d080cc 100644 (file)
@@ -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<int> 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<int> 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<int> 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);
+                }
             }
         }
     }
index 9d61dd3afb7d9cb96ba2082d219a408773179dff..ee96fd4f6c62fb5b9dd3270f441154eb1afeadd7 100644 (file)
@@ -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