]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESH/SMESH_Gen.cxx
Salome HOME
0020982: EDF 1547 SMESH: Creation of non-conformal quadratic pyramids
[modules/smesh.git] / src / SMESH / SMESH_Gen.cxx
1 // Copyright (C) 2007-2012  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_Gen.cxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : SMESH
27 //
28
29 //#define CHRONODEF
30
31 #include "SMESH_Gen.hxx"
32
33 #include "SMDS_Mesh.hxx"
34 #include "SMDS_MeshElement.hxx"
35 #include "SMDS_MeshNode.hxx"
36 #include "SMESHDS_Document.hxx"
37 #include "SMESH_HypoFilter.hxx"
38 #include "SMESH_MesherHelper.hxx"
39 #include "SMESH_subMesh.hxx"
40
41 #include "utilities.h"
42 #include "OpUtil.hxx"
43 #include "Utils_ExceptHandlers.hxx"
44
45 #include <TopoDS_Iterator.hxx>
46 #include <LDOMParser.hxx>
47
48 #include "memoire.h"
49
50 using namespace std;
51
52 //=============================================================================
53 /*!
54  *  Constructor
55  */
56 //=============================================================================
57
58 SMESH_Gen::SMESH_Gen()
59 {
60         MESSAGE("SMESH_Gen::SMESH_Gen");
61         _localId = 0;
62         _hypId = 0;
63         _segmentation = _nbSegments = 10;
64         SMDS_Mesh::_meshList.clear();
65         MESSAGE(SMDS_Mesh::_meshList.size());
66         _counters = new counters(100);
67 #ifdef WITH_SMESH_CANCEL_COMPUTE
68         _compute_canceled = false;
69         _sm_current = NULL;
70 #endif
71 }
72
73 //=============================================================================
74 /*!
75  * Destructor
76  */
77 //=============================================================================
78
79 SMESH_Gen::~SMESH_Gen()
80 {
81   MESSAGE("SMESH_Gen::~SMESH_Gen");
82 }
83
84 //=============================================================================
85 /*!
86  * Creates a mesh in a study.
87  * if (theIsEmbeddedMode) { mesh modification commands are not logged }
88  */
89 //=============================================================================
90
91 SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode)
92   throw(SALOME_Exception)
93 {
94   Unexpect aCatch(SalomeException);
95   MESSAGE("SMESH_Gen::CreateMesh");
96
97   // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
98   StudyContextStruct *aStudyContext = GetStudyContext(theStudyId);
99
100   // create a new SMESH_mesh object
101   SMESH_Mesh *aMesh = new SMESH_Mesh(_localId++,
102                                      theStudyId,
103                                      this,
104                                      theIsEmbeddedMode,
105                                      aStudyContext->myDocument);
106   aStudyContext->mapMesh[_localId-1] = aMesh;
107
108   return aMesh;
109 }
110
111 //=============================================================================
112 /*!
113  * Compute a mesh
114  */
115 //=============================================================================
116
117 bool SMESH_Gen::Compute(SMESH_Mesh &          aMesh,
118                         const TopoDS_Shape &  aShape,
119                         const bool            anUpward,
120                         const ::MeshDimension aDim,
121                         TSetOfInt*            aShapesId)
122 {
123   MESSAGE("SMESH_Gen::Compute");
124   MEMOSTAT;
125
126   bool ret = true;
127
128   SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
129
130   const bool includeSelf = true;
131   const bool complexShapeFirst = true;
132   const int  globalAlgoDim = 100;
133
134   SMESH_subMeshIteratorPtr smIt;
135
136   if ( anUpward ) // is called from below code here
137   {
138     // -----------------------------------------------
139     // mesh all the sub-shapes starting from vertices
140     // -----------------------------------------------
141     smIt = sm->getDependsOnIterator(includeSelf, !complexShapeFirst);
142     while ( smIt->more() )
143     {
144       SMESH_subMesh* smToCompute = smIt->next();
145
146       // do not mesh vertices of a pseudo shape
147       const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
148       if ( !aMesh.HasShapeToMesh() && aShType == TopAbs_VERTEX )
149         continue;
150
151       // check for preview dimension limitations
152       if ( aShapesId && GetShapeDim( aShType ) > (int)aDim )
153       {
154         // clear compute state to not show previous compute errors
155         //  if preview invoked less dimension less than previous
156         smToCompute->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
157         continue;
158       }
159
160       if (smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
161       {
162 #ifdef WITH_SMESH_CANCEL_COMPUTE
163         if (_compute_canceled)
164           return false;
165         _sm_current = smToCompute;
166 #endif
167         smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
168 #ifdef WITH_SMESH_CANCEL_COMPUTE
169         _sm_current = NULL;
170 #endif
171       }
172
173       // we check all the submeshes here and detect if any of them failed to compute
174       if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE)
175         ret = false;
176       else if ( aShapesId )
177         aShapesId->insert( smToCompute->GetId() );
178     }
179     //aMesh.GetMeshDS()->Modified();
180     return ret;
181   }
182   else
183   {
184     // -----------------------------------------------------------------
185     // apply algos that DO NOT require Discreteized boundaries and DO NOT
186     // support submeshes, starting from the most complex shapes
187     // and collect submeshes with algos that DO support submeshes
188     // -----------------------------------------------------------------
189     list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes;
190
191     // map to sort sm with same dim algos according to dim of
192     // the shape the algo assigned to (issue 0021217)
193     multimap< int, SMESH_subMesh* > shDim2sm;
194     multimap< int, SMESH_subMesh* >::reverse_iterator shDim2smIt;
195     TopoDS_Shape algoShape;
196     int prevShapeDim = -1;
197
198     smIt = sm->getDependsOnIterator(includeSelf, complexShapeFirst);
199     while ( smIt->more() )
200     {
201       SMESH_subMesh* smToCompute = smIt->next();
202       if ( smToCompute->GetComputeState() != SMESH_subMesh::READY_TO_COMPUTE )
203         continue;
204
205       const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
206       int aShapeDim = GetShapeDim( aSubShape );
207       if ( aShapeDim < 1 ) break;
208       
209       // check for preview dimension limitations
210       if ( aShapesId && aShapeDim > (int)aDim )
211         continue;
212
213       SMESH_Algo* algo = GetAlgo( aMesh, aSubShape, &algoShape );
214       if ( algo && !algo->NeedDiscreteBoundary() )
215       {
216         if ( algo->SupportSubmeshes() )
217         {
218           // reload sub-meshes from shDim2sm into smWithAlgoSupportingSubmeshes
219           // so that more local algos to go first
220           if ( prevShapeDim != aShapeDim )
221           {
222             prevShapeDim = aShapeDim;
223             for ( shDim2smIt = shDim2sm.rbegin(); shDim2smIt != shDim2sm.rend(); ++shDim2smIt )
224               if ( shDim2smIt->first == globalAlgoDim )
225                 smWithAlgoSupportingSubmeshes.push_back( shDim2smIt->second );
226               else
227                 smWithAlgoSupportingSubmeshes.push_front( shDim2smIt->second );
228             shDim2sm.clear();
229           }
230           // add smToCompute to shDim2sm map
231           if ( algoShape.IsSame( aMesh.GetShapeToMesh() ))
232           {
233             aShapeDim = globalAlgoDim; // to compute last
234           }
235           else
236           {
237             aShapeDim = GetShapeDim( algoShape );
238             if ( algoShape.ShapeType() == TopAbs_COMPOUND )
239             {
240               TopoDS_Iterator it( algoShape );
241               aShapeDim += GetShapeDim( it.Value() );
242             }
243           }
244           shDim2sm.insert( make_pair( aShapeDim, smToCompute ));
245         }
246         else
247         {
248 #ifdef WITH_SMESH_CANCEL_COMPUTE
249           if (_compute_canceled)
250             return false;
251           _sm_current = smToCompute;
252 #endif
253           smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
254 #ifdef WITH_SMESH_CANCEL_COMPUTE
255           _sm_current = NULL;
256 #endif
257           if ( aShapesId )
258             aShapesId->insert( smToCompute->GetId() );
259         }
260       }
261     }
262     // reload sub-meshes from shDim2sm into smWithAlgoSupportingSubmeshes
263     for ( shDim2smIt = shDim2sm.rbegin(); shDim2smIt != shDim2sm.rend(); ++shDim2smIt )
264       if ( shDim2smIt->first == globalAlgoDim )
265         smWithAlgoSupportingSubmeshes.push_back( shDim2smIt->second );
266       else
267         smWithAlgoSupportingSubmeshes.push_front( shDim2smIt->second );
268
269     // ------------------------------------------------------------
270     // sort list of submeshes according to mesh order
271     // ------------------------------------------------------------
272     aMesh.SortByMeshOrder( smWithAlgoSupportingSubmeshes );
273
274     // ------------------------------------------------------------
275     // compute submeshes under shapes with algos that DO NOT require
276     // Discreteized boundaries and DO support submeshes
277     // ------------------------------------------------------------
278     list< SMESH_subMesh* >::iterator subIt, subEnd;
279     subIt  = smWithAlgoSupportingSubmeshes.begin();
280     subEnd = smWithAlgoSupportingSubmeshes.end();
281     // start from lower shapes
282     for ( ; subIt != subEnd; ++subIt )
283     {
284       sm = *subIt;
285
286       // get a shape the algo is assigned to
287       if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape ))
288         continue; // strange...
289
290       // look for more local algos
291       smIt = sm->getDependsOnIterator(!includeSelf, !complexShapeFirst);
292       while ( smIt->more() )
293       {
294         SMESH_subMesh* smToCompute = smIt->next();
295
296         const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
297         const int aShapeDim = GetShapeDim( aSubShape );
298         //if ( aSubShape.ShapeType() == TopAbs_VERTEX ) continue;
299         if ( aShapeDim < 1 ) continue;
300
301         // check for preview dimension limitations
302         if ( aShapesId && GetShapeDim( aSubShape.ShapeType() ) > (int)aDim )
303           continue;
304         
305         SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
306         filter
307           .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
308           .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh ));
309
310         if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) {
311           SMESH_Hypothesis::Hypothesis_Status status;
312           if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
313             // mesh a lower smToCompute starting from vertices
314             Compute( aMesh, aSubShape, /*anUpward=*/true, aDim, aShapesId );
315         }
316       }
317     }
318     // ----------------------------------------------------------
319     // apply the algos that do not require Discreteized boundaries
320     // ----------------------------------------------------------
321     for ( subIt = smWithAlgoSupportingSubmeshes.begin(); subIt != subEnd; ++subIt )
322     {
323       sm = *subIt;
324       if ( sm->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
325       {
326         const TopAbs_ShapeEnum aShType = sm->GetSubShape().ShapeType();
327         // check for preview dimension limitations
328         if ( aShapesId && GetShapeDim( aShType ) > (int)aDim )
329           continue;
330
331 #ifdef WITH_SMESH_CANCEL_COMPUTE
332         if (_compute_canceled)
333           return false;
334         _sm_current = sm;
335 #endif
336         sm->ComputeStateEngine( SMESH_subMesh::COMPUTE );
337 #ifdef WITH_SMESH_CANCEL_COMPUTE
338         _sm_current = NULL;
339 #endif
340         if ( aShapesId )
341           aShapesId->insert( sm->GetId() );
342       }
343     }
344     // -----------------------------------------------
345     // mesh the rest sub-shapes starting from vertices
346     // -----------------------------------------------
347     ret = Compute( aMesh, aShape, /*anUpward=*/true, aDim, aShapesId );
348   }
349
350   MESSAGE( "VSR - SMESH_Gen::Compute() finished, OK = " << ret);
351   MEMOSTAT;
352
353   SMESHDS_Mesh *myMesh = aMesh.GetMeshDS();
354   myMesh->adjustStructure();
355   MESSAGE("*** compactMesh after compute");
356   myMesh->compactMesh();
357   //myMesh->adjustStructure();
358   list<int> listind = myMesh->SubMeshIndices();
359   list<int>::iterator it = listind.begin();
360   int total = 0;
361   for(; it != listind.end(); ++it)
362     {
363       ::SMESHDS_SubMesh *subMesh = myMesh->MeshElements(*it);
364       total +=  subMesh->getSize();
365     }
366   MESSAGE("total elements and nodes in submesh sets:" << total);
367   MESSAGE("Number of node objects " << SMDS_MeshNode::nbNodes);
368   MESSAGE("Number of cell objects " << SMDS_MeshCell::nbCells);
369   //myMesh->dumpGrid();
370   //aMesh.GetMeshDS()->Modified();
371
372   // fix quadratic mesh by bending iternal links near concave boundary
373   if ( aShape.IsSame( aMesh.GetShapeToMesh() ) &&
374        !aShapesId ) // not preview
375   {
376     SMESH_MesherHelper aHelper( aMesh );
377     if ( aHelper.IsQuadraticMesh() != SMESH_MesherHelper::LINEAR )
378     {
379       aHelper.FixQuadraticElements( sm->GetComputeError() );
380     }
381   }
382   return ret;
383 }
384
385
386 #ifdef WITH_SMESH_CANCEL_COMPUTE
387 //=============================================================================
388 /*!
389  * Prepare Compute a mesh
390  */
391 //=============================================================================
392 void SMESH_Gen::PrepareCompute(SMESH_Mesh &          aMesh,
393                                const TopoDS_Shape &  aShape)
394 {
395   _compute_canceled = false;
396   _sm_current = NULL;
397 }
398 //=============================================================================
399 /*!
400  * Cancel Compute a mesh
401  */
402 //=============================================================================
403 void SMESH_Gen::CancelCompute(SMESH_Mesh &          aMesh,
404                               const TopoDS_Shape &  aShape)
405 {
406   _compute_canceled = true;
407   if(_sm_current)
408     {
409       _sm_current->ComputeStateEngine( SMESH_subMesh::COMPUTE_CANCELED );
410     }
411 }
412 #endif
413
414 //=============================================================================
415 /*!
416  * Evaluate a mesh
417  */
418 //=============================================================================
419
420 bool SMESH_Gen::Evaluate(SMESH_Mesh &          aMesh,
421                          const TopoDS_Shape &  aShape,
422                          MapShapeNbElems&      aResMap,
423                          const bool            anUpward,
424                          TSetOfInt*            aShapesId)
425 {
426   MESSAGE("SMESH_Gen::Evaluate");
427
428   bool ret = true;
429
430   SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
431
432   const bool includeSelf = true;
433   const bool complexShapeFirst = true;
434   SMESH_subMeshIteratorPtr smIt;
435
436   if ( anUpward ) { // is called from below code here
437     // -----------------------------------------------
438     // mesh all the sub-shapes starting from vertices
439     // -----------------------------------------------
440     smIt = sm->getDependsOnIterator(includeSelf, !complexShapeFirst);
441     while ( smIt->more() ) {
442       SMESH_subMesh* smToCompute = smIt->next();
443
444       // do not mesh vertices of a pseudo shape
445       const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
446       //if ( !aMesh.HasShapeToMesh() && aShType == TopAbs_VERTEX )
447       //  continue;
448       if ( !aMesh.HasShapeToMesh() ) {
449         if( aShType == TopAbs_VERTEX || aShType == TopAbs_WIRE ||
450             aShType == TopAbs_SHELL )
451           continue;
452       }
453
454       smToCompute->Evaluate(aResMap);
455       if( aShapesId )
456         aShapesId->insert( smToCompute->GetId() );
457     }
458     return ret;
459   }
460   else {
461     // -----------------------------------------------------------------
462     // apply algos that DO NOT require Discreteized boundaries and DO NOT
463     // support submeshes, starting from the most complex shapes
464     // and collect submeshes with algos that DO support submeshes
465     // -----------------------------------------------------------------
466     list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes;
467     smIt = sm->getDependsOnIterator(includeSelf, complexShapeFirst);
468     while ( smIt->more() ) {
469       SMESH_subMesh* smToCompute = smIt->next();
470       const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
471       const int aShapeDim = GetShapeDim( aSubShape );
472       if ( aShapeDim < 1 ) break;
473       
474       SMESH_Algo* algo = GetAlgo( aMesh, aSubShape );
475       if ( algo && !algo->NeedDiscreteBoundary() ) {
476         if ( algo->SupportSubmeshes() ) {
477           smWithAlgoSupportingSubmeshes.push_front( smToCompute );
478         }
479         else {
480           smToCompute->Evaluate(aResMap);
481           if ( aShapesId )
482             aShapesId->insert( smToCompute->GetId() );
483         }
484       }
485     }
486
487     // ------------------------------------------------------------
488     // sort list of meshes according to mesh order
489     // ------------------------------------------------------------
490     aMesh.SortByMeshOrder( smWithAlgoSupportingSubmeshes );
491
492     // ------------------------------------------------------------
493     // compute submeshes under shapes with algos that DO NOT require
494     // Discreteized boundaries and DO support submeshes
495     // ------------------------------------------------------------
496     list< SMESH_subMesh* >::iterator subIt, subEnd;
497     subIt  = smWithAlgoSupportingSubmeshes.begin();
498     subEnd = smWithAlgoSupportingSubmeshes.end();
499     // start from lower shapes
500     for ( ; subIt != subEnd; ++subIt ) {
501       sm = *subIt;
502
503       // get a shape the algo is assigned to
504       TopoDS_Shape algoShape;
505       if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape ))
506         continue; // strange...
507
508       // look for more local algos
509       smIt = sm->getDependsOnIterator(!includeSelf, !complexShapeFirst);
510       while ( smIt->more() ) {
511         SMESH_subMesh* smToCompute = smIt->next();
512
513         const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
514         const int aShapeDim = GetShapeDim( aSubShape );
515         if ( aShapeDim < 1 ) continue;
516
517         //const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
518
519         SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
520         filter
521           .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
522           .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh ));
523
524         if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) {
525           SMESH_Hypothesis::Hypothesis_Status status;
526           if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
527             // mesh a lower smToCompute starting from vertices
528             Evaluate( aMesh, aSubShape, aResMap, /*anUpward=*/true, aShapesId );
529         }
530       }
531     }
532     // ----------------------------------------------------------
533     // apply the algos that do not require Discreteized boundaries
534     // ----------------------------------------------------------
535     for ( subIt = smWithAlgoSupportingSubmeshes.begin(); subIt != subEnd; ++subIt )
536     {
537       sm = *subIt;
538       sm->Evaluate(aResMap);
539       if ( aShapesId )
540         aShapesId->insert( sm->GetId() );
541     }
542
543     // -----------------------------------------------
544     // mesh the rest sub-shapes starting from vertices
545     // -----------------------------------------------
546     ret = Evaluate( aMesh, aShape, aResMap, /*anUpward=*/true, aShapesId );
547   }
548
549   MESSAGE( "VSR - SMESH_Gen::Evaluate() finished, OK = " << ret);
550   return ret;
551 }
552
553
554 //=======================================================================
555 //function : checkConformIgnoredAlgos
556 //purpose  :
557 //=======================================================================
558
559 static bool checkConformIgnoredAlgos(SMESH_Mesh&               aMesh,
560                                      SMESH_subMesh*            aSubMesh,
561                                      const SMESH_Algo*         aGlobIgnoAlgo,
562                                      const SMESH_Algo*         aLocIgnoAlgo,
563                                      bool &                    checkConform,
564                                      set<SMESH_subMesh*>&      aCheckedMap,
565                                      list< SMESH_Gen::TAlgoStateError > & theErrors)
566 {
567   ASSERT( aSubMesh );
568   if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX)
569     return true;
570
571
572   bool ret = true;
573
574   const list<const SMESHDS_Hypothesis*>& listHyp =
575     aMesh.GetMeshDS()->GetHypothesis( aSubMesh->GetSubShape() );
576   list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
577   for ( ; it != listHyp.end(); it++)
578   {
579     const SMESHDS_Hypothesis * aHyp = *it;
580     if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
581       continue;
582
583     const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
584     ASSERT ( algo );
585
586     if ( aLocIgnoAlgo ) // algo is hidden by a local algo of upper dim
587     {
588       INFOS( "Local <" << algo->GetName() << "> is hidden by local <"
589             << aLocIgnoAlgo->GetName() << ">");
590     }
591     else
592     {
593       bool isGlobal = (aMesh.IsMainShape( aSubMesh->GetSubShape() ));
594       int dim = algo->GetDim();
595       int aMaxGlobIgnoDim = ( aGlobIgnoAlgo ? aGlobIgnoAlgo->GetDim() : -1 );
596
597       if ( dim < aMaxGlobIgnoDim )
598       {
599         // algo is hidden by a global algo
600         INFOS( ( isGlobal ? "Global" : "Local" )
601               << " <" << algo->GetName() << "> is hidden by global <"
602               << aGlobIgnoAlgo->GetName() << ">");
603       }
604       else if ( !algo->NeedDiscreteBoundary() && !isGlobal)
605       {
606         // local algo is not hidden and hides algos on sub-shapes
607         if (checkConform && !aSubMesh->IsConform( algo ))
608         {
609           ret = false;
610           checkConform = false; // no more check conformity
611           INFOS( "ERROR: Local <" << algo->GetName() <<
612                 "> would produce not conform mesh: "
613                 "<Not Conform Mesh Allowed> hypotesis is missing");
614           theErrors.push_back( SMESH_Gen::TAlgoStateError() );
615           theErrors.back().Set( SMESH_Hypothesis::HYP_NOTCONFORM, algo, false );
616         }
617
618         // sub-algos will be hidden by a local <algo>
619         SMESH_subMeshIteratorPtr revItSub =
620           aSubMesh->getDependsOnIterator( /*includeSelf=*/false, /*complexShapeFirst=*/true);
621         bool checkConform2 = false;
622         while ( revItSub->more() )
623         {
624           SMESH_subMesh* sm = revItSub->next();
625           checkConformIgnoredAlgos (aMesh, sm, aGlobIgnoAlgo,
626                                     algo, checkConform2, aCheckedMap, theErrors);
627           aCheckedMap.insert( sm );
628         }
629       }
630     }
631   }
632
633   return ret;
634 }
635
636 //=======================================================================
637 //function : checkMissing
638 //purpose  : notify on missing hypothesis
639 //           Return false if algo or hipothesis is missing
640 //=======================================================================
641
642 static bool checkMissing(SMESH_Gen*                aGen,
643                          SMESH_Mesh&               aMesh,
644                          SMESH_subMesh*            aSubMesh,
645                          const int                 aTopAlgoDim,
646                          bool*                     globalChecked,
647                          const bool                checkNoAlgo,
648                          set<SMESH_subMesh*>&      aCheckedMap,
649                          list< SMESH_Gen::TAlgoStateError > & theErrors)
650 {
651   if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX ||
652        aCheckedMap.count( aSubMesh ))
653     return true;
654
655   //MESSAGE("=====checkMissing");
656
657   int ret = true;
658   SMESH_Algo* algo = 0;
659
660   switch (aSubMesh->GetAlgoState())
661   {
662   case SMESH_subMesh::NO_ALGO: {
663     if (checkNoAlgo)
664     {
665       // should there be any algo?
666       int shapeDim = SMESH_Gen::GetShapeDim( aSubMesh->GetSubShape() );
667       if (aTopAlgoDim > shapeDim)
668       {
669         MESSAGE( "ERROR: " << shapeDim << "D algorithm is missing" );
670         ret = false;
671         theErrors.push_back( SMESH_Gen::TAlgoStateError() );
672         theErrors.back().Set( SMESH_Hypothesis::HYP_MISSING, shapeDim, true );
673       }
674     }
675     return ret;
676   }
677   case SMESH_subMesh::MISSING_HYP: {
678     // notify if an algo missing hyp is attached to aSubMesh
679     algo = aGen->GetAlgo( aMesh, aSubMesh->GetSubShape() );
680     ASSERT( algo );
681     bool IsGlobalHypothesis = aGen->IsGlobalHypothesis( algo, aMesh );
682     if (!IsGlobalHypothesis || !globalChecked[ algo->GetDim() ])
683     {
684       TAlgoStateErrorName errName = SMESH_Hypothesis::HYP_MISSING;
685       SMESH_Hypothesis::Hypothesis_Status status;
686       algo->CheckHypothesis( aMesh, aSubMesh->GetSubShape(), status );
687       if ( status == SMESH_Hypothesis::HYP_BAD_PARAMETER ) {
688         MESSAGE( "ERROR: hypothesis of " << (IsGlobalHypothesis ? "Global " : "Local ")
689                  << "<" << algo->GetName() << "> has a bad parameter value");
690         errName = status;
691       } else if ( status == SMESH_Hypothesis::HYP_BAD_GEOMETRY ) {
692         MESSAGE( "ERROR: " << (IsGlobalHypothesis ? "Global " : "Local ")
693                  << "<" << algo->GetName() << "> assigned to mismatching geometry");
694         errName = status;
695       } else {
696         MESSAGE( "ERROR: " << (IsGlobalHypothesis ? "Global " : "Local ")
697                  << "<" << algo->GetName() << "> misses some hypothesis");
698       }
699       if (IsGlobalHypothesis)
700         globalChecked[ algo->GetDim() ] = true;
701       theErrors.push_back( SMESH_Gen::TAlgoStateError() );
702       theErrors.back().Set( errName, algo, IsGlobalHypothesis );
703     }
704     ret = false;
705     break;
706   }
707   case SMESH_subMesh::HYP_OK:
708     algo = aSubMesh->GetAlgo();
709     ret = true;
710     if (!algo->NeedDiscreteBoundary())
711     {
712       SMESH_subMeshIteratorPtr itsub = aSubMesh->getDependsOnIterator( /*includeSelf=*/false,
713                                                                        /*complexShapeFirst=*/false);
714       while ( itsub->more() )
715         aCheckedMap.insert( itsub->next() );
716     }
717     break;
718   default: ASSERT(0);
719   }
720
721   // do not check under algo that hides sub-algos or
722   // re-start checking NO_ALGO state
723   ASSERT (algo);
724   bool isTopLocalAlgo =
725     ( aTopAlgoDim <= algo->GetDim() && !aGen->IsGlobalHypothesis( algo, aMesh ));
726   if (!algo->NeedDiscreteBoundary() || isTopLocalAlgo)
727   {
728     bool checkNoAlgo2 = ( algo->NeedDiscreteBoundary() );
729     SMESH_subMeshIteratorPtr itsub = aSubMesh->getDependsOnIterator( /*includeSelf=*/false,
730                                                                      /*complexShapeFirst=*/false);
731     while ( itsub->more() )
732     {
733       // sub-meshes should not be checked further more
734       SMESH_subMesh* sm = itsub->next();
735
736       if (isTopLocalAlgo)
737       {
738         //check algo on sub-meshes
739         int aTopAlgoDim2 = algo->GetDim();
740         if (!checkMissing (aGen, aMesh, sm, aTopAlgoDim2,
741                            globalChecked, checkNoAlgo2, aCheckedMap, theErrors))
742         {
743           ret = false;
744           if (sm->GetAlgoState() == SMESH_subMesh::NO_ALGO )
745             checkNoAlgo2 = false;
746         }
747       }
748       aCheckedMap.insert( sm );
749     }
750   }
751   return ret;
752 }
753
754 //=======================================================================
755 //function : CheckAlgoState
756 //purpose  : notify on bad state of attached algos, return false
757 //           if Compute() would fail because of some algo bad state
758 //=======================================================================
759
760 bool SMESH_Gen::CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
761 {
762   list< TAlgoStateError > errors;
763   return GetAlgoState( aMesh, aShape, errors );
764 }
765
766 //=======================================================================
767 //function : GetAlgoState
768 //purpose  : notify on bad state of attached algos, return false
769 //           if Compute() would fail because of some algo bad state
770 //           theErrors list contains problems description
771 //=======================================================================
772
773 bool SMESH_Gen::GetAlgoState(SMESH_Mesh&               theMesh,
774                              const TopoDS_Shape&       theShape,
775                              list< TAlgoStateError > & theErrors)
776 {
777   //MESSAGE("SMESH_Gen::CheckAlgoState");
778
779   bool ret = true;
780   bool hasAlgo = false;
781
782   SMESH_subMesh*          sm = theMesh.GetSubMesh(theShape);
783   const SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
784   TopoDS_Shape     mainShape = meshDS->ShapeToMesh();
785
786   // -----------------
787   // get global algos
788   // -----------------
789
790   const SMESH_Algo* aGlobAlgoArr[] = {0,0,0,0};
791
792   const list<const SMESHDS_Hypothesis*>& listHyp = meshDS->GetHypothesis( mainShape );
793   list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
794   for ( ; it != listHyp.end(); it++)
795   {
796     const SMESHDS_Hypothesis * aHyp = *it;
797     if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
798       continue;
799
800     const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
801     ASSERT ( algo );
802
803     int dim = algo->GetDim();
804     aGlobAlgoArr[ dim ] = algo;
805
806     hasAlgo = true;
807   }
808
809   // --------------------------------------------------------
810   // info on algos that will be ignored because of ones that
811   // don't NeedDiscreteBoundary() attached to super-shapes,
812   // check that a conform mesh will be produced
813   // --------------------------------------------------------
814
815
816   // find a global algo possibly hiding sub-algos
817   int dim;
818   const SMESH_Algo* aGlobIgnoAlgo = 0;
819   for (dim = 3; dim > 0; dim--)
820   {
821     if (aGlobAlgoArr[ dim ] &&
822         !aGlobAlgoArr[ dim ]->NeedDiscreteBoundary())
823     {
824       aGlobIgnoAlgo = aGlobAlgoArr[ dim ];
825       break;
826     }
827   }
828
829   set<SMESH_subMesh*> aCheckedSubs;
830   bool checkConform = ( !theMesh.IsNotConformAllowed() );
831
832   // loop on theShape and its sub-shapes
833   SMESH_subMeshIteratorPtr revItSub = sm->getDependsOnIterator( /*includeSelf=*/true,
834                                                                 /*complexShapeFirst=*/true);
835   while ( revItSub->more() )
836   {
837     SMESH_subMesh* smToCheck = revItSub->next();
838     if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
839       break;
840
841     if ( aCheckedSubs.insert( smToCheck ).second ) // not yet checked
842       if (!checkConformIgnoredAlgos (theMesh, smToCheck, aGlobIgnoAlgo,
843                                      0, checkConform, aCheckedSubs, theErrors))
844         ret = false;
845
846     if ( smToCheck->GetAlgoState() != SMESH_subMesh::NO_ALGO )
847       hasAlgo = true;
848   }
849
850   // ----------------------------------------------------------------
851   // info on missing hypothesis and find out if all needed algos are
852   // well defined
853   // ----------------------------------------------------------------
854
855   //MESSAGE( "---info on missing hypothesis and find out if all needed algos are");
856
857   // find max dim of global algo
858   int aTopAlgoDim = 0;
859   for (dim = 3; dim > 0; dim--)
860   {
861     if (aGlobAlgoArr[ dim ])
862     {
863       aTopAlgoDim = dim;
864       break;
865     }
866   }
867   bool checkNoAlgo = theMesh.HasShapeToMesh() ? bool( aTopAlgoDim ) : false;
868   bool globalChecked[] = { false, false, false, false };
869
870   // loop on theShape and its sub-shapes
871   aCheckedSubs.clear();
872   revItSub = sm->getDependsOnIterator( /*includeSelf=*/true, /*complexShapeFirst=*/true);
873   while ( revItSub->more() )
874   {
875     SMESH_subMesh* smToCheck = revItSub->next();
876     if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
877       break;
878
879     if ( aCheckedSubs.insert( smToCheck ).second ) // not yet checked
880       if (!checkMissing (this, theMesh, smToCheck, aTopAlgoDim,
881                          globalChecked, checkNoAlgo, aCheckedSubs, theErrors))
882       {
883         ret = false;
884         if (smToCheck->GetAlgoState() == SMESH_subMesh::NO_ALGO )
885           checkNoAlgo = false;
886       }
887   }
888
889   if ( !hasAlgo ) {
890     ret = false;
891     INFOS( "None algorithm attached" );
892     theErrors.push_back( TAlgoStateError() );
893     theErrors.back().Set( SMESH_Hypothesis::HYP_MISSING, 1, true );
894   }
895
896   return ret;
897 }
898
899 //=======================================================================
900 //function : IsGlobalHypothesis
901 //purpose  : check if theAlgo is attached to the main shape
902 //=======================================================================
903
904 bool SMESH_Gen::IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh)
905 {
906   SMESH_HypoFilter filter( SMESH_HypoFilter::Is( theHyp ));
907   return aMesh.GetHypothesis( aMesh.GetMeshDS()->ShapeToMesh(), filter, false );
908 }
909
910 //================================================================================
911 /*!
912  * \brief Return paths to xml files of plugins
913  */
914 //================================================================================
915
916 std::vector< std::string > SMESH_Gen::GetPluginXMLPaths()
917 {
918   // Get paths to xml files of plugins
919   vector< string > xmlPaths;
920   string sep;
921   if ( const char* meshersList = getenv("SMESH_MeshersList") )
922   {
923     string meshers = meshersList, plugin;
924     string::size_type from = 0, pos;
925     while ( from < meshers.size() )
926     {
927       // cut off plugin name
928       pos = meshers.find( ':', from );
929       if ( pos != string::npos )
930         plugin = meshers.substr( from, pos-from );
931       else
932         plugin = meshers.substr( from ), pos = meshers.size();
933       from = pos + 1;
934
935       // get PLUGIN_ROOT_DIR path
936       string rootDirVar, pluginSubDir = plugin;
937       if ( plugin == "StdMeshers" )
938         rootDirVar = "SMESH", pluginSubDir = "smesh";
939       else
940         for ( pos = 0; pos < plugin.size(); ++pos )
941           rootDirVar += toupper( plugin[pos] );
942       rootDirVar += "_ROOT_DIR";
943
944       const char* rootDir = getenv( rootDirVar.c_str() );
945       if ( !rootDir || strlen(rootDir) == 0 )
946       {
947         rootDirVar = plugin + "_ROOT_DIR"; // HexoticPLUGIN_ROOT_DIR
948         rootDir = getenv( rootDirVar.c_str() );
949         if ( !rootDir || strlen(rootDir) == 0 ) continue;
950       }
951
952       // get a separator from rootDir
953       for ( pos = strlen( rootDir )-1; pos >= 0 && sep.empty(); --pos )
954         if ( rootDir[pos] == '/' || rootDir[pos] == '\\' )
955         {
956           sep = rootDir[pos];
957           break;
958         }
959 #ifdef WNT
960       if (sep.empty() ) sep = "\\";
961 #else
962       if (sep.empty() ) sep = "/";
963 #endif
964
965       // get a path to resource file
966       string xmlPath = rootDir;
967       if ( xmlPath[ xmlPath.size()-1 ] != sep[0] )
968         xmlPath += sep;
969       xmlPath += "share" + sep + "salome" + sep + "resources" + sep;
970       for ( pos = 0; pos < pluginSubDir.size(); ++pos )
971         xmlPath += tolower( pluginSubDir[pos] );
972       xmlPath += sep + plugin + ".xml";
973       bool fileOK;
974 #ifdef WNT
975       fileOK = (GetFileAttributes(xmlPath.c_str()) != INVALID_FILE_ATTRIBUTES);
976 #else
977       fileOK = (access(xmlPath.c_str(), F_OK) == 0);
978 #endif
979       if ( fileOK )
980         xmlPaths.push_back( xmlPath );
981     }
982   }
983
984   return xmlPaths;
985 }
986
987 //=======================================================================
988 namespace // Access to type of input and output of an algorithm
989 //=======================================================================
990 {
991   struct AlgoData
992   {
993     int                       _dim;
994     set<SMDSAbs_GeometryType> _inElemTypes; // acceptable types of input mesh element
995     set<SMDSAbs_GeometryType> _outElemTypes; // produced types of mesh elements
996
997     bool IsCompatible( const AlgoData& algo2 ) const
998     {
999       if ( _dim > algo2._dim ) return algo2.IsCompatible( *this );
1000       // algo2 is of highter dimension
1001       if ( _outElemTypes.empty() || algo2._inElemTypes.empty() )
1002         return false;
1003       bool compatible = true;
1004       set<SMDSAbs_GeometryType>::const_iterator myOutType = _outElemTypes.begin();
1005       for ( ; myOutType != _outElemTypes.end() && compatible; ++myOutType )
1006         compatible = algo2._inElemTypes.count( *myOutType );
1007       return compatible;
1008     }
1009   };
1010
1011   //================================================================================
1012   /*!
1013    * \brief Return AlgoData of the algorithm
1014    */
1015   //================================================================================
1016
1017   const AlgoData& getAlgoData( const SMESH_Algo* algo )
1018   {
1019     static map< string, AlgoData > theDataByName;
1020     if ( theDataByName.empty() )
1021     {
1022       // Read Plugin.xml files
1023       vector< string > xmlPaths = SMESH_Gen::GetPluginXMLPaths();
1024       LDOMParser xmlParser;
1025       for ( size_t iXML = 0; iXML < xmlPaths.size(); ++iXML )
1026       {
1027         bool error = xmlParser.parse( xmlPaths[iXML].c_str() );
1028         if ( error )
1029         {
1030           TCollection_AsciiString data;
1031           INFOS( xmlParser.GetError(data) );
1032           continue;
1033         }
1034         // <algorithm type="Regular_1D"
1035         //            ...
1036         //            input="EDGE"
1037         //            output="QUAD,TRIA">
1038         //
1039         LDOM_Document xmlDoc = xmlParser.getDocument();
1040         LDOM_NodeList algoNodeList = xmlDoc.getElementsByTagName( "algorithm" );
1041         for ( int i = 0; i < algoNodeList.getLength(); ++i )
1042         {
1043           LDOM_Node     algoNode           = algoNodeList.item( i );
1044           LDOM_Element& algoElem           = (LDOM_Element&) algoNode;
1045           TCollection_AsciiString algoType = algoElem.getAttribute("type");
1046           TCollection_AsciiString input    = algoElem.getAttribute("input");
1047           TCollection_AsciiString output   = algoElem.getAttribute("output");
1048           TCollection_AsciiString dim      = algoElem.getAttribute("dim");
1049           if ( algoType.IsEmpty() ) continue;
1050           AlgoData & data                  = theDataByName[ algoType.ToCString() ];
1051           data._dim = dim.IntegerValue();
1052           for ( int isInput = 0; isInput < 2; ++isInput )
1053           {
1054             TCollection_AsciiString&   typeStr = isInput ? input : output;
1055             set<SMDSAbs_GeometryType>& typeSet = isInput ? data._inElemTypes : data._outElemTypes;
1056             int beg = 1, end;
1057             while ( beg <= typeStr.Length() )
1058             {
1059               while ( beg < typeStr.Length() && !isalpha( typeStr.Value( beg ) ))
1060                 ++beg;
1061               end = beg;
1062               while ( end < typeStr.Length() && isalpha( typeStr.Value( end + 1 ) ))
1063                 ++end;
1064               if ( end > beg )
1065               {
1066                 TCollection_AsciiString typeName = typeStr.SubString( beg, end );
1067                 if      ( typeName == "EDGE" ) typeSet.insert( SMDSGeom_EDGE );
1068                 else if ( typeName == "TRIA" ) typeSet.insert( SMDSGeom_TRIANGLE );
1069                 else if ( typeName == "QUAD" ) typeSet.insert( SMDSGeom_QUADRANGLE );
1070               }
1071               beg = end + 1;
1072             }
1073           }
1074         }
1075       }
1076     }
1077     return theDataByName[ algo->GetName() ];
1078   }
1079 }
1080
1081 //=============================================================================
1082 /*!
1083  * Finds algo to mesh a shape. Optionally returns a shape the found algo is bound to
1084  */
1085 //=============================================================================
1086
1087 SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh &         aMesh,
1088                                const TopoDS_Shape & aShape,
1089                                TopoDS_Shape*        assignedTo)
1090 {
1091   SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
1092   filter.And( filter.IsApplicableTo( aShape ));
1093
1094   TopoDS_Shape assignedToShape;
1095   SMESH_Algo* algo =
1096     (SMESH_Algo*) aMesh.GetHypothesis( aShape, filter, true, &assignedToShape );
1097
1098   if ( algo &&
1099        aShape.ShapeType() == TopAbs_FACE &&
1100        !aShape.IsSame( assignedToShape ) &&
1101        SMESH_MesherHelper::NbAncestors( aShape, aMesh, TopAbs_SOLID ) > 1 )
1102   {
1103     // Issue 0021559. If there is another 2D algo with different types of output
1104     // elements that can be used to mesh aShape, and 3D algos on adjacent SOLIDs
1105     // have different types of input elements, we choose a most appropriate 2D algo.
1106
1107     // try to find a concurrent 2D algo
1108     filter.AndNot( filter.Is( algo ));
1109     TopoDS_Shape assignedToShape2;
1110     SMESH_Algo* algo2 =
1111       (SMESH_Algo*) aMesh.GetHypothesis( aShape, filter, true, &assignedToShape2 );
1112     if ( algo2 &&                                                  // algo found
1113          !assignedToShape2.IsSame( aMesh.GetShapeToMesh() ) &&     // algo is local
1114          ( SMESH_MesherHelper::GetGroupType( assignedToShape2 ) == // algo of the same level
1115            SMESH_MesherHelper::GetGroupType( assignedToShape )) &&
1116          aMesh.IsOrderOK( aMesh.GetSubMesh( assignedToShape2 ),    // no forced order
1117                           aMesh.GetSubMesh( assignedToShape  )))
1118     {
1119       // get algos on the adjacent SOLIDs
1120       filter.Init( filter.IsAlgo() ).And( filter.HasDim( 3 ));
1121       vector< SMESH_Algo* > algos3D;
1122       PShapeIteratorPtr solidIt = SMESH_MesherHelper::GetAncestors( aShape, aMesh,
1123                                                                     TopAbs_SOLID );
1124       while ( const TopoDS_Shape* solid = solidIt->next() )
1125         if ( SMESH_Algo* algo3D = (SMESH_Algo*) aMesh.GetHypothesis( *solid, filter, true ))
1126         {
1127           algos3D.push_back( algo3D );
1128           filter.AndNot( filter.HasName( algo3D->GetName() ));
1129         }
1130       // check compatibility of algos
1131       if ( algos3D.size() > 1 )
1132       {
1133         const AlgoData& algoData    = getAlgoData( algo );
1134         const AlgoData& algoData2   = getAlgoData( algo2 );
1135         const AlgoData& algoData3d0 = getAlgoData( algos3D[0] );
1136         const AlgoData& algoData3d1 = getAlgoData( algos3D[1] );
1137         if (( algoData2.IsCompatible( algoData3d0 ) &&
1138               algoData2.IsCompatible( algoData3d1 ))
1139             &&
1140             !(algoData.IsCompatible( algoData3d0 ) &&
1141               algoData.IsCompatible( algoData3d1 )))
1142           algo = algo2;
1143       }
1144     }
1145   }
1146
1147   if ( assignedTo && algo )
1148     * assignedTo = assignedToShape;
1149
1150   return algo;
1151 }
1152
1153 //=============================================================================
1154 /*!
1155  * Returns StudyContextStruct for a study
1156  */
1157 //=============================================================================
1158
1159 StudyContextStruct *SMESH_Gen::GetStudyContext(int studyId)
1160 {
1161   // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
1162
1163   if (_mapStudyContext.find(studyId) == _mapStudyContext.end())
1164   {
1165     _mapStudyContext[studyId] = new StudyContextStruct;
1166     _mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId);
1167   }
1168   StudyContextStruct *myStudyContext = _mapStudyContext[studyId];
1169   return myStudyContext;
1170 }
1171
1172 //================================================================================
1173 /*!
1174  * \brief Return shape dimension by TopAbs_ShapeEnum
1175  */
1176 //================================================================================
1177
1178 int SMESH_Gen::GetShapeDim(const TopAbs_ShapeEnum & aShapeType)
1179 {
1180   static vector<int> dim;
1181   if ( dim.empty() )
1182   {
1183     dim.resize( TopAbs_SHAPE, -1 );
1184     dim[ TopAbs_COMPOUND ]  = MeshDim_3D;
1185     dim[ TopAbs_COMPSOLID ] = MeshDim_3D;
1186     dim[ TopAbs_SOLID ]     = MeshDim_3D;
1187     dim[ TopAbs_SHELL ]     = MeshDim_2D;
1188     dim[ TopAbs_FACE  ]     = MeshDim_2D;
1189     dim[ TopAbs_WIRE ]      = MeshDim_1D;
1190     dim[ TopAbs_EDGE ]      = MeshDim_1D;
1191     dim[ TopAbs_VERTEX ]    = MeshDim_0D;
1192   }
1193   return dim[ aShapeType ];
1194 }
1195
1196 //=============================================================================
1197 /*!
1198  * Genarate a new id unique withing this Gen
1199  */
1200 //=============================================================================
1201
1202 int SMESH_Gen::GetANewId()
1203 {
1204   return _hypId++;
1205 }