Salome HOME
PAL8196. Fix GetAlgo() for the case with the same algo on several ancestors
[modules/smesh.git] / src / SMESH / SMESH_Gen.cxx
1 //  SMESH SMESH : implementaion of SMESH idl descriptions
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : SMESH_Gen.cxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : SMESH
27 //  $Header$
28
29 #include "SMESH_Gen.hxx"
30 #include "SMESH_subMesh.hxx"
31 #include "SMESH_HypoFilter.hxx"
32 #include "SMDS_MeshElement.hxx"
33 #include "SMDS_MeshNode.hxx"
34
35 #include "utilities.h"
36 #include "OpUtil.hxx"
37 #include "Utils_ExceptHandlers.hxx"
38
39 #include <gp_Pnt.hxx>
40 #include <BRep_Tool.hxx>
41 #include <TopTools_ListOfShape.hxx>
42 #include <TopTools_ListIteratorOfListOfShape.hxx>
43
44 using namespace std;
45
46 //=============================================================================
47 /*!
48  *  default constructor:
49  */
50 //=============================================================================
51
52 SMESH_Gen::SMESH_Gen()
53 {
54         MESSAGE("SMESH_Gen::SMESH_Gen");
55         _localId = 0;
56         _hypId = 0;
57 }
58
59 //=============================================================================
60 /*!
61  *
62  */
63 //=============================================================================
64
65 SMESH_Gen::~SMESH_Gen()
66 {
67         MESSAGE("SMESH_Gen::~SMESH_Gen");
68 }
69
70 //=============================================================================
71 /*!
72  *
73  */
74 //=============================================================================
75
76 /*SMESH_Hypothesis *SMESH_Gen::CreateHypothesis(const char *anHyp, int studyId)
77         throw(SALOME_Exception)
78 {
79
80         MESSAGE("CreateHypothesis("<<anHyp<<","<<studyId<<")");
81         // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
82
83         StudyContextStruct *myStudyContext = GetStudyContext(studyId);
84
85         // create a new hypothesis object, store its ref. in studyContext
86
87         SMESH_Hypothesis *myHypothesis = _hypothesisFactory.Create(anHyp, studyId);
88         int hypId = myHypothesis->GetID();
89         myStudyContext->mapHypothesis[hypId] = myHypothesis;
90         SCRUTE(studyId);
91         SCRUTE(hypId);
92
93         // store hypothesis in SMESHDS document
94
95         myStudyContext->myDocument->AddHypothesis(myHypothesis);
96         return myHypothesis;
97 }*/
98
99 //=============================================================================
100 /*!
101  *
102  */
103 //=============================================================================
104
105 SMESH_Mesh* SMESH_Gen::CreateMesh(int studyId)
106 throw(SALOME_Exception)
107 {
108         Unexpect aCatch(SalomeException);
109         MESSAGE("SMESH_Gen::CreateMesh");
110 //   if (aShape.ShapeType() == TopAbs_COMPOUND)
111 //     {
112 //       INFOS("Mesh Compound not yet implemented!");
113 //       throw(SALOME_Exception(LOCALIZED("Mesh Compound not yet implemented!")));
114 //     }
115
116         // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
117
118         StudyContextStruct *myStudyContext = GetStudyContext(studyId);
119
120         // create a new SMESH_mesh object
121
122         SMESH_Mesh *mesh = new SMESH_Mesh(_localId++,
123                 studyId,
124                 this,
125                 myStudyContext->myDocument);
126         myStudyContext->mapMesh[_localId] = mesh;
127
128         // associate a TopoDS_Shape to the mesh
129
130 //mesh->ShapeToMesh(aShape);
131         return mesh;
132 }
133
134 //=============================================================================
135 /*!
136  *
137  */
138 //=============================================================================
139
140 bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
141 {
142   MESSAGE("SMESH_Gen::Compute");
143   //   bool isDone = false;
144   /*
145      Algo : s'appuie ou non sur une geometrie
146      Si geometrie:
147      Vertex : rien à faire (range le point)
148      Edge, Wire, collection d'edge et wire : 1D
149      Face, Shell, collection de Face et Shells : 2D
150      Solid, Collection de Solid : 3D
151      */
152   // *** corriger commentaires
153   // check hypothesis associated to the mesh :
154   // - only one algo : type compatible with the type of the shape
155   // - hypothesis = compatible with algo
156   //    - check if hypothesis are applicable to this algo
157   //    - check contradictions within hypothesis
158   //    (test if enough hypothesis is done further)
159
160   bool ret = true;
161
162 //   if ( !CheckAlgoState( aMesh, aShape ))
163 //   {
164 //     INFOS( "ABORT MESHING: some algos or hypothesis are missing");
165 //     return false;
166 //   }
167
168   SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
169
170   if ( sm->GetComputeState() == SMESH_subMesh::COMPUTE_OK )
171     return true; // already computed
172
173   // -----------------------------------------------------------------
174   // apply algos that do not require descretized boundaries, starting
175   // from the most complex shapes
176   // -----------------------------------------------------------------
177
178   // map containing all subshapes in the order: vertices, edges, faces...
179   const map<int, SMESH_subMesh*>& smMap = sm->DependsOn();
180   map<int, SMESH_subMesh*>::const_reverse_iterator revItSub = smMap.rbegin();
181
182   SMESH_subMesh* smToCompute = sm;
183   while ( smToCompute )
184   {
185     const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
186     if ( GetShapeDim( aSubShape ) < 1 ) break;
187
188     SMESH_Algo* algo = GetAlgo( aMesh, aSubShape );
189     if (algo && !algo->NeedDescretBoundary()) {
190       if (smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE) {
191         ret = smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
192       } else if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE) {
193         // JFA for PAL6524
194         ret = false;
195       } else {
196       }
197     }
198     if (!ret)
199       return false;
200
201     // next subMesh
202     if (revItSub != smMap.rend())
203     {
204       smToCompute = (*revItSub).second;
205       revItSub++;
206     }
207     else
208       smToCompute = 0;
209   }
210
211   // -----------------------------------------------
212   // mesh the rest subshapes starting from vertices
213   // -----------------------------------------------
214
215   int i, nbSub = smMap.size();
216   map<int, SMESH_subMesh*>::const_iterator itSub = smMap.begin();
217   for ( i = 0; i <= nbSub; ++i ) // loop on the whole map plus <sm>
218   {
219     if ( itSub == smMap.end() )
220       smToCompute = sm;
221     else
222       smToCompute = (itSub++)->second;
223     if (smToCompute->GetComputeState() != SMESH_subMesh::READY_TO_COMPUTE) {
224       if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE)
225         ret = false;
226       continue;
227     }
228     TopoDS_Shape subShape = smToCompute->GetSubShape();
229     if ( subShape.ShapeType() != TopAbs_VERTEX )
230     {
231       if ( !smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE) )
232         ret = false;
233     }
234     else
235     {
236       TopoDS_Vertex V1 = TopoDS::Vertex(subShape);
237       gp_Pnt P1 = BRep_Tool::Pnt(V1);
238       SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
239       SMDS_MeshNode * node = meshDS->AddNode(P1.X(), P1.Y(), P1.Z());
240       if ( node ) {  // san - increase robustness
241         meshDS->SetNodeOnVertex(node, V1);
242         smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
243       }
244     }
245   }
246
247   MESSAGE( "VSR - SMESH_Gen::Compute() finished, OK = " << ret);
248   return ret;
249 }
250
251
252 //=======================================================================
253 //function : checkConformIgnoredAlgos
254 //purpose  :
255 //=======================================================================
256
257 static bool checkConformIgnoredAlgos(SMESH_Mesh&               aMesh,
258                                      SMESH_subMesh*            aSubMesh,
259                                      const SMESH_Algo*         aGlobIgnoAlgo,
260                                      const SMESH_Algo*         aLocIgnoAlgo,
261                                      bool &                    checkConform,
262                                      map<int, SMESH_subMesh*>& aCheckedMap)
263 {
264   ASSERT( aSubMesh );
265   if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX)
266     return true;
267
268
269   bool ret = true;
270
271   const list<const SMESHDS_Hypothesis*>& listHyp =
272     aMesh.GetMeshDS()->GetHypothesis( aSubMesh->GetSubShape() );
273   list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
274   for ( ; it != listHyp.end(); it++)
275   {
276     const SMESHDS_Hypothesis * aHyp = *it;
277     if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
278       continue;
279
280     const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
281     ASSERT ( algo );
282
283     if ( aLocIgnoAlgo ) // algo is hidden by a local algo of upper dim
284     {
285       INFOS( "Local <" << algo->GetName() << "> is hidden by local <"
286             << aLocIgnoAlgo->GetName() << ">");
287     }
288     else
289     {
290       bool isGlobal = (aMesh.IsMainShape( aSubMesh->GetSubShape() ));
291       int dim = algo->GetDim();
292       int aMaxGlobIgnoDim = ( aGlobIgnoAlgo ? aGlobIgnoAlgo->GetDim() : -1 );
293
294       if ( dim < aMaxGlobIgnoDim )
295       {
296         // algo is hidden by a global algo
297         INFOS( ( isGlobal ? "Global" : "Local" )
298               << " <" << algo->GetName() << "> is hidden by global <"
299               << aGlobIgnoAlgo->GetName() << ">");
300       }
301       else if ( !algo->NeedDescretBoundary() && !isGlobal)
302       {
303         // local algo is not hidden and hides algos on sub-shapes
304         if (checkConform && !aSubMesh->IsConform( algo ))
305         {
306           ret = false;
307           checkConform = false; // no more check conformity
308           INFOS( "ERROR: Local <" << algo->GetName() <<
309                 "> would produce not conform mesh: "
310                 "<Not Conform Mesh Allowed> hypotesis is missing");
311         }
312
313         // sub-algos will be hidden by a local <algo>
314         const map<int, SMESH_subMesh*>& smMap = aSubMesh->DependsOn();
315         map<int, SMESH_subMesh*>::const_reverse_iterator revItSub;
316         bool checkConform2 = false;
317           for ( revItSub = smMap.rbegin(); revItSub != smMap.rend(); revItSub++)
318         {
319           checkConformIgnoredAlgos (aMesh, (*revItSub).second, aGlobIgnoAlgo,
320                                     algo, checkConform2, aCheckedMap);
321           int key = (*revItSub).first;
322           SMESH_subMesh* sm = (*revItSub).second;
323           if ( aCheckedMap.find( key ) == aCheckedMap.end() )
324           {
325             aCheckedMap[ key ] = sm;
326           }
327         }
328       }
329     }
330   }
331
332   return ret;
333 }
334
335 //=======================================================================
336 //function : checkMissing
337 //purpose  : notify on missing hypothesis
338 //           Return false if algo or hipothesis is missing
339 //=======================================================================
340
341 static bool checkMissing(SMESH_Gen*                aGen,
342                          SMESH_Mesh&               aMesh,
343                          SMESH_subMesh*            aSubMesh,
344                          const int                 aTopAlgoDim,
345                          bool*                     globalChecked,
346                          const bool                checkNoAlgo,
347                          map<int, SMESH_subMesh*>& aCheckedMap)
348 {
349   if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX)
350     return true;
351
352   //MESSAGE("=====checkMissing");
353
354   int ret = true;
355   SMESH_Algo* algo = 0;
356
357   switch (aSubMesh->GetAlgoState())
358   {
359   case SMESH_subMesh::NO_ALGO: {
360     if (checkNoAlgo)
361     {
362       // should there be any algo?
363       int shapeDim = SMESH_Gen::GetShapeDim( aSubMesh->GetSubShape() );
364       if (aTopAlgoDim > shapeDim)
365       {
366         INFOS( "ERROR: " << shapeDim << "D algorithm is missing" );
367         ret = false;
368       }
369     }
370     return ret;
371   }
372   case SMESH_subMesh::MISSING_HYP: {
373     // notify if an algo missing hyp is attached to aSubMesh
374     algo = aGen->GetAlgo( aMesh, aSubMesh->GetSubShape() );
375     ASSERT( algo );
376     bool IsGlobalHypothesis = aGen->IsGlobalHypothesis( algo, aMesh );
377     if (!IsGlobalHypothesis || !globalChecked[ algo->GetDim() ])
378     {
379       INFOS( "ERROR: " << (IsGlobalHypothesis ? "Global " : "Local ")
380             << "<" << algo->GetName() << "> misses some hypothesis");
381       if (IsGlobalHypothesis)
382         globalChecked[ algo->GetDim() ] = true;
383     }
384     ret = false;
385     break;
386   }
387   case SMESH_subMesh::HYP_OK:
388     algo = aGen->GetAlgo( aMesh, aSubMesh->GetSubShape() );
389     ret = true;
390     break;
391   default: ASSERT(0);
392   }
393
394   // do not check under algo that hides sub-algos or
395   // re-start checking NO_ALGO state
396   ASSERT (algo);
397   bool isTopLocalAlgo =
398     ( aTopAlgoDim <= algo->GetDim() && !aGen->IsGlobalHypothesis( algo, aMesh ));
399   if (!algo->NeedDescretBoundary() || isTopLocalAlgo)
400   {
401     bool checkNoAlgo2 = ( algo->NeedDescretBoundary() );
402     const map<int, SMESH_subMesh*>& subMeshes = aSubMesh->DependsOn();
403     map<int, SMESH_subMesh*>::const_iterator itsub;
404     for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
405     {
406       // sub-meshes should not be checked further more
407       int key = (*itsub).first;
408       SMESH_subMesh* sm = (*itsub).second;
409       if ( aCheckedMap.find( key ) == aCheckedMap.end() )
410         aCheckedMap[ key ] = sm;
411
412       if (isTopLocalAlgo)
413       {
414         //check algo on sub-meshes
415         int aTopAlgoDim2 = algo->GetDim();
416         if (!checkMissing (aGen, aMesh, sm, aTopAlgoDim2,
417                            globalChecked, checkNoAlgo2, aCheckedMap))
418         {
419           ret = false;
420           if (sm->GetAlgoState() == SMESH_subMesh::NO_ALGO )
421             checkNoAlgo2 = false;
422         }
423       }
424     }
425   }
426   return ret;
427 }
428
429 //=======================================================================
430 //function : CheckAlgoState
431 //purpose  : notify on bad state of attached algos, return false
432 //           if Compute() would fail because of some algo bad state
433 //=======================================================================
434
435 bool SMESH_Gen::CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
436 {
437   //MESSAGE("SMESH_Gen::CheckAlgoState");
438
439   bool ret = true;
440   bool hasAlgo = false;
441
442   SMESH_subMesh* sm = aMesh.GetSubMesh(aShape);
443   const SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
444   TopoDS_Shape mainShape = meshDS->ShapeToMesh();
445
446   // -----------------
447   // get global algos
448   // -----------------
449
450   const SMESH_Algo* aGlobAlgoArr[] = {0,0,0,0};
451
452   const list<const SMESHDS_Hypothesis*>& listHyp = meshDS->GetHypothesis( mainShape );
453   list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
454   for ( ; it != listHyp.end(); it++)
455   {
456     const SMESHDS_Hypothesis * aHyp = *it;
457     if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
458       continue;
459
460     const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
461     ASSERT ( algo );
462
463     int dim = algo->GetDim();
464     aGlobAlgoArr[ dim ] = algo;
465
466     hasAlgo = true;
467   }
468
469   // --------------------------------------------------------
470   // info on algos that will be ignored because of ones that
471   // don't NeedDescretBoundary() attached to super-shapes,
472   // check that a conform mesh will be produced
473   // --------------------------------------------------------
474
475
476   // find a global algo possibly hidding sub-algos
477   int dim;
478   const SMESH_Algo* aGlobIgnoAlgo = 0;
479   for (dim = 3; dim > 0; dim--)
480   {
481     if (aGlobAlgoArr[ dim ] &&
482         !aGlobAlgoArr[ dim ]->NeedDescretBoundary())
483     {
484       aGlobIgnoAlgo = aGlobAlgoArr[ dim ];
485       break;
486     }
487   }
488
489   const map<int, SMESH_subMesh*>& smMap = sm->DependsOn();
490   map<int, SMESH_subMesh*>::const_reverse_iterator revItSub = smMap.rbegin();
491   map<int, SMESH_subMesh*> aCheckedMap;
492   bool checkConform = ( !aMesh.IsNotConformAllowed() );
493   int aKey = 1;
494   SMESH_subMesh* smToCheck = sm;
495
496   // loop on aShape and its sub-shapes
497   while ( smToCheck )
498   {
499     if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
500       break;
501
502     if ( aCheckedMap.find( aKey ) == aCheckedMap.end() )
503       if (!checkConformIgnoredAlgos (aMesh, smToCheck, aGlobIgnoAlgo,
504                                      0, checkConform, aCheckedMap))
505         ret = false;
506
507     if ( smToCheck->GetAlgoState() != SMESH_subMesh::NO_ALGO )
508       hasAlgo = true;
509
510     // next subMesh
511     if (revItSub != smMap.rend())
512     {
513       aKey = (*revItSub).first;
514       smToCheck = (*revItSub).second;
515       revItSub++;
516     }
517     else
518     {
519       smToCheck = 0;
520     }
521
522   }
523
524   // ----------------------------------------------------------------
525   // info on missing hypothesis and find out if all needed algos are
526   // well defined
527   // ----------------------------------------------------------------
528
529   //MESSAGE( "---info on missing hypothesis and find out if all needed algos are");
530
531   // find max dim of global algo
532   int aTopAlgoDim = 0;
533   for (dim = 3; dim > 0; dim--)
534   {
535     if (aGlobAlgoArr[ dim ])
536     {
537       aTopAlgoDim = dim;
538       break;
539     }
540   }
541   aCheckedMap.clear();
542   smToCheck = sm;
543   revItSub = smMap.rbegin();
544   bool checkNoAlgo = (bool) aTopAlgoDim;
545   bool globalChecked[] = { false, false, false, false };
546
547   // loop on aShape and its sub-shapes
548   while ( smToCheck )
549   {
550     if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
551       break;
552
553     if ( aCheckedMap.find( aKey ) == aCheckedMap.end() )
554       if (!checkMissing (this, aMesh, smToCheck, aTopAlgoDim,
555                          globalChecked, checkNoAlgo, aCheckedMap))
556       {
557         ret = false;
558         if (smToCheck->GetAlgoState() == SMESH_subMesh::NO_ALGO )
559           checkNoAlgo = false;
560       }
561
562     // next subMesh
563     if (revItSub != smMap.rend())
564     {
565       aKey = (*revItSub).first;
566       smToCheck = (*revItSub).second;
567       revItSub++;
568     }
569     else
570       smToCheck = 0;
571   }
572
573   if ( !hasAlgo )
574     INFOS( "None algorithm attached" );
575
576   return ( ret && hasAlgo );
577 }
578
579 //=======================================================================
580 //function : IsGlobalHypothesis
581 //purpose  : check if theAlgo is attached to the main shape
582 //=======================================================================
583
584 bool SMESH_Gen::IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh)
585 {
586   SMESH_HypoFilter filter( SMESH_HypoFilter::Is( theHyp ));
587   return aMesh.GetHypothesis( aMesh.GetMeshDS()->ShapeToMesh(), filter, false );
588 }
589
590 //=============================================================================
591 /*!
592  *
593  */
594 //=============================================================================
595
596 SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
597 {
598 //  MESSAGE("SMESH_Gen::GetAlgo");
599
600   SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
601   filter.And( filter.IsApplicableTo( aShape ));
602
603   list <const SMESHDS_Hypothesis * > algoList;
604   aMesh.GetHypotheses( aShape, filter, algoList, true );
605
606   if ( algoList.empty() )
607     return NULL;
608
609   if (algoList.size() > 1 ) { // check if there is one algo several times
610     list <const SMESHDS_Hypothesis * >::iterator algo = algoList.begin();
611     for ( ; algo != algoList.end(); ++algo )
612       if ( (*algo) != algoList.front() &&
613            (*algo)->GetName() != algoList.front()->GetName() )
614         return NULL;
615   }
616
617   return const_cast<SMESH_Algo*> ( static_cast<const SMESH_Algo* >( algoList.front() ));
618 }
619
620 //=============================================================================
621 /*!
622  *
623  */
624 //=============================================================================
625
626 StudyContextStruct *SMESH_Gen::GetStudyContext(int studyId)
627 {
628         // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
629
630         if (_mapStudyContext.find(studyId) == _mapStudyContext.end())
631         {
632                 _mapStudyContext[studyId] = new StudyContextStruct;
633                 _mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId);
634         }
635         StudyContextStruct *myStudyContext = _mapStudyContext[studyId];
636 //   ASSERT(_mapStudyContext.find(studyId) != _mapStudyContext.end());
637         return myStudyContext;
638 }
639
640 //=============================================================================
641 /*!
642  *
643  */
644 //=============================================================================
645
646 void SMESH_Gen::Save(int studyId, const char *aUrlOfFile)
647 {
648 }
649
650 //=============================================================================
651 /*!
652  *
653  */
654 //=============================================================================
655
656 void SMESH_Gen::Load(int studyId, const char *aUrlOfFile)
657 {
658 }
659
660 //=============================================================================
661 /*!
662  *
663  */
664 //=============================================================================
665
666 void SMESH_Gen::Close(int studyId)
667 {
668 }
669
670 //=============================================================================
671 /*!
672  *
673  */
674 //=============================================================================
675
676 int SMESH_Gen::GetShapeDim(const TopAbs_ShapeEnum & aShapeType)
677 {
678         int shapeDim = -1;                      // Shape dimension: 0D, 1D, 2D, 3D
679         int type = aShapeType;//.ShapeType();
680         switch (type)
681         {
682         case TopAbs_COMPOUND:
683         case TopAbs_COMPSOLID:
684         case TopAbs_SOLID:
685         case TopAbs_SHELL:
686         {
687                 shapeDim = 3;
688                 break;
689         }
690                 //    case TopAbs_SHELL:
691         case TopAbs_FACE:
692         {
693                 shapeDim = 2;
694                 break;
695         }
696         case TopAbs_WIRE:
697         case TopAbs_EDGE:
698         {
699                 shapeDim = 1;
700                 break;
701         }
702         case TopAbs_VERTEX:
703         {
704                 shapeDim = 0;
705                 break;
706         }
707         }
708         return shapeDim;
709 }
710
711 //=============================================================================
712 /*!
713  *
714  */
715 //=============================================================================
716
717 int SMESH_Gen::GetANewId()
718 {
719         //MESSAGE("SMESH_Gen::GetANewId");
720         return _hypId++;
721 }