From: ageay Date: Fri, 12 Aug 2011 12:28:13 +0000 (+0000) Subject: Modification of spec of method convertExtrudedPolyhedra. X-Git-Tag: V6_main_FINAL~990 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=194aef84462501207de974624159667d430c3e27;p=tools%2Fmedcoupling.git Modification of spec of method convertExtrudedPolyhedra. --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 79bc77431..04e737fb1 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -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;jalloc(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(); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 86c7f2ebd..4773a0b0e 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -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();