]> SALOME platform Git repositories - modules/smesh.git/blobdiff - src/StdMeshers/StdMeshers_Penta_3D.cxx
Salome HOME
PAL13460 (PAL EDF 301 force the mesh to go through a point)
[modules/smesh.git] / src / StdMeshers / StdMeshers_Penta_3D.cxx
index a16f08b99b18481c8a391a1b1e423aaa5d9bbdc1..51b33214fadc17d02597a094a397f46650cba7a2 100644 (file)
@@ -17,7 +17,7 @@
 //  License along with this library; if not, write to the Free Software 
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
 // 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
 #include "SMDS_VolumeTool.hxx"
 #include "SMESHDS_SubMesh.hxx"
 #include "SMESH_Mesh.hxx"
-#include "SMESH_subMesh.hxx"
 #include "SMESH_MeshEditor.hxx"
+#include "SMESH_subMesh.hxx"
+#include "SMESH_subMeshEventListener.hxx"
 
+#include <BRepTools.hxx>
+#include <BRepTools_WireExplorer.hxx>
 #include <BRep_Tool.hxx>
 #include <TopAbs_ShapeEnum.hxx>
 #include <TopExp.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_ListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Shell.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <gp_Pnt.hxx>
-#include <BRepTools.hxx>
-#include <BRepTools_WireExplorer.hxx>
-#include <TopTools_MapOfShape.hxx>
 
 #include <stdio.h>
 #include <algorithm>
@@ -63,6 +64,8 @@ using namespace std;
 typedef map < int, int, less<int> >::iterator   \
   StdMeshers_IteratorOfDataMapOfIntegerInteger;
 
+enum { NB_WALL_FACES = 4 };
+
 //=======================================================================
 //function : StdMeshers_Penta_3D
 //purpose  : 
@@ -264,81 +267,17 @@ void StdMeshers_Penta_3D::MakeNodes()
       ++j;
     }
   }
-  /*
-  //DEB
-  {
-    int iShapeSupportID, iBaseNodeID;
-    //
-    //printf("\n\n*** Base Face\n");
-    i=0;
-    for (j=0; j<myJSize; ++j) {
-      ij=i*myJSize+j;
-      const StdMeshers_TNode& aTNode=myTNodes[ij];
-      iShapeSupportID=aTNode.ShapeSupportID();
-      iBaseNodeID=aTNode.BaseNodeID();
-      const gp_XYZ& aXYZ=aTNode.NormCoord();
-      printf("*** j:%d bID#%d iSS:%d { %lf %lf %lf }\n",
-            j,  iBaseNodeID, iShapeSupportID, aXYZ.X(),  aXYZ.Y(), aXYZ.Z());
-    }
-  }
-  */
-  //DEB
-  //return; //zz
-  //
-  // 3. Finding of Z-layers
-//   vector<double> aZL(myISize);
-//   vector<double>::iterator aItZL1, aItZL2 ;
-//   //
-//   const TopoDS_Shape& aE00z=myBlock.Shape(SMESH_Block::ID_E00z);
-//   SMDS_NodeIteratorPtr aItaE00z =
-//     pMesh->GetSubMeshContaining(aE00z)->GetSubMeshDS()->GetNodes();
-//   //
-//   aZL[0]=0.;
-//   i=1;
-//   while (aItaE00z->more()) {
-//     const SMDS_MeshNode* aNode=aItaE00z->next();
-//     const SMDS_EdgePosition* epos =
-//       static_cast<const SMDS_EdgePosition*>(aNode->GetPosition().get());
-//     myBlock.ComputeParameters( epos->GetUParameter(), aE00z, aCoords );
-//     iErr=myBlock.ErrorStatus();
-//     if (iErr) {
-//       MESSAGE("StdMeshers_Penta_3D::MakeNodes()," <<
-//               "SMESHBlock: ComputeParameters operation failed");
-//       myErrorStatus=101; // SMESHBlock: ComputeParameters operation failed
-//       return;
-//     }
-//     aZL[i]=aCoords.Z();
-//     ++i;
-//   }
-//   aZL[i]=1.;
-//   //
-//   aItZL1=aZL.begin();
-//   aItZL2=aZL.end();
-//   //
-//   // Sorting the layers
-//   sort(aItZL1, aItZL2);
-  //DEB
-  /*
-  printf("** \n\n Layers begin\n");
-  for(i=0, aItZL=aItZL1; aItZL!=aItZL2; ++aItZL, ++i) {
-    printf(" #%d : %lf\n", i, *aItZL);
-  } 
-  printf("** Layers end\n");
-  */
-  //DEB
-  //
-  //
 
   // 3.1 Fill maps of wall nodes
