+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief return compute error
+ */
+//================================================================================
+
+SMESH_ComputeErrorPtr SMESH_Algo::GetComputeError() const
+{
+ SMESH_ComputeErrorPtr err = SMESH_ComputeError::New( _error, _comment, this );
+ // hope this method is called by only SMESH_subMesh after this->Compute()
+ err->myBadElements.splice( err->myBadElements.end(),
+ (list<const SMDS_MeshElement*>&) _badInputElements );
+ return err;
+}
+
+//================================================================================
+/*!
+ * \brief initialize compute error before call of Compute()
+ */
+//================================================================================
+
+void SMESH_Algo::InitComputeError()
+{
+ _error = COMPERR_OK;
+ _comment.clear();
+ list<const SMDS_MeshElement*>::iterator elem = _badInputElements.begin();
+ for ( ; elem != _badInputElements.end(); ++elem )
+ if ( (*elem)->GetID() < 1 )
+ delete *elem;
+ _badInputElements.clear();
+
+ _computeCanceled = false;
+ _progressTic = 0;
+ _progress = 0.;
+}
+
+//================================================================================
+/*!
+ * \brief Return compute progress by nb of calls of this method
+ */
+//================================================================================
+
+double SMESH_Algo::GetProgressByTic() const
+{
+ int computeCost = 0;
+ for ( size_t i = 0; i < _smToCompute.size(); ++i )
+ computeCost += _smToCompute[i]->GetComputeCost();
+
+ const_cast<SMESH_Algo*>( this )->_progressTic++;
+
+ double x = 5 * _progressTic;
+ x = ( x < computeCost ) ? ( x / computeCost ) : 1.;
+ return 0.9 * sin( x * M_PI / 2 );
+}
+
+//================================================================================
+/*!
+ * \brief store a bad input element preventing computation,
+ * which may be a temporary one i.e. not residing the mesh,
+ * then it will be deleted by InitComputeError()
+ */
+//================================================================================
+
+void SMESH_Algo::addBadInputElement(const SMDS_MeshElement* elem)
+{
+ if ( elem )
+ _badInputElements.push_back( elem );
+}
+
+//=======================================================================
+//function : addBadInputElements
+//purpose : store a bad input elements or nodes preventing computation
+//=======================================================================
+
+void SMESH_Algo::addBadInputElements(const SMESHDS_SubMesh* sm,
+ const bool addNodes)
+{
+ if ( sm )
+ {
+ if ( addNodes )
+ {
+ SMDS_NodeIteratorPtr nIt = sm->GetNodes();
+ while ( nIt->more() ) addBadInputElement( nIt->next() );
+ }
+ else
+ {
+ SMDS_ElemIteratorPtr eIt = sm->GetElements();
+ while ( eIt->more() ) addBadInputElement( eIt->next() );
+ }
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+// int SMESH_Algo::NumberOfWires(const TopoDS_Shape& S)
+// {
+// int i = 0;
+// for (TopExp_Explorer exp(S,TopAbs_WIRE); exp.More(); exp.Next())
+// i++;
+// return i;
+// }
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_Algo::NumberOfPoints(SMESH_Mesh& aMesh, const TopoDS_Wire& W)
+{
+ int nbPoints = 0;
+ for (TopExp_Explorer exp(W,TopAbs_EDGE); exp.More(); exp.Next()) {
+ const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
+ int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
+ if(_quadraticMesh)
+ nb = nb/2;
+ nbPoints += nb + 1; // internal points plus 1 vertex of 2 (last point ?)
+ }
+ return nbPoints;
+}
+
+
+//================================================================================
+/*!
+ * Method in which an algorithm generating a structured mesh
+ * fixes positions of in-face nodes after there movement
+ * due to insertion of viscous layers.
+ */
+//================================================================================
+
+bool SMESH_2D_Algo::FixInternalNodes(const SMESH_ProxyMesh& mesh,
+ const TopoDS_Face& face)
+{
+ const SMESHDS_SubMesh* smDS = mesh.GetSubMesh(face);
+ if ( !smDS || smDS->NbElements() < 1 )
+ return false;
+
+ SMESH_MesherHelper helper( *mesh.GetMesh() );
+
+ // get all faces from a proxy sub-mesh
+ typedef SMDS_StdIterator< const SMDS_MeshElement*, SMDS_ElemIteratorPtr > TIterator;
+ TIDSortedElemSet allFaces( TIterator( smDS->GetElements() ), TIterator() );
+ TIDSortedElemSet avoidSet, firstRowQuads;
+
+ // indices of nodes to pass to a neighbour quad using SMESH_MeshAlgos::FindFaceInSet()
+ int iN1, iN2;
+
+ // get two first rows of nodes by passing through the first row of faces
+ vector< vector< const SMDS_MeshNode* > > nodeRows;
+ int iRow1 = 0, iRow2 = 1;
+ const SMDS_MeshElement* quad;
+ {
+ // look for a corner quadrangle and it's corner node
+ const SMDS_MeshElement* cornerQuad = 0;
+ int cornerNodeInd = -1;
+ SMDS_ElemIteratorPtr fIt = smDS->GetElements();
+ while ( !cornerQuad && fIt->more() )
+ {
+ cornerQuad = fIt->next();
+ if ( cornerQuad->NbCornerNodes() != 4 )
+ return false;
+ SMDS_NodeIteratorPtr nIt = cornerQuad->nodeIterator();
+ for ( int i = 0; i < 4; ++i )
+ {
+ int nbInverseQuads = 0;
+ SMDS_ElemIteratorPtr fIt = nIt->next()->GetInverseElementIterator(SMDSAbs_Face);
+ while ( fIt->more() )
+ nbInverseQuads += allFaces.count( fIt->next() );
+ if ( nbInverseQuads == 1 )
+ cornerNodeInd = i, i = 4;
+ }
+ if ( cornerNodeInd < 0 )
+ cornerQuad = 0;
+ }
+ if ( !cornerQuad || cornerNodeInd < 0 )
+ return false;
+
+ iN1 = helper.WrapIndex( cornerNodeInd + 1, 4 );
+ iN2 = helper.WrapIndex( cornerNodeInd + 2, 4 );
+ int iN3 = helper.WrapIndex( cornerNodeInd + 3, 4 );
+ nodeRows.resize(2);
+ nodeRows[iRow1].push_back( cornerQuad->GetNode( cornerNodeInd ));
+ nodeRows[iRow1].push_back( cornerQuad->GetNode( iN1 ));
+ nodeRows[iRow2].push_back( cornerQuad->GetNode( iN3 ));
+ nodeRows[iRow2].push_back( cornerQuad->GetNode( iN2 ));
+ firstRowQuads.insert( cornerQuad );
+
+ // pass through the rest quads in a face row
+ quad = cornerQuad;
+ while ( quad )
+ {
+ avoidSet.clear();
+ avoidSet.insert( quad );
+ if (( quad = SMESH_MeshAlgos::FindFaceInSet( nodeRows[iRow1].back(),
+ nodeRows[iRow2].back(),
+ allFaces, avoidSet, &iN1, &iN2)))
+ {
+ nodeRows[iRow1].push_back( quad->GetNode( helper.WrapIndex( iN2 + 2, 4 )));
+ nodeRows[iRow2].push_back( quad->GetNode( helper.WrapIndex( iN1 + 2, 4 )));
+ if ( quad->NbCornerNodes() != 4 )
+ return false;
+ }
+ }
+ if ( nodeRows[iRow1].size() < 3 )
+ return true; // there is nothing to fix
+ }
+
+ nodeRows.reserve( smDS->NbElements() / nodeRows[iRow1].size() );
+
+ // get the rest node rows
+ while ( true )