]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Modification of spec of method convertExtrudedPolyhedra.
authorageay <ageay>
Fri, 12 Aug 2011 12:28:13 +0000 (12:28 +0000)
committerageay <ageay>
Fri, 12 Aug 2011 12:28:13 +0000 (12:28 +0000)
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 79bc77431845ed3a19cde356405452703028730f..04e737fb155cb852d7e183138fd3cb5c5db2306b 100644 (file)
@@ -671,8 +671,9 @@ void MEDCouplingUMesh::convertAllToPoly()
 /*!
  * This method expects that 'this' has a spacedim equal to 3 and a mesh dimension equal to 3 too, if not an exception will be thrown.
  * This method work only on cells with type NORM_POLYHED, all other cells with different type, are remains unchanged.
-. For such polyhedra, they are expected to have only 2 faces, and each face should
- * have the same number of nodes. The first face is expected to be right oriented because all faces of this polyhedron will be deduced.
+ * For such polyhedra, they are expected to have only 1 face (containing 2 faces in opposition), having 2*n number of nodes (n nodes on
+ * each 2 faces hidden in the single face of polyhedron).
+ * The first face is expected to be right oriented because all faces of this polyhedron will be deduced.
  * When called 'this' is an invalid mesh on MED sense. This method will correct that for polyhedra.
  * In case of presence of polyhedron that has not the extruded aspect (2 faces with the same number of nodes) an exception is thrown and 'this'
  * remains unchanged.
@@ -697,19 +698,18 @@ void MEDCouplingUMesh::convertExtrudedPolyhedra() throw(INTERP_KERNEL::Exception
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)c[ci[i]];
       if(type==INTERP_KERNEL::NORM_POLYHED)
         {
-          if(std::count(c+ci[i]+1,c+ci[i+1],-1)!=1)
+          if(std::count(c+ci[i]+1,c+ci[i+1],-1)!=0)
             {
-              std::ostringstream oss; oss << "MEDCouplingUMesh::convertExtrudedPolyhedra : cell # " << i << " is a polhedron BUT it has NOT exactly 2 faces !";
+              std::ostringstream oss; oss << "MEDCouplingUMesh::convertExtrudedPolyhedra : cell # " << i << " is a polhedron BUT it has NOT exactly 1 face !";
               throw INTERP_KERNEL::Exception(oss.str().c_str());
             }
-          const int *sp=std::find(c+ci[i]+1,c+ci[i+1],-1);
-          int n1=std::distance(c+ci[i]+1,sp);
-          int n2=std::distance(sp+1,c+ci[i+1]);
-          if(n1!=n2)
+          int n2=std::distance(c+ci[i]+1,c+ci[i+1]);
+          if(n2%2!=0)
             {
-              std::ostringstream oss; oss << "MEDCouplingUMesh::convertExtrudedPolyhedra : cell # " << i << " is a polhedron with 2 faces but there is a mismatch of number of nodes in faces !";
+              std::ostringstream oss; oss << "MEDCouplingUMesh::convertExtrudedPolyhedra : cell # " << i << " is a polhedron with 1 face but there is a mismatch of number of nodes in face should be even !";
               throw INTERP_KERNEL::Exception(oss.str().c_str());
             }
+          int n1=n2/2;
           newci[i+1]=7*n1+2+newci[i];//6*n1 (nodal length) + n1+2 (number of faces) - 1 (number of '-1' separator is equal to number of faces -1) + 1 (for cell type)
         }
       else
@@ -723,17 +723,17 @@ void MEDCouplingUMesh::convertExtrudedPolyhedra() throw(INTERP_KERNEL::Exception
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)c[ci[i]];
       if(type==INTERP_KERNEL::NORM_POLYHED)
         {
-          const int *sp=std::find(c+ci[i]+1,c+ci[i+1],-1);
-          int n1=std::distance(c+ci[i]+1,sp);
-          newc=std::copy(c+ci[i],sp+1,newc);
+          int n1=std::distance(c+ci[i]+1,c+ci[i+1])/2;
+          newc=std::copy(c+ci[i],c+ci[i]+n1+1,newc);
+          *newc++=-1;
           for(int j=0;j<n1;j++)
             {
-              newc[j]=c[ci[i]+2+n1+(n1-j)%n1];
+              newc[j]=c[ci[i]+1+n1+(n1-j)%n1];
               newc[n1+5*j]=-1;
               newc[n1+5*j+1]=c[ci[i]+1+j];
               newc[n1+5*j+2]=c[ci[i]+1+(j+1)%n1];
-              newc[n1+5*j+3]=c[ci[i]+1+(j+1)%n1+n1+1];
-              newc[n1+5*j+4]=c[ci[i]+1+j+n1+1];
+              newc[n1+5*j+3]=c[ci[i]+1+(j+1)%n1+n1];
+              newc[n1+5*j+4]=c[ci[i]+1+j+n1];
             }
           newc+=n1*6;
         }
index a2b2b6c54844a3ed64ac9b971f33bf434141be5f..347ff88475745cd3a8e934c7e372e2f7c7d5348a 100644 (file)
@@ -1589,7 +1589,7 @@ void MEDCouplingBasicsTest::testFindAndCorrectBadOriented3DExtrudedCells1()
 
 void MEDCouplingBasicsTest::testConvertExtrudedPolyhedra1()
 {
-  const int conn[75]={1,2,3,4, 5,6,7,8,9,10,11,12, 13,14,15,16, 17,18,19,-1,20,21,22, 23,24,25,26,27,28, 29,30,31,32,33,-1,34,35,36,37,38, 39,40,41,42,43,44,45,46, 47,48,49,50,51,52,53,54,55,56,57,58, 59,60,61,62,63,64,65,-1,66,67,68,69,70,71,72};
+  const int conn[72]={1,2,3,4, 5,6,7,8,9,10,11,12, 13,14,15,16, 17,18,19,20,21,22, 23,24,25,26,27,28, 29,30,31,32,33,34,35,36,37,38, 39,40,41,42,43,44,45,46, 47,48,49,50,51,52,53,54,55,56,57,58, 59,60,61,62,63,64,65,66,67,68,69,70,71,72};
   MEDCouplingUMesh *m=MEDCouplingUMesh::New("Example",3);
   DataArrayDouble *coo=DataArrayDouble::New();
   coo->alloc(73,3);
@@ -1600,12 +1600,12 @@ void MEDCouplingBasicsTest::testConvertExtrudedPolyhedra1()
   m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
   m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+4);
   m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn+12);
-  m->insertNextCell(INTERP_KERNEL::NORM_POLYHED,7,conn+16);
-  m->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+23);
-  m->insertNextCell(INTERP_KERNEL::NORM_POLYHED,11,conn+29);
-  m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+40);
-  m->insertNextCell(INTERP_KERNEL::NORM_HEXGP12,12,conn+48);
-  m->insertNextCell(INTERP_KERNEL::NORM_POLYHED,15,conn+60);
+  m->insertNextCell(INTERP_KERNEL::NORM_POLYHED,6,conn+16);
+  m->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+22);
+  m->insertNextCell(INTERP_KERNEL::NORM_POLYHED,10,conn+28);
+  m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+38);
+  m->insertNextCell(INTERP_KERNEL::NORM_HEXGP12,12,conn+46);
+  m->insertNextCell(INTERP_KERNEL::NORM_POLYHED,14,conn+58);
   m->finishInsertingCells();
   //
   m->convertExtrudedPolyhedra();
index 86c7f2ebd46bfe7587c574b92986c94544a0013f..4773a0b0e476c2035a3de1ffd10570df1023b68d 100644 (file)
@@ -7651,7 +7651,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         pass
 
     def testConvertExtrudedPolyhedra1(self):
-        conn=[1,2,3,4, 5,6,7,8,9,10,11,12, 13,14,15,16, 17,18,19,-1,20,21,22, 23,24,25,26,27,28, 29,30,31,32,33,-1,34,35,36,37,38, 39,40,41,42,43,44,45,46, 47,48,49,50,51,52,53,54,55,56,57,58, 59,60,61,62,63,64,65,-1,66,67,68,69,70,71,72]
+        conn=[1,2,3,4, 5,6,7,8,9,10,11,12, 13,14,15,16, 17,18,19,20,21,22, 23,24,25,26,27,28, 29,30,31,32,33,34,35,36,37,38, 39,40,41,42,43,44,45,46, 47,48,49,50,51,52,53,54,55,56,57,58, 59,60,61,62,63,64,65,66,67,68,69,70,71,72]
         m=MEDCouplingUMesh.New("Example",3);
         coo=DataArrayDouble.New();
         coo.alloc(73,3);
@@ -7661,12 +7661,12 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         m.insertNextCell(NORM_TETRA4,4,conn[0:4])
         m.insertNextCell(NORM_HEXA8,8,conn[4:12])
         m.insertNextCell(NORM_TETRA4,4,conn[12:16])
-        m.insertNextCell(NORM_POLYHED,7,conn[16:23])
-        m.insertNextCell(NORM_PENTA6,6,conn[23:29])
-        m.insertNextCell(NORM_POLYHED,11,conn[29:40])
-        m.insertNextCell(NORM_HEXA8,8,conn[40:48])
-        m.insertNextCell(NORM_HEXGP12,12,conn[48:60])
-        m.insertNextCell(NORM_POLYHED,15,conn[60:75])
+        m.insertNextCell(NORM_POLYHED,6,conn[16:22])
+        m.insertNextCell(NORM_PENTA6,6,conn[22:28])
+        m.insertNextCell(NORM_POLYHED,10,conn[28:38])
+        m.insertNextCell(NORM_HEXA8,8,conn[38:46])
+        m.insertNextCell(NORM_HEXGP12,12,conn[46:58])
+        m.insertNextCell(NORM_POLYHED,14,conn[58:72])
         m.finishInsertingCells();
         #
         m.convertExtrudedPolyhedra();