-  SMESH_Block::TShapeID wallFaceID[4] = {
+  SMESH_Block::TShapeID wallFaceID[ NB_WALL_FACES ] = {
     SMESH_Block::ID_Fx0z, SMESH_Block::ID_Fx1z,
     SMESH_Block::ID_F0yz, SMESH_Block::ID_F1yz
     };
-  SMESH_Block::TShapeID baseEdgeID[4] = {
+  SMESH_Block::TShapeID baseEdgeID[ NB_WALL_FACES ] = {
     SMESH_Block::ID_Ex00, SMESH_Block::ID_Ex10,
     SMESH_Block::ID_E0y0, SMESH_Block::ID_E1y0
     };
-  for ( i = 0; i < 4; ++i ) {
+  for ( i = 0; i < NB_WALL_FACES ; ++i ) {
     int fIndex = SMESH_Block::ShapeIndex( wallFaceID[ i ]);
     bool ok = LoadIJNodes (myWallNodesMaps[ fIndex ],
                            TopoDS::Face( myBlock.Shape( wallFaceID[ i ] )),
@@ -352,9 +291,9 @@ void StdMeshers_Penta_3D::MakeNodes()
   }
 
   // 3.2 find node columns for vertical edges and edge IDs
-  vector<const SMDS_MeshNode*> * verticEdgeNodes[ 4 ];
-  SMESH_Block::TShapeID          verticEdgeID   [ 4 ];
-  for ( i = 0; i < 4; ++i ) { // 4 first base nodes are nodes on vertices
+  vector<const SMDS_MeshNode*> * verticEdgeNodes[ NB_WALL_FACES ];
+  SMESH_Block::TShapeID          verticEdgeID   [ NB_WALL_FACES ];
+  for ( i = 0; i < NB_WALL_FACES ; ++i ) { // 4 first base nodes are nodes on vertices
     // edge ID
     SMESH_Block::TShapeID eID, vID = aSIDs[ i ];
     ShapeSupportID(false, vID, eID);
@@ -362,7 +301,7 @@ void StdMeshers_Penta_3D::MakeNodes()
     // column nodes
     StdMeshers_TNode& aTNode = myTNodes[ i ];
     verticEdgeNodes[ i ] = 0;
-    for ( j = 0; j < 4; ++j ) { // loop on 4 wall faces
+    for ( j = 0; j < NB_WALL_FACES ; ++j ) { // loop on 4 wall faces
       int fIndex = SMESH_Block::ShapeIndex( wallFaceID[ j ]);
       StdMeshers_IJNodeMap & ijNodes= myWallNodesMaps[ fIndex ];
       if ( ijNodes.begin()->second[0] == aTNode.Node() )
@@ -416,20 +355,20 @@ void StdMeshers_Penta_3D::MakeNodes()
   N = itn->next();
   gp_XY UV111 = myTool->GetNodeUV(TopFace,N);
 
-  for (j=0; j<myJSize; ++j) {
+  for (j=0; j<myJSize; ++j) { // loop on all nodes of the base face (ID_Fxy0)
     // base node info
     const StdMeshers_TNode& aBN = myTNodes[j];
     aBNSSID = (SMESH_Block::TShapeID)aBN.ShapeSupportID();
     iBNID = aBN.BaseNodeID();
     const gp_XYZ& aBNXYZ = aBN.NormCoord();
-    bool createNode = ( aBNSSID == SMESH_Block::ID_Fxy0 );
+    bool createNode = ( aBNSSID == SMESH_Block::ID_Fxy0 ); // if base node is inside a bottom face
     //
     // set XYZ on horizontal edges and get node columns of faces:
     // 2 columns for each face, between which a base node is located
     vector<const SMDS_MeshNode*>* nColumns[8];
-    double ratio[4]; // base node position between columns [0.-1.]
+    double ratio[ NB_WALL_FACES ]; // base node position between columns [0.-1.]
     if ( createNode ) {
-      for ( k = 0; k < 4; ++k ) {
+      for ( k = 0; k < NB_WALL_FACES ; ++k ) {
         ratio[ k ] = SetHorizEdgeXYZ (aBNXYZ, wallFaceID[ k ],
                                       nColumns[k*2], nColumns[k*2+1]);
       }
@@ -441,27 +380,31 @@ void StdMeshers_Penta_3D::MakeNodes()
     myShapeXYZ[ SMESH_Block::ID_Fxy1 ].SetCoord( 0., 0., 0. );
     //
     // first create or find a top node, then the rest ones in a column
-    for (i=myISize-1; i>0; --i) {
+    for (i=myISize-1; i>0; --i) // vertical loop, from top to bottom
+    {
       bIsUpperLayer = (i==(myISize-1));
       gp_XY UV_Ex01, UV_Ex11, UV_E0y1, UV_E1y1;
-      if ( createNode ) {
+      if ( createNode ) // a base node is inside a top face
+      {
         // set XYZ on vertical edges and faces
-        for ( k = 0; k < 4; ++k ) {
+        for ( k = 0; k < NB_WALL_FACES ; ++k ) {
+          // XYZ on a vertical edge 
           const SMDS_MeshNode* n = (*verticEdgeNodes[ k ]) [ i ];
           myShapeXYZ[ verticEdgeID[ k ] ].SetCoord( n->X(), n->Y(), n->Z() );
-          //
+          // XYZ on a face (part 1 from one column)
           n = (*nColumns[k*2]) [ i ];
+          gp_XYZ xyz( n->X(), n->Y(), n->Z() );
+          myShapeXYZ[ wallFaceID[ k ]] = ( 1. - ratio[ k ]) * xyz;
           gp_XY tmp1;
-          if( i==myISize-1 ) {
+          if( bIsUpperLayer ) {
             tmp1 = myTool->GetNodeUV(TopFace,n);
             tmp1 = ( 1. - ratio[ k ]) * tmp1;
           }
-          gp_XYZ xyz( n->X(), n->Y(), n->Z() );
-          myShapeXYZ[ wallFaceID[ k ]] = ( 1. - ratio[ k ]) * xyz;
+          // XYZ on a face (part 2 from other column)
           n = (*nColumns[k*2+1]) [ i ];
           xyz.SetCoord( n->X(), n->Y(), n->Z() );
           myShapeXYZ[ wallFaceID[ k ]] += ratio[ k ] * xyz;
-          if( i==myISize-1 ) {
+          if( bIsUpperLayer ) {
             gp_XY tmp2 = myTool->GetNodeUV(TopFace,n);
             tmp1 +=  ratio[ k ] * tmp2;
             if( k==0 )
@@ -662,12 +605,15 @@ double StdMeshers_Penta_3D::SetHorizEdgeXYZ(const gp_XYZ&                  aBase
                                             vector<const SMDS_MeshNode*>*& aCol2)
 {
   // find base and top edges of the face
+  enum { BASE = 0, TOP };
   vector< int > edgeVec; // 0-base, 1-top
   SMESH_Block::GetFaceEdgesIDs( aFaceID, edgeVec );
   //
-  int coord = SMESH_Block::GetCoordIndOnEdge( edgeVec[ 0 ] );
+  int coord = SMESH_Block::GetCoordIndOnEdge( edgeVec[ BASE ] );
+  bool isForward = myBlock.IsForwadEdge( edgeVec[ BASE ] );
+
   double param = aBaseNodeParams.Coord( coord );
-  if ( !myBlock.IsForwadEdge( edgeVec[ 0 ] ))
+  if ( !isForward)
     param = 1. - param;
   //
   // look for columns around param
@@ -686,19 +632,34 @@ double StdMeshers_Penta_3D::SetHorizEdgeXYZ(const gp_XYZ&                  aBase
   aCol1 = & par_nVec_1->second;
   aCol2 = & par_nVec_2->second;
 
-  // base edge
-  const SMDS_MeshNode* n1 = aCol1->front();
-  const SMDS_MeshNode* n2 = aCol2->front();
-  gp_XYZ xyz1( n1->X(), n1->Y(), n1->Z() ), xyz2( n2->X(), n2->Y(), n2->Z() );
-  myShapeXYZ[ edgeVec[ 0 ] ] = ( 1. - r ) * xyz1 + r * xyz2;
-
   // top edge
-  n1 = aCol1->back();
-  n2 = aCol2->back();
-  xyz1.SetCoord( n1->X(), n1->Y(), n1->Z() );
-  xyz2.SetCoord( n2->X(), n2->Y(), n2->Z() );
-  myShapeXYZ[ edgeVec[ 1 ] ] = ( 1. - r ) * xyz1 + r * xyz2;
+  if (1) {
+    // this variant is better for cases with curved edges and
+    // different nodes distribution on top and base edges
+    const SMDS_MeshNode* n1 = aCol1->back();
+    const SMDS_MeshNode* n2 = aCol2->back();
+    gp_XYZ xyz1( n1->X(), n1->Y(), n1->Z() );
+    gp_XYZ xyz2( n2->X(), n2->Y(), n2->Z() );
+    myShapeXYZ[ edgeVec[ 1 ] ] = ( 1. - r ) * xyz1 + r * xyz2;
+  }
+  else {
+    // this variant is better for other cases
+//   SMESH_MesherHelper helper( *GetMesh() );
+//   const TopoDS_Edge & edge = TopoDS::Edge( myBlock.Shape( edgeVec[ TOP ]));
+//   double u1 = helper.GetNodeU( edge, n1 );
+//   double u2 = helper.GetNodeU( edge, n2 );
+//   double u = ( 1. - r ) * u1 + r * u2;
+//   gp_XYZ topNodeParams;
+//   myBlock.Block().EdgeParameters( edgeVec[ TOP ], u, topNodeParams );
+//   myBlock.Block().EdgePoint( edgeVec[ TOP ],
+//                              topNodeParams,
+//                              myShapeXYZ[ edgeVec[ TOP ]]);
+  }
 
+  // base edge
+  myBlock.Block().EdgePoint( edgeVec[ BASE ],
+                             aBaseNodeParams,
+                             myShapeXYZ[ edgeVec[ BASE ]]);
   return r;
 }
 
@@ -862,10 +823,13 @@ void StdMeshers_Penta_3D::MakeMeshOnFxy1()
     TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy0));
   const TopoDS_Face& aFxy1=
     TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy1));
+  SMESH_MesherHelper faceHelper( *GetMesh() );
+  faceHelper.IsQuadraticSubMesh(aFxy1);
   //
   SMESH_Mesh* pMesh = GetMesh();
   SMESHDS_Mesh * meshDS = pMesh->GetMeshDS();
   //
+  SMESH_subMesh *aSubMesh1 = pMesh->GetSubMeshContaining(aFxy1);
   SMESH_subMesh *aSubMesh0 = pMesh->GetSubMeshContaining(aFxy0);
   SMESHDS_SubMesh *aSM0 = aSubMesh0->GetSubMeshDS();
   //
@@ -889,9 +853,6 @@ void StdMeshers_Penta_3D::MakeMeshOnFxy1()
     aNbNodes = pE0->NbNodes();
     if(myCreateQuadratic)
       aNbNodes = aNbNodes/2;
-//     if (aNbNodes!=3) {
-//       continue;
-//     }
     if ( aNodes1.size() < aNbNodes )
       aNodes1.resize( aNbNodes );
     //
@@ -919,18 +880,26 @@ void StdMeshers_Penta_3D::MakeMeshOnFxy1()
     SMDS_MeshFace * face = 0;
     switch ( aNbNodes ) {
     case 3:
-      //face = meshDS->AddFace(aNodes1[0], aNodes1[1], aNodes1[2]);
-      face = myTool->AddFace(aNodes1[0], aNodes1[1], aNodes1[2]);
+      face = faceHelper.AddFace(aNodes1[0], aNodes1[1], aNodes1[2]);
       break;
     case 4:
-      //face = meshDS->AddFace(aNodes1[0], aNodes1[1], aNodes1[2], aNodes1[3]);
-      face = myTool->AddFace(aNodes1[0], aNodes1[1], aNodes1[2], aNodes1[3]);
+      face = faceHelper.AddFace(aNodes1[0], aNodes1[1], aNodes1[2], aNodes1[3]);
       break;
     default:
       continue;
     }
     meshDS->SetMeshElementOnShape(face, aFxy1);
   }
+
+  // update compute state of top face submesh
+  aSubMesh1->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
+
+  // assure that mesh on the top face will be cleaned when it is cleaned
+  // on the bottom face
+  SMESH_subMesh* volSM = pMesh->GetSubMesh( myTool->GetSubShape() );
+  volSM->SetEventListener( new SMESH_subMeshEventListener(true),
+                           SMESH_subMeshEventListenerData::MakeData( aSubMesh1 ),
+                           aSubMesh0 ); // translate CLEAN event of aSubMesh0 to aSubMesh1
 }
 
 //=======================================================================
@@ -1130,15 +1099,175 @@ void StdMeshers_Penta_3D::MakeBlock()
          aFTr = aF;
          ++iCnt;
          if (iCnt>1) {
-            MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
-           myErrorStatus=5; // more than one face has triangulation
-           return;
+           // \begin{E.A.}
+           // The current algorithm fails if there is more that one
+           // face wich contains triangles ...
+           // In that case, replace return by break to try another
+           // method (coded in "if (iCnt != 1) { ... }")
+           //
+            // MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
+           // myErrorStatus=5; // more than one face has triangulation
+           // return;
+           break;
+           // \end{E.A.}
          }
          break; // next face
        }
       }
     }
   }
+  //
+  // \begin{E.A.}
+  // The current algorithm fails if "iCnt != 1", the case "iCnt == 0"
+  // was not reached 'cause it was not called from Hexa_3D ... Now it
+  // can occurs and in my opinion, it is the most common case.
+  //
+  if (iCnt != 1) {
+    // The suggested algorithm is the following :
+    //
+    // o Check that nb_of_faces == 6 and nb_of_edges == 12
+    //   then the shape is tologically equivalent to a box
+    // o In a box, there are three set of four // edges ...
+    //   In the cascade notation, it seems to be the edges
+    //   numbered : 
+    //     - 1, 3, 5, 7
+    //     - 2, 4, 6, 8
+    //     - 9, 10, 11, 12
+    // o For each one of this set, check if the four edges
+    //   have the same number of element.
+    // o If so, check if the "corresponding" // faces contains
+    //   only quads. It's the faces numbered:
+    //     - 1, 2, 3, 4
+    //     - 1, 2, 5, 6
+    //     - 3, 4, 5, 6
+    // o If so, check if the opposite edges of each // faces
+    //   have the same number of elements. It is the edges
+    //   numbered :
+    //     - 2 and 4, 6 and 8, 9 and 10, 11 and 12
+    //     - 1 and 3, 5 and 7, 9 and 11, 10 and 12
+    //     - 1 and 5, 3 and 7, 4 and 8, 2 and 6
+    // o If so, check if the two other faces have the same
+    //   number of elements. It is the faces numbered:
+    //     - 5, 6
+    //     - 3, 4
+    //     - 1, 2
+    //   This test should be improved to test if the nodes
+    //   of the two faces are really "en face".
+    // o If so, one of the two faces is a candidate to an extrusion,
+    //   It is the faces numbered :
+    //     - 5
+    //     - 3
+    //     - 1
+    // o Finally, if there is only one candidate, let do the
+    //   extrusion job for the corresponding face
+    //
+    int isOK = 0;
+    //
+    int iNbF = aM.Extent();
+    if (iNbF == 6) {
+      //
+      int nb_f1 = pMesh->GetSubMeshContaining(aM(1))->GetSubMeshDS()->NbElements();
+      int nb_f2 = pMesh->GetSubMeshContaining(aM(2))->GetSubMeshDS()->NbElements();
+      int nb_f3 = pMesh->GetSubMeshContaining(aM(3))->GetSubMeshDS()->NbElements();
+      int nb_f4 = pMesh->GetSubMeshContaining(aM(4))->GetSubMeshDS()->NbElements();
+      int nb_f5 = pMesh->GetSubMeshContaining(aM(5))->GetSubMeshDS()->NbElements();
+      int nb_f6 = pMesh->GetSubMeshContaining(aM(6))->GetSubMeshDS()->NbElements();
+      //
+      int has_only_quad_f1 = 1;
+      int has_only_quad_f2 = 1;
+      int has_only_quad_f3 = 1;
+      int has_only_quad_f4 = 1;
+      int has_only_quad_f5 = 1;
+      int has_only_quad_f6 = 1;
+      //
+      for (i=1; i<=iNbF; ++i) {
+       int ok = 1;
+       const TopoDS_Shape& aF = aM(i);
+       SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aF);
+       SMESHDS_SubMesh *aSM = aSubMesh->GetSubMeshDS();
+       SMDS_ElemIteratorPtr itf = aSM->GetElements();
+       while(itf->more()) {
+         const SMDS_MeshElement * pElement = itf->next();
+         aElementType = pElement->GetType();
+         if (aElementType==SMDSAbs_Face) {
+           iNbNodes = pElement->NbNodes();
+           if ( iNbNodes!=4 ) {
+             ok = 0;
+             break ;
+           }
+         }
+       }
+       if (i==1) has_only_quad_f1 = ok ;
+       if (i==2) has_only_quad_f2 = ok ;
+       if (i==3) has_only_quad_f3 = ok ;
+       if (i==4) has_only_quad_f4 = ok ;
+       if (i==5) has_only_quad_f5 = ok ;
+       if (i==6) has_only_quad_f6 = ok ;
+      }
+      //
+      TopTools_IndexedMapOfShape aE;
+      TopExp::MapShapes(myShape, TopAbs_EDGE, aE);
+      int iNbE = aE.Extent();
+      if (iNbE == 12) {
+       //
+       int nb_e01 = pMesh->GetSubMeshContaining(aE(1))->GetSubMeshDS()->NbElements();
+       int nb_e02 = pMesh->GetSubMeshContaining(aE(2))->GetSubMeshDS()->NbElements();
+       int nb_e03 = pMesh->GetSubMeshContaining(aE(3))->GetSubMeshDS()->NbElements();
+       int nb_e04 = pMesh->GetSubMeshContaining(aE(4))->GetSubMeshDS()->NbElements();
+       int nb_e05 = pMesh->GetSubMeshContaining(aE(5))->GetSubMeshDS()->NbElements();
+       int nb_e06 = pMesh->GetSubMeshContaining(aE(6))->GetSubMeshDS()->NbElements();
+       int nb_e07 = pMesh->GetSubMeshContaining(aE(7))->GetSubMeshDS()->NbElements();
+       int nb_e08 = pMesh->GetSubMeshContaining(aE(8))->GetSubMeshDS()->NbElements();
+       int nb_e09 = pMesh->GetSubMeshContaining(aE(9))->GetSubMeshDS()->NbElements();
+       int nb_e10 = pMesh->GetSubMeshContaining(aE(10))->GetSubMeshDS()->NbElements();
+       int nb_e11 = pMesh->GetSubMeshContaining(aE(11))->GetSubMeshDS()->NbElements();
+       int nb_e12 = pMesh->GetSubMeshContaining(aE(12))->GetSubMeshDS()->NbElements();
+       //
+       int nb_ok = 0 ;
+       //
+       if ( (nb_e01==nb_e03) && (nb_e03==nb_e05) && (nb_e05==nb_e07) ) {
+         if ( has_only_quad_f1 && has_only_quad_f2 && has_only_quad_f3 && has_only_quad_f4 ) {
+           if ( (nb_e09==nb_e10) && (nb_e08==nb_e06) && (nb_e11==nb_e12) && (nb_e04==nb_e02) ) {
+             if (nb_f5==nb_f6) {
+               nb_ok += 1;
+               aFTr = aM(5);
+             }
+           }
+         }
+       }
+       if ( (nb_e02==nb_e04) && (nb_e04==nb_e06) && (nb_e06==nb_e08) ) {
+         if ( has_only_quad_f1 && has_only_quad_f2 && has_only_quad_f5 && has_only_quad_f6 ) {
+           if ( (nb_e01==nb_e03) && (nb_e10==nb_e12) && (nb_e05==nb_e07) && (nb_e09==nb_e11) ) {
+             if (nb_f3==nb_f4) {
+               nb_ok += 1;
+               aFTr = aM(3);
+             }
+           }
+         }
+       }
+       if ( (nb_e09==nb_e10) && (nb_e10==nb_e11) && (nb_e11==nb_e12) ) {
+         if ( has_only_quad_f3 && has_only_quad_f4 && has_only_quad_f5 && has_only_quad_f6 ) {
+           if ( (nb_e01==nb_e05) && (nb_e02==nb_e06) && (nb_e03==nb_e07) && (nb_e04==nb_e08) ) {
+             if (nb_f1==nb_f2) {
+               nb_ok += 1;
+               aFTr = aM(1);
+             }
+           }
+         }
+       }
+       //
+       if ( nb_ok == 1 ) {
+         isOK = 1;
+       }
+       //
+      }
+    }
+    if (!isOK) {
+      myErrorStatus=5; // more than one face has triangulation
+      return;
+    }
+  }
+  // \end{E.A.}
   // 
   // 1. Vetrices V00, V001;
   //
@@ -1147,7 +1276,7 @@ void StdMeshers_Penta_3D::MakeBlock()
   //
   // 1.1 Base vertex V000
   iNbE = aME.Extent();
-  if (iNbE!=4){
+  if (iNbE!= NB_WALL_FACES ){
     MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
     myErrorStatus=7; // too few edges are in base face aFTr 
     return;
@@ -1288,7 +1417,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
   TopExp_Explorer exp( theFace, TopAbs_EDGE );
   int nbEdges = 0;
   for ( ; exp.More(); exp.Next() ) {
-    if ( ++nbEdges > 4 ) {
+    if ( ++nbEdges > NB_WALL_FACES ) {
       return false; // more than 4 edges in theFace
     }
     TopoDS_Edge e = TopoDS::Edge( exp.Current() );
@@ -1307,7 +1436,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
     else
       e2 = e;
   }
-  if ( nbEdges < 4 ) {
+  if ( nbEdges < NB_WALL_FACES ) {
     return false; // less than 4 edges in theFace
   }
 
@@ -1425,12 +1554,12 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
   // try to load the rest nodes
 
   // get all faces from theFace
-  map<int,const SMDS_MeshElement*> allFaces, foundFaces;
+  TIDSortedElemSet allFaces, foundFaces;
   SMDS_ElemIteratorPtr eIt = smFace->GetElements();
   while ( eIt->more() ) {
     const SMDS_MeshElement* e = eIt->next();
     if ( e->GetType() == SMDSAbs_Face )
-      allFaces.insert( make_pair(e->GetID(),e) );
+      allFaces.insert( e );
   }
   // Starting from 2 neighbour nodes on theBaseEdge, look for a face
   // the nodes belong to, and between the nodes of the found face,
@@ -1477,7 +1606,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
             return false;
           }
           par_nVec_2->second[ row ] = node;
-          foundFaces.insert( make_pair(face->GetID(),face) );
+          foundFaces.insert( face );
           n2 = node;
           if ( nbFaceNodes==4 || (myCreateQuadratic && nbFaceNodes==8) ) {
             n1 = par_nVec_1->second[ row ];