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