Salome HOME
PR: merged from V5_1_4rc1
[modules/smesh.git] / src / SMESH / SMESH_Algo.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SMESH SMESH : implementaion of SMESH idl descriptions
24 //  File   : SMESH_Algo.cxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : SMESH
27 //
28 #include "SMESH_Algo.hxx"
29 #include "SMESH_Comment.hxx"
30 #include "SMESH_Gen.hxx"
31 #include "SMESH_Mesh.hxx"
32 #include "SMESH_HypoFilter.hxx"
33 #include "SMDS_FacePosition.hxx"
34 #include "SMDS_EdgePosition.hxx"
35 #include "SMDS_MeshElement.hxx"
36 #include "SMDS_MeshNode.hxx"
37 #include "SMESHDS_Mesh.hxx"
38 #include "SMESHDS_SubMesh.hxx"
39
40 #include <BRepAdaptor_Curve.hxx>
41 #include <BRepLProp.hxx>
42 #include <BRep_Tool.hxx>
43 #include <GCPnts_AbscissaPoint.hxx>
44 #include <GeomAdaptor_Curve.hxx>
45 #include <Geom_Surface.hxx>
46 #include <TopExp.hxx>
47 #include <TopLoc_Location.hxx>
48 #include <TopTools_ListIteratorOfListOfShape.hxx>
49 #include <TopTools_ListOfShape.hxx>
50 #include <TopoDS.hxx>
51 #include <TopoDS_Edge.hxx>
52 #include <TopoDS_Face.hxx>
53 #include <TopoDS_Vertex.hxx>
54 #include <gp_Pnt.hxx>
55 #include <gp_Pnt2d.hxx>
56 #include <gp_Vec.hxx>
57
58 #include <Standard_ErrorHandler.hxx>
59 #include <Standard_Failure.hxx>
60
61 #include "utilities.h"
62
63 #include <algorithm>
64 #include <limits>
65
66 using namespace std;
67
68 //=============================================================================
69 /*!
70  *  
71  */
72 //=============================================================================
73
74 SMESH_Algo::SMESH_Algo (int hypId, int studyId, SMESH_Gen * gen)
75   : SMESH_Hypothesis(hypId, studyId, gen)
76 {
77   gen->_mapAlgo[hypId] = this;
78
79   _onlyUnaryInput = _requireDescretBoundary = _requireShape = true;
80   _quadraticMesh = _supportSubmeshes = false;
81   _error = COMPERR_OK;
82 }
83
84 //=============================================================================
85 /*!
86  *  
87  */
88 //=============================================================================
89
90 SMESH_Algo::~SMESH_Algo()
91 {
92 }
93
94 //=============================================================================
95 /*!
96  * Usually an algoritm has nothing to save
97  */
98 //=============================================================================
99
100 ostream & SMESH_Algo::SaveTo(ostream & save) { return save; }
101 istream & SMESH_Algo::LoadFrom(istream & load) { return load; }
102
103 //=============================================================================
104 /*!
105  *  
106  */
107 //=============================================================================
108
109 const vector < string > &SMESH_Algo::GetCompatibleHypothesis()
110 {
111   return _compatibleHypothesis;
112 }
113
114 //=============================================================================
115 /*!
116  *  List the hypothesis used by the algorithm associated to the shape.
117  *  Hypothesis associated to father shape -are- taken into account (see
118  *  GetAppliedHypothesis). Relevant hypothesis have a name (type) listed in
119  *  the algorithm. This method could be surcharged by specific algorithms, in 
120  *  case of several hypothesis simultaneously applicable.
121  */
122 //=============================================================================
123
124 const list <const SMESHDS_Hypothesis *> &
125 SMESH_Algo::GetUsedHypothesis(SMESH_Mesh &         aMesh,
126                               const TopoDS_Shape & aShape,
127                               const bool           ignoreAuxiliary)
128 {
129   _usedHypList.clear();
130   SMESH_HypoFilter filter;
131   if ( InitCompatibleHypoFilter( filter, ignoreAuxiliary ))
132   {
133     aMesh.GetHypotheses( aShape, filter, _usedHypList, true );
134     if ( ignoreAuxiliary && _usedHypList.size() > 1 )
135       _usedHypList.clear(); //only one compatible hypothesis allowed
136   }
137   return _usedHypList;
138 }
139
140 //=============================================================================
141 /*!
142  *  List the relevant hypothesis associated to the shape. Relevant hypothesis
143  *  have a name (type) listed in the algorithm. Hypothesis associated to
144  *  father shape -are not- taken into account (see GetUsedHypothesis)
145  */
146 //=============================================================================
147
148 const list<const SMESHDS_Hypothesis *> &
149 SMESH_Algo::GetAppliedHypothesis(SMESH_Mesh &         aMesh,
150                                  const TopoDS_Shape & aShape,
151                                  const bool           ignoreAuxiliary)
152 {
153   _appliedHypList.clear();
154   SMESH_HypoFilter filter;
155   if ( InitCompatibleHypoFilter( filter, ignoreAuxiliary ))
156     aMesh.GetHypotheses( aShape, filter, _appliedHypList, false );
157
158   return _appliedHypList;
159 }
160
161 //=============================================================================
162 /*!
163  *  Compute length of an edge
164  */
165 //=============================================================================
166
167 double SMESH_Algo::EdgeLength(const TopoDS_Edge & E)
168 {
169   double UMin = 0, UMax = 0;
170   if (BRep_Tool::Degenerated(E))
171     return 0;
172   TopLoc_Location L;
173   Handle(Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
174   GeomAdaptor_Curve AdaptCurve(C);
175   double length = GCPnts_AbscissaPoint::Length(AdaptCurve, UMin, UMax);
176   return length;
177 }
178
179 //================================================================================
180 /*!
181  * \brief Calculate normal of a mesh face
182  */
183 //================================================================================
184
185 bool SMESH_Algo::FaceNormal(const SMDS_MeshElement* F, gp_XYZ& normal, bool normalized)
186 {
187   if ( !F || F->GetType() != SMDSAbs_Face )
188     return false;
189
190   normal.SetCoord(0,0,0);
191   int nbNodes = F->IsQuadratic() ? F->NbNodes()/2 : F->NbNodes();
192   for ( int i = 0; i < nbNodes-2; ++i )
193   {
194     gp_XYZ p[3];
195     for ( int n = 0; n < 3; ++n )
196     {
197       const SMDS_MeshNode* node = F->GetNode( i + n );
198       p[n].SetCoord( node->X(), node->Y(), node->Z() );
199     }
200     normal += ( p[2] - p[1] ) ^ ( p[0] - p[1] );
201   }
202   double size2 = normal.SquareModulus();
203   bool ok = ( size2 > numeric_limits<double>::min() * numeric_limits<double>::min());
204   if ( normalized && ok )
205     normal /= sqrt( size2 );
206
207   return ok;
208 }
209
210 //================================================================================
211 /*!
212  * \brief Find out elements orientation on a geometrical face
213  * \param theFace - The face correctly oriented in the shape being meshed
214  * \param theMeshDS - The mesh data structure
215  * \retval bool - true if the face normal and the normal of first element
216  *                in the correspoding submesh point in different directions
217  */
218 //================================================================================
219
220 bool SMESH_Algo::IsReversedSubMesh (const TopoDS_Face&  theFace,
221                                     SMESHDS_Mesh*       theMeshDS)
222 {
223   if ( theFace.IsNull() || !theMeshDS )
224     return false;
225
226   // find out orientation of a meshed face
227   int faceID = theMeshDS->ShapeToIndex( theFace );
228   TopoDS_Shape aMeshedFace = theMeshDS->IndexToShape( faceID );
229   bool isReversed = ( theFace.Orientation() != aMeshedFace.Orientation() );
230
231   const SMESHDS_SubMesh * aSubMeshDSFace = theMeshDS->MeshElements( faceID );
232   if ( !aSubMeshDSFace )
233     return isReversed;
234
235   // find element with node located on face and get its normal
236   const SMDS_FacePosition* facePos = 0;
237   int vertexID = 0;
238   gp_Pnt nPnt[3];
239   gp_Vec Ne;
240   bool normalOK = false;
241   SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
242   while ( iteratorElem->more() ) // loop on elements on theFace
243   {
244     const SMDS_MeshElement* elem = iteratorElem->next();
245     if ( elem && elem->NbNodes() > 2 ) {
246       SMDS_ElemIteratorPtr nodesIt = elem->nodesIterator();
247       const SMDS_FacePosition* fPos = 0;
248       int i = 0, vID = 0;
249       while ( nodesIt->more() ) { // loop on nodes
250         const SMDS_MeshNode* node
251           = static_cast<const SMDS_MeshNode *>(nodesIt->next());
252         if ( i == 3 ) i = 2;
253         nPnt[ i++ ].SetCoord( node->X(), node->Y(), node->Z() );
254         // check position
255         const SMDS_PositionPtr& pos = node->GetPosition();
256         if ( !pos ) continue;
257         if ( pos->GetTypeOfPosition() == SMDS_TOP_FACE ) {
258           fPos = dynamic_cast< const SMDS_FacePosition* >( pos );
259         }
260         else if ( pos->GetTypeOfPosition() == SMDS_TOP_VERTEX ) {
261           vID = pos->GetShapeId();
262         }
263       }
264       if ( fPos || ( !normalOK && vID )) {
265         // compute normal
266         gp_Vec v01( nPnt[0], nPnt[1] ), v02( nPnt[0], nPnt[2] );
267         if ( v01.SquareMagnitude() > RealSmall() &&
268              v02.SquareMagnitude() > RealSmall() )
269         {
270           Ne = v01 ^ v02;
271           normalOK = ( Ne.SquareMagnitude() > RealSmall() );
272         }
273         // we need position on theFace or at least on vertex
274         if ( normalOK ) {
275           vertexID = vID;
276           if ((facePos = fPos))
277             break;
278         }
279       }
280     }
281   }
282   if ( !normalOK )
283     return isReversed;
284
285   // node position on face
286   double u,v;
287   if ( facePos ) {
288     u = facePos->GetUParameter();
289     v = facePos->GetVParameter();
290   }
291   else if ( vertexID ) {
292     TopoDS_Shape V = theMeshDS->IndexToShape( vertexID );
293     if ( V.IsNull() || V.ShapeType() != TopAbs_VERTEX )
294       return isReversed;
295     gp_Pnt2d uv = BRep_Tool::Parameters( TopoDS::Vertex( V ), theFace );
296     u = uv.X();
297     v = uv.Y();
298   }
299   else
300   {
301     return isReversed;
302   }
303
304   // face normal at node position
305   TopLoc_Location loc;
306   Handle(Geom_Surface) surf = BRep_Tool::Surface( theFace, loc );
307   if ( surf.IsNull() || surf->Continuity() < GeomAbs_C1 ) return isReversed;
308   gp_Vec d1u, d1v;
309   surf->D1( u, v, nPnt[0], d1u, d1v );
310   gp_Vec Nf = (d1u ^ d1v).Transformed( loc );
311
312   if ( theFace.Orientation() == TopAbs_REVERSED )
313     Nf.Reverse();
314
315   return Ne * Nf < 0.;
316 }
317
318 //================================================================================
319 /*!
320  * \brief Just return false as the algorithm does not hold parameters values
321  */
322 //================================================================================
323
324 bool SMESH_Algo::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
325                                      const TopoDS_Shape& /*theShape*/)
326 {
327   return false;
328 }
329 bool SMESH_Algo::SetParametersByDefaults(const TDefaults& , const SMESH_Mesh*)
330 {
331   return false;
332 }
333 //================================================================================
334 /*!
335  * \brief Fill vector of node parameters on geometrical edge, including vertex nodes
336  * \param theMesh - The mesh containing nodes
337  * \param theEdge - The geometrical edge of interest
338  * \param theParams - The resulting vector of sorted node parameters
339  * \retval bool - false if not all parameters are OK
340  */
341 //================================================================================
342
343 bool SMESH_Algo::GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
344                                     const TopoDS_Edge&  theEdge,
345                                     vector< double > &  theParams)
346 {
347   theParams.clear();
348
349   if ( !theMesh || theEdge.IsNull() )
350     return false;
351
352   SMESHDS_SubMesh * eSubMesh = theMesh->MeshElements( theEdge );
353   if ( !eSubMesh || !eSubMesh->GetElements()->more() )
354     return false; // edge is not meshed
355
356   //int nbEdgeNodes = 0;
357   set < double > paramSet;
358   if ( eSubMesh )
359   {
360     // loop on nodes of an edge: sort them by param on edge
361     SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes();
362     while ( nIt->more() )
363     {
364       const SMDS_MeshNode* node = nIt->next();
365       const SMDS_PositionPtr& pos = node->GetPosition();
366       if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
367         return false;
368       const SMDS_EdgePosition* epos =
369         static_cast<const SMDS_EdgePosition*>(node->GetPosition());
370       if ( !paramSet.insert( epos->GetUParameter() ).second )
371         return false; // equal parameters
372     }
373   }
374   // add vertex nodes params
375   TopoDS_Vertex V1,V2;
376   TopExp::Vertices( theEdge, V1, V2);
377   if ( VertexNode( V1, theMesh ) &&
378        !paramSet.insert( BRep_Tool::Parameter(V1,theEdge) ).second )
379     return false; // there are equal parameters
380   if ( VertexNode( V2, theMesh ) &&
381        !paramSet.insert( BRep_Tool::Parameter(V2,theEdge) ).second )
382     return false; // there are equal parameters
383
384   // fill the vector
385   theParams.resize( paramSet.size() );
386   set < double >::iterator   par    = paramSet.begin();
387   vector< double >::iterator vecPar = theParams.begin();
388   for ( ; par != paramSet.end(); ++par, ++vecPar )
389     *vecPar = *par;
390
391   return theParams.size() > 1;
392 }
393
394 //================================================================================
395 /*!
396  * \brief Fill vector of node parameters on geometrical edge, including vertex nodes
397  * \param theMesh - The mesh containing nodes
398  * \param theEdge - The geometrical edge of interest
399  * \param theParams - The resulting vector of sorted node parameters
400  * \retval bool - false if not all parameters are OK
401  */
402 //================================================================================
403
404 bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh*                   theMesh,
405                                       const TopoDS_Edge&                    theEdge,
406                                       const bool                            ignoreMediumNodes,
407                                       map< double, const SMDS_MeshNode* > & theNodes)
408 {
409   theNodes.clear();
410
411   if ( !theMesh || theEdge.IsNull() )
412     return false;
413
414   SMESHDS_SubMesh * eSubMesh = theMesh->MeshElements( theEdge );
415   if ( !eSubMesh || !eSubMesh->GetElements()->more() )
416     return false; // edge is not meshed
417
418   int nbNodes = 0;
419   set < double > paramSet;
420   if ( eSubMesh )
421   {
422     // loop on nodes of an edge: sort them by param on edge
423     SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes();
424     while ( nIt->more() )
425     {
426       const SMDS_MeshNode* node = nIt->next();
427       if ( ignoreMediumNodes ) {
428         SMDS_ElemIteratorPtr elemIt = node->GetInverseElementIterator();
429         if ( elemIt->more() && elemIt->next()->IsMediumNode( node ))
430           continue;
431       }
432       const SMDS_PositionPtr& pos = node->GetPosition();
433       if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
434         return false;
435       const SMDS_EdgePosition* epos =
436         static_cast<const SMDS_EdgePosition*>(node->GetPosition());
437       theNodes.insert( make_pair( epos->GetUParameter(), node ));
438       ++nbNodes;
439     }
440   }
441   // add vertex nodes
442   TopoDS_Vertex v1, v2;
443   TopExp::Vertices(theEdge, v1, v2);
444   const SMDS_MeshNode* n1 = VertexNode( v1, (SMESHDS_Mesh*) theMesh );
445   const SMDS_MeshNode* n2 = VertexNode( v2, (SMESHDS_Mesh*) theMesh );
446   Standard_Real f, l;
447   BRep_Tool::Range(theEdge, f, l);
448   if ( v1.Orientation() != TopAbs_FORWARD )
449     std::swap( f, l );
450   if ( n1 && ++nbNodes )
451     theNodes.insert( make_pair( f, n1 ));
452   if ( n2 && ++nbNodes )
453     theNodes.insert( make_pair( l, n2 ));
454
455   return theNodes.size() == nbNodes;
456 }
457
458 //================================================================================
459 /*!
460  * \brief Make filter recognize only compatible hypotheses
461  * \param theFilter - the filter to initialize
462  * \param ignoreAuxiliary - make filter ignore compatible auxiliary hypotheses
463  */
464 //================================================================================
465
466 bool SMESH_Algo::InitCompatibleHypoFilter( SMESH_HypoFilter & theFilter,
467                                            const bool         ignoreAuxiliary) const
468 {
469   if ( !_compatibleHypothesis.empty() )
470   {
471     theFilter.Init( theFilter.HasName( _compatibleHypothesis[0] ));
472     for ( int i = 1; i < _compatibleHypothesis.size(); ++i )
473       theFilter.Or( theFilter.HasName( _compatibleHypothesis[ i ] ));
474
475     if ( ignoreAuxiliary )
476       theFilter.AndNot( theFilter.IsAuxiliary() );
477
478     return true;
479   }
480   return false;
481 }
482
483 //================================================================================
484 /*!
485  * \brief Return continuity of two edges
486  * \param E1 - the 1st edge
487  * \param E2 - the 2nd edge
488  * \retval GeomAbs_Shape - regularity at the junction between E1 and E2
489  */
490 //================================================================================
491
492 GeomAbs_Shape SMESH_Algo::Continuity(TopoDS_Edge E1,
493                                      TopoDS_Edge E2)
494 {
495   E1.Orientation(TopAbs_FORWARD), E2.Orientation(TopAbs_FORWARD); // avoid pb with internal edges
496   TopoDS_Vertex V = TopExp::LastVertex (E1, true);
497   if ( !V.IsSame( TopExp::FirstVertex(E2, true )))
498     if ( !TopExp::CommonVertex( E1, E2, V ))
499       return GeomAbs_C0;
500   Standard_Real u1 = BRep_Tool::Parameter( V, E1 );
501   Standard_Real u2 = BRep_Tool::Parameter( V, E2 );
502   BRepAdaptor_Curve C1( E1 ), C2( E2 );
503   Standard_Real tol = BRep_Tool::Tolerance( V );
504   Standard_Real angTol = 2e-3;
505   try {
506 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
507     OCC_CATCH_SIGNALS;
508 #endif
509     return BRepLProp::Continuity(C1, C2, u1, u2, tol, angTol);
510   }
511   catch (Standard_Failure) {
512   }
513   return GeomAbs_C0;
514 }
515
516 //================================================================================
517 /*!
518  * \brief Return the node built on a vertex
519  * \param V - the vertex
520  * \param meshDS - mesh
521  * \retval const SMDS_MeshNode* - found node or NULL
522  */
523 //================================================================================
524
525 const SMDS_MeshNode* SMESH_Algo::VertexNode(const TopoDS_Vertex& V,
526                                             const SMESHDS_Mesh*  meshDS)
527 {
528   if ( SMESHDS_SubMesh* sm = meshDS->MeshElements(V) ) {
529     SMDS_NodeIteratorPtr nIt= sm->GetNodes();
530     if (nIt->more())
531       return nIt->next();
532   }
533   return 0;
534 }
535
536 //=======================================================================
537 //function : GetCommonNodes
538 //purpose  : Return nodes common to two elements
539 //=======================================================================
540
541 vector< const SMDS_MeshNode*> SMESH_Algo::GetCommonNodes(const SMDS_MeshElement* e1,
542                                                          const SMDS_MeshElement* e2)
543 {
544   vector< const SMDS_MeshNode*> common;
545   for ( int i = 0 ; i < e1->NbNodes(); ++i )
546     if ( e2->GetNodeIndex( e1->GetNode( i )) >= 0 )
547       common.push_back( e1->GetNode( i ));
548   return common;
549 }
550
551 //================================================================================
552 /*!
553  * \brief Sets event listener to submeshes if necessary
554  * \param subMesh - submesh where algo is set
555  * 
556  * After being set, event listener is notified on each event of a submesh.
557  * By default non listener is set
558  */
559 //================================================================================
560
561 void SMESH_Algo::SetEventListener(SMESH_subMesh* /*subMesh*/)
562 {
563 }
564
565 //================================================================================
566 /*!
567  * \brief Allow algo to do something after persistent restoration
568  * \param subMesh - restored submesh
569  *
570  * This method is called only if a submesh has HYP_OK algo_state.
571  */
572 //================================================================================
573
574 void SMESH_Algo::SubmeshRestored(SMESH_subMesh* /*subMesh*/)
575 {
576 }
577
578 //================================================================================
579 /*!
580  * \brief Computes mesh without geometry
581  * \param aMesh - the mesh
582  * \param aHelper - helper that must be used for adding elements to \aaMesh
583  * \retval bool - is a success
584  */
585 //================================================================================
586
587 bool SMESH_Algo::Compute(SMESH_Mesh & /*aMesh*/, SMESH_MesherHelper* /*aHelper*/)
588 {
589   return error( COMPERR_BAD_INPUT_MESH, "Mesh built on shape expected");
590 }
591
592 //================================================================================
593 /*!
594  * \brief store error and comment and then return ( error == COMPERR_OK )
595  */
596 //================================================================================
597
598 bool SMESH_Algo::error(int error, const SMESH_Comment& comment)
599 {
600   _error   = error;
601   _comment = comment;
602   return ( error == COMPERR_OK );
603 }
604
605 //================================================================================
606 /*!
607  * \brief store error and return ( error == COMPERR_OK )
608  */
609 //================================================================================
610
611 bool SMESH_Algo::error(SMESH_ComputeErrorPtr error)
612 {
613   if ( error ) {
614     _error   = error->myName;
615     _comment = error->myComment;
616     _badInputElements = error->myBadElements;
617     return error->IsOK();
618   }
619   return true;
620 }
621
622 //================================================================================
623 /*!
624  * \brief return compute error
625  */
626 //================================================================================
627
628 SMESH_ComputeErrorPtr SMESH_Algo::GetComputeError() const
629 {
630   SMESH_ComputeErrorPtr err = SMESH_ComputeError::New( _error, _comment, this );
631   // hope this method is called by only SMESH_subMesh after this->Compute()
632   err->myBadElements.splice( err->myBadElements.end(),
633                              (list<const SMDS_MeshElement*>&) _badInputElements );
634   return err;
635 }
636
637 //================================================================================
638 /*!
639  * \brief initialize compute error
640  */
641 //================================================================================
642
643 void SMESH_Algo::InitComputeError()
644 {
645   _error = COMPERR_OK;
646   _comment.clear();
647   list<const SMDS_MeshElement*>::iterator elem = _badInputElements.begin();
648   for ( ; elem != _badInputElements.end(); ++elem )
649     if ( (*elem)->GetID() < 1 )
650       delete *elem;
651   _badInputElements.clear();
652 }
653
654 //================================================================================
655 /*!
656  * \brief store a bad input element preventing computation,
657  *        which may be a temporary one i.e. not residing the mesh,
658  *        then it will be deleted by InitComputeError()
659  */
660 //================================================================================
661
662 void SMESH_Algo::addBadInputElement(const SMDS_MeshElement* elem)
663 {
664   if ( elem )
665     _badInputElements.push_back( elem );
666 }