+ if ( foundNbRows != expectedNbRows )
+ return false;
+ avoidSet.clear();
+ }
+ return ( theParam2ColumnMap.size() > 1 &&
+ theParam2ColumnMap.begin()->second.size() == prevNbRows + expectedNbRows );
+}
+
+namespace
+{
+ //================================================================================
+ /*!
+ * \brief Return true if a node is at a corner of a 2D structured mesh of FACE
+ */
+ //================================================================================
+
+ bool isCornerOfStructure( const SMDS_MeshNode* n,
+ const SMESHDS_SubMesh* faceSM )
+ {
+ int nbFacesInSM = 0;
+ if ( n ) {
+ SMDS_ElemIteratorPtr fIt = n->GetInverseElementIterator( SMDSAbs_Face );
+ while ( fIt->more() )
+ nbFacesInSM += faceSM->Contains( fIt->next() );
+ }
+ return ( nbFacesInSM == 1 );
+ }
+}
+
+//=======================================================================
+//function : IsStructured
+//purpose : Return true if 2D mesh on FACE is structured
+//=======================================================================
+
+bool SMESH_MesherHelper::IsStructured( SMESH_subMesh* faceSM )
+{
+ SMESHDS_SubMesh* fSM = faceSM->GetSubMeshDS();
+ if ( !fSM || fSM->NbElements() == 0 )
+ return false;
+
+ list< TopoDS_Edge > edges;
+ list< int > nbEdgesInWires;
+ int nbWires = SMESH_Block::GetOrderedEdges( TopoDS::Face( faceSM->GetSubShape() ),
+ edges, nbEdgesInWires );
+ if ( nbWires != 1 )
+ return false;
+
+ // algo: find corners of a structure and then analyze nb of faces and
+ // length of structure sides
+
+ SMESHDS_Mesh* meshDS = faceSM->GetFather()->GetMeshDS();
+
+ // rotate edges to get the first node being at corner
+ // (in principle it's not necessary but so far none SALOME algo can make
+ // such a structured mesh that all corner nodes are not on VERTEXes)
+ bool isCorner = false;
+ int nbRemainEdges = nbEdgesInWires.front();
+ do {
+ TopoDS_Vertex V = IthVertex( 0, edges.front() );
+ isCorner = isCornerOfStructure( SMESH_Algo::VertexNode( V, meshDS ), fSM);
+ if ( !isCorner ) {
+ edges.splice( edges.end(), edges, edges.begin() );
+ --nbRemainEdges;
+ }
+ }
+ while ( !isCorner && nbRemainEdges > 0 );
+
+ if ( !isCorner )
+ return false;
+
+ // get all nodes from EDGEs
+ list< const SMDS_MeshNode* > nodes;
+ list< TopoDS_Edge >::iterator edge = edges.begin();
+ for ( ; edge != edges.end(); ++edge )
+ {
+ map< double, const SMDS_MeshNode* > u2Nodes;
+ if ( !SMESH_Algo::GetSortedNodesOnEdge( meshDS, *edge,
+ /*skipMedium=*/true, u2Nodes ))
+ return false;
+
+ list< const SMDS_MeshNode* > edgeNodes;
+ map< double, const SMDS_MeshNode* >::iterator u2n = u2Nodes.begin();
+ if ( !nodes.empty() && nodes.back() == u2n->second )
+ ++u2n;
+ map< double, const SMDS_MeshNode* >::iterator u2nEnd = --u2Nodes.end();
+ if ( nodes.empty() || nodes.back() != u2nEnd->second )
+ ++u2nEnd;
+ for ( ; u2n != u2nEnd; ++u2n )
+ edgeNodes.push_back( u2n->second );
+
+ if ( edge->Orientation() == TopAbs_REVERSED )
+ edgeNodes.reverse();
+ nodes.splice( nodes.end(), edgeNodes, edgeNodes.begin(), edgeNodes.end() );
+ }
+
+ // get length of structured sides
+ vector<int> nbEdgesInSide;
+ int nbEdges = 0;
+ list< const SMDS_MeshNode* >::iterator n = ++nodes.begin();
+ for ( ; n != nodes.end(); ++n )
+ {
+ ++nbEdges;
+ if ( isCornerOfStructure( *n, fSM )) {
+ nbEdgesInSide.push_back( nbEdges );
+ nbEdges = 0;
+ }
+ }
+
+ // checks
+ if ( nbEdgesInSide.size() != 4 )
+ return false;
+ if ( nbEdgesInSide[0] != nbEdgesInSide[2] )
+ return false;
+ if ( nbEdgesInSide[1] != nbEdgesInSide[3] )
+ return false;
+ if ( nbEdgesInSide[0] * nbEdgesInSide[1] != fSM->NbElements() )
+ return false;
+
+ return true;
+}
+
+//=======================================================================
+//function : Count
+//purpose : Count nb of sub-shapes
+//=======================================================================
+
+int SMESH_MesherHelper::Count(const TopoDS_Shape& shape,
+ const TopAbs_ShapeEnum type,
+ const bool ignoreSame)
+{
+ if ( ignoreSame ) {
+ TopTools_IndexedMapOfShape map;
+ TopExp::MapShapes( shape, type, map );
+ return map.Extent();
+ }
+ else {
+ int nb = 0;
+ for ( TopExp_Explorer exp( shape, type ); exp.More(); exp.Next() )
+ ++nb;
+ return nb;