+ // Check presence of regular grid mesh on FACEs of the cube
+ // ------------------------------------------------------------
+
+ // tool creating quadratic elements if needed
+ SMESH_MesherHelper helper (aMesh);
+ _quadraticMesh = helper.IsQuadraticSubMesh(aShape);
+
+ for ( int i = 0; i < 6; ++i )
+ {
+ const TopoDS_Face& F = aCubeSide[i]._quad->face;
+ StdMeshers_FaceSide* baseQuadSide = aCubeSide[i]._quad->side[ Q_BOTTOM ];
+ vector< TopAbs_Orientation > eOri( baseQuadSide->NbEdges() );
+
+ for ( int iE = 0; iE < baseQuadSide->NbEdges(); ++iE )
+ {
+ const TopoDS_Edge& baseE = baseQuadSide->Edge( iE );
+ eOri[ iE ] = baseE.Orientation();
+
+ // assure correctness of node positions on baseE:
+ // helper.GetNodeU() will fix positions if they are wrong
+ if ( SMESHDS_SubMesh* smDS = meshDS->MeshElements( baseE ))
+ {
+ bool ok;
+ helper.SetSubShape( baseE );
+ SMDS_ElemIteratorPtr eIt = smDS->GetElements();
+ while ( eIt->more() )
+ {
+ const SMDS_MeshElement* e = eIt->next();
+ helper.GetNodeU( baseE, e->GetNode(0), e->GetNode(1), &ok);
+ helper.GetNodeU( baseE, e->GetNode(1), e->GetNode(0), &ok);
+ }
+ }
+
+ // load grid
+ TParam2ColumnMap u2nodesMap;
+ if ( !helper.LoadNodeColumns( u2nodesMap, F, baseE, meshDS, proxymesh.get() ))
+ {
+ SMESH_ComputeErrorPtr err = ComputePentahedralMesh(aMesh, aShape, proxymesh.get());
+ return error( err );
+ }
+ // store u2nodesMap
+ if ( iE == 0 )
+ {
+ aCubeSide[i]._u2nodesMap.swap( u2nodesMap );
+ }
+ else // unite 2 maps
+ {
+ if ( eOri[0] == eOri[iE] )
+ append( aCubeSide[i]._u2nodesMap, u2nodesMap.begin(), u2nodesMap.end());
+ else
+ append( aCubeSide[i]._u2nodesMap, u2nodesMap.rbegin(), u2nodesMap.rend());
+ }
+ }
+ // check if the loaded grid corresponds to nb of quadrangles
+ const SMESHDS_SubMesh* faceSubMesh =
+ proxymesh ? proxymesh->GetSubMesh( F ) : meshDS->MeshElements( F );
+ const int nbQuads = faceSubMesh->NbElements();
+ const int nbHor = aCubeSide[i]._u2nodesMap.size() - 1;
+ const int nbVer = aCubeSide[i]._u2nodesMap.begin()->second.size() - 1;
+ if ( nbQuads != nbHor * nbVer )
+ {
+ SMESH_ComputeErrorPtr err = ComputePentahedralMesh(aMesh, aShape, proxymesh.get());
+ return error( err );
+ }
+ }
